*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
  background: radial-gradient(circle at top left, #111827, #020617);
  color: #e5e7eb;
}

body {
  display: flex;
  justify-content: center;
  /* Let the shell grow with content (no background cutoff) */
  align-items: flex-start;
}

.app-shell {
  --content-max: 960px;
  /* ~1 inch honeycomb frame (varies by display DPI) */
  --honey-band: 60px;
  --shell-gutter: 16px;
  max-width: calc(var(--content-max) + (2 * var(--honey-band)));
  width: 100%;
  padding: 24px calc(var(--honey-band) + var(--shell-gutter))
    calc(24px + var(--honey-band));
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin: 0 auto;
  position: relative;
  isolation: isolate;
}

.app-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: 12px;
  /* Add a warm orange tint to the comb */
  background-image: linear-gradient(
      135deg,
      rgba(249, 115, 22, 0.42),
      rgba(245, 158, 11, 0.22)
    ),
    url("assets/honeycomb-frame.jpg");
  background-repeat: repeat;
  /* Bigger cells */
  background-size: 420px auto;
  opacity: 0.62;
  filter: saturate(1.25) contrast(1.22);
}

/*
  Honeycomb achievement glow — same duration / ease / peak beat as .game-header-bee-reward-glow (1.05s, ease-out, peak 45%).
  Keep app.js HONEYCOMB_GLOW_TOTAL_MS in sync (~duration + ~0.25s buffer).
*/
@keyframes honeycomb-glow-shine {
  0% {
    opacity: 0.62;
    filter: saturate(1.25) contrast(1.22) brightness(1);
    box-shadow: inset 0 0 0 transparent;
  }
  45% {
    opacity: 0.82;
    filter: saturate(1.55) contrast(1.12) brightness(1.22);
    box-shadow: inset 0 0 100px rgba(251, 191, 36, 0.45);
  }
  100% {
    opacity: 0.62;
    filter: saturate(1.25) contrast(1.22) brightness(1);
    box-shadow: inset 0 0 0 transparent;
  }
}

.app-shell.app-shell--honeycomb-glow::before {
  --honeycomb-pulse-duration: 1.05s;
  animation-name: honeycomb-glow-shine;
  animation-duration: var(--honeycomb-pulse-duration);
  animation-timing-function: ease-out;
  animation-iteration-count: 1;
}

@media (prefers-reduced-motion: reduce) {
  .app-shell.app-shell--honeycomb-glow::before {
    --honeycomb-pulse-duration: 0.5s;
    animation-name: honeycomb-glow-shine-reduced;
    animation-duration: var(--honeycomb-pulse-duration);
    animation-timing-function: ease-out;
    animation-iteration-count: 1;
  }

  @keyframes honeycomb-glow-shine-reduced {
    0%,
    100% {
      opacity: 0.62;
    }
    50% {
      opacity: 0.82;
      filter: saturate(1.35) brightness(1.08);
    }
  }
}

.app-shell::after {
  content: "";
  position: absolute;
  z-index: 1;
  top: 0;
  left: var(--honey-band);
  right: var(--honey-band);
  bottom: var(--honey-band);
  border-radius: 18px;
  background: radial-gradient(circle at top left, #111827, #020617);
}

.app-shell > * {
  position: relative;
  z-index: 2;
}

.app-header {
  text-align: left;
}

.app-header h1 {
  margin: 0;
  font-size: 2.4rem;
  letter-spacing: -0.04em;
}

.title-bee {
  margin-left: 0.01em;
  display: inline-block;
  /* Baseline alignment so we can nudge the bee up optically (not locked to descenders) */
  vertical-align: baseline;
  line-height: 0;
  font-size: inherit;
}

/* Scale with the <h1> font size so the bee matches the title on all breakpoints */
.title-bee-img {
  display: inline-block;
  vertical-align: baseline;
  height: 1.45em;
  width: auto;
  object-fit: contain;
  /* Sit closer to cap-height / “Studio” band; default middle sat too low vs descenders like p */
  position: relative;
  top: -0.16em;
}

.subtitle {
  margin: 6px 0 0;
  color: #9ca3af;
}

.app-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: rgba(15, 23, 42, 0.9);
  border-radius: 16px;
  padding: 18px 18px 20px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(18px);
}

