:root {
  --color-primary: #1E4BD1;
  --color-accent: #E91E63;
  --color-green: #2ECC71;
  --color-yellow: #F1C40F;
  --bg: #0B0E14;
  --surface: #121723;
  --text: #F5F7FA;
  --muted: #AAB2C8;
  --border: rgba(255, 255, 255, .12);
}

[data-theme="light"] {
  --bg: #fff;
  --surface: #f7f8fa;
  --text: #0b0e14;
  --muted: #5b6478;
  --border: rgba(0, 0, 0, .12);
}

* {
  box-sizing: border-box
}

html,
body {
  height: 100%
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, Segoe UI, Arial
}

.header {
  position: sticky;
  top: 0;
  z-index: 5;
  border-bottom: 1px solid var(--border);
  background: var(--surface)
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  position: relative;
  min-height: 80px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 auto;
}

.header-home {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
}

.logo {
  height: 60px;
}

.title {
  display: none;
  /* Hide text title in favor of new logo */
}

/* Default Lobby Header (Centered Logo) */
.brand {
  margin: 0 auto;
}

/* Game Active Header (Logo to Right, Actions Visible) */
.header.is-game-active .brand {
  margin-left: auto;
  /* Pushes logo to right */
  margin-right: 0;
  order: 2;
}

.header.is-game-active .header-actions {
  display: flex !important;
  margin-left: 50px;
  /* Offset for absolute home button */
  order: 1;
}

.actions {
  display: flex;
  gap: 8px
}

.header-actions {
  display: flex;
  gap: 8px;
}

.btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform .05s ease, box-shadow .05s ease
}

.btn.is-pressed,
.btn:active {
  transform: translateY(1px) scale(.985);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, .35)
}

.btn[aria-disabled="true"] {
  opacity: .6
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px
}

.field {
  margin: 10px 0
}

.players-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px
}

.player-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px
}

.right {
  text-align: right
}

.grid {
  display: grid;
  gap: 8px
}

#headers {
  position: sticky;
  top: 80px;
  /* Below main header */
  z-index: 4;
  text-align: right;
  margin-top: 12px;
  background: var(--bg);
  /* Prevent transparency overlap */
  padding-bottom: 8px;
  /* Visual spacing */
}

.sticky-footer {
  position: sticky;
  bottom: 0;
  z-index: 5;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 12px;
  display: flex;
  justify-content: flex-end;
  /* Right align button */
  margin-top: 16px;
}

.banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #223;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 12px
}

.banner.hidden {
  display: none
}

.banner-actions {
  display: flex;
  gap: 8px
}

.label {
  font-size: 12px;
  text-transform: uppercase;
  color: var(--muted)
}

.muted {
  color: var(--muted)
}

.small {
  font-size: 12px
}

.round {
  margin-top: 8px
}

.cell {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, .02);
  text-align: center
}

.header-cell {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  text-align: center
}

.header-points {
  font-size: 22px;
  font-weight: 900
}

.edit-row {
  margin-top: 12px
}

input[type='text'],
input[type='number'],
select {
  width: 100%;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, .04);
  color: var(--text)
}

select option {
  background-color: var(--surface);
  color: var(--text);
}

select.pts {
  appearance: none
}

input[type='color'] {
  width: 44px;
  height: 36px;
  border: 1px solid var(--border);
  background: transparent
}

.row-actions {
  margin-top: 6px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-start
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .7);
  display: flex;
  align-items: center;
  justify-content: center
}

.overlay.hidden {
  display: none
}

.overlay-card {
  position: relative;
  z-index: 2;
  max-width: 700px;
  width: 92%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  text-align: center
}

#confetti {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%
}

.winner-title {
  font-size: 20px;
  margin-bottom: 8px
}

.winner-name {
  font-size: 40px;
  font-weight: 900;
  margin-bottom: 6px
}

.blink {
  animation: blink 1.2s step-start infinite
}

@keyframes blink {
  50% {
    opacity: .2
  }
}

@media(prefers-reduced-motion:reduce) {
  .blink {
    animation: pulse 2s ease-in-out infinite
  }

  @keyframes pulse {

    0%,
    100% {
      transform: scale(1)
    }

    50% {
      transform: scale(1.03)
    }
  }
}

.runner-up {
  font-size: 18px;
  margin-top: 6px
}

.runner-list {
  margin-top: 6px
}

.hidden {
  display: none !important
}

.radio-row {
  display: flex;
  align-items: center;
  gap: 8px
}

.icon-yes {
  color: #2ECC71;
  font-size: 20px;
  line-height: 1;
  display: inline-block;
  margin-left: 6px
}

.icon-no {
  color: #E74C3C;
  font-size: 20px;
  line-height: 1;
  display: inline-block;
  margin-left: 6px
}

.inline-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Spectator View */
#spectator-view {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
}

.spectator-player-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}

.spectator-player-card .name {
  font-weight: 700;
  font-size: 18px;
}

.spectator-player-card .points {
  font-size: 28px;
  font-weight: 900;
  margin: 4px 0;
}

.spectator-phase-list {
  text-align: left;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 14px;
}

.spectator-phase-list .phase-item {
  padding: 4px 8px;
  border-radius: 4px;
  margin-bottom: 2px;
  opacity: 0.5;
}

.spectator-phase-list .phase-item.current-phase {
  font-weight: bold;
  background: rgba(255, 255, 0, 0.15);
  opacity: 1;
}

.spectator-phase-list .phase-item.attempting-phase {
  background: rgba(33, 150, 243, 0.2);
  border-left: 3px solid #2196F3;
  font-weight: bold;
  opacity: 1;
}

