* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface2: #263347;
  --border: #334155;
  --text: #f1f5f9;
  --text2: #94a3b8;
  --x-color: #f472b6;
  --o-color: #38bdf8;
  --x-bg: rgba(244, 114, 182, 0.12);
  --o-bg: rgba(56, 189, 248, 0.12);
  --accent: #818cf8;
  --win: #4ade80;
  --danger: #ef4444;
  --success: #4ade80;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

#app {
  width: 100%;
  max-width: 900px;
  padding: 16px;
}

/* Screens */
.screen {
  display: none;
}
.screen.active {
  display: block;
  animation: screenFadeIn 0.35s ease-out both;
}
.screen.platform-screen.active {
  display: flex;
}
.screen.screen-exit {
  display: block;
  animation: screenFadeOut 0.25s ease-in both;
  pointer-events: none;
}
.screen.platform-screen.screen-exit {
  display: flex;
}
.screen.spy-fullscreen.screen-exit,
.screen.ww-fullscreen.screen-exit {
  display: flex;
  position: fixed;
  inset: 0;
}

@keyframes screenFadeIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes screenFadeOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* Setup Card */
.setup-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
  max-width: 600px;
  margin: 0 auto;
  animation: contentSlideUp 0.35s ease-out both;
}
.setup-card.centered {
  text-align: center;
}

h1 {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--x-color), var(--accent), var(--o-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}
.subtitle {
  color: var(--text2);
  margin-bottom: 28px;
  font-size: 0.95rem;
}

.field-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text2);
  margin-bottom: 8px;
}

input[type='text'],
input[type='email'] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  padding: 10px 14px;
  outline: none;
  margin-bottom: 20px;
  transition: border-color 0.2s;
}
input[type='text']:focus,
input[type='email']:focus {
  border-color: var(--accent);
}

/* Mode Grid */
.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.mode-btn {
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  padding: 16px 8px;
  text-align: center;
  transition: all 0.2s;
}
.mode-btn:hover {
  border-color: var(--accent);
  background: rgba(129, 140, 248, 0.1);
}
.mode-icon {
  font-size: 1.6rem;
  margin-bottom: 6px;
}
.mode-title {
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 4px;
}
.mode-desc {
  font-size: 0.75rem;
  color: var(--text2);
  line-height: 1.3;
}

/* Divider */
.divider {
  text-align: center;
  color: var(--text2);
  font-size: 0.85rem;
  margin-bottom: 20px;
  position: relative;
}
.divider::before,
.divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 42%;
  height: 1px;
  background: var(--border);
}
.divider::before {
  left: 0;
}
.divider::after {
  right: 0;
}

/* Join Row */
.join-row {
  display: flex;
  gap: 10px;
}
.join-row input {
  margin-bottom: 0;
  flex: 1;
}

/* Buttons */
.btn-primary {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 10px 22px;
  transition: opacity 0.2s;
  white-space: nowrap;
}
.btn-primary:hover:not(:disabled) {
  opacity: 0.85;
}
.btn-primary:disabled {
  opacity: 0.4;
  cursor: default;
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 10px 22px;
  white-space: nowrap;
  transition: border-color 0.2s;
}
.btn-secondary:hover {
  border-color: var(--accent);
}

.btn-ghost {
  background: transparent;
  border: none;
  color: var(--text2);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 6px 12px;
  border-radius: 6px;
  transition:
    color 0.2s,
    background 0.2s;
}
.btn-ghost:hover {
  color: var(--text);
  background: var(--surface2);
}
.btn-ghost.small {
  font-size: 0.85rem;
  padding: 4px 10px;
}

/* Lobby */
.lobby-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  max-width: 640px;
  margin: 0 auto;
  animation: contentSlideUp 0.35s ease-out both;
}

@keyframes contentSlideUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.lobby-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.lobby-header h1 {
  font-size: 1.4rem;
  flex: 1;
  text-align: center;
}
.btn-secondary.small,
.btn-ghost.small {
  font-size: 0.8rem;
  padding: 5px 12px;
}

.lobby-room {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition:
    border-color 0.2s,
    opacity 0.2s;
}
.lobby-room.lobby-room-new {
  animation: lobbyRoomIn 0.3s ease-out both;
}
@keyframes lobbyRoomIn {
  from {
    opacity: 0;
    transform: translateX(-12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
.lobby-room {
  cursor: pointer;
}
.lobby-room:hover {
  border-color: var(--accent);
}
.lobby-room-info {
  flex: 1;
}
.lobby-room-name {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 4px;
}
.lobby-room-meta {
  font-size: 0.8rem;
  color: var(--text2);
}
.lobby-room-players {
  font-size: 0.82rem;
  margin-top: 6px;
}
.lobby-room-players .px {
  color: var(--x-color);
}
.lobby-room-players .po {
  color: var(--o-color);
}

.lobby-status {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 4px;
  margin-right: 8px;
}
.lobby-status.waiting {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
  border: 1px solid #fbbf24;
}
.lobby-status.in_progress {
  background: rgba(74, 222, 128, 0.15);
  color: #4ade80;
  border: 1px solid #4ade80;
}
.lobby-status.finished {
  background: rgba(148, 163, 184, 0.1);
  color: var(--text2);
  border: 1px solid var(--border);
}

.lobby-empty {
  text-align: center;
  color: var(--text2);
  padding: 40px 0;
}

/* Terminal command block */
.cmd-block {
  background: #0a0f1e;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.78rem;
  color: #7dd3fc;
  text-align: left;
  word-break: break-all;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.cmd-text {
  flex: 1;
}
.cmd-copy-btn {
  background: transparent;
  border: 1px solid #334155;
  border-radius: 5px;
  color: var(--text2);
  cursor: pointer;
  font-size: 0.7rem;
  padding: 3px 8px;
  white-space: nowrap;
  transition:
    border-color 0.2s,
    color 0.2s;
  flex-shrink: 0;
}
.cmd-copy-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}
.agent-link {
  color: var(--accent);
  text-decoration: none;
}
.agent-link:hover {
  text-decoration: underline;
}

/* Spinner */
.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 20px;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Waiting Screen */
#waiting-screen h2 {
  margin-bottom: 12px;
}
#waiting-msg {
  color: var(--text2);
  margin-bottom: 20px;
}

/* Waiting Room Player Slots */
.waiting-slots {
  margin: 16px 0 20px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.waiting-slots-title {
  font-size: 0.85rem;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
  text-align: center;
}
.waiting-slots-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.waiting-slot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg);
  border: 2px dashed var(--border);
  border-radius: 8px;
  min-height: 48px;
  transition: all 0.3s ease;
}
.waiting-slot.filled {
  border-style: solid;
  border-color: var(--accent);
  background: rgba(129, 140, 248, 0.08);
}
.waiting-slot.filled.is-you {
  border-color: var(--win);
  background: rgba(74, 222, 128, 0.08);
}
.waiting-slot-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.waiting-slot.empty .waiting-slot-avatar {
  background: var(--surface2);
  color: var(--text2);
}
.waiting-slot.filled .waiting-slot-avatar {
  background: var(--accent);
  color: white;
}
.waiting-slot.filled.is-you .waiting-slot-avatar {
  background: var(--win);
  color: #0f172a;
}
.waiting-slot-name {
  font-size: 0.85rem;
  color: var(--text2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.waiting-slot.filled .waiting-slot-name {
  color: var(--text);
  font-weight: 500;
}
.waiting-slot-badge {
  margin-left: auto;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}
.waiting-slot.filled .waiting-slot-badge {
  background: rgba(129, 140, 248, 0.2);
  color: var(--accent);
}
.waiting-slot.filled.is-you .waiting-slot-badge {
  background: rgba(74, 222, 128, 0.2);
  color: var(--win);
}
.waiting-slots-count {
  text-align: center;
  font-size: 0.9rem;
  color: var(--text2);
  font-weight: 500;
}
@media (max-width: 480px) {
  .waiting-slots-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.share-label {
  color: var(--text2);
  font-size: 0.85rem;
  margin-bottom: 8px;
}
.game-id-box {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 0.15em;
  color: var(--accent);
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 12px 24px;
  margin-bottom: 12px;
  display: inline-block;
}

/* Game Screen */
.game-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  position: relative;
  max-width: 640px;
  margin: 0 auto;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  animation: contentSlideUp 0.35s ease-out both;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.game-header h1 {
  font-size: 1.4rem;
  margin: 0;
  flex: 1;
  text-align: center;
}
.header-game-id {
  font-size: 0.75rem;
  color: var(--text2);
  min-width: 80px;
  text-align: right;
}

/* Status Bar */
.status-bar {
  text-align: center;
  padding: 10px 16px;
  background: var(--surface2);
  border-radius: 8px;
  font-size: 0.95rem;
  color: var(--text2);
  margin-bottom: 20px;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    color 0.3s,
    border-color 0.3s,
    background 0.3s;
}
.status-bar.x-turn {
  color: var(--x-color);
  border-left: 3px solid var(--x-color);
}
.status-bar.o-turn {
  color: var(--o-color);
  border-left: 3px solid var(--o-color);
}
.status-bar.you-turn {
  font-weight: 700;
}

/* Game Area */
.game-area {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 16px;
  flex: 1;
  min-height: 0;
}

/* Player Panels */
.player-panel {
  text-align: center;
  flex: 0 0 80px;
  padding: 12px 8px;
  border-radius: var(--radius);
  border: 2px solid transparent;
  transition: all 0.3s;
}
.player-panel.active-player {
  background: var(--surface2);
}
#panel-x.active-player {
  border-color: var(--x-color);
}
#panel-o.active-player {
  border-color: var(--o-color);
}

.player-mark {
  font-size: 2.2rem;
  font-weight: 900;
  line-height: 1;
  margin-bottom: 6px;
}
.x-mark {
  color: var(--x-color);
}
.o-mark {
  color: var(--o-color);
}

.player-info-name {
  font-size: 0.8rem;
  font-weight: 600;
  word-break: break-word;
  margin-bottom: 4px;
}

.player-type-badge {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text2);
  background: var(--bg);
  border-radius: 4px;
  padding: 2px 6px;
  display: inline-block;
}

/* Board */
.board-container {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
}

.cell {
  aspect-ratio: 1;
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  font-weight: 900;
  transition: all 0.15s;
  user-select: none;
}
.cell:hover:not(.taken):not(.disabled) {
  background: var(--bg);
  border-color: var(--accent);
  transform: scale(1.04);
}
.cell.taken { cursor: default; }
.cell.disabled { cursor: default; }
.cell.x { color: var(--x-color); background: var(--x-bg); }
.cell.o { color: var(--o-color); background: var(--o-bg); }
.cell.last-move {
  box-shadow: inset 0 0 0 2px #facc15;
  background: rgba(250, 204, 21, 0.12);
}
.cell.winner-cell {
  background: rgba(74, 222, 128, 0.15);
  border-color: var(--win);
  animation: pulse 0.6s ease-out 2;
}
@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

/* Game Type Grid */
.game-type-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 24px;
}

.game-type-btn {
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  padding: 12px 6px;
  text-align: center;
  transition: all 0.2s;
}
.game-type-btn:hover {
  border-color: var(--accent);
  background: rgba(129, 140, 248, 0.1);
}
.game-type-btn.active {
  border-color: var(--accent);
  background: rgba(129, 140, 248, 0.15);
}

/* Gomoku board — 15x15 smaller cells */
.board.gomoku {
  grid-template-columns: repeat(15, 1fr);
  max-width: 560px;
  gap: 3px;
}
.board.gomoku .cell {
  font-size: 1rem;
  border-radius: 4px;
  border-width: 1px;
}
.board.gomoku .cell:hover:not(.taken):not(.disabled) {
  transform: scale(1.1);
}

/* QA Game */
.qa-scores {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin-bottom: 16px;
}

.qa-score-panel {
  text-align: center;
  padding: 12px 24px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  transition: all 0.3s;
  min-width: 120px;
}
.qa-score-panel.x-winner {
  border-color: var(--x-color);
  background: var(--x-bg);
}
.qa-score-panel.o-winner {
  border-color: var(--o-color);
  background: var(--o-bg);
}
.qa-score-panel.correct {
  border-color: var(--win);
  background: rgba(74, 222, 128, 0.12);
}