.config-card h2 {
  margin: 0 0 6px;
  font-size: 1.1rem;
}

/* Step 1: collapsed by default so setup copy is optional */
.config-details {
  margin: 0;
  overflow: visible;
}

.config-details-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  user-select: none;
}

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

.config-details-summary::marker {
  content: "";
}

.config-details-summary-text {
  flex: 1;
  min-width: 0;
}

.config-details-heading {
  margin: 0 0 4px;
  font-size: 1.1rem;
}

.config-details-summary-hint {
  display: block;
  font-size: 0.8rem;
  font-weight: 400;
  color: #9ca3af;
  line-height: 1.35;
}

.config-details-chevron {
  flex-shrink: 0;
  width: 0.5em;
  height: 0.5em;
  margin-top: 0.28em;
  border-right: 2px solid rgba(156, 163, 175, 0.85);
  border-bottom: 2px solid rgba(156, 163, 175, 0.85);
  transform: rotate(45deg);
  transition: transform 0.15s ease;
}

/* Step 1 “Load Your Words” summary chevron only */
.config-details[open] > .config-details-summary .config-details-chevron {
  transform: rotate(-135deg);
  margin-top: 0.42em;
}

.config-details-body {
  margin-top: 12px;
  padding-top: 2px;
  border-top: 1px solid rgba(55, 65, 81, 0.55);
  overflow: visible;
}

.helper-text {
  margin: 0;
  font-size: 0.9rem;
  color: #9ca3af;
}

.file-input-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  margin-top: 12px;
}

.file-input-row-main {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  width: 100%;
}

#download-csv {
  white-space: nowrap;
  align-self: flex-start;
}

.load-words-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  margin-top: 6px;
}

.load-words-panel {
  border-radius: 14px;
  border: 1px solid rgba(55, 65, 81, 0.8);
  background: rgba(15, 23, 42, 0.7);
  padding: 12px 12px 14px;
  overflow: visible;
}

/* Stack above following .app-main sections while grade list is open (siblings share z-index: 2) */
.config-card.config-card--grade-dropdown-open {
  position: relative;
  z-index: 100;
}

.panel-title {
  margin: 0 0 6px;
  font-size: 1rem;
  font-weight: 650;
}

.grade-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.grade-select {
  appearance: none;
  border-radius: 999px;
  padding: 9px 14px;
  border: 1px solid rgba(75, 85, 99, 0.9);
  background: rgba(15, 23, 42, 0.95);
  color: #e5e7eb;
  font-size: 0.95rem;
  min-width: 10.5rem;
}

/* Custom grade combobox — native <option> lists can’t be centered on macOS; button + list are styled */
.grade-combobox {
  position: relative;
  display: inline-block;
}

.grade-select--custom {
  box-sizing: border-box;
  display: block;
  width: 100%;
  min-width: 10.5rem;
  height: 2.375rem;
  min-height: 2.375rem;
  padding: 0 14px;
  line-height: calc(2.375rem - 2px);
  text-align: center;
  cursor: pointer;
  font-family: inherit;
}

.grade-select--custom:focus-visible {
  outline: 2px solid rgba(56, 189, 248, 0.75);
  outline-offset: 2px;
}

.grade-select-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  z-index: 200;
  margin: 0;
  padding: 3px 0;
  list-style: none;
  border-radius: 12px;
  border: 1px solid rgba(75, 85, 99, 0.95);
  background: rgba(15, 23, 42, 0.98);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
}

