* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  --bg: #fff0f5;
  --ink: #1a1a1a;
  --muted: #555;
  --panel: #ffffff;
  --surface: #ffffff;
  --surface-muted: #fff7fb;
  --stroke: #000000;
  --stroke-soft: rgba(0, 0, 0, 0.25);
  --accent: #ff90e8;
  --accent-second: #ffc900;
  --accent-third: #23d5ab;
  --warning: #ffc900;
  --danger: #ff4d4d;
  --radius-lg: 12px;
  --radius-md: 8px;
  --space: clamp(1rem, 2.2vw, 1.6rem);
  --space-sm: 0.65rem;
  --space-md: 1rem;
  --space-lg: clamp(1.2rem, 3vw, 2rem);
  --space-xl: clamp(1.8rem, 4vw, 2.8rem);
  --content-max: 1200px;
  --shadow: 4px 4px 0px 0px #000000;
  font-family: 'Space Grotesk', 'Bricolage Grotesque', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  background-image: radial-gradient(rgba(0, 0, 0, 0.08) 1px, transparent 1px);
  background-size: 26px 26px;
}

body::before,
body::after {
  display: none;
}

main {
  width: min(var(--content-max), 100%);
  margin: auto;
  padding: clamp(1rem, 3vw, 1.5rem);
  display: flex;
  flex-direction: column;
  gap: var(--space);
}

.hero {
  width: min(var(--content-max), 100%);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: clamp(1rem, 3vw, 1.5rem);
  align-items: center;
  padding: clamp(1rem, 3vw, 1.5rem) clamp(1rem, 4vw, 1.5rem) 0;
}

.hero-copy {
  flex: 1 1 320px;
}

.hero h1 {
  font-size: clamp(2.5rem, 6vw, 4.4rem);
  margin: 0.2rem 0 0.4rem;
}

.lead {
  margin: 0;
  color: var(--muted);
  font-size: 1.15rem;
}


.hero-steps {
  list-style: none;
  display: flex;
  gap: 0.75rem;
  padding: 0;
  margin: 1.5rem 0 0;
  flex-wrap: wrap;
}

.hero-steps li {
  border: 3px solid var(--stroke);
  border-radius: 999px;
  padding: 0.4rem 1rem;
  background: #fff;
  font-weight: 700;
  box-shadow: 4px 4px 0px 0px rgba(0,0,0,0.1);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.75rem;
  border: 3px solid var(--stroke);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  background: var(--accent-second);
  font-weight: 700;
  box-shadow: 4px 4px 0px 0px #000;
}

.experience-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-lg);
}

.panel,
.summary,
.answer-review-item,
.toast {
  border: 3px solid var(--stroke);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel {
  padding: clamp(1.2rem, 2.6vw, 1.8rem);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: var(--space);
}

.panel-head {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  border: none;
  background: transparent;
  padding: 0;
  box-shadow: none;
}

.lobby-head {
  flex-direction: row;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: var(--space);
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.panel :is(.field input,
  .topic-groups,
  .pill,
  .settings-list li,
  .info-list li,
  .pill-list li,
  .code-tile,
  .timer-chip) {
  border: none;
  box-shadow: none;
}

.field-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.field-head > div {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.field input {
  border-radius: var(--radius-md);
  border: 2px solid rgba(0, 0, 0, 0.12);
  padding: 0.75rem 0.9rem;
  font-size: 1rem;
  background: #fff;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field input:focus {
  outline: none;
  border-color: var(--stroke);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.08);
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-md);
}

.btn {
  border-radius: 999px;
  border: 3px solid var(--stroke);
  padding: 0.9rem 1.4rem;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  background: var(--accent);
  color: var(--ink);
  transition: transform 0.1s, box-shadow 0.1s;
  font-family: inherit;
  box-shadow: var(--shadow);
}

.btn.primary {
  background: var(--accent);
  color: var(--ink);
}

.btn.secondary {
  background: #fff;
  color: var(--ink);
}

.btn.accent {
  background: var(--accent-third);
  color: var(--ink);
}

.btn.ghost {
  background: transparent;
  color: var(--ink);
  box-shadow: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn:hover:not(:disabled) {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0px 0px #000000;
}

.btn:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0px 0px #000000;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
}

.switch input {
  display: none;
}

.slider {
  width: 50px;
  height: 28px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.1);
  position: relative;
}