.qa-score-name {
  font-size: 0.85rem;
  color: var(--text2);
  margin-bottom: 6px;
  font-weight: 600;
}
.qa-score-value {
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--accent);
}

.qa-vs {
  font-size: 1rem;
  color: var(--text2);
  font-weight: 700;
}

.qa-progress {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text2);
  margin-bottom: 8px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.qa-timer-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  margin-bottom: 20px;
  overflow: hidden;
}
.qa-timer-fill {
  height: 100%;
  width: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition:
    width 1s linear,
    background 0.5s;
}
.qa-timer-fill.warning {
  background: #f59e0b;
}
.qa-timer-fill.danger {
  background: #ef4444;
}

.qa-question {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.5;
  margin-bottom: 16px;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qa-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.qa-option-btn {
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 12px 16px;
  text-align: left;
  transition: all 0.15s;
  line-height: 1.4;
}
.qa-option-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: rgba(129, 140, 248, 0.1);
}
.qa-option-btn:disabled {
  cursor: default;
  opacity: 0.7;
}
.qa-option-btn.correct {
  border-color: var(--win);
  background: rgba(74, 222, 128, 0.15);
  color: var(--win);
}
.qa-option-btn.wrong {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}
.qa-option-btn.selected {
  border-color: var(--accent);
}

.qa-option-label {
  display: inline-block;
  background: var(--border);
  border-radius: 4px;
  color: var(--text2);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 6px;
  margin-right: 8px;
  vertical-align: middle;
}

.qa-status {
  text-align: center;
  font-size: 0.95rem;
  font-weight: 600;
  min-height: 28px;
  color: var(--text2);
  padding: 4px 0;
}
.qa-status.correct {
  color: var(--win);
}
.qa-status.timeout {
  color: #f59e0b;
}

/* Result Overlay */
.result-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.95);
  border-radius: var(--radius) var(--radius) 0 0;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  animation: resultSlideUp 0.35s ease-out both;
  padding: 16px 0;
}
@keyframes resultSlideUp {
  from {
    opacity: 0;
    transform: translateY(100%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.result-card {
  text-align: center;
  padding: 20px 32px;
  animation: resultCardIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s both;
}
.result-emoji {
  font-size: 2.5rem;
  margin-bottom: 8px;
  animation: resultEmojiPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s both;
}
.result-title {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 4px;
}
.result-sub {
  color: var(--text2);
  margin-bottom: 16px;
  font-size: 0.9rem;
}

@keyframes resultCardIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
@keyframes resultEmojiPop {
  0% {
    transform: scale(0);
  }
  50% {
    transform: scale(1.3);
  }
  100% {
    transform: scale(1);
  }
}

/* Battle Arena — RTS */
.battle-game-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  position: relative;
  animation: contentSlideUp 0.35s ease-out both;
}

/* HUD bar above canvas */
.battle-hud {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  margin-bottom: 10px;
  font-size: 0.82rem;
}
.battle-hud-side {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}
.battle-hud-right {
  flex-direction: row-reverse;
}
.battle-hud-gold {
  color: #fbbf24;
  font-weight: 700;
}
.battle-hud-units {
  color: var(--text2);
  font-size: 0.75rem;
}
.battle-hud-status {
  flex: 0 0 auto;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text2);
  text-align: center;
  min-width: 120px;
}

/* Canvas */
.rts-canvas-wrap {
  position: relative;
  width: 100%;
  margin-bottom: 10px;
}
#rts-canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: crosshair;
}
.rts-hint {
  position: absolute;
  bottom: 6px;
  right: 8px;
  font-size: 0.7rem;
  color: rgba(148, 163, 184, 0.6);
  pointer-events: none;
}

/* Buy buttons row */
.battle-buy-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.buy-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.buy-btn {
  flex: 1;
  min-width: 70px;
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 8px 6px;
  text-align: center;
  transition: all 0.15s;
  line-height: 1.3;
}
.buy-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: rgba(129, 140, 248, 0.12);
}
.buy-btn:disabled {
  opacity: 0.4;
  cursor: default;
}
.buy-btn small {
  color: var(--text2);
  font-weight: 400;
  font-size: 0.7rem;
}
#autopath-btn {
  flex: 0 0 auto;
  min-width: 90px;
}
#autopath-btn.autopath-on {
  border-color: #4ade80;
  color: #4ade80;
}
#autopath-btn.autopath-off {
  border-color: #f87171;
  color: #f87171;
}

.battle-status {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text2);
  font-weight: 600;
}

/* Welcome Modal */
.welcome-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: modalOverlayIn 0.3s ease-out both;
}
.welcome-modal.modal-exit {
  animation: modalOverlayOut 0.25s ease-in both;
  pointer-events: none;
}

.welcome-card {
  background: var(--surface);
  border: 2px solid var(--x-color);
  border-radius: var(--radius);
  padding: 40px 32px;
  max-width: 480px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow);
  animation: modalCardIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.welcome-modal.modal-exit .welcome-card {
  animation: modalCardOut 0.2s ease-in both;
}

@keyframes modalOverlayIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes modalOverlayOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}
@keyframes modalCardIn {
  from {
    opacity: 0;
    transform: scale(0.85) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}
@keyframes modalCardOut {
  from {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
  to {
    opacity: 0;
    transform: scale(0.9) translateY(10px);
  }
}

.welcome-emoji {
  font-size: 3.5rem;
  margin-bottom: 16px;
}

.welcome-card h2 {
  font-size: 1.6rem;
  margin-bottom: 16px;
  background: linear-gradient(135deg, var(--x-color), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome-card p {
  color: var(--text2);
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 12px;
}

.welcome-card p strong {
  color: var(--text);
  font-weight: 700;
}

/* Home Screen Hero */
.home-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.hero-section {
  position: relative;
  max-width: 680px;
  width: 100%;
  text-align: center;
  z-index: 1;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 32px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  animation: heroIn 0.5s ease-out both;
}

@keyframes heroIn {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.hero-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.35;
  pointer-events: none;
}
.hero-orb-1 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle at 30% 40%, #f472b6, transparent 70%);
  top: -150px;
  left: -100px;
  animation: floatOrb 8s ease-in-out infinite;
}
.hero-orb-2 {
  width: 350px;
  height: 350px;
  background: radial-gradient(circle at 50% 50%, #818cf8, transparent 70%);
  top: 50px;
  right: -80px;
  animation: floatOrb 10s ease-in-out infinite reverse;
  animation-delay: 1s;
}
.hero-orb-3 {
  width: 300px;
  height: 300px;
  background: radial-gradient(circle at 70% 60%, #38bdf8, transparent 70%);
  bottom: -80px;
  left: 10%;
  animation: floatOrb 12s ease-in-out infinite;
  animation-delay: 2s;
}
@keyframes floatOrb {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-30px);
  }
}

.hero-eyebrow {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text2);
  margin-bottom: 12px;
}

.hero-title {
  font-size: 3.5rem;
  font-weight: 900;
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--x-color), var(--accent), var(--o-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-size: 1.1rem;
  color: var(--text2);
  margin-bottom: 32px;
  line-height: 1.6;
}

.hero-cta-row {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  position: relative;
  z-index: 10;
}

.hero-cta-row button {
  min-width: 150px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-divider {
  text-align: center;
  color: var(--text2);
  font-size: 0.85rem;
  margin: 16px 0;
  position: relative;
}
.hero-divider::before,
.hero-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background: var(--border);
}
.hero-divider::before {
  left: 0;
}
.hero-divider::after {
  right: 0;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-top: 40px;
}

.feature-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  transition: all 0.2s;
  cursor: default;
  animation: featureCardIn 0.4s ease-out both;
}
.feature-card:nth-child(1) { animation-delay: 0.15s; }
.feature-card:nth-child(2) { animation-delay: 0.25s; }
.feature-card:nth-child(3) { animation-delay: 0.35s; }
.feature-card:nth-child(4) { animation-delay: 0.45s; }
.feature-card:nth-child(5) { animation-delay: 0.55s; }
.feature-card:nth-child(6) { animation-delay: 0.65s; }
.feature-card:nth-child(7) { animation-delay: 0.75s; }
.feature-card:nth-child(8) { animation-delay: 0.85s; }

@keyframes featureCardIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
.feature-card:hover {
  border-color: var(--accent);
  background: rgba(129, 140, 248, 0.08);
  transform: translateY(-2px);
}

.feature-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.feature-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 4px;
}

.feature-desc {
  font-size: 0.8rem;
  color: var(--text2);
}

/* Full-screen background screens (home + auth) */
#home-screen,
#auth-screen {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  max-width: none;
  padding: 0;
  margin: 0;
  z-index: 100;
  background: #0a0f1e url('/media/platform_images/background_image.png') no-repeat center center;
  background-size: cover;
  overflow-y: auto;
}

#home-screen.active,
#auth-screen.active {
  display: block;
}

#home-screen::before,
#auth-screen::before {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 30, 0.55);
  z-index: 0;
  pointer-events: none;
}

#home-screen > *,
#auth-screen > * {
  position: relative;
  z-index: 1;
}

/* Auth Screen Wrapper */
.auth-screen-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: authCardIn 0.4s ease-out both;
}

@keyframes authCardIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Auth flow switch animation */
#login-flow,
#signup-flow,
#verify-flow {
  animation: flowFadeIn 0.3s ease-out both;
}
@keyframes flowFadeIn {
  from {
    opacity: 0;
    transform: translateX(12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.agent-card {
  border-color: transparent;
}

.tab-row {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
}

.tab-btn {
  flex: 1;
  padding: 12px 20px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text2);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.verify-section {
  border-top: 1px solid var(--border);
  padding-top: 20px;
  margin-top: 20px;
  animation: contentSlideUp 0.3s ease-out both;
}

.verify-prompt {
  color: var(--text2);
  font-size: 0.9rem;
  margin-bottom: 12px;
  line-height: 1.5;
}

.cred-warning-box {
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid #fbbf24;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
  color: var(--text);
  animation: contentSlideUp 0.3s ease-out both;
}

.cred-token-row {
  margin-bottom: 16px;
}

/* Identity Bar (on setup screen) */
.identity-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 0.9rem;
  font-weight: 600;
}

#identity-user-info {
  color: var(--text);
}

/* Auth Bar */
.auth-bar {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 20px;
}
.auth-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.auth-row input {
  margin-bottom: 0;
  flex: 1;
  font-size: 0.85rem;
  padding: 7px 10px;
}
input[type='password'] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  padding: 10px 14px;
  outline: none;
  margin-bottom: 20px;
  transition: border-color 0.2s;
}
input[type='password']:focus {
  border-color: var(--accent);
}
.auth-error {
  color: #ef4444;
  font-size: 0.8rem;
  margin-top: 6px;
  min-height: 18px;
}
#auth-logged-in {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  font-weight: 600;
}
.auth-badge {
  background: rgba(74, 222, 128, 0.15);
  color: var(--win);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--win);
}
.btn-primary.small,
.btn-secondary.small {
  font-size: 0.8rem;
  padding: 6px 14px;
}

/* Verification Modal */
.verify-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.verify-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
  max-width: 420px;
  width: 90%;
  box-shadow: var(--shadow);
}
.verify-card h3 {
  font-size: 1.1rem;
  margin-bottom: 12px;
}
.verify-card p {
  color: var(--text2);
  font-size: 0.9rem;
  margin-bottom: 14px;
  line-height: 1.5;
}
.verify-card input {
  margin-bottom: 12px;
}
.verify-actions {
  display: flex;
  gap: 10px;
}

/* Admin Dashboard */
.admin-dashboard {
  min-height: 100vh;
  padding: 40px 20px;
  background: var(--bg);
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 40px;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}

.admin-header h1 {
  font-size: 2.2rem;
  background: linear-gradient(135deg, var(--x-color), var(--accent), var(--o-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0;
}

.admin-content {
  max-width: 1200px;
  margin: 0 auto;
}

.admin-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}

.admin-section h2 {
  font-size: 1.3rem;
  margin-bottom: 20px;
  color: var(--text);
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.stat-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}

.stat-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text2);
  margin-bottom: 8px;
  font-weight: 600;
}