.grade-select-option {
  margin: 0;
  padding: 5px 12px 5px 8px;
  text-align: left;
  cursor: pointer;
  color: #e5e7eb;
  font-size: 0.95rem;
  line-height: 1.25;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.12rem;
}

.grade-select-option-check {
  flex: 0 0 1.125rem;
  width: 1.125rem;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  font-size: 0.8rem;
  line-height: 1;
  opacity: 0.95;
}

.grade-select-option--selected .grade-select-option-check::before {
  content: "✓";
}

.grade-select-option-label {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35em;
  min-width: 0;
}

/* Ordinals share one column so “grade” lines up; checkmark column is separate */
.grade-select-option-ordinal {
  min-width: 2.65em;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.grade-select-option:hover,
.grade-select-option:focus-visible {
  background: rgba(56, 189, 248, 0.12);
  outline: none;
}

.grade-select-option--selected {
  font-weight: 600;
}

.subtle-status {
  margin-top: 10px;
}

.file-label {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px dashed rgba(148, 163, 184, 0.8);
  color: #e5e7eb;
  font-size: 0.9rem;
  cursor: pointer;
  background: radial-gradient(circle at top left, rgba(56, 189, 248, 0.2), rgba(15, 23, 42, 0.9));
}

.file-label input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.file-name {
  font-size: 0.85rem;
  color: #9ca3af;
}

.csv-example {
  margin-top: 12px;
  font-size: 0.8rem;
  color: #9ca3af;
}

.csv-example pre {
  background: rgba(15, 23, 42, 0.9);
  border-radius: 10px;
  padding: 8px 10px;
  border: 1px solid rgba(55, 65, 81, 0.8);
  overflow-x: auto;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.start-game-card {
  overflow: visible;
}

/* Lift entire card when Options is open so the popover stacks above following sections (e.g. Spelling Round) */
.start-game-card:has(#game-options-details[open]) {
  position: relative;
  z-index: 25;
}

.start-game-card-columns {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 14px 20px;
}

.start-game-card-primary {
  flex: 1 1 260px;
  min-width: 0;
}

.start-game-card-primary .start-game-card-title,
.game-header-heading {
  margin: 0;
  font-size: 1.1rem;
}

.start-game-card-primary .start-game-main {
  margin-top: 12px;
}

.start-game-card-options-col {
  flex: 0 0 auto;
  width: min(17.5rem, 100%);
  min-width: min(17.5rem, 100%);
  align-self: stretch;
}

.start-game-card-options-col .game-options-details.game-options-details--inline {
  position: relative;
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 0 0 0 auto;
  padding: 0;
  border: none;
}

.start-game-card-options-col .game-options-sidebar-summary {
  width: fit-content;
  max-width: 100%;
}

/* Match `.score-pill` in the game header (size + pill look) */
.game-options-sidebar-summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  user-select: none;
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.2;
  color: #e5e7eb;
  padding: 6px 14px;
  min-height: 30px;
  box-sizing: border-box;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.7);
  background: radial-gradient(circle at top right, rgba(56, 189, 248, 0.15), rgba(15, 23, 42, 0.95));
}

.game-options-sidebar-summary::-webkit-details-marker {
  display: none;
}

.game-options-sidebar-summary::marker {
  content: "";
}

.game-options-sidebar-title {
  line-height: 1.2;
}

.game-options-details[open] > .game-options-sidebar-summary {
  border-color: rgba(56, 189, 248, 0.65);
  color: #f1f5f9;
}

.game-options-details[open] > .game-options-sidebar-summary .config-details-chevron {
  transform: rotate(-135deg);
  margin-top: 0.15em;
}