.slider::after {
  content: '';
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  position: absolute;
  top: 3px;
  left: 3px;
  transition: transform 0.2s ease;
}

.switch input:checked + .slider {
  background: var(--accent-second);
}

.switch input:checked + .slider::after {
  transform: translateX(22px);
}

.switch-label {
  font-weight: 500;
}

.switch.mini {
  transform: scale(0.85);
  transform-origin: top right;
  gap: 0.4rem;
}

.switch.mini .slider {
  width: 40px;
  height: 22px;
}

.switch.mini .slider::after {
  width: 16px;
  height: 16px;
}

.switch.mini input:checked + .slider::after {
  transform: translateX(18px);
}

.switch.mini .switch-label {
  font-size: 0.75rem;
  letter-spacing: 0;
}

.switch.filter-toggle {
  gap: 0.9rem;
  transform: none;
}

.switch.filter-toggle .slider {
  width: 64px;
  height: 34px;
}

.switch.filter-toggle .slider::after {
  width: 26px;
  height: 26px;
  top: 4px;
  left: 4px;
}

.switch.filter-toggle input:checked + .slider::after {
  transform: translateX(30px);
}

.switch.filter-toggle .switch-label {
  font-size: 1rem;
  font-weight: 700;
}

.topic-groups {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-height: 220px;
  overflow-y: auto;
  padding: 0.6rem;
  border-radius: var(--radius-md);
  background: var(--surface-muted);
}

.topic-group {
  border-radius: var(--radius-md);
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.6);
}

.topic-group summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.topic-group summary::-webkit-details-marker {
  display: none;
}

.topic-group summary span {
  font-size: 0.85rem;
  color: var(--muted);
}

#question-view,
#question-breadcrumbs,
#scoreboard-list,
#lobby-players,
#settings-list,
#sidebar-info,
#topic-pills,
#answer-review,
#match-summary,
#lobby-view {
  transition: opacity 0.2s ease;
}

.is-swapping {
  opacity: 0;
  pointer-events: none;
}

.topic-group-body {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.pill {
  border-radius: 999px;
  border: 2px solid rgba(0, 0, 0, 0.2);
  padding: 0.4rem 0.9rem;
  font-size: 0.9rem;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.9);
  display: inline-flex;
  gap: 0.4rem;
  align-items: center;
  transition: all 0.2s ease;
}

.pill input {
  display: none;
}

.pill small {
  color: var(--muted);
  font-size: 0.75rem;
}

.pill.active {
  background: var(--accent-third);
  color: var(--ink);
  border-color: var(--stroke);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  transform: translateY(-1px);
}

.hidden {
  display: none !important;
}

.panel .card-head,
.card::after,
.card {
  display: none;
}

.panel-grid,
.card {
  display: contents;
}

.panel-head h2,
.panel-head h3,
.panel-head p {
  margin: 0;
}


#lobby-view {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.lobby-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-lg);
  align-items: start;
}

.settings-list,
.pill-list,
.info-list,
.scoreboard-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.settings-list li,
.info-list li,
.pill-list li {
  border-radius: var(--radius-md);
  padding: 0.6rem 0.85rem;
  background: var(--surface-muted);
}

.info-list li span:first-child {
  color: var(--muted);
}

.lobby-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-top: 1rem;
}

.code-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  border-radius: var(--radius-lg);
  padding: 1.2rem 1.4rem;
  min-width: 200px;
  background: var(--surface-muted);
}

.code-tile strong {
  font-size: 2rem;
  letter-spacing: 0.2em;
}

