:root {
  --bg: #0f1419;
  --surface: #1a222d;
  --surface2: #243040;
  --text: #e8eef5;
  --muted: #8b9cb3;
  --accent: #4f8cff;
  --accent2: #7c5cff;
  --success: #51cf66;
  --warn: #fcc419;
  --danger: #ff6b6b;
  --radius: 14px;
  --font: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(79, 140, 255, 0.18), transparent),
    var(--bg);
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: 1rem 1rem 2rem;
  display: flex;
  flex-direction: column;
}

.top-bar {
  display: none;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.top-bar[data-visible="true"] {
  display: flex;
}

.top-title {
  flex: 1;
  font-weight: 600;
  font-size: 0.95rem;
}

.connection-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
}

.connection-dot.online {
  background: var(--success);
}

.connection-dot.offline {
  background: var(--danger);
}

.screen {
  display: none;
  flex: 1;
  animation: fade 0.2s ease;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.hero {
  margin: 1.5rem 0 2rem;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  color: var(--accent);
  margin: 0 0 0.5rem;
}

h1 {
  font-size: clamp(1.75rem, 6vw, 2.25rem);
  line-height: 1.15;
  margin: 0 0 0.75rem;
}

h2 {
  font-size: 1.35rem;
  margin: 0 0 1rem;
}

.sub {
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}

.stack-actions {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: auto;
}

.row-actions {
  display: flex;
  gap: 0.5rem;
}

.row-actions .btn {
  flex: 1;
}

.btn {
  border: none;
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.1s, opacity 0.15s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--surface2);
}

.btn-lg {
  padding: 1rem 1.25rem;
  font-size: 1.05rem;
}

.btn-sm {
  padding: 0.45rem 0.75rem;
  font-size: 0.85rem;
}

.btn-icon {
  background: var(--surface);
  border: none;
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  font-size: 1.1rem;
  cursor: pointer;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  flex: 1;
}

.form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.form input,
.form select {
  background: var(--surface);
  border: 1px solid var(--surface2);
  color: var(--text);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  font-size: 1rem;
  font-family: inherit;
}

.input-code {
  font-size: 1.5rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-align: center;
}

.checkbox {
  flex-direction: row !important;
  align-items: center;
  gap: 0.5rem !important;
  color: var(--text) !important;
}

.room-code-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  margin-bottom: 1rem;
}

.room-code-card .label {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.room-code {
  font-size: 2.5rem;
  letter-spacing: 0.25em;
  font-weight: 800;
  margin: 0.25rem 0;
  color: var(--accent);
}

.teams-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 1;
  overflow-y: auto;
}

.team-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.85rem;
  border-left: 4px solid var(--team-color, var(--accent));
}

.team-card h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}

.player-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--surface2);
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
  margin: 0.2rem 0.25rem 0 0;
}

.player-chip.ready::after {
  content: "✓";
  color: var(--success);
}

.player-chip.host::before {
  content: "★ ";
  color: var(--warn);
}

.lobby-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.lobby-actions .btn {
  flex: 1;
}

.hint-text {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.hud {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--warn);
}

.puzzle-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  flex: 1;
  margin-bottom: 1rem;
}

.puzzle-prompt {
  color: var(--muted);
  line-height: 1.5;
}

.clues {
  margin-top: 1rem;
}

.clue {
  background: var(--surface2);
  border-radius: 10px;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  line-height: 1.45;
}

.role-badge {
  display: inline-block;
  margin-top: 0.75rem;
  padding: 0.35rem 0.65rem;
  background: rgba(124, 92, 255, 0.2);
  border-radius: 8px;
  font-size: 0.85rem;
}

.inline-form {
  flex-direction: row;
  align-items: stretch;
}

.inline-form input {
  flex: 1;
}

.hint-display {
  background: rgba(252, 196, 25, 0.12);
  border: 1px solid var(--warn);
  border-radius: 10px;
  padding: 0.75rem;
  font-size: 0.9rem;
}

.results-hero {
  text-align: center;
  padding: 1.5rem 0;
  font-size: 1.5rem;
  font-weight: 800;
}

.results-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  line-height: 1.5;
}

.card-list .card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.5rem;
}

.card-btn {
  width: 100%;
  text-align: left;
  border: 1px solid var(--surface2);
  color: inherit;
  cursor: pointer;
  font-family: inherit;
}

.card-btn:active {
  transform: scale(0.99);
}

.profile-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  margin-bottom: 1rem;
}

.avatar {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.profile-name {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 1rem;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  text-align: left;
  margin: 0;
}

.stats dt {
  color: var(--muted);
  font-size: 0.75rem;
}

.stats dd {
  margin: 0 0 0.5rem;
  font-weight: 600;
}

.footer-note {
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 1.5rem;
}

/* Mode identity */
.mode-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(79, 140, 255, 0.15);
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  margin-bottom: 0.5rem;
}

.mode-badge-solo {
  color: #7c5cff;
  background: rgba(124, 92, 255, 0.18);
}

.mode-badge-sm {
  font-size: 0.65rem;
  margin-bottom: 0;
}

.tagline {
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}

.hero-home h1 {
  margin-bottom: 0.5rem;
}

/* Play screen hierarchy */
.screen-play {
  gap: 0.65rem;
}

.play-hud {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.25rem;
}

.hud-timer {
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--warn);
  margin-left: auto;
}

.hud-team {
  font-size: 0.85rem;
  color: var(--muted);
}

.mission-card {
  background: linear-gradient(135deg, rgba(79, 140, 255, 0.12), rgba(124, 92, 255, 0.08));
  border: 1px solid rgba(79, 140, 255, 0.25);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.25rem;
}

.mission-mode {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin: 0 0 0.35rem;
}

.mission-title {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
}

.mission-situation,
.mission-rules,
.mission-interaction {
  margin: 0.35rem 0;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--muted);
}

.mission-interaction {
  color: var(--text);
}

.puzzle-primary {
  flex: 1;
}

.interaction-zone .puzzle-prompt {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 0.75rem;
}

.answer-bar {
  flex-direction: column;
  gap: 0.5rem;
}

.answer-bar input {
  font-size: 1.05rem;
  padding: 0.85rem;
}

.answer-bar .btn {
  width: 100%;
}

.hint-panel {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.75rem;
}

.hint-panel-title {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.hint-levels {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.hint-level-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface2);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  color: var(--text);
  font-family: inherit;
  font-size: 0.88rem;
  cursor: pointer;
  text-align: left;
}

.hint-level-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.hint-level-btn:not(:disabled):not([disabled]) .hint-state {
  color: var(--accent);
}

.hint-lv {
  font-weight: 600;
}

.hint-state {
  font-size: 0.78rem;
  color: var(--muted);
}

.btn-back-low,
.btn-text {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0.35rem 0;
  cursor: pointer;
  font-family: inherit;
}

.top-bar .btn-back-low {
  width: auto;
  height: auto;
}

/* Solo library */
.solo-stats {
  display: flex;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

.solo-stats strong {
  color: var(--text);
}

.library-section {
  margin-bottom: 1rem;
}

.library-heading {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 0.5rem;
}

.card-list-locked .card-locked {
  opacity: 0.7;
}

.card .check {
  color: var(--success);
  margin-right: 0.25rem;
}

.card .lock {
  margin-right: 0.25rem;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  padding: 0.65rem 1rem;
  border-radius: 999px;
  font-size: 0.9rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 100;
  max-width: 90%;
}