.game-options-body {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(55, 65, 81, 0.45);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Panel opens to the LEFT of the Options pill (same row, does not push primary column) */
.start-game-card-options-col .game-options-details--inline .game-options-body {
  position: absolute;
  right: calc(100% + 8px);
  left: auto;
  top: 0;
  margin: 0;
  padding: 10px 12px 11px;
  width: min(17.5rem, calc(100vw - 40px));
  max-width: 17.5rem;
  min-width: 0;
  box-sizing: border-box;
  border-top: none;
  border-radius: 12px;
  border: 1px solid rgba(75, 85, 99, 0.95);
  background: rgba(15, 23, 42, 0.99);
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.35),
    0 12px 28px rgba(2, 6, 23, 0.55),
    0 28px 56px rgba(2, 6, 23, 0.5),
    0 0 0 1px rgba(56, 189, 248, 0.14);
  gap: 8px;
  z-index: 1;
}

.start-game-card .game-options-details--inline .game-option-label {
  font-size: 0.82rem;
  line-height: 1.28;
}

.start-game-card .game-options-details--inline .game-option-row--checkbox .game-option-label {
  padding-top: 1px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.start-game-card .game-options-details--inline .game-option-checkbox {
  margin-top: 2px;
}

.game-options-details .option-tag {
  font-weight: 500;
  font-size: 0.88em;
  color: #9ca3af;
}

.game-option-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.game-option-row--voice {
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.game-option-row--voice .game-option-label {
  flex-shrink: 0;
  margin: 0;
  padding-top: 0;
}

.game-option-row--voice .tts-voice-select {
  align-self: auto;
}

.game-option-row--checkbox {
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
}

.game-option-label {
  font-size: 0.9rem;
  line-height: 1.35;
  color: #d1d5db;
}

.game-option-row--checkbox .game-option-label {
  flex: 1;
  min-width: 0;
  padding-top: 2px;
}

.game-option-checkbox {
  margin-top: 3px;
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
  accent-color: #38bdf8;
}

/* Match `.grade-select` in `.grade-row`: intrinsic width + shared min-width, not full panel width */
.tts-voice-select {
  width: auto;
  align-self: flex-start;
  max-width: 100%;
}

.mode-button {
  border-radius: 14px;
  padding: 12px 14px;
  border: 1px solid rgba(55, 65, 81, 0.9);
  background: radial-gradient(circle at top left, rgba(59, 130, 246, 0.2), rgba(15, 23, 42, 0.9));
  color: #e5e7eb;
  text-align: left;
  cursor: pointer;
  transition: transform 0.08s ease-out, box-shadow 0.08s ease-out, border-color 0.08s ease-out,
    background 0.08s ease-out;
}

.mode-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 25px rgba(15, 23, 42, 0.9);
  border-color: rgba(129, 140, 248, 0.9);
}

.mode-button.selected {
  border-color: rgba(56, 189, 248, 0.95);
  box-shadow: 0 14px 32px rgba(8, 47, 73, 0.9);
}

.mode-title {
  display: block;
  font-weight: 600;
}

.mode-desc {
  display: block;
  margin-top: 2px;
  font-size: 0.85rem;
  color: #9ca3af;
}

.start-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 0;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button,
.ghost-button {
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 0.9rem;
  border: none;
  cursor: pointer;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.primary-button {
  background: linear-gradient(135deg, #22c55e, #38bdf8);
  color: #020617;
  box-shadow: 0 12px 28px rgba(8, 47, 73, 0.85);
}

.primary-button:disabled {
  background: linear-gradient(135deg, #4b5563, #374151);
  color: #9ca3af;
  cursor: not-allowed;
  box-shadow: none;
}

.secondary-button {
  background: rgba(15, 23, 42, 0.95);
  color: #e5e7eb;
  border: 1px solid rgba(55, 65, 81, 0.9);
}

#next-word:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

#next-word:not(:disabled) {
  border-color: rgba(129, 140, 248, 0.85);
  box-shadow: 0 10px 22px rgba(30, 27, 75, 0.45);
}

.ghost-button {
  background: transparent;
  color: #9ca3af;
  border: 1px dashed rgba(75, 85, 99, 0.9);
}

.icon-button {
  padding-inline: 12px;
}

.icon-button span {
  font-size: 1.3rem;
  line-height: 1;
}

.status-text {
  font-size: 0.85rem;
  color: #9ca3af;
}

.game-card {
  margin-top: 4px;
}

/* Inherits `.card` padding (18px 18px 20px) — same top inset as step cards (e.g. “3. Start Game”) */

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

.game-header-title-col {
  min-width: 0;
  flex: 1;
}

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

.game-header-bees {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.game-header-bee-img {
  width: 20px;
  height: 20px;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
}

@keyframes game-header-bee-reward-glow {
  0% {
    filter: drop-shadow(0 0 0 transparent);
    transform: scale(1);
  }
  45% {
    filter:
      drop-shadow(0 0 8px rgba(253, 224, 71, 0.95))
      drop-shadow(0 0 18px rgba(251, 191, 36, 0.7))
      drop-shadow(0 0 3px rgba(255, 255, 255, 0.55));
    transform: scale(1.22);
  }
  100% {
    filter: drop-shadow(0 0 0 transparent);
    transform: scale(1);
  }
}

.game-header-bee-img--reward-enter {
  animation: game-header-bee-reward-glow 1.05s ease-out forwards;
}

@media (prefers-reduced-motion: reduce) {
  @keyframes game-header-bee-reward-glow-soft {
    0%,
    100% {
      filter: none;
      transform: none;
    }
    50% {
      filter: brightness(1.2);
    }
  }

  .game-header-bee-img--reward-enter {
    animation: game-header-bee-reward-glow-soft 0.5s ease-out forwards;
  }
}

.game-header-metrics {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.game-timer {
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
  color: #93c5fd;
  min-width: 3.25rem;
  text-align: right;
}

.score-pill {
  border-radius: 999px;
  padding: 6px 14px;
  border: 1px solid rgba(148, 163, 184, 0.7);
  font-size: 0.85rem;
  color: #e5e7eb;
  background: radial-gradient(circle at top right, rgba(56, 189, 248, 0.15), rgba(15, 23, 42, 0.95));
}

.prompt-area {
  margin-top: 4px;
  padding: 10px 12px 12px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(55, 65, 81, 0.9);
  /* Match ~sentence + label + speaker row so the shell doesn't jump on Start */
  min-height: 7rem;
}

.prompt-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #9ca3af;
  margin-bottom: 4px;
}

.prompt-content {
  font-size: 1.12rem;
  line-height: 1.45;
}

.prompt-main-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.prompt-main-row > .prompt-content {
  flex: 1;
  min-width: 0;
}

/* Definition sentence sits in .prompt-content directly; audio puts #audio-prompt-lead inside with .hint-text margin-top — match that inset */
.prompt-main-row > .prompt-content:not(:has(#audio-prompt-lead)) {
  padding-top: 6px;
}

.hint-text {
  margin-top: 6px;
  font-size: 0.85rem;
  color: #a5b4fc;
}

#audio-prompt-lead {
  font-size: 1.12rem;
  line-height: 1.45;
}

#audio-prompt-lead.audio-prompt-placeholder {
  min-height: 2.35rem;
}

#show-hint.show-hint-used:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  color: #6b7280;
  border-style: solid;
  border-color: rgba(75, 85, 99, 0.45);
  background: rgba(15, 23, 42, 0.4);
}

.input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}

/* Match width in both "Submit" and ">>" states */
#submit-answer {
  min-width: 6.75rem;
  flex-shrink: 0;
  box-sizing: border-box;
}