.stat-value {
  font-size: 2rem;
  font-weight: 900;
  color: var(--accent);
}

/* Admin Table */
.admin-table {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.admin-table-header {
  display: grid;
  grid-template-columns: 1fr 1fr 0.7fr 0.7fr 1fr;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text2);
  gap: 12px;
}

.admin-table-row {
  display: grid;
  grid-template-columns: 1fr 1fr 0.7fr 0.7fr 1fr;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  align-items: center;
  font-size: 0.9rem;
}

.admin-table-row:last-child {
  border-bottom: none;
}

.admin-table-row:hover {
  background: var(--surface2);
}

.admin-table-col {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid transparent;
}

/* Admin Table Tabs */
.admin-table-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.admin-tab-btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text2);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}

.admin-tab-btn:hover {
  background: var(--surface2);
  color: var(--text);
}

.admin-tab-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Admin Data Table */
.admin-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.admin-data-table th {
  background: var(--surface2);
  color: var(--text2);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 12px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
  font-size: 0.72rem;
}

.admin-data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.admin-data-table tr:hover td {
  background: var(--surface2);
}

.admin-actions-cell {
  display: flex;
  gap: 4px;
  white-space: nowrap !important;
  overflow: visible;
  max-width: none;
}

.admin-edit-btn,
.admin-delete-btn {
  padding: 3px 8px;
  font-size: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
}

.admin-edit-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.admin-delete-btn:hover {
  background: #dc2626;
  color: #fff;
  border-color: #dc2626;
}

.admin-field-input {
  width: 100%;
  padding: 8px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
  margin-top: 4px;
}

.admin-field-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.badge.human {
  background: var(--x-bg);
  color: var(--x-color);
  border-color: var(--x-color);
}

.badge.agent {
  background: rgba(56, 189, 248, 0.12);
  color: var(--o-color);
  border-color: var(--o-color);
}

/* Taboo Game — Full-screen Layout */
.taboo-fullscreen {
  position: fixed;
  inset: 0;
  flex-direction: column;
  padding: 16px 24px;
  box-sizing: border-box;
  background: var(--bg);
  z-index: 50;
}
.taboo-fullscreen.active {
  display: flex;
}
.taboo-fullscreen .status-bar {
  flex-shrink: 0;
  margin-bottom: 10px;
}
.taboo-fullscreen .result-overlay {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  top: auto;
  border-radius: var(--radius) var(--radius) 0 0;
  z-index: 60;
}

.taboo-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.taboo-title {
  font-size: 1.3rem;
  margin: 0;
  text-align: center;
  flex: 1;
}

.taboo-top-right {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 120px;
  justify-content: flex-end;
}

.taboo-main {
  display: flex;
  gap: 14px;
  flex: 1;
  min-height: 0;
}

.taboo-sidebar {
  flex: 0 0 220px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  min-height: 0;
}

.taboo-sidebar-right {
  flex: 0 0 180px;
}

.taboo-sidebar-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 4px 0;
  flex-shrink: 0;
}

.taboo-chat-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.taboo-players-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.taboo-player-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  font-size: 0.85rem;
}

.taboo-player-card.eliminated {
  opacity: 0.45;
  background: var(--surface);
}

.taboo-player-card.taboo-player-self {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.1);
}

.taboo-player-name {
  font-weight: 600;
  margin-bottom: 6px;
}

.taboo-forbidden-words {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
  font-size: 0.75rem;
}

.taboo-word {
  background: var(--surface);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  color: #fbbf24;
}

.taboo-word-triggered {
  text-decoration: line-through;
  opacity: 0.45;
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.3);
}

.taboo-lives {
  font-size: 0.9rem;
}

.life-heart {
  margin-right: 2px;
}

.taboo-chat-history {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 8px 4px 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
}

.taboo-chat-message {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.9rem;
}

.taboo-chat-header {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.taboo-chat-text {
  line-height: 1.5;
  word-wrap: break-word;
  font-size: 0.9rem;
}

.taboo-triggered-warning {
  font-size: 0.8rem;
  color: #f87171;
  margin-top: 6px;
  padding: 3px 6px;
  background: rgba(248, 113, 113, 0.1);
  border-radius: 4px;
}

.taboo-input-area {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
  flex-shrink: 0;
}

.taboo-message-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 12px;
  resize: vertical;
  min-height: 80px;
  outline: none;
  transition: border-color 0.2s;
}

.taboo-message-input:focus {
  border-color: var(--accent);
}

.taboo-input-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}

.taboo-char-count {
  color: var(--text2);
}

.taboo-current-speaker {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  font-size: 0.95rem;
  text-align: center;
}

.taboo-current-speaker-name {
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--accent);
}

.taboo-countdown {
  font-family: monospace;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 8px;
}

.lang-selector {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  outline: none;
}
.lang-selector:hover {
  border-color: var(--accent);
}
.lang-selector option {
  background: var(--surface);
  color: var(--text);
}

/* ============================================
   Platform Main Page (Setup Screen)
   ============================================ */

.platform-screen {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  max-width: none;
  padding: 0;
  margin: 0;
  z-index: 100;
  background: radial-gradient(ellipse at 20% 50%, #0a0e27 0%, #060912 100%);
  overflow-y: auto;
  flex-direction: column;
  /* display is controlled by .screen / .screen.active rules */
}

/* Vignette overlay — deep darkness at edges */
.platform-screen::before {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at 50% 30%, transparent 30%, rgba(4, 6, 14, 0.85) 100%);
  z-index: 0;
  pointer-events: none;
}

/* Canvas for the agent world */
#platform-bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* Ambient glow — subtle, not the main show */
.platform-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
}
.platform-orb-1 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(129, 140, 248, 0.25), transparent 70%);
  top: 10%;
  left: 35%;
  animation: orbSlow 30s ease-in-out infinite;
}
.platform-orb-2 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.15), transparent 70%);
  bottom: 5%;
  right: 10%;
  animation: orbSlow 25s ease-in-out infinite reverse;
}
.platform-orb-3 {
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(244, 114, 182, 0.1), transparent 70%);
  top: 60%;
  left: 5%;
  animation: orbSlow 35s ease-in-out infinite;
}
.platform-orb-4 {
  display: none;
}

@keyframes orbSlow {
  0%,
  100% {
    transform: translate(0, 0);
    opacity: 0.6;
  }
  50% {
    transform: translate(40px, -30px);
    opacity: 1;
  }
}

.platform-screen > * {
  position: relative;
  z-index: 1;
}
.platform-screen > .platform-orb {
  position: fixed;
  z-index: 0;
}

/* Header Bar */
.platform-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(51, 65, 85, 0.5);
  flex-shrink: 0;
  gap: 16px;
}

.platform-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.platform-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--accent);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
}

.platform-user-info {
  min-width: 0;
}

.platform-user-name {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.platform-user-type {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text2);
}

.platform-link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.78rem;
  padding: 0;
  text-decoration: underline;
}
.platform-link-btn:hover {
  color: var(--text);
}

.platform-header-stats {
  display: flex;
  align-items: center;
  gap: 20px;
}

.platform-stat {
  text-align: center;
  padding: 4px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(30, 41, 59, 0.6);
}

.platform-stat-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text2);
  margin-bottom: 2px;
}

.platform-stat-value {
  font-size: 1rem;
  font-weight: 800;
  color: var(--accent);
}

.platform-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.platform-logout-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 6px;
  letter-spacing: 0.05em;
  transition: all 0.2s;
}
.platform-logout-btn:hover {
  border-color: var(--x-color);
  color: var(--x-color);
}

/* Main Content Area */
.platform-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 32px 24px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  gap: 14px;
  overflow-y: auto;
  min-height: 0;
}

/* Title */
.platform-title-section {
  text-align: center;
}

.platform-main-title {
  font-size: 2.4rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  background: linear-gradient(135deg, var(--x-color), var(--accent), var(--o-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0 0 4px 0;
}

.platform-main-subtitle {
  font-size: 0.95rem;
  color: var(--text2);
}

/* Game Carousel */
.game-carousel-wrapper {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
}

.carousel-arrow {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 2rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
  line-height: 1;
}
.carousel-arrow:hover {
  border-color: var(--accent);
  background: rgba(129, 140, 248, 0.2);
}

.game-carousel {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  scroll-behavior: smooth;
  padding: 8px 4px;
  flex: 1;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.game-carousel::-webkit-scrollbar {
  display: none;
}

.game-card {
  flex: 0 0 200px;
  cursor: pointer;
  transition: all 0.3s;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  opacity: 1;
  filter: brightness(1);
}
.game-card:hover {
  transform: translateY(-4px);
}
/* Dim non-active cards only after a selection is made */
.game-carousel.has-selection .game-card {
  opacity: 0.45;
  filter: brightness(0.7);
}
.game-carousel.has-selection .game-card:hover {
  opacity: 0.8;
  filter: brightness(0.9);
}
.game-carousel.has-selection .game-card.active {
  opacity: 1;
  filter: brightness(1);
  transform: translateY(-4px) scale(1.04);
}
.game-card.active .game-card-image {
  box-shadow: 0 0 24px rgba(129, 140, 248, 0.5);
}
/* Shake hint when no game selected */
@keyframes carouselShake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-6px);
  }
  40% {
    transform: translateX(6px);
  }
  60% {
    transform: translateX(-4px);
  }
  80% {
    transform: translateX(4px);
  }
}
.carousel-shake {
  animation: carouselShake 0.5s ease;
}

.game-card-image {
  width: 100%;
  height: 180px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  overflow: hidden;
  transition: all 0.3s;
}
.game-card.active .game-card-image {
  border-color: var(--accent);
}
.game-card:hover .game-card-image {
  border-color: var(--text2);
}

.game-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.game-card-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 24px 10px 8px;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.85) 0%,
    rgba(0, 0, 0, 0.4) 60%,
    transparent 100%
  );
  border-radius: 0 0 var(--radius) var(--radius);
  pointer-events: none;
}

.game-card-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: #fff;
  margin-bottom: 2px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.game-card-desc {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.8);
  line-height: 1.3;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Carousel Dots */
.carousel-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.carousel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  cursor: pointer;
  transition: all 0.2s;
}
.carousel-dot.active {
  background: var(--accent);
  width: 24px;
  border-radius: 4px;
}

/* VS Modes Section */
.vs-modes-section {
  width: 100%;
}

.vs-modes-label {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text2);
  margin-bottom: 12px;
}

.vs-modes-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.vs-mode-card {
  position: relative;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.9));
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 12px 14px;
  cursor: pointer;
  text-align: center;
  transition: all 0.25s;
  overflow: hidden;
  color: var(--text);
}

.vs-mode-card.vs-mode-hvh {
  border-color: rgba(56, 189, 248, 0.4);
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.1), rgba(15, 23, 42, 0.9));
}
.vs-mode-card.vs-mode-hvai {
  border-color: rgba(244, 114, 182, 0.4);
  background: linear-gradient(135deg, rgba(244, 114, 182, 0.1), rgba(15, 23, 42, 0.9));
}
.vs-mode-card.vs-mode-avai {
  border-color: rgba(192, 132, 252, 0.4);
  background: linear-gradient(135deg, rgba(192, 132, 252, 0.1), rgba(15, 23, 42, 0.9));
}

.vs-mode-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}
.vs-mode-card.vs-mode-hvh:hover {
  border-color: var(--o-color);
}
.vs-mode-card.vs-mode-hvai:hover {
  border-color: var(--x-color);
}
.vs-mode-card.vs-mode-avai:hover {
  border-color: #c084fc;
}

.vs-mode-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 1.8rem;
}

.vs-text {
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--accent);
  text-shadow: 0 0 12px rgba(129, 140, 248, 0.6);
}

.vs-silhouette {
  font-size: 2rem;
  opacity: 0.9;
}

.vs-mode-title {
  font-weight: 700;
  font-size: 0.88rem;
  margin-bottom: 4px;
}

.vs-mode-desc {
  font-size: 0.72rem;
  color: var(--text2);
}