.timer-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  background: #fff9df;
  color: var(--ink);
  border-radius: var(--radius-md);
  padding: 0.6rem 2.2rem;
  min-width: 0;
  align-self: flex-start;
  box-sizing: border-box;
  width: 320px;
  flex: 0 0 320px;
  max-width: 100%;
}


@media (max-width: 360px) {
  .pregame-code-pill {
    width: 100%;
    flex: 0 0 100%;
  }
}
.timer-chip span {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(260px, 300px) minmax(0, 1fr);
  gap: var(--space-lg);
  align-items: start;
  width: min(1280px, 100%);
  margin: 0 auto;
}

.game-sidebar {
  background: var(--panel);
  border: 3px solid var(--stroke);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.3rem;
  display: flex;
  flex-direction: column;
  gap: 1.3rem;
  position: sticky;
  top: 1.5rem;
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
}

.sidebar-header {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  border-bottom: 2px dashed var(--stroke-soft);
  padding-bottom: 0.8rem;
}

.match-heading-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
#scoreboard-list {
  width: 100%;
}

.players-panel {
  gap: 0;
}

.scoreboard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.scoreboard-head h3 {
  margin: 0;
}

.code-heading {
  margin: 0;
  font-size: clamp(1.3rem, 2.8vw, 1.7rem);
  flex: 1;
  min-width: 0;
}

#match-heading-code {
  font-family: 'Space Grotesk', 'Bricolage Grotesque', monospace;
  letter-spacing: 0.18em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem 0.95rem;
  border: 2px solid rgba(0,0,0,0.28);
  border-radius: 999px;
  background: var(--surface);
  font-weight: 700;
  font-size: 1.15rem;
  max-width: 100%;
  min-width: 12ch;
  max-width: 12ch;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s ease, filter 0.2s ease;
}

#match-heading-code.is-copyable {
  cursor: pointer;
}

#match-heading-code.is-copyable:focus-visible {
  outline: 3px dashed var(--stroke);
  outline-offset: 4px;
}

.code-spoiler {
  color: transparent;
  border-color: rgba(0,0,0,0.4);
  position: relative;
}

.code-spoiler::after {
  content: attr(data-placeholder);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  letter-spacing: inherit;
  text-transform: uppercase;
  color: #6a6a6a;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  border-radius: inherit;
  background: rgba(255, 255, 255, 0.96);
  filter: blur(var(--code-blur, 8px)) saturate(0.35);
  box-sizing: border-box;
}

.heading-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.eye-toggle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  flex: 0 0 44px;
  padding: 0;
}

.eye-toggle svg {
  display: none;
}

.eye-toggle .eye-open {
  display: block;
}

.eye-toggle.is-hidden .eye-open {
  display: none;
}

.eye-toggle.is-hidden .eye-off {
  display: block;
}

.text-btn {
  border: 2px solid var(--stroke);
  border-radius: var(--radius-md);
  padding: 0.35rem 0.85rem;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 3px 3px 0px 0px rgba(0,0,0,0.12);
}

.timer-display {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 2rem;
  font-weight: 700;
  color: var(--ink);
  background: var(--warning);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  justify-content: center;
}

.sidebar-actions {
  width: 100%;
}

.sidebar-actions .text-btn {
  width: 100%;
  justify-content: center;
  font-weight: 700;
  display: inline-flex;
}


.sidebar-section h3 {
  margin: 0 0 0.8rem;
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

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

.info-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.info-list li span:first-child {
  color: var(--muted);
  font-weight: 500;
}

.info-list li strong {
  text-align: right;
}

.game-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.question-stage {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0;
  gap: var(--space);
}

.pregame-panel {
  border: 3px solid var(--stroke);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: clamp(1.5rem, 3vw, 2.5rem);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-height: 420px;
  justify-content: center;
  max-width: 720px;
  margin: 0 auto;
}

.pregame-head h3 {
  margin: 0 0 0.4rem 0;
  font-size: 1.6rem;
}

.pregame-head p {
  margin: 0;
  color: var(--muted);
}

.pregame-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.2rem;
}