.spectator-phase-list .phase-item.completed-phase {
  text-decoration: line-through;
  opacity: 0.3;
}


/* Dialog readability */
.dialog {
  color: var(--text)
}

.dialog .card {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text)
}

dialog::backdrop {
  background: rgba(0, 0, 0, .6)
}

/* Small icon button */
.icon-btn {
  background: transparent;
  border: 0;
  color: var(--text);
  padding: 0 4px;
  border-radius: 6px;
  cursor: pointer
}

.icon-btn:active,
.icon-btn.is-pressed {
  transform: translateY(1px) scale(.985)
}

/* Phase description italic */
.phase-desc {
  font-style: italic
}

/* ========== LOBBY REDESIGN ========== */
.lobby-gradient {
  min-height: calc(100vh - 80px);
  background: radial-gradient(circle at 20% 30%, rgba(220, 50, 50, 0.4) 0%, transparent 50%),
    radial-gradient(circle at 80% 50%, rgba(70, 130, 220, 0.4) 0%, transparent 50%),
    radial-gradient(circle at 50% 90%, rgba(200, 180, 80, 0.35) 0%, transparent 50%),
    var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.hero-section {
  text-align: center;
  margin-bottom: 60px;
  z-index: 1;
}

.hero-title {
  font-size: clamp(32px, 8vw, 64px);
  font-weight: 900;
  letter-spacing: 2px;
  margin: 0 0 16px 0;
  color: #fff;
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.hero-subtitle {
  font-size: clamp(16px, 3vw, 20px);
  color: rgba(255, 255, 255, 0.9);
  margin: 0;
  font-weight: 400;
}

.lobby-cards {
  display: flex;
  gap: 24px;
  max-width: 900px;
  width: 100%;
  flex-wrap: wrap;
  justify-content: center;
  z-index: 1;
}

.lobby-card {
  flex: 1;
  min-width: 280px;
  max-width: 420px;
  border-radius: 20px;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  position: relative;
}

.lobby-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 20px;
  padding: 3px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.1));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.join-card {
  background: linear-gradient(135deg, #4A90E2 0%, #357ABD 100%);
}

.join-card::after {
  content: '';
  position: absolute;
  inset: -100px;
  background: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.15) 0%, transparent 70%);
  pointer-events: none;
}

.create-card {
  background: linear-gradient(135deg, #F5C542 0%, #E6A623 100%);
}

.create-card::after {
  content: '';
  position: absolute;
  inset: -100px;
  background: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.15) 0%, transparent 70%);
  pointer-events: none;
}

.card-title {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 1px;
  margin: 0;
  padding: 20px 24px;
  text-align: center;
  position: relative;
  z-index: 1;
}

.join-card .card-title {
  background: rgba(0, 0, 0, 0.15);
  color: #fff;
}

.create-card .card-title {
  background: rgba(0, 0, 0, 0.15);
  color: #1a1a1a;
}

.card-content {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  z-index: 1;
}

.join-card .card-content {
  background: rgba(30, 40, 60, 0.7);
}

.create-card .card-content {
  background: rgba(40, 35, 25, 0.7);
}

.card-description {
  color: rgba(255, 255, 255, 0.9);
  text-align: center;
  margin: 0;
  font-size: 15px;
}

.btn-primary,
.btn-secondary {
  width: 100%;
  padding: 14px 24px;
  border-radius: 12px;
  border: none;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
}

.btn-primary {
  background: #fff;
  color: #357ABD;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 255, 255, 0.3);
}

.btn-secondary {
  background: #2C2416;
  color: #F5C542;
  border: 2px solid #F5C542;
}

.btn-secondary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(245, 197, 66, 0.3);
}

@media (max-width: 768px) {
  .lobby-cards {
    flex-direction: column;
  }

  .lobby-card {
    max-width: 100%;
  }
}
/* ========== MULTIPLAYER MODE SELECTION ========== */
.mode-selection {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin-top: 8px;
}

.mode-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-card:hover {
  background: rgba(255, 255, 255, 0.06);
}

.mode-card.selected {
  background: rgba(30, 75, 209, 0.2);
  border-color: var(--color-primary);
}

.mode-card input[type="radio"] {
  margin-top: 4px;
}

.mode-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mode-info strong {
  color: var(--text);
  font-size: 15px;
}

.mode-info small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
}

/* ========== LOBBY ROOM ========== */
#lobby-room h2 {
    font-size: 28px;
    margin-top: 10px;
}

#lobbyPlayerList {
    margin-top: 20px;
}

/* ========== MY ACTION CARD ========== */
#myActionCard::backdrop {
    background: rgba(0, 0, 0, 0.85); /* Darker backdrop for focus */
}

/* Floating Action Button for Player (Interactive Mode) */
.fab-action {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 100;
    background: var(--color-accent);
    color: white;
    font-weight: bold;
    padding: 16px 24px;
    border-radius: 50px;
    border: none;
    box-shadow: 0 4px 12px rgba(233, 30, 99, 0.4);
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: slideUp 0.3s ease-out;
}

.fab-action:active {
    transform: scale(0.95);
}

@keyframes slideUp {
    from { transform: translateY(100px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Host Controls in Lobby */
#lobbyHostControls button:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

/* Lobby Reordering Controls */
.lobby-order-controls-absolute {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.lobby-order-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid var(--border);
    color: var(--text);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    padding: 0;
    line-height: 1;
    transition: background 0.1s;
}

.lobby-order-btn:hover {
    background: rgba(255,255,255,0.25);
}

.lobby-order-btn:active {
    transform: scale(0.95);
}