/* Game Action Bar (Create Room / Ranked Match) */
.game-action-bar {
  width: 100%;
  padding: 16px 20px;
  background: rgba(56, 189, 248, 0.06);
  border: 1px solid rgba(56, 189, 248, 0.15);
  border-radius: 12px;
  margin-bottom: 8px;
}

.game-action-buttons {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.game-active-buttons {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  margin-top: 10px;
  margin-bottom: 8px;
  opacity: 0;
  transform: translateY(-8px);
  transition:
    opacity 0.4s ease,
    transform 0.4s ease;
}
.game-active-buttons.visible {
  opacity: 1;
  transform: translateY(0);
}

.game-action-btn {
  padding: 10px 28px;
  font-size: 0.95rem;
}

.create-room-btn {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  border: none;
}

.ranked-btn {
  background: linear-gradient(135deg, #f59e0b, #eab308);
  border: none;
}
.ranked-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

.back-to-game-btn {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  border: none;
}

.give-up-btn {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  border: none;
}

.matchmaking-row {
  margin-top: 0;
}

.matchmaking-status-badge {
  flex: 1;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  color: #fff;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  animation: matchmakingPulse 2s ease-in-out infinite;
}

.matchmaking-status-badge.matched {
  background: rgba(74, 222, 128, 0.15);
  border-color: rgba(74, 222, 128, 0.4);
  color: var(--win);
  animation: none;
}

@keyframes matchmakingPulse {
  0%,
  100% {
    border-color: rgba(56, 189, 248, 0.3);
  }
  50% {
    border-color: rgba(56, 189, 248, 0.6);
  }
}

.ranked-note {
  font-size: 0.8rem;
  color: var(--text2);
  margin-top: 6px;
}

.vs-mode-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}

/* Bottom Bar */
.platform-bottom-bar {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.platform-join-section {
  width: 100%;
  max-width: 500px;
}

.platform-join-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text2);
  margin-bottom: 8px;
}

.platform-join-section .join-row {
  display: flex;
  gap: 10px;
}
.platform-join-section .join-row input {
  flex: 1;
}

.platform-watch-btn {
  background: rgba(74, 222, 128, 0.12);
  border: 1px solid var(--win);
  color: var(--win);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 12px 32px;
  border-radius: 8px;
  width: 100%;
  max-width: 500px;
  transition: all 0.2s;
}
.platform-watch-btn:hover {
  background: rgba(74, 222, 128, 0.2);
  box-shadow: 0 0 16px rgba(74, 222, 128, 0.2);
}

/* ============================================
   Platform Main Layout (Sidebar + Content)
   ============================================ */

.platform-main-layout {
  flex: 1;
  display: flex;
  width: 100%;
  min-height: 0;
  overflow: hidden;
}

/* Left Sidebar */
.platform-sidebar {
  width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  background: rgba(10, 14, 30, 0.6);
  border-right: 1px solid rgba(51, 65, 85, 0.4);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px 10px;
  flex-shrink: 0;
}

.sidebar-section-icon {
  font-size: 1rem;
  opacity: 0.8;
}

.sidebar-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text2);
}

/* Leaderboard */
.sidebar-leaderboard {
  flex: 0 0 auto;
  border-bottom: 1px solid rgba(51, 65, 85, 0.4);
  padding-bottom: 8px;
}

.leaderboard-list {
  padding: 0 12px;
  overflow-y: auto;
  max-height: 340px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.leaderboard-list::-webkit-scrollbar {
  width: 4px;
}
.leaderboard-list::-webkit-scrollbar-track {
  background: transparent;
}
.leaderboard-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.leaderboard-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 8px;
  transition: background 0.2s;
}
.leaderboard-row:hover {
  background: rgba(129, 140, 248, 0.08);
}

.leaderboard-rank {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 800;
  flex-shrink: 0;
  background: rgba(51, 65, 85, 0.5);
  color: var(--text2);
}
.leaderboard-rank.rank-1 {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #0f172a;
}
.leaderboard-rank.rank-2 {
  background: linear-gradient(135deg, #94a3b8, #64748b);
  color: #0f172a;
}
.leaderboard-rank.rank-3 {
  background: linear-gradient(135deg, #d97706, #b45309);
  color: #0f172a;
}

.leaderboard-info {
  flex: 1;
  min-width: 0;
}
.leaderboard-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.leaderboard-name .player-type-tag {
  font-size: 0.6rem;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 4px;
  vertical-align: middle;
}
.leaderboard-name .tag-ai {
  background: rgba(244, 114, 182, 0.2);
  color: var(--x-color);
}
.leaderboard-name .tag-human {
  background: rgba(56, 189, 248, 0.2);
  color: var(--o-color);
}
.leaderboard-wins {
  font-size: 0.68rem;
  color: var(--text2);
}
.leaderboard-rating {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

/* Recent Matches */
.sidebar-recent-matches {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.recent-matches-scroller {
  max-height: 400px;
  overflow-y: auto;
  padding: 0 2px;
}

.recent-matches-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.recent-match-card {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(51, 65, 85, 0.4);
  border-radius: 8px;
  padding: 10px 12px;
  transition: all 0.2s;
  flex-shrink: 0;
}
.recent-match-card:hover {
  border-color: rgba(129, 140, 248, 0.3);
  background: rgba(30, 41, 59, 0.8);
}

.recent-match-card.match-live {
  border-color: rgba(74, 222, 128, 0.4);
  cursor: pointer;
}
.recent-match-card.match-live:hover {
  border-color: rgba(74, 222, 128, 0.7);
  background: rgba(74, 222, 128, 0.08);
  transform: translateY(-1px);
}

.match-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.match-game-type {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text2);
}

.match-badge {
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
}
.match-badge.badge-live {
  background: rgba(74, 222, 128, 0.2);
  color: var(--win);
  animation: livePulse 2s ease-in-out infinite;
}
.match-badge.badge-finished {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text2);
}

@keyframes livePulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.match-players-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.match-player {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.match-player-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.match-vs {
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--text2);
  flex-shrink: 0;
}

.match-player.winner .match-player-name {
  color: var(--win);
}

.match-score-change {
  font-size: 0.68rem;
  font-weight: 700;
  flex-shrink: 0;
}
.match-score-change.positive {
  color: var(--win);
}
.match-score-change.negative {
  color: #ef4444;
}

.match-result-line {
  font-size: 0.65rem;
  color: var(--text2);
  margin-top: 4px;
  text-align: center;
}

/* =============================================
   Responsive — Platform Main Page
   ============================================= */

/* Tablet / small desktop (<=1024px) */
@media (max-width: 1024px) {
  .platform-sidebar {
    width: 240px;
  }
  .platform-header {
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 16px;
  }
  .platform-header-stats {
    order: 3;
    width: 100%;
    justify-content: center;
    gap: 12px;
  }
  .platform-main-title {
    font-size: 2rem;
  }
  .platform-content {
    padding: 10px 20px 20px;
    gap: 12px;
  }
}

/* Small tablet / large phone (<=768px) */
@media (max-width: 768px) {
  .platform-sidebar {
    display: none;
  }
  .platform-main-title {
    font-size: 1.6rem;
    letter-spacing: 0.02em;
  }
  .platform-main-subtitle {
    font-size: 0.85rem;
  }
  .vs-modes-grid {
    grid-template-columns: 1fr;
    max-width: 400px;
    margin: 0 auto;
  }
  .vs-mode-card {
    padding: 14px 12px;
  }
  .vs-mode-icon {
    font-size: 1.4rem;
    gap: 6px;
  }
  .game-card {
    flex: 0 0 160px;
  }
  .game-card-image {
    height: 120px;
  }
  .game-card-title {
    font-size: 0.82rem;
  }
  .platform-stat-label {
    font-size: 0.58rem;
  }
  .platform-stat-value {
    font-size: 0.88rem;
  }
  .platform-stat {
    padding: 4px 10px;
  }
  .platform-bottom-bar {
    gap: 10px;
  }
}

/* Phone (<=480px) */
@media (max-width: 480px) {
  .platform-header {
    padding: 8px 12px;
    gap: 8px;
  }
  .platform-avatar {
    width: 34px;
    height: 34px;
  }
  .platform-avatar svg {
    width: 28px;
    height: 28px;
  }
  .platform-user-name {
    font-size: 0.88rem;
  }
  .platform-user-type {
    font-size: 0.7rem;
  }
  .platform-link-btn {
    font-size: 0.7rem;
  }
  .platform-header-stats {
    gap: 6px;
  }
  .platform-stat {
    padding: 3px 6px;
    border-radius: 6px;
  }
  .platform-stat-label {
    font-size: 0.5rem;
    letter-spacing: 0.03em;
  }
  .platform-stat-value {
    font-size: 0.78rem;
  }
  .platform-header-right {
    gap: 4px;
    flex-shrink: 1;
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  .platform-logout-btn {
    font-size: 0.7rem;
    padding: 4px 8px;
  }
  .lang-selector {
    font-size: 0.75rem;
    padding: 4px 6px;
  }
  .platform-content {
    padding: 8px 12px 16px;
    gap: 10px;
  }
  .platform-main-title {
    font-size: 1.3rem;
  }
  .platform-main-subtitle {
    font-size: 0.78rem;
  }
  .game-carousel-wrapper {
    gap: 4px;
  }
  .carousel-arrow {
    width: 30px;
    height: 30px;
    font-size: 1.4rem;
  }
  .game-card {
    flex: 0 0 130px;
  }
  .game-card-image {
    height: 95px;
    border-radius: 8px;
  }
  .game-card-info {
    padding: 16px 6px 4px;
  }
  .game-card-title {
    font-size: 0.75rem;
  }
  .game-card-desc {
    font-size: 0.6rem;
  }
  .carousel-dots {
    gap: 6px;
  }
  .carousel-dot {
    width: 6px;
    height: 6px;
  }
  .carousel-dot.active {
    width: 18px;
  }
  .vs-modes-label {
    font-size: 0.78rem;
    margin-bottom: 8px;
  }
  .vs-modes-grid {
    grid-template-columns: 1fr;
    max-width: none;
    gap: 10px;
  }
  .vs-mode-card {
    padding: 12px 10px;
  }
  .vs-mode-icon {
    font-size: 1.2rem;
    margin-bottom: 4px;
  }
  .vs-text {
    font-size: 1rem;
  }
  .vs-silhouette {
    font-size: 1.5rem;
  }
  .vs-mode-title {
    font-size: 0.82rem;
  }
  .vs-mode-desc {
    font-size: 0.68rem;
  }
  .platform-join-label {
    font-size: 0.68rem;
  }
  .platform-join-section .join-row input {
    font-size: 0.88rem;
    padding: 8px 10px;
  }
  .platform-join-section .join-row .btn-primary {
    font-size: 0.85rem;
    padding: 8px 16px;
  }
  .platform-watch-btn {
    font-size: 0.82rem;
    padding: 10px 20px;
  }
}

/* Very small phone (<=360px) */
@media (max-width: 360px) {
  .platform-header {
    flex-wrap: wrap;
    gap: 6px;
  }
  .platform-header-left {
    gap: 8px;
  }
  .platform-avatar {
    width: 28px;
    height: 28px;
  }
  .platform-avatar svg {
    width: 24px;
    height: 24px;
  }
  .platform-user-name {
    font-size: 0.8rem;
  }
  .platform-header-stats {
    flex-wrap: wrap;
    gap: 4px;
    width: 100%;
    justify-content: center;
  }
  .platform-stat {
    flex: 1;
    min-width: 0;
  }
  .platform-main-title {
    font-size: 1.1rem;
  }
  .game-card {
    flex: 0 0 110px;
  }
  .game-card-image {
    height: 80px;
  }
  .vs-modes-grid {
    gap: 8px;
  }
  .feature-grid {
    grid-template-columns: 1fr;
  }
}

/* =============================================
   Responsive — Other Screens (existing pages)
   ============================================= */

/* Game screens on small devices */
@media (max-width: 600px) {
  #app {
    padding: 8px;
  }
  .setup-card {
    padding: 20px 16px;
  }
  .game-container {
    padding: 16px;
    max-height: none;
  }
  .game-header {
    flex-wrap: wrap;
    gap: 4px;
  }
  .game-header h1 {
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
  }
  .game-area {
    flex-direction: column;
    gap: 12px;
  }
  .player-panel {
    flex: none;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
  }
  .player-mark {
    font-size: 1.5rem;
    margin-bottom: 0;
  }
  .board {
    max-width: 280px;
  }
  .cell {
    font-size: 2rem;
  }
  .mode-grid {
    grid-template-columns: 1fr;
  }
  .lobby-container {
    padding: 16px;
  }
  .lobby-header h1 {
    font-size: 1.1rem;
  }
  .battle-game-container {
    padding: 10px;
  }
  .battle-hud {
    flex-wrap: wrap;
    font-size: 0.72rem;
    padding: 4px 8px;
  }
  .battle-buy-row {
    flex-wrap: wrap;
    gap: 6px;
  }
  .buy-btn {
    min-width: 60px;
    font-size: 0.72rem;
    padding: 6px 4px;
  }
  /* QA */
  .qa-scores {
    gap: 12px;
  }
  .qa-score-panel {
    padding: 8px 12px;
    min-width: 80px;
  }
  .qa-score-value {
    font-size: 1.6rem;
  }
  .qa-options {
    grid-template-columns: 1fr;
  }
  /* Home screen hero */
  .hero-title {
    font-size: 2.2rem;
  }
  .hero-subtitle {
    font-size: 0.95rem;
    margin-bottom: 20px;
  }
  .hero-section {
    padding: 28px 20px;
  }
  .feature-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 24px;
  }
  .feature-card {
    padding: 14px;
  }
  .hero-cta-row {
    flex-direction: column;
    gap: 10px;
  }
  .hero-cta-row button {
    min-width: 0;
    width: 100%;
  }
  /* Auth */
  .auth-card {
    padding: 24px 16px;
  }
  .welcome-card {
    padding: 28px 20px;
  }
  /* Taboo */
  .taboo-main {
    flex-direction: column;
  }
  .taboo-sidebar {
    flex: none;
    max-height: 120px;
  }
  .taboo-sidebar-right {
    flex: none;
    max-height: 80px;
  }
  .taboo-fullscreen {
    padding: 8px 12px;
  }
  .taboo-title {
    font-size: 1rem;
  }
}

/* ===== Ready Section ===== */

.ready-game-preview {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  align-items: flex-start;
}

.ready-game-image {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 10px;
  border: 2px solid var(--border);
  flex-shrink: 0;
}

.ready-game-info {
  flex: 1;
  min-width: 0;
}

.ready-game-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
}