.pregame-code-block {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  text-align: center;
  color: var(--muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.pregame-code-pill {
  letter-spacing: 0.3em;
  border: 3px solid var(--stroke);
  border-radius: 999px;
  font-size: 1.8rem;
  font-weight: 700;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0.6rem 2.2rem;
  background: var(--surface);
  box-shadow: 4px 4px 0px 0px rgba(0,0,0,0.15);
  --code-pill-width: 320px;
  box-sizing: border-box;
  width: var(--code-pill-width);
  flex: 0 0 var(--code-pill-width);
  white-space: nowrap;
  text-transform: uppercase;
  position: relative;
  overflow: hidden;
}

@media (max-width: 400px) {
  .pregame-code-pill {
    --code-pill-width: calc(100vw - 2rem);
  }
}

.pregame-card {
  border: 2px solid var(--stroke-soft);
  border-radius: var(--radius-md);
  padding: 1rem;
  background: var(--surface-muted);
}

.pregame-card h4 {
  margin: 0 0 0.6rem 0;
  font-size: 0.95rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.pregame-player-list,
.pregame-info {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.pregame-player-list li,
.pregame-info li {
  background: #fff;
  border-radius: var(--radius-md);
  padding: 0.6rem 0.8rem;
  border: 1px solid rgba(0,0,0,0.08);
  font-weight: 600;
}

.pregame-player-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem;
}

.pregame-player-list li:only-child {
  grid-column: 1 / -1;
}

.pregame-note {
  margin: 0;
  color: var(--muted);
  text-align: center;
}

.question-stage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: none;
  background: transparent;
}

.question-meta {
  flex: 1;
  text-align: center;
  display: flex;
  flex-direction: column;
}

.question-view {
  display: grid;
  grid-template-columns: 280px 1fr;
  grid-template-rows: 1fr auto;
  grid-template-areas: 
    "image text"
    "buttons buttons";
  gap: var(--space-lg);
  background: var(--panel);
  border: 3px solid var(--stroke);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: clamp(1.5rem, 3vw, 2.5rem);
  width: 100%;
  height: 550px; /* Fixed height */
  align-items: start;
  position: relative;
  overflow: hidden;
}

.stage-cta {
  width: 100%;
  display: flex;
  flex-direction: column;
}

.stage-cta .btn {
  width: 100%;
}

.question-view img {
  grid-area: image;
  width: 100%;
  height: 100%;
  max-height: 300px;
  min-height: 200px; /* Prevent layout shift */
  object-fit: contain;
  border-radius: var(--radius-md);
  background: #f4f4f4;
  padding: 0.5rem;
  border: 2px solid rgba(0,0,0,0.05);
  align-self: start;
}

.question-view h3 {
  grid-area: text;
  margin: 0;
  font-size: 1.6rem;
  line-height: 1.3;
  align-self: center;
}

.question-prompt,
.question-image {
  position: relative;
}

.question-view.question-enter .question-prompt,
.question-view.question-enter .question-image {
  animation: questionSwipe 0.2s ease-out both;
}

.question-view.question-enter .question-image {
  animation-delay: 0.05s;
}

@keyframes questionSwipe {
  from {
    transform: translateX(40px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}


.answer-buttons {
  grid-area: buttons;
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr 1fr;
  margin-top: auto;
  width: 100%;
  align-self: end;
}

.answer-buttons button {
  flex: 1;
  padding: 1.5rem;
  font-size: 1.2rem;
  font-weight: 700;
  border: 3px solid var(--stroke);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
  box-shadow: 4px 4px 0px 0px rgba(0,0,0,0.1);
}

.answer-buttons button.true {
  background: var(--accent-third);
  color: var(--ink);
}

.answer-buttons button.false {
  background: var(--danger);
  color: #fff;
}

.answer-buttons button:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0px 0px #000;
}

.answer-buttons button:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0px 0px #000;
}

.question-breadcrumbs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(44px, 1fr));
  column-gap: 0.5rem;
  row-gap: 0.35rem;
}