#answer-input {
  flex: 1;
  border-radius: 999px;
  box-sizing: border-box;
  height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(75, 85, 99, 0.9);
  background: rgba(15, 23, 42, 0.95);
  color: #e5e7eb;
  font-size: 1.125rem;
  line-height: 1.2;
}

#answer-input:focus {
  outline: none;
  border-color: rgba(56, 189, 248, 0.95);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.8);
}

.game-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.session-summary-dialog {
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 16px;
  padding: 32px 36px 36px;
  max-width: min(28rem, calc(100vw - 40px));
  width: min(28rem, calc(100vw - 40px));
  box-sizing: border-box;
  background: #0f172a;
  color: #e5e7eb;
  /* Avoid clipping above the viewport (default centered dialog can go negative top when tall) */
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  --session-dialog-inset-top: max(1.75rem, calc(env(safe-area-inset-top, 0px) + 1rem));
  --session-dialog-inset-bottom: max(1.25rem, env(safe-area-inset-bottom, 0px));
  top: var(--session-dialog-inset-top);
  max-height: calc(100vh - var(--session-dialog-inset-top) - var(--session-dialog-inset-bottom));
  max-height: calc(100dvh - var(--session-dialog-inset-top) - var(--session-dialog-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
}

.session-summary-dialog::backdrop {
  background: rgba(2, 6, 23, 0.72);
  cursor: pointer;
}

.session-summary-form {
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.session-summary-title {
  margin: 0 0 4px;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

.session-summary-body {
  font-size: 0.95rem;
  line-height: 1.55;
  /* Fixed label column so stats values stay aligned regardless of misspelling list length */
  display: grid;
  grid-template-columns: minmax(11.5rem, 12rem) minmax(0, 1fr);
  column-gap: 0.75rem;
  row-gap: 14px;
  align-items: start;
}

.session-summary-line {
  display: contents;
  margin: 0;
}

.session-summary-label {
  font-weight: 600;
  color: #9ca3af;
}

.session-summary-value {
  text-align: left;
  font-variant-numeric: tabular-nums;
  color: #f1f5f9;
  min-width: 0;
  justify-self: start;
}

.session-summary-unit {
  font-weight: 400;
  color: #94a3b8;
  font-size: 0.88em;
}

.session-summary-body > .session-misspell-list {
  grid-column: 1 / -1;
}

.session-misspell-list {
  margin: 0;
  padding: 10px 12px 10px 1.5rem;
  font-size: 0.9rem;
  line-height: 1.5;
  color: #d1d5db;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(55, 65, 81, 0.75);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.session-misspell-word {
  font-weight: 600;
  color: #fde68a;
}

.session-misspell-typed {
  color: #fca5a5;
}

.session-summary-close {
  align-self: flex-end;
  margin-top: 6px;
  padding-inline: 1.35rem;
  padding-block: 0.55rem;
}

.feedback-text {
  margin-top: 10px;
  font-size: 0.9rem;
  line-height: 1.35;
  /* Reserve space so the game card doesn't jump when feedback appears/disappears */
  min-height: 2.2em;
}

.feedback-correct {
  color: #4ade80;
}

.feedback-incorrect {
  color: #f97373;
}

.feedback-highlight-word {
  font-weight: 700;
  font-size: 1.08em;
  letter-spacing: 0.03em;
}

.feedback-incorrect .feedback-highlight-word {
  color: #fde68a;
  text-shadow: 0 0 12px rgba(250, 204, 21, 0.35);
}

.feedback-correct .feedback-highlight-word {
  color: #ecfdf5;
  text-shadow: 0 0 10px rgba(52, 211, 153, 0.45);
}

.feedback-answer .feedback-highlight-word {
  color: #fde68a;
}

.feedback-answer {
  color: #e5e7eb;
}

.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ── Full list cleared: party poppers + bees + SFX (triggerFinishCelebration in app.js) ── */
/* Absolute to .app-shell (not the viewport) so bees/poppers stay over the honeycomb frame on ultra-wide screens */
.finish-celebration-root {
  position: absolute;
  inset: 0;
  z-index: 9990;
  pointer-events: none;
  overflow: hidden;
  contain: strict;
}

.finish-celebration-stage {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 1;
}

/* Fade poppers/confetti out so opacity hits 0 when the last bee dance ends (see triggerFinishCelebration) */
.finish-celebration-stage.finish-celebration-stage--fade {
  opacity: 0;
  transition: opacity var(--finish-popper-fade-sec, 0.7s) ease-out;
}

.finish-popper {
  position: absolute;
  /* Higher on the screen so mouths sit nearer the bee swarm (bees use ~top 16–38%) */
  bottom: max(140px, 18vh);
  width: 112px;
  height: 132px;
  pointer-events: none;
}

/* Tip down, mouth up — ±30° tilt; centers 5in apart (2.5in each side of viewport center) */
.finish-popper--left {
  left: max(3rem, calc(50% - 2.5in));
  transform: translateX(-50%) rotate(30deg);
  transform-origin: 50% 100%;
}

.finish-popper--right {
  left: min(calc(100% - 3rem), calc(50% + 2.5in));
  right: auto;
  transform: translateX(-50%) rotate(-30deg);
  transform-origin: 50% 100%;
}

@keyframes finish-popper-pop-left {
  0%,
  100% {
    transform: translateX(-50%) rotate(30deg) scale(1);
  }
  40% {
    transform: translateX(-50%) rotate(30deg) scale(1.14);
  }
}

@keyframes finish-popper-pop-right {
  0%,
  100% {
    transform: translateX(-50%) rotate(-30deg) scale(1);
  }
  40% {
    transform: translateX(-50%) rotate(-30deg) scale(1.14);
  }
}

.finish-popper--left.finish-popper--pop {
  animation: finish-popper-pop-left 0.34s ease;
}

.finish-popper--right.finish-popper--pop {
  animation: finish-popper-pop-right 0.34s ease;
}

.finish-popper-body {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
}

.finish-popper-cap {
  width: 54px;
  height: 13px;
  border-radius: 2px 2px 5px 5px;
  box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.1);
  order: 0;
}

.finish-popper-cap--warm {
  background: linear-gradient(180deg, #f97316 0%, #ea580c 100%);
}

.finish-popper-cap--cool {
  background: linear-gradient(180deg, #3b82f6 0%, #1d4ed8 100%);
}

/* Wide opening at top (mouth), narrow tip at bottom — tip points down */
.finish-popper-cone {
  width: 72px;
  height: 86px;
  margin-top: -1px;
  order: 1;
  flex-shrink: 0;
  clip-path: polygon(0% 0%, 100% 0%, 50% 100%);
  box-shadow: inset 0 6px 14px rgba(0, 0, 0, 0.12);
}

.finish-popper-cone--warm {
  background: repeating-linear-gradient(-62deg, #fbbf24 0px, #fbbf24 9px, #fdba74 9px, #fdba74 18px);
}

.finish-popper-cone--cool {
  background: repeating-linear-gradient(-62deg, #bfdbfe 0px, #bfdbfe 8px, #60a5fa 8px, #60a5fa 16px);
}

.finish-popper-string {
  order: 2;
  align-self: center;
  width: 3px;
  height: 22px;
  margin-top: -2px;
  border-radius: 2px;
}

.finish-popper-string--purple {
  background: linear-gradient(180deg, #a78bfa, #7c3aed);
}

.finish-popper-string--red {
  background: linear-gradient(180deg, #fb7185, #dc2626);
}

/* Confetti originates at the wide mouth (top of cone, below cap) */
.finish-popper-burst {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 13px;
  bottom: auto;
  width: 0;
  height: 0;
  transform: translateX(-50%);
  overflow: visible;
}

@keyframes finish-confetti-shoot {
  0% {
    transform: translate(0, 0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translate(var(--dx), var(--dy)) rotate(720deg);
    opacity: 0;
  }
}

.finish-confetti-bit {
  position: absolute;
  left: 0;
  bottom: 0;
  margin-left: -2px;
  margin-bottom: 0;
  border-radius: 1px;
  background: var(--c);
  animation: finish-confetti-shoot ease-out forwards;
  will-change: transform, opacity;
}

@keyframes finish-streamer-shoot {
  0% {
    transform: translate(0, 0) rotate(0deg) scaleY(0.25);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  100% {
    transform: translate(var(--dx), var(--dy)) rotate(var(--curl, 18deg)) scaleY(1);
    opacity: 0;
  }
}

.finish-streamer {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 5px;
  height: 96px;
  margin-left: -2px;
  border-radius: 50% 50% 45% 55% / 40% 40% 60% 60%;
  transform-origin: bottom center;
  background: linear-gradient(180deg, var(--stream-c) 0%, transparent 92%);
  box-shadow: 1px 0 0 rgba(255, 255, 255, 0.12);
  animation: finish-streamer-shoot ease-out forwards;
  will-change: transform, opacity;
}

@keyframes finish-bee-fly-around {
  0% {
    transform: translate(-50%, -50%) translate(0, 0) scale(0) rotate(0deg);
    opacity: 0;
  }
  5% {
    transform: translate(-50%, -50%) translate(0, 0) scale(1.12) rotate(-10deg);
    opacity: 1;
  }
  11% {
    transform: translate(-50%, -50%) translate(0, 0) scale(1) rotate(14deg);
    opacity: 1;
  }
  26% {
    transform: translate(-50%, -50%) translate(var(--p1x), var(--p1y)) scale(1) rotate(-20deg);
    opacity: 1;
  }
  44% {
    transform: translate(-50%, -50%) translate(var(--p2x), var(--p2y)) scale(1.05) rotate(24deg);
    opacity: 1;
  }
  62% {
    transform: translate(-50%, -50%) translate(var(--p3x), var(--p3y)) scale(1) rotate(-18deg);
    opacity: 1;
  }
  80% {
    transform: translate(-50%, -50%) translate(var(--p4x), var(--p4y)) scale(0.92) rotate(18deg);
    opacity: 0.88;
  }
  100% {
    transform: translate(-50%, -50%) translate(var(--p4x), var(--p4y)) scale(0.35) rotate(22deg);
    opacity: 0;
  }
}

.finish-bee-pop {
  position: absolute;
  left: var(--cx);
  top: var(--cy);
  z-index: 1;
  width: 40px;
  height: 40px;
  /* duration overridden by inline style from JS (per-bee variation); base ≈ 2× original dance length */
  animation: finish-bee-fly-around 6.2s cubic-bezier(0.33, 0.72, 0.36, 1) forwards;
  will-change: transform, opacity;
}

.finish-bee-pop-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.4));
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .finish-celebration-root {
    display: none !important;
  }
}

@media (max-width: 640px) {
  .app-shell {
    --honey-band: 72px;
    --shell-gutter: 12px;
    padding: 16px calc(var(--honey-band) + var(--shell-gutter))
      calc(16px + var(--honey-band));
  }

  .app-shell::after {
    left: var(--honey-band);
    right: var(--honey-band);
    bottom: var(--honey-band);
  }

  .app-header h1 {
    font-size: 1.8rem;
  }

  .input-row {
    flex-direction: column;
    align-items: stretch;
  }

  #answer-input {
    width: 100%;
  }

  .start-game-card-columns {
    flex-direction: column;
  }

  .start-game-card-options-col {
    width: 100%;
    min-width: 0;
    align-self: stretch;
  }

  .start-game-card-options-col .game-options-details.game-options-details--inline {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    width: 100%;
    margin-left: 0;
  }

  .start-game-card-options-col .game-options-details--inline .game-options-body {
    position: static;
    align-self: stretch;
    width: 100%;
    max-width: none;
    margin-top: 10px;
    box-shadow: none;
    z-index: auto;
  }
}