.ready-game-guide {
  font-size: 0.8rem;
  color: var(--text2);
  line-height: 1.5;
  max-height: 140px;
  overflow-y: auto;
}

.ready-game-guide ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.ready-game-guide li {
  padding: 2px 0 2px 14px;
  position: relative;
}

.ready-game-guide li:before {
  content: '\2022';
  position: absolute;
  left: 2px;
  color: var(--accent);
}

.ready-game-guide li strong {
  color: var(--text);
}

.ready-players-list {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 16px 0;
  flex-wrap: wrap;
}

.ready-player-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 120px;
}

.ready-player-item .ready-player-mark {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.9rem;
}

.ready-player-item .ready-player-mark.x-mark {
  background: var(--x-bg);
  color: var(--x-color);
  border: 2px solid var(--x-color);
}

.ready-player-item .ready-player-mark.o-mark {
  background: var(--o-bg);
  color: var(--o-color);
  border: 2px solid var(--o-color);
}

.ready-player-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.ready-status {
  font-size: 0.75rem;
  color: var(--text2);
  padding: 3px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
}

.ready-status.is-ready {
  color: var(--win);
  background: rgba(74, 222, 128, 0.15);
  font-weight: 600;
}

.ready-btn {
  width: 100%;
  margin-top: 12px;
  font-size: 1.1rem;
  padding: 14px;
  animation: readyPulse 2s infinite;
}

@keyframes readyPulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(129, 140, 248, 0.4);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(129, 140, 248, 0);
  }
}

.ready-btn:disabled {
  animation: none;
  opacity: 0.7;
}

.ready-countdown {
  text-align: center;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
  margin-top: 10px;
  padding: 8px 0;
}

.ready-countdown.urgent {
  color: #ef4444;
  animation: countdownPulse 1s infinite;
}

@keyframes countdownPulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

@media (max-width: 500px) {
  .ready-game-preview {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  .ready-game-image {
    width: 80px;
    height: 80px;
  }
}

/* ===== Board Timer ===== */

.board-timer-bar {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin: 8px 0 4px;
}

.board-timer {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  padding: 4px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 100px;
  text-align: center;
  transition: color 0.3s;
}

/* ===== Game Header Right ===== */

.game-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== Instructions Modal ===== */

.instructions-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(4px);
}

.instructions-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: screenFadeIn 0.2s ease-out;
}

.instructions-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.instructions-header h2 {
  font-size: 1.2rem;
  color: var(--accent);
}

.instructions-close {
  background: none;
  border: none;
  color: var(--text2);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  border-radius: 6px;
  transition: all 0.2s;
}

.instructions-close:hover {
  color: var(--text);
  background: var(--surface2);
}

.instructions-body ul {
  list-style: none;
  padding: 0;
}

.instructions-body li {
  padding: 8px 0 8px 20px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.5;
  position: relative;
}

.instructions-body li:before {
  content: '\2022';
  position: absolute;
  left: 4px;
  color: var(--accent);
  font-weight: bold;
}

.instructions-body li:last-child {
  border-bottom: none;
}

/* ===== Info Buttons ===== */

.game-card {
  position: relative;
}

.game-card-info-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border);
  color: var(--text2);
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  transition: all 0.2s;
  line-height: 1;
}

.game-card-info-btn:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.game-info-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text2);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
  line-height: 1;
}

.game-info-btn:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* ── Identity Bar Avatar ─────────────────────────────────────────────────── */
.identity-avatar-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  flex-shrink: 0;
  transition:
    transform 0.15s,
    box-shadow 0.15s;
  vertical-align: middle;
  margin-right: 6px;
}
.platform-header-left .identity-avatar-btn {
  width: 44px;
  height: 44px;
  font-size: 1.1rem;
  border: 2px solid var(--accent);
}
.identity-avatar-btn:hover {
  transform: scale(1.15);
  box-shadow:
    0 0 0 4px rgba(129, 140, 248, 0.45),
    0 0 16px rgba(129, 140, 248, 0.25);
  border-color: var(--accent);
}
.identity-avatar-btn:active {
  transform: scale(1.05);
}

/* ── Profile Screen ──────────────────────────────────────────────────────── */
.profile-screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}
.profile-main {
  padding: 0;
  max-width: 100%;
}
.profile-cards-grid {
  display: flex;
  flex-direction: column;
  max-width: 100%;
  width: 100%;
}
.profile-card {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0 0 32px;
  box-shadow: none;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}
.profile-card-secondary {
  border: 1px solid rgba(129, 140, 248, 0.3);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 28px;
  max-width: 700px;
  margin: 0 auto 24px;
}
.profile-card-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 16px;
}
.agent-avatar {
  font-size: 1.6rem;
}
.agent-unbind-btn {
  color: #f87171 !important;
  border-color: rgba(248, 113, 113, 0.4) !important;
}
.agent-unbind-btn:hover {
  border-color: #f87171 !important;
  background: rgba(248, 113, 113, 0.08) !important;
}
/* Bind agent form card */
.profile-card-bind {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 40px 28px;
}
.bind-agent-icon {
  font-size: 2.5rem;
  margin-bottom: 14px;
}
.bind-agent-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 10px;
}
.bind-agent-desc {
  font-size: 0.88rem;
  color: var(--text2);
  line-height: 1.5;
  margin: 0 0 24px;
}
.bind-agent-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bind-agent-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 14px;
  font-size: 0.95rem;
  box-sizing: border-box;
  font-family: inherit;
}
.bind-agent-input:focus {
  outline: none;
  border-color: var(--accent);
}
/* Profile Hero Banner */
.profile-hero-banner {
  height: 160px;
  background: linear-gradient(135deg, var(--accent) 0%, #6366f1 40%, #ec4899 100%);
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 100%;
}
.profile-hero-avatar {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  background: var(--accent);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  border: 4px solid var(--surface);
  position: relative;
  top: 45px;
}
.profile-identity {
  text-align: center;
  padding: 52px 28px 0;
  max-width: 700px;
  margin: 0 auto;
}
.profile-identity-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 6px;
}
.profile-joined {
  font-size: 0.78rem;
  color: var(--text2);
}
/* Highlight row for rank / points / coins / win rate */
.profile-highlight-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 0 32px;
  margin: 16px auto 8px;
  max-width: 700px;
}
.profile-highlight {
  text-align: center;
  padding: 12px 6px;
  border-radius: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
}
.profile-highlight-value {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text);
}
.profile-highlight-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text2);
  margin-top: 2px;
}
.rank-highlight .profile-highlight-value {
  background: linear-gradient(135deg, #ffd700, #f59e0b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.coins-highlight .profile-highlight-value {
  color: #fbbf24;
}
/* Old profile-top kept for agent card compatibility */
.profile-top {
  display: flex;
  align-items: center;
  gap: 22px;
  margin: 20px 0 24px;
}
.profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  background: var(--accent);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
.profile-info {
  flex: 1;
  min-width: 0;
}
.profile-name {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0 0 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.profile-type-badge {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  margin-bottom: 8px;
}
.profile-type-badge.human {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}
.profile-type-badge.agent {
  background: rgba(129, 140, 248, 0.15);
  color: #818cf8;
  border: 1px solid rgba(129, 140, 248, 0.3);
}
.profile-id-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}
.profile-id-text {
  font-size: 0.72rem;
  color: var(--text2);
  font-family: monospace;
  word-break: break-all;
}
.profile-section {
  margin: 0 auto 24px;
  padding: 0 32px 24px;
  border-bottom: 1px solid var(--border);
  max-width: 700px;
  width: 100%;
  box-sizing: border-box;
}
.profile-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}
.profile-section-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text2);
  margin-bottom: 10px;
}
.profile-bio-text {
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.55;
  min-height: 1.4em;
}
.profile-bio-text.empty {
  color: var(--text2);
  font-style: italic;
}
.profile-bio-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 0.95rem;
  line-height: 1.5;
  resize: vertical;
  box-sizing: border-box;
  font-family: inherit;
}
.profile-bio-input:focus {
  outline: none;
  border-color: var(--accent);
}
.profile-bio-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  justify-content: flex-end;
}
.profile-edit-bio-btn {
  margin-top: 10px;
}
.profile-token-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  flex-wrap: wrap;
}
.profile-token-value {
  font-family: monospace;
  font-size: 0.82rem;
  color: var(--text);
  flex: 1;
  word-break: break-all;
}
.profile-token-hint {
  font-size: 0.75rem;
  color: var(--text2);
  margin-top: 8px;
  line-height: 1.4;
}
.profile-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.profile-stat {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 8px;
  text-align: center;
  transition: transform 0.15s;
}
.profile-stat:hover {
  transform: translateY(-2px);
}
.profile-stat-value {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--accent);
}
.profile-stat-label {
  font-size: 0.68rem;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 4px;
}
.stat-wins .profile-stat-value {
  color: #4ade80;
}
.stat-losses .profile-stat-value {
  color: #ef4444;
}
.stat-draws .profile-stat-value {
  color: #fbbf24;
}
.profile-history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
}
.profile-history-row,
.profile-history-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--surface2);
  border-radius: 8px;
  font-size: 0.85rem;
}
.profile-history-item.win { border-left: 3px solid var(--win, #4ade80); }
.profile-history-item.loss { border-left: 3px solid #f87171; }
.profile-history-item.draw { border-left: 3px solid var(--text2); }
.history-vs { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-result {
  font-weight: 700;
  font-size: 0.72rem;
  text-align: center;
  padding: 2px 5px;
  border-radius: 4px;
}
.history-result.win {
  color: var(--win);
  background: rgba(74, 222, 128, 0.12);
}
.history-result.loss {
  color: #f87171;
  background: rgba(248, 113, 113, 0.12);
}
.history-result.draw {
  color: var(--text2);
  background: rgba(148, 163, 184, 0.12);
}
.history-game-type {
  color: var(--text2);
  font-size: 0.8rem;
  text-transform: capitalize;
}
.history-opponent {
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-date {
  color: var(--text2);
  font-size: 0.72rem;
  white-space: nowrap;
}
.profile-empty,
.profile-loading {
  color: var(--text2);
  font-style: italic;
  text-align: center;
  padding: 24px 0;
  font-size: 0.9rem;
}

/* ─── Economy: Shop, Market, Skills ────────────────────────────────── */

/* Shared screen header for shop/market/skills */
.shop-screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.shop-balance {
  font-size: 0.9rem;
  color: var(--text2);
  font-weight: 600;
}

/* Shop/Market/Skills screens as full-page */
#shop-screen,
#market-screen,
#skills-screen {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  max-width: none;
  padding: 0;
  margin: 0;
  z-index: 100;
  background: var(--bg);
  overflow-y: auto;
}

/* Product/skill card grid */
.shop-grid,
.market-grid,
.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  padding: 24px;
  max-width: 1200px;
  margin: 0 auto;
}

/* Shop product card */
.shop-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all 0.2s;
  animation: contentSlideUp 0.35s ease-out both;
}

.shop-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.shop-card-icon {
  font-size: 2.5rem;
  text-align: center;
}

.shop-card-name {
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
}

.shop-card-desc {
  font-size: 0.85rem;
  color: var(--text2);
  text-align: center;
  line-height: 1.5;
}

.shop-card-category {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--surface2);
  color: var(--text2);
  border: 1px solid var(--border);
  text-align: center;
  align-self: center;
}

.shop-card-price {
  font-size: 1.3rem;
  font-weight: 900;
  color: #fbbf24;
  text-align: center;
}

.shop-card-stock {
  font-size: 0.75rem;
  color: var(--text2);
  text-align: center;
}

.shop-card-stock.low {
  color: var(--danger);
}

.shop-buy-btn {
  width: 100%;
  padding: 10px;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: opacity 0.2s;
}

.shop-buy-btn:hover:not(:disabled) {
  opacity: 0.85;
}

.shop-buy-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

/* Skill card (market & my skills) */
.skill-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 0.2s;
  animation: contentSlideUp 0.35s ease-out both;
}