.question-breadcrumbs::-webkit-scrollbar {
  height: 6px;
}

.question-breadcrumbs::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.05);
  border-radius: 3px;
}

.question-breadcrumbs::-webkit-scrollbar-thumb {
  background: var(--stroke-soft);
  border-radius: 3px;
}

.question-breadcrumbs button {
  width: 100%;
  height: 44px;
  border: 2px solid var(--stroke);
  border-radius: 12px;
  background: #fff;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
  box-shadow: 3px 3px 0px 0px rgba(0,0,0,0.1);
}

.question-breadcrumbs button:hover {
  transform: translateY(-2px);
  box-shadow: 3px 5px 0px 0px rgba(0,0,0,0.2);
}

.question-breadcrumbs button.current {
  background: var(--accent);
  color: var(--ink);
  transform: translateY(-2px);
  box-shadow: 4px 4px 0px 0px #000;
}

.question-breadcrumbs button.answered {
  background: var(--accent-third);
  color: var(--ink);
}

.nav-btn {
  width: 52px;
  height: 52px;
  border: 3px solid var(--stroke);
  border-radius: var(--radius-md);
  background: var(--warning);
  color: var(--ink);
  font-weight: 800;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: 4px 4px 0px 0px #000;
  transition: transform 0.1s, box-shadow 0.1s;
  margin: 0;
  flex-shrink: 0;
}

.nav-btn:hover:not(:disabled) {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0px 0px #000;
}

.nav-btn:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0px 0px #000;
}

.nav-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
  background: #eee;
}

.score-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 2px solid var(--stroke-soft);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  background: #fffdf7;
  font-weight: 600;
  width: 100%;
}

.score-row.self {
  background: var(--accent-second);
  color: #1f1500;
  border-color: var(--stroke);
  box-shadow: 4px 4px 0px 0px rgba(0,0,0,0.15);
}

.score-row.obscured span:last-child {
  color: var(--muted);
}

@keyframes slideUpFade {
  from {
    opacity: 0;
    transform: translate(-50%, 20px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  padding: 1rem 2rem;
  background: var(--ink);
  color: #fff;
  border-radius: 999px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  z-index: 1000;
  animation: slideUpFade 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.summary table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 0.5rem;
  margin-bottom: 1.5rem;
}

.summary thead {
  background: transparent;
}

.summary th {
  text-align: left;
  padding: 0.5rem 1rem;
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: none;
}

.summary tbody tr {
  background: #fff;
  box-shadow: 2px 2px 0px 0px rgba(0,0,0,0.1);
  transition: transform 0.1s;
}

.summary tbody tr:hover {
  transform: scale(1.01);
}

.summary td {
  padding: 1rem;
  border-top: 2px solid var(--stroke-soft);
  border-bottom: 2px solid var(--stroke-soft);
}

.summary td:first-child {
  border-left: 2px solid var(--stroke-soft);
  border-top-left-radius: var(--radius-md);
  border-bottom-left-radius: var(--radius-md);
  font-weight: 700;
  color: var(--accent-second);
}

.summary td:last-child {
  border-right: 2px solid var(--stroke-soft);
  border-top-right-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
}

.answer-review {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.answer-review-item {
  background: #fff;
  border: 2px solid var(--stroke);
  border-radius: var(--radius-lg);
  padding: 1.3rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1.2rem;
  box-shadow: 4px 4px 0px 0px rgba(0,0,0,0.1);
}

.answer-review-item img {
  width: 120px;
  height: 120px;
  object-fit: contain;
  border-radius: var(--radius-md);
  background: transparent;
  padding: 0;
  grid-column: 2 / 3;
  grid-row: 1 / 3;
}

.review-index {
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 0.5rem 0;
  grid-column: 1 / 2;
}

.answer-review-item h4 {
  margin: 0 0 1rem 0;
  font-size: 1.1rem;
  grid-column: 1 / 2;
}

.review-correct,
.review-player {
  margin: 0.2rem 0;
  font-weight: 500;
  grid-column: 1 / 2;
}

.review-correct {
  color: var(--accent-third);
}

.review-player.good {
  color: var(--accent-third);
  font-weight: 700;
}

.review-player.bad {
  color: var(--danger);
  font-weight: 700;
  text-decoration: line-through;
}

@media (max-width: 1000px) {
  .game-layout {
    grid-template-columns: 1fr;
  }
  .game-sidebar {
    position: static;
    max-height: none;
  }
  .question-view {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
    grid-template-areas: 
      "image"
      "text"
      "buttons";
    height: auto;
    min-height: 500px;
  }
  .question-view img {
    max-height: 200px;
    margin: 0 auto;
  }
  .question-view h3 {
    font-size: 1.3rem;
  }
}

@media (max-width: 700px) {
  .answer-review-item {
    grid-template-columns: 1fr;
  }
  .answer-review-item img {
    grid-column: 1 / -1;
    grid-row: auto;
    width: 100%;
    max-width: 200px;
    height: auto;
  }
}

@media (max-width: 640px) {
  .question-stage-head {
    flex-wrap: wrap;
    justify-content: center;
    text-align: center;
  }
  .question-stage-head .nav-btn {
    margin: 0;
  }
  .question-meta {
    order: 3;
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .eye-toggle,
  .heading-actions,
  .question-view.question-enter .question-prompt,
  .question-view.question-enter .question-image {
    animation: none !important;
    transition: none !important;
  }
}

/* New Lobby Styles */
.lobby-panel {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  overflow: visible;
}

.lobby-content {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space);
}

.lobby-header-center {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.lobby-header-center h2 {
  font-size: 3rem;
  margin: 0;
}

.code-display-large {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.code-label {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}

.code-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #fff;
  padding: 0.5rem 0.5rem 0.5rem 1.5rem;
  border-radius: 999px;
  border: 3px solid var(--stroke);
  box-shadow: 4px 4px 0px 0px rgba(0,0,0,0.1);
}

.code-box strong {
  font-size: 2.5rem;
  letter-spacing: 0.15em;
  line-height: 1;
  flex: 1;
  text-align: center;
}

.icon-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.lobby-details-card {
  background: var(--panel);
  border: 3px solid var(--stroke);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space);
}

.lobby-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

.lobby-column h3 {
  margin-top: 0;
  border-bottom: 2px solid var(--stroke-soft);
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}

.players-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--stroke-soft);
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}

.players-header h3 {
  border: none;
  padding: 0;
  margin: 0;
}

.badge {
  background: var(--accent-second);
  color: var(--ink);
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.85rem;
  outline: 2px solid var(--stroke);
}

.players-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.5rem;
}

.players-grid li {
  text-align: center;
  justify-content: center;
}

.lobby-footer-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.btn.large {
  font-size: 1.2rem;
  padding: 1rem 3rem;
}

.dotted-line {
  border-top: 2px dashed var(--stroke-soft);
}

.waiting-hint {
  color: var(--muted);
  font-style: italic;
  animation: pulse 2s infinite;
  margin: 0;
}

@keyframes pulse {
  0% { opacity: 0.6; }
  50% { opacity: 1; }
  100% { opacity: 0.6; }
}

.waiting-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  grid-column: 1 / -1;
  grid-row: 1 / -1;
}

.waiting-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  animation: bounce 2s infinite;
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {transform: translateY(0);}
  40% {transform: translateY(-20px);}
  60% {transform: translateY(-10px);}
}

@media (max-width: 700px) {
  .lobby-columns {
    grid-template-columns: 1fr;
  }
}

/* --- New Summary / Leaderboard Styles --- */

.summary-header {
  text-align: center;
  margin-bottom: 2rem;
}

.summary-subtitle {
  color: var(--muted);
  margin-top: 0.5rem;
}

.summary {
  padding: 2rem;
}