.skill-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.skill-card.rarity-common {
  border-color: #94a3b8;
}
.skill-card.rarity-rare {
  border-color: #38bdf8;
}
.skill-card.rarity-epic {
  border-color: #c084fc;
}
.skill-card.rarity-legendary {
  border-color: #fbbf24;
}

.skill-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.skill-card-name {
  font-size: 1rem;
  font-weight: 700;
}

.skill-rarity-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 4px;
}

.skill-rarity-badge.common {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
  border: 1px solid #94a3b8;
}
.skill-rarity-badge.rare {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid #38bdf8;
}
.skill-rarity-badge.epic {
  background: rgba(192, 132, 252, 0.15);
  color: #c084fc;
  border: 1px solid #c084fc;
}
.skill-rarity-badge.legendary {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
  border: 1px solid #fbbf24;
}

.skill-card-desc {
  font-size: 0.85rem;
  color: var(--text2);
  line-height: 1.4;
}

.skill-card-seller {
  font-size: 0.8rem;
  color: var(--text2);
}

.skill-card-price {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fbbf24;
}

.skill-card-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
}

.skill-card-actions button {
  flex: 1;
}

.skill-listed-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(74, 222, 128, 0.15);
  color: #4ade80;
  border: 1px solid #4ade80;
}

/* Toast notification */
.toast-notification {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 16px 32px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  z-index: 9999;
  text-align: center;
  animation: toastIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.toast-notification.toast-exit {
  animation: toastOut 0.3s ease-in both;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  to {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
  }
}

.toast-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.toast-detail {
  font-size: 0.9rem;
  color: var(--text2);
}

.toast-points {
  color: var(--accent);
  font-weight: 700;
}

.toast-coins {
  color: #fbbf24;
  font-weight: 700;
}

/* Navigation buttons in platform header */
.platform-nav-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 14px;
  transition: all 0.2s;
  white-space: nowrap;
}

.platform-nav-btn:hover {
  border-color: var(--accent);
  background: rgba(129, 140, 248, 0.1);
  color: var(--accent);
}

/* Empty state for grids */
.economy-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text2);
  padding: 60px 20px;
  font-size: 1rem;
}

/* List price input modal */
.price-input-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: modalOverlayIn 0.3s ease-out both;
}

.price-input-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
  max-width: 360px;
  width: 90%;
  box-shadow: var(--shadow);
  animation: modalCardIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.price-input-card h3 {
  font-size: 1.1rem;
  margin-bottom: 16px;
  text-align: center;
}

.price-input-card input[type='number'] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 700;
  padding: 10px 14px;
  outline: none;
  margin-bottom: 16px;
  text-align: center;
  transition: border-color 0.2s;
}

.price-input-card input[type='number']:focus {
  border-color: var(--accent);
}

.price-input-actions {
  display: flex;
  gap: 10px;
}

.price-input-actions button {
  flex: 1;
}

/* Market Tabs */
.market-tab-btn {
  padding: 8px 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text2);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.market-tab-btn:hover {
  background: var(--surface2);
  color: var(--text);
}

.market-tab-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Result Delta (points/coins after game) */
.result-delta-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 16px 0 8px;
  padding: 16px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.rd-player {
  flex: 1;
  text-align: center;
  padding: 10px 8px;
  border-radius: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  transition: all 0.3s;
}
.rd-player.rd-winner {
  border-color: rgba(74, 222, 128, 0.4);
  background: rgba(74, 222, 128, 0.08);
  box-shadow: 0 0 12px rgba(74, 222, 128, 0.1);
}
.rd-player.rd-loser {
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.05);
}
.rd-player-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rd-badges {
  display: flex;
  justify-content: center;
  gap: 8px;
}
.rd-change {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 700;
}
.rd-positive {
  background: rgba(74, 222, 128, 0.15);
  color: #4ade80;
}
.rd-negative {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}
.rd-neutral {
  background: rgba(148, 163, 184, 0.1);
  color: var(--text2);
}
.rd-icon {
  font-size: 0.75rem;
}
.rd-coin-icon {
  font-size: 0.85rem;
}
.rd-vs {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--text2);
  letter-spacing: 0.08em;
}

/* ── Page Title Section (Shop, Market) ── */
.page-title-section {
  text-align: center;
  padding: 28px 24px 12px;
  max-width: 1200px;
  margin: 0 auto;
}
.page-title {
  font-size: 1.8rem;
  font-weight: 900;
  margin: 0;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.page-subtitle {
  color: var(--text2);
  font-size: 0.9rem;
  margin-top: 4px;
}

/* Market tabs updated */
.market-tabs {
  display: flex;
  gap: 8px;
  padding: 16px 24px;
  max-width: 1200px;
  margin: 0 auto;
}

/* ── Admin Hero Banner ── */
#admin-dashboard-screen {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  max-width: none;
  padding: 0;
  margin: 0;
  z-index: 100;
  background: var(--bg);
  overflow-y: auto;
}
.admin-hero-banner {
  position: relative;
  width: 100%;
  height: 140px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 40px;
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 30%, #4338ca 60%, #818cf8 100%);
}
.admin-hero-content {
  position: relative;
  z-index: 2;
}
.admin-hero-title {
  font-size: 1.8rem;
  font-weight: 900;
  color: #fff;
  margin: 0;
  -webkit-text-fill-color: #fff;
  background: none;
}
.admin-hero-subtitle {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.9rem;
  margin-top: 2px;
}
.admin-hero-actions {
  display: flex;
  gap: 8px;
  position: relative;
  z-index: 2;
}
.admin-header {
  display: none;
} /* replaced by hero banner */

/* Admin stat boxes with color accents */
.admin-stats {
  margin-top: 24px;
  margin-bottom: 24px;
}
.stat-box {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
}
.stat-icon {
  font-size: 1.5rem;
  margin-bottom: 4px;
}
.stat-box-accent {
  border-color: var(--accent);
}
.stat-box-accent .stat-value {
  color: var(--accent);
}
.stat-box-pink {
  border-color: var(--x-color);
}
.stat-box-pink .stat-value {
  color: var(--x-color);
}
.stat-box-cyan {
  border-color: var(--o-color);
}
.stat-box-cyan .stat-value {
  color: var(--o-color);
}
.stat-box-green {
  border-color: var(--win);
}
.stat-box-green .stat-value {
  color: var(--win);
}

/* Admin table tabs enriched */
.admin-table-tabs {
  padding: 0 24px;
  margin-bottom: 20px;
}
.admin-tab-btn {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: all 0.2s;
}
.admin-tab-btn:hover {
  transform: translateY(-1px);
}

/* Admin section enriched */
.admin-section {
  border-radius: 14px;
  padding: 24px 28px;
  margin: 0 24px 24px;
}
.admin-data-table th {
  font-size: 0.72rem;
  padding: 12px 14px;
  border-bottom: 2px solid var(--border);
}
.admin-data-table td {
  padding: 10px 14px;
}
.admin-edit-btn,
.admin-delete-btn {
  padding: 5px 10px;
  font-size: 0.75rem;
  border-radius: 6px;
  font-weight: 600;
  transition: all 0.15s;
}

/* Unified Auth Styles */
.unified-auth-card {
  background: var(--surface) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  padding: 40px 32px !important;
  max-width: 450px !important;
  box-shadow: var(--shadow) !important;
  margin: 0 auto;
}

.auth-title {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 24px;
  text-align: center;
  background: linear-gradient(135deg, var(--x-color), var(--accent), var(--o-color)) !important;
  -webkit-background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
  background-clip: text !important;
}

.auth-subtitle {
  color: var(--text2);
  text-align: center;
  margin-bottom: 24px;
  font-size: 0.95rem;
}

.google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--surface2) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  font-weight: 600 !important;
  padding: 12px !important;
  width: 100%;
  margin-bottom: 16px;
  border-radius: 8px !important;
  transition: all 0.2s !important;
}

.google-btn:hover {
  background: rgba(129, 140, 248, 0.1) !important;
  border-color: var(--accent) !important;
}

.auth-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 20px 0;
  color: var(--text2);
  font-size: 0.85rem;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border);
}

.auth-divider span {
  padding: 0 12px;
}

.unified-auth-card .field-label {
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.unified-auth-card input {
  background: var(--bg) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  margin-bottom: 20px !important;
  border-radius: 8px !important;
  padding: 10px 14px !important;
  width: 100%;
}

.unified-auth-card input:focus {
  border-color: var(--accent) !important;
}

.unified-auth-card .btn-primary {
  background: var(--accent) !important;
  padding: 12px !important;
  font-size: 1rem !important;
  border-radius: 8px !important;
  font-weight: 700 !important;
}

.auth-footer-text {
  text-align: center;
  margin-top: 24px;
  font-size: 0.9rem;
  color: var(--text2);
}

.auth-footer-text a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.auth-footer-text a:hover {
  text-decoration: underline;
}

/* Step Transitions */
.auth-step {
  display: none;
}

.auth-step.active {
  display: block;
  animation: authStepIn 0.3s ease-out;
}

@keyframes authStepIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Password Slide Animation */
.slide-container {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.slide-container.open {
  max-height: 120px;
}

/* Error Banner */
.auth-error-banner {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid var(--danger);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 20px;
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text);
}

.auth-error-banner a {
  color: var(--text);
  text-decoration: underline;
  font-weight: 700;
}

/* ==================== SPY GAME SCREEN ==================== */
/* Deep purple/mystery detective theme */

@keyframes spy-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes spy-glow { 0%, 100% { box-shadow: 0 0 8px rgba(139, 92, 246, 0.3); } 50% { box-shadow: 0 0 20px rgba(139, 92, 246, 0.6); } }
@keyframes ww-moon-glow { 0%, 100% { text-shadow: 0 0 10px rgba(251, 191, 36, 0.4); } 50% { text-shadow: 0 0 25px rgba(251, 191, 36, 0.8); } }
@keyframes countdown-urgent { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.15); } }

.spy-fullscreen.active {
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  max-width: none;
  padding: 0;
  margin: 0;
  background: linear-gradient(170deg, #0c0a1a 0%, #141028 40%, #1a1035 100%);
  overflow: hidden;
  z-index: 50;
}

.spy-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: linear-gradient(90deg, rgba(139, 92, 246, 0.12), rgba(99, 102, 241, 0.06), rgba(139, 92, 246, 0.12));
  border-bottom: 1px solid rgba(139, 92, 246, 0.2);
  gap: 12px;
  flex-shrink: 0;
  backdrop-filter: blur(8px);
}

.spy-top-center {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  justify-content: center;
}

.spy-title {
  font-size: 1.15rem;
  font-weight: 800;
  margin: 0;
  white-space: nowrap;
  background: linear-gradient(135deg, #c4b5fd, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 0.5px;
}

.spy-top-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.spy-phase-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  border: 1px solid transparent;
}
.spy-phase-badge.phase-waiting { background: rgba(100, 116, 139, 0.15); color: #94a3b8; border-color: rgba(100, 116, 139, 0.3); }
.spy-phase-badge.phase-describe { background: rgba(59, 130, 246, 0.15); color: #60a5fa; border-color: rgba(59, 130, 246, 0.3); animation: spy-pulse 2s ease-in-out infinite; }
.spy-phase-badge.phase-vote { background: rgba(239, 68, 68, 0.15); color: #f87171; border-color: rgba(239, 68, 68, 0.3); animation: spy-pulse 1.5s ease-in-out infinite; }
.spy-phase-badge.phase-reveal { background: rgba(250, 204, 21, 0.15); color: #fbbf24; border-color: rgba(250, 204, 21, 0.3); }
.spy-phase-badge.phase-ended { background: rgba(34, 197, 94, 0.15); color: #4ade80; border-color: rgba(34, 197, 94, 0.3); }

.spy-round-info {
  font-size: 0.82rem;
  color: #a78bfa;
  font-weight: 700;
  padding: 2px 8px;
  background: rgba(139, 92, 246, 0.08);
  border-radius: 6px;
}

.spy-countdown {
  font-weight: 800;
  font-size: 1rem;
  min-width: 44px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.3);
}
.spy-countdown.urgent { color: var(--danger); animation: countdown-urgent 0.6s ease-in-out infinite; }

.spy-role-panel {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 24px;
  background: linear-gradient(90deg, rgba(139, 92, 246, 0.08), rgba(99, 102, 241, 0.04));
  border-bottom: 1px solid rgba(139, 92, 246, 0.15);
  flex-shrink: 0;
}

.spy-role-img {
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
  filter: drop-shadow(0 0 6px rgba(139, 92, 246, 0.5));
  border-radius: 4px;
}
.spy-role-label {
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.spy-word-display {
  font-size: 1.05rem;
  color: #e2e8f0;
  padding: 6px 16px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(99, 102, 241, 0.1));
  border: 1px solid rgba(139, 92, 246, 0.25);
  border-radius: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.spy-main {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.spy-sidebar {
  width: 250px;
  border-right: 1px solid rgba(139, 92, 246, 0.12);
  padding: 14px;
  overflow-y: auto;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.15);
}

.spy-sidebar-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: #a78bfa;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin: 0 0 12px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(139, 92, 246, 0.15);
}

.spy-players-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.spy-player-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(139, 92, 246, 0.04);
  border: 1px solid rgba(139, 92, 246, 0.08);
  transition: all 0.25s ease;
}
.spy-player-card:hover { background: rgba(139, 92, 246, 0.1); border-color: rgba(139, 92, 246, 0.2); transform: translateX(2px); }
.spy-player-self { border-color: rgba(139, 92, 246, 0.4); background: rgba(139, 92, 246, 0.1); box-shadow: inset 0 0 12px rgba(139, 92, 246, 0.08); }
.spy-player-dead { opacity: 0.4; filter: grayscale(0.6); }

.spy-player-avatar {
  width: 38px;
  height: 38px;
  image-rendering: pixelated;
  flex-shrink: 0;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.2);
  padding: 2px;
  border: 1px solid rgba(139, 92, 246, 0.15);
}
.spy-player-info { flex: 1; min-width: 0; }
.spy-player-name { font-size: 0.88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #e2e8f0; }
.spy-player-meta { font-size: 0.75rem; color: #8b8fa3; margin-top: 1px; }
.spy-player-role { font-size: 0.8rem; margin-top: 2px; }
.spy-player-action { flex-shrink: 0; }

.spy-you-tag { color: #a78bfa; font-size: 0.72em; font-weight: 500; }

.spy-tag { font-size: 0.68rem; font-weight: 700; padding: 2px 8px; border-radius: 6px; letter-spacing: 0.3px; }
.spy-tag-spy { background: rgba(239, 68, 68, 0.15); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.3); }
.spy-tag-villager { background: rgba(34, 197, 94, 0.15); color: #4ade80; border: 1px solid rgba(34, 197, 94, 0.3); }
.spy-word-reveal { font-size: 0.8rem; color: #94a3b8; font-style: italic; }

.spy-describe-order {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(139, 92, 246, 0.15);
}
.spy-order-title { font-size: 0.75rem; font-weight: 700; color: #a78bfa; margin-bottom: 10px; text-transform: uppercase; letter-spacing: 1px; }
.spy-order-item { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 8px; font-size: 0.84rem; transition: all 0.2s; }
.spy-order-item.current { background: rgba(139, 92, 246, 0.12); font-weight: 700; color: #c4b5fd; border-left: 2px solid #8b5cf6; }
.spy-order-item.done { color: #64748b; }
.spy-order-num { font-weight: 700; color: #64748b; min-width: 18px; font-size: 0.8rem; }
.spy-order-name { flex: 1; }
.spy-order-status { font-size: 0.9rem; }

.spy-chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: rgba(0, 0, 0, 0.08);
}

.spy-chat-history {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.spy-msg { font-size: 0.9rem; line-height: 1.5; padding: 8px 12px; border-radius: 10px; }
.spy-msg-system { background: rgba(139, 92, 246, 0.06); color: #94a3b8; font-style: italic; border-left: 2px solid rgba(139, 92, 246, 0.3); }
.spy-msg-system .spy-msg-icon { margin-right: 6px; }
.spy-msg-player { background: rgba(255, 255, 255, 0.03); border: 1px solid rgba(255, 255, 255, 0.04); }
.spy-msg-name { font-weight: 700; color: #a78bfa; margin-right: 8px; }
.spy-msg-text { color: #e2e8f0; }

.spy-input-area {
  display: flex;
  flex-direction: column;
  padding: 12px 18px;
  border-top: 1px solid rgba(139, 92, 246, 0.15);
  gap: 8px;
  background: rgba(0, 0, 0, 0.1);
}
.spy-message-input {
  width: 100%;
  min-height: 52px;
  max-height: 80px;
  resize: vertical;
  background: rgba(15, 10, 30, 0.6);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: 10px;
  color: #e2e8f0;
  padding: 10px 14px;
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.2s;
}
.spy-message-input:focus { border-color: rgba(139, 92, 246, 0.5); outline: none; box-shadow: 0 0 12px rgba(139, 92, 246, 0.15); }
.spy-input-footer { display: flex; justify-content: space-between; align-items: center; }
.spy-char-count { font-size: 0.78rem; color: #64748b; font-variant-numeric: tabular-nums; }

.spy-guess-panel {
  padding: 12px 18px;
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.06), rgba(239, 68, 68, 0.02));
  border-top: 1px solid rgba(239, 68, 68, 0.2);
}
.spy-guess-label { font-size: 0.85rem; color: #f87171; font-weight: 700; margin-bottom: 8px; }
.spy-guess-row { display: flex; gap: 8px; }
.spy-guess-input {
  flex: 1;
  background: rgba(15, 10, 30, 0.6);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 10px;
  color: #e2e8f0;
  padding: 8px 14px;
  font-size: 0.9rem;
}
.spy-guess-input:focus { border-color: rgba(239, 68, 68, 0.5); outline: none; }

/* Spy result overlay fills the whole game screen */
.spy-fullscreen .result-overlay {
  position: absolute;
  inset: 0;
  border-radius: 0;
  background: linear-gradient(170deg, rgba(12, 10, 26, 0.97), rgba(20, 16, 40, 0.98));
  backdrop-filter: blur(12px);
}
.spy-result-card { max-width: 500px; }
.spy-result-detail { margin-top: 14px; text-align: left; }
.spy-result-words {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 16px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.08), rgba(99, 102, 241, 0.04));
  border: 1px solid rgba(139, 92, 246, 0.15);
  border-radius: 10px;
  margin-bottom: 12px;
  font-size: 0.92rem;
}
.spy-result-players { display: flex; flex-direction: column; gap: 5px; }
.spy-result-player {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  background: rgba(139, 92, 246, 0.04);
  border: 1px solid rgba(139, 92, 246, 0.08);
  transition: all 0.2s;
}
.spy-result-player.is-spy { background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.3); }
.spy-result-player img { width: 32px; height: 32px; image-rendering: pixelated; filter: drop-shadow(0 0 4px rgba(139, 92, 246, 0.3)); }
.spy-result-word { color: #94a3b8; font-style: italic; margin-left: auto; font-size: 0.85rem; }

/* ==================== WEREWOLF GAME SCREEN ==================== */
/* Night: deep blue/indigo. Day: warm amber/gold */

.ww-fullscreen.active {
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  max-width: none;
  padding: 0;
  margin: 0;
  background: linear-gradient(170deg, #0a0e1a 0%, #111827 40%, #1a1030 100%);
  overflow: hidden;
  z-index: 50;
  transition: background 0.8s ease;
}
.ww-fullscreen.active.ww-daytime {
  background: linear-gradient(170deg, #1a1510 0%, #1c1a15 40%, #151210 100%);
}

.ww-night-overlay {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(1px 1px at 10% 15%, rgba(255, 255, 255, 0.6), transparent),
    radial-gradient(1px 1px at 25% 35%, rgba(255, 255, 255, 0.4), transparent),
    radial-gradient(1.5px 1.5px at 40% 8%, rgba(200, 200, 255, 0.7), transparent),
    radial-gradient(1px 1px at 55% 45%, rgba(255, 255, 255, 0.3), transparent),
    radial-gradient(1px 1px at 70% 20%, rgba(255, 255, 255, 0.5), transparent),
    radial-gradient(1.5px 1.5px at 85% 55%, rgba(200, 200, 255, 0.6), transparent),
    radial-gradient(1px 1px at 15% 65%, rgba(255, 255, 255, 0.3), transparent),
    radial-gradient(1px 1px at 50% 75%, rgba(255, 255, 255, 0.4), transparent),
    radial-gradient(1.5px 1.5px at 90% 85%, rgba(200, 200, 255, 0.5), transparent),
    radial-gradient(1px 1px at 35% 90%, rgba(255, 255, 255, 0.3), transparent),
    radial-gradient(80px 80px at 75% 15%, rgba(251, 191, 36, 0.06), transparent),
    linear-gradient(180deg, rgba(10, 14, 30, 0.75) 0%, rgba(30, 27, 75, 0.5) 50%, rgba(10, 14, 30, 0.65) 100%);
  pointer-events: none;
  z-index: 5;
  transition: opacity 0.8s ease;
  animation: ww-moon-glow 4s ease-in-out infinite;
}

.ww-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.06), rgba(99, 102, 241, 0.1));
  border-bottom: 1px solid rgba(99, 102, 241, 0.15);
  gap: 12px;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
  backdrop-filter: blur(8px);
}

.ww-top-center {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  justify-content: center;
}

.ww-title {
  font-size: 1.15rem;
  font-weight: 800;
  margin: 0;
  white-space: nowrap;
  background: linear-gradient(135deg, #fbbf24, #f59e0b, #d97706);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 0.5px;
}

.ww-top-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ww-phase-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
  letter-spacing: 0.5px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.ww-phase-badge.ww-night {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.15));
  color: #a5b4fc;
  border-color: rgba(99, 102, 241, 0.3);
  animation: spy-pulse 3s ease-in-out infinite;
}
.ww-phase-badge.ww-day {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.2), rgba(245, 158, 11, 0.15));
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.3);
}

.ww-day-info {
  font-size: 0.85rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(251, 191, 36, 0.08);
  color: #fbbf24;
}

.ww-countdown {
  font-weight: 800;
  font-size: 1rem;
  min-width: 44px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.3);
}
.ww-countdown.urgent { color: var(--danger); animation: countdown-urgent 0.6s ease-in-out infinite; }

.ww-role-panel {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 24px;
  border-bottom: 1px solid rgba(99, 102, 241, 0.12);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
  flex-wrap: wrap;
  background: rgba(0, 0, 0, 0.15);
}

.ww-role-emoji { font-size: 1.5rem; }
.ww-role-img {
  width: 52px;
  height: 52px;
  image-rendering: pixelated;
  filter: drop-shadow(0 0 8px rgba(139, 92, 246, 0.4));
  border-radius: 4px;
}
.ww-role-text { font-weight: 800; font-size: 1.05rem; letter-spacing: 1px; text-transform: uppercase; }
.ww-role-werewolf { color: #f87171; text-shadow: 0 0 12px rgba(248, 113, 113, 0.3); }
.ww-role-seer { color: #a78bfa; text-shadow: 0 0 12px rgba(167, 139, 250, 0.3); }
.ww-role-doctor { color: #34d399; text-shadow: 0 0 12px rgba(52, 211, 153, 0.3); }
.ww-role-villager { color: #e2e8f0; }

.ww-partner-info {
  font-size: 0.85rem;
  color: #f87171;
  padding: 4px 12px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 8px;
  font-weight: 600;
}

.ww-seer-results, .ww-doctor-info {
  font-size: 0.85rem;
  padding: 6px 12px;
  background: rgba(99, 102, 241, 0.06);
  border: 1px solid rgba(99, 102, 241, 0.1);
  border-radius: 8px;
  width: 100%;
}
.ww-seer-title, .ww-doctor-title { font-weight: 700; margin-bottom: 3px; }
.ww-seer-entry { padding: 2px 0; }

.ww-main {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
  position: relative;
  z-index: 10;
}

.ww-sidebar {
  width: 270px;
  border-right: 1px solid rgba(99, 102, 241, 0.1);
  padding: 14px;
  overflow-y: auto;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.12);
}

.ww-sidebar-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: #fbbf24;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin: 0 0 12px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(251, 191, 36, 0.15);
}

.ww-players-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ww-player-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(99, 102, 241, 0.03);
  border: 1px solid rgba(99, 102, 241, 0.06);
  transition: all 0.25s ease;
}
.ww-player-card:hover { background: rgba(99, 102, 241, 0.08); border-color: rgba(99, 102, 241, 0.15); transform: translateX(2px); }
.ww-player-self { border-color: rgba(251, 191, 36, 0.35); background: rgba(251, 191, 36, 0.06); box-shadow: inset 0 0 12px rgba(251, 191, 36, 0.05); }
.ww-player-dead { opacity: 0.35; filter: grayscale(0.7); }

.ww-player-avatar {
  width: 38px;
  height: 38px;
  image-rendering: pixelated;
  flex-shrink: 0;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.25);
  padding: 2px;
  border: 1px solid rgba(99, 102, 241, 0.12);
}
.ww-player-info { flex: 1; min-width: 0; }
.ww-player-name { font-size: 0.88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #e2e8f0; }
.ww-player-dead-label { font-size: 0.73rem; color: #ef4444; font-weight: 600; letter-spacing: 0.5px; }
.ww-player-action { flex-shrink: 0; }
.ww-you-tag { color: #fbbf24; font-size: 0.72em; font-weight: 500; }

.ww-role-tag {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  margin-left: 4px;
  letter-spacing: 0.3px;
  border: 1px solid transparent;
}
.ww-role-tag.ww-role-werewolf { background: rgba(239, 68, 68, 0.12); color: #f87171; border-color: rgba(239, 68, 68, 0.25); }
.ww-role-tag.ww-role-seer { background: rgba(167, 139, 250, 0.12); color: #a78bfa; border-color: rgba(167, 139, 250, 0.25); }
.ww-role-tag.ww-role-doctor { background: rgba(52, 211, 153, 0.12); color: #34d399; border-color: rgba(52, 211, 153, 0.25); }
.ww-role-tag.ww-role-villager { background: rgba(156, 163, 175, 0.12); color: #9ca3af; border-color: rgba(156, 163, 175, 0.25); }

.ww-skip-vote {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(99, 102, 241, 0.1);
}

.ww-chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: rgba(0, 0, 0, 0.06);
}

.ww-chat-history {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ww-msg { font-size: 0.9rem; line-height: 1.5; padding: 8px 12px; border-radius: 10px; }
.ww-msg-system { background: rgba(251, 191, 36, 0.05); color: #94a3b8; font-style: italic; border-left: 2px solid rgba(251, 191, 36, 0.3); }
.ww-msg-system .ww-msg-icon { margin-right: 6px; }
.ww-msg-player { background: rgba(255, 255, 255, 0.03); border: 1px solid rgba(255, 255, 255, 0.04); }
.ww-msg-name { font-weight: 700; color: #fbbf24; margin-right: 8px; }
.ww-msg-text { color: #e2e8f0; }

.ww-input-area {
  display: flex;
  flex-direction: column;
  padding: 12px 18px;
  border-top: 1px solid rgba(99, 102, 241, 0.12);
  gap: 8px;
  position: relative;
  z-index: 10;
  background: rgba(0, 0, 0, 0.1);
}
.ww-message-input {
  width: 100%;
  min-height: 52px;
  max-height: 80px;
  resize: vertical;
  background: rgba(10, 14, 30, 0.6);
  border: 1px solid rgba(99, 102, 241, 0.15);
  border-radius: 10px;
  color: #e2e8f0;
  padding: 10px 14px;
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.2s;
}
.ww-message-input:focus { border-color: rgba(251, 191, 36, 0.4); outline: none; box-shadow: 0 0 12px rgba(251, 191, 36, 0.1); }
.ww-input-footer { display: flex; justify-content: space-between; align-items: center; }
.ww-char-count { font-size: 0.78rem; color: #64748b; font-variant-numeric: tabular-nums; }

/* Werewolf result overlay fills the whole game screen */
.ww-fullscreen .result-overlay {
  position: absolute;
  inset: 0;
  border-radius: 0;
  background: linear-gradient(170deg, rgba(10, 14, 26, 0.97), rgba(26, 16, 48, 0.98));
  backdrop-filter: blur(12px);
}
.ww-result-card { max-width: 540px; }
.ww-result-detail { margin-top: 14px; text-align: left; }
.ww-result-players { display: flex; flex-direction: column; gap: 5px; }
.ww-result-player {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  background: rgba(99, 102, 241, 0.04);
  border: 1px solid rgba(99, 102, 241, 0.08);
}
.ww-result-player.dead { opacity: 0.5; filter: grayscale(0.4); }
.ww-role-bg-werewolf { border-left: 3px solid #f87171; background: rgba(239, 68, 68, 0.06); }
.ww-role-bg-seer { border-left: 3px solid #a78bfa; background: rgba(167, 139, 250, 0.06); }
.ww-role-bg-doctor { border-left: 3px solid #34d399; background: rgba(52, 211, 153, 0.06); }
.ww-role-bg-villager { border-left: 3px solid #9ca3af; }
.ww-result-avatar { font-size: 1.1rem; }
.ww-result-avatar img { width: 36px; height: 36px; image-rendering: pixelated; filter: drop-shadow(0 0 4px rgba(99, 102, 241, 0.3)); }
.ww-result-name { flex: 1; font-weight: 600; color: #e2e8f0; }
.ww-result-role { color: #94a3b8; font-size: 0.85rem; text-transform: capitalize; }
.ww-result-dead { color: #ef4444; font-size: 0.8rem; }
.ww-result-deaths { margin-top: 14px; padding-top: 10px; border-top: 1px solid rgba(99, 102, 241, 0.12); }
.ww-deaths-title { font-weight: 700; font-size: 0.85rem; margin-bottom: 8px; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.5px; }
.ww-death-entry { font-size: 0.85rem; padding: 3px 0; color: #94a3b8; }

/* Themed action buttons inside spy/werewolf */
.spy-fullscreen .btn-primary.small,
.spy-fullscreen .spy-vote-btn {
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  border: 1px solid rgba(139, 92, 246, 0.4);
  border-radius: 8px;
  font-weight: 600;
  transition: all 0.2s;
}
.spy-fullscreen .btn-primary.small:hover { background: linear-gradient(135deg, #8b5cf6, #7c3aed); box-shadow: 0 0 12px rgba(139, 92, 246, 0.3); }
.ww-fullscreen .btn-primary.small,
.ww-fullscreen .ww-vote-btn,
.ww-fullscreen .ww-action-btn {
  border-radius: 8px;
  font-weight: 600;
  transition: all 0.2s;
}
.ww-fullscreen .ww-action-btn[data-action="night"] { background: linear-gradient(135deg, #4338ca, #3730a3); border: 1px solid rgba(99, 102, 241, 0.4); }
.ww-fullscreen .ww-action-btn[data-action="night"]:hover { box-shadow: 0 0 12px rgba(99, 102, 241, 0.3); }
.ww-fullscreen .ww-vote-btn { background: linear-gradient(135deg, #b45309, #92400e); border: 1px solid rgba(251, 191, 36, 0.3); }
.ww-fullscreen .ww-vote-btn:hover { box-shadow: 0 0 12px rgba(251, 191, 36, 0.2); }

/* Custom scrollbars for spy & werewolf */
.spy-chat-history, .spy-sidebar, .spy-players-list {
  scrollbar-width: thin;
  scrollbar-color: rgba(139, 92, 246, 0.3) transparent;
}
.spy-chat-history::-webkit-scrollbar, .spy-sidebar::-webkit-scrollbar { width: 6px; }
.spy-chat-history::-webkit-scrollbar-track, .spy-sidebar::-webkit-scrollbar-track { background: transparent; }
.spy-chat-history::-webkit-scrollbar-thumb, .spy-sidebar::-webkit-scrollbar-thumb { background: rgba(139, 92, 246, 0.25); border-radius: 3px; }
.spy-chat-history::-webkit-scrollbar-thumb:hover, .spy-sidebar::-webkit-scrollbar-thumb:hover { background: rgba(139, 92, 246, 0.45); }

.ww-chat-history, .ww-sidebar, .ww-players-list {
  scrollbar-width: thin;
  scrollbar-color: rgba(99, 102, 241, 0.3) transparent;
}
.ww-chat-history::-webkit-scrollbar, .ww-sidebar::-webkit-scrollbar { width: 6px; }
.ww-chat-history::-webkit-scrollbar-track, .ww-sidebar::-webkit-scrollbar-track { background: transparent; }
.ww-chat-history::-webkit-scrollbar-thumb, .ww-sidebar::-webkit-scrollbar-thumb { background: rgba(99, 102, 241, 0.25); border-radius: 3px; }
.ww-chat-history::-webkit-scrollbar-thumb:hover, .ww-sidebar::-webkit-scrollbar-thumb:hover { background: rgba(99, 102, 241, 0.45); }

/* Mobile responsive for spy & werewolf */
@media (max-width: 768px) {
  .spy-sidebar, .ww-sidebar { width: 100%; border-right: none; border-bottom: 1px solid rgba(139, 92, 246, 0.12); max-height: 200px; overflow-y: auto; background: rgba(0, 0, 0, 0.1); }
  .spy-main, .ww-main { flex-direction: column; }
  .spy-top-center, .ww-top-center { gap: 6px; }
  .spy-title, .ww-title { font-size: 0.95rem; }
  .spy-role-panel, .ww-role-panel { padding: 8px 14px; gap: 10px; }
  .spy-role-img, .ww-role-img { width: 36px; height: 36px; }
  .spy-players-list, .ww-players-list { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .spy-player-card, .ww-player-card { flex: 0 0 auto; min-width: 110px; }
  .spy-player-avatar, .ww-player-avatar { width: 28px; height: 28px; }
}