.leaderboard-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.leaderboard-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: #fff;
  padding: 1rem 1.5rem;
  border-radius: var(--radius-md);
  border: 2px solid var(--stroke-soft);
  box-shadow: 2px 2px 0px 0px rgba(0,0,0,0.05);
}

.leaderboard-card.self {
  border-color: var(--accent);
  background: #fff0f5;
  box-shadow: 4px 4px 0px 0px rgba(0,0,0,0.1);
}

.rank-badge {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--stroke);
  color: #fff;
  border-radius: 50%;
  font-weight: 700;
  font-size: 1.1rem;
}

.leaderboard-card.rank-1 .rank-badge {
  background: #ffd700;
  color: #000;
  border: 2px solid #000;
}

.leaderboard-card.rank-2 .rank-badge {
  background: #c0c0c0;
  color: #000;
  border: 2px solid #000;
}

.leaderboard-card.rank-3 .rank-badge {
  background: #cd7f32;
  color: #000;
  border: 2px solid #000;
}

.player-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.player-name {
  font-weight: 700;
  font-size: 1.1rem;
}

.player-stats {
  font-size: 0.85rem;
  color: var(--muted);
}

.player-score {
  text-align: right;
  line-height: 1;
}

.player-score strong {
  display: block;
  font-size: 1.8rem;
  color: var(--accent-third);
}

.player-score small {
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--muted);
}

.summary-actions {
  display: flex;
  justify-content: center;
  padding-top: 1.5rem;
  border-top: 2px dashed var(--stroke-soft);
}

/* --- New Answer Review Styles --- */

.review-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 0.5rem;
}

.review-section-header h3 {
  margin: 0;
  font-size: 1.2rem;
}

.show-errors-only .review-card.correct {
  display: none;
}

.answer-buttons button:disabled {
  cursor: default;
  transform: none !important;
  box-shadow: 4px 4px 0px 0px rgba(0,0,0,0.1) !important;
  opacity: 0.8;
  pointer-events: none;
}

.review-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.review-card {
  background: #fff;
  border: 2px solid var(--stroke-soft);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.review-card.correct {
  border-color: var(--accent-third);
}

.review-card.wrong {
  border-color: var(--danger);
}

.review-card.skipped {
  border-color: var(--muted);
  opacity: 0.8;
}

.review-header {
  display: flex;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  background: var(--surface-muted);
  border-bottom: 1px solid rgba(0,0,0,0.05);
  font-size: 0.85rem;
  font-weight: 600;
}

.review-card.correct .review-header {
  background: #e6fffa;
  color: #006d5b;
}

.review-card.wrong .review-header {
  background: #fff5f5;
  color: #c53030;
}

.review-body {
  padding: 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.review-prompt {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.review-image img {
  width: 100%;
  height: 120px;
  object-fit: contain;
  background: #f9f9f9;
  border-radius: 4px;
  border: 1px solid rgba(0,0,0,0.1);
}

.review-footer {
  padding: 0.8rem 1rem;
  background: #fff;
  border-top: 1px solid rgba(0,0,0,0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
}

.ans-box {
  display: flex;
  flex-direction: column;
}

.ans-box small {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
}

.ans-box.correct strong {
  color: var(--accent-third);
}

/* --- Enhanced Selection & Actions --- */

.answer-buttons button.selected {
  transform: scale(1.03);
  box-shadow: 0 0 0 4px rgba(0,0,0,0.15), 4px 4px 0px 0px rgba(0,0,0,0.3);
  z-index: 2;
  position: relative;
  filter: brightness(0.92) contrast(1.1);
}

.confirm-finish-btn {
  background: var(--accent-second);
  color: var(--ink);
  font-size: 1.1rem;
  padding: 1rem 2rem;
  border: 3px solid var(--stroke);
  box-shadow: 6px 6px 0px 0px #000;
  transition: all 0.2s;
}

.confirm-finish-btn:hover {
  transform: translate(-2px, -2px);
  box-shadow: 8px 8px 0px 0px #000;
}

.confirm-finish-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0px 0px #000;
}
