:root {
  color-scheme: light;
  --paper: #f6f4ed;
  --white: #fffefa;
  --ink: #201b35;
  --muted: #5e5771;
  --blue: #5333be;
  --blue-hover: #4324aa;
  --board: #252046;
  --board-deep: #1b1737;
  --lime: #e1ef81;
  --lavender: #ddd4fa;
  --coral: #f7a98f;
  --line: #ddd8e4;
  --field-border: #827792;
  --soft: #efebf9;
  --green: #186547;
  --radius: 17px;
  --fast: 145ms;
  --normal: 225ms;
  --quiet: 340ms;
  --card-exit: 180ms;
  --ease: cubic-bezier(.2, .74, .25, 1);
  --gutter: clamp(16px, 4vw, 60px);
  --shadow: 0 12px 32px #29204412;
  --content: 1440px;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 88px; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.52 "Segoe UI", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}
button, input, select { font: inherit; }
button, a, summary { touch-action: manipulation; }
button, a, input, select, summary { -webkit-tap-highlight-color: transparent; }
button { background: none; border: 0; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .53; }
a { color: var(--blue); }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
main:focus { outline: none; }
svg { display: block; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-weight: 800; line-height: 1.1; letter-spacing: -.037em; }
h1 { font-size: clamp(2.35rem, 5vw, 4.45rem); }
h2 { font-size: clamp(1.62rem, 3.1vw, 2.55rem); }
h3 { font-size: 1.22rem; }
small { font-size: .82rem; }
input[type=search], input[type=text], select {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 10px 13px;
  border: 1px solid var(--field-border);
  border-radius: 12px;
  background: var(--white);
  color: var(--ink);
}
input::placeholder { color: var(--muted); opacity: 1; }
input[type=checkbox] {
  accent-color: var(--blue);
  width: 19px;
  height: 19px;
  margin: 0;
  flex: none;
  cursor: pointer;
}
.muted { color: var(--muted); }
.blue { color: var(--blue); }
.eyebrow { font-size: .77rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.skip-link {
  position: fixed;
  z-index: 40;
  inset: 12px auto auto 12px;
  transform: translateY(calc(-100% - 24px));
  padding: 12px 18px;
  background: var(--white);
  border-radius: 10px;
}
.skip-link:focus { transform: none; }
.header {
  position: sticky;
  z-index: 20;
  top: 0;
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.header-inner, main, .footer {
  max-width: var(--content);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.header-inner { display: flex; align-items: center; gap: clamp(16px, 4vw, 60px); min-height: 70px; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding-block: 5px;
  color: var(--ink);
  font-size: 1.85rem;
  font-weight: 850;
  line-height: 1;
  letter-spacing: -.07em;
  text-decoration: none;
}
.brand > svg { width: 39px; height: 39px; margin-right: 3px; color: var(--blue); }
.brand > span { color: var(--blue); }
nav { display: flex; align-items: center; gap: clamp(8px, 1.7vw, 25px); }
nav a, nav button, .footer button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px;
  color: var(--ink);
  font-size: .91rem;
  font-weight: 700;
  text-decoration: none;
}
nav .nav-play, nav a:hover, nav button:hover, .footer button:hover { color: var(--blue); }
.circle-help {
  display: inline-grid;
  place-items: center;
  width: 19px;
  height: 19px;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: .75rem;
}
main { min-height: calc(100vh - 150px); padding-bottom: clamp(28px, 5vw, 65px); }
.footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 18px;
  min-height: 70px;
  border-top: 1px solid var(--line);
}
.footer > span:first-child { margin-right: auto; font-weight: 800; }
.footer button { font-size: .85rem; color: var(--muted); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  min-height: 49px;
  padding: 10px 19px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-weight: 760;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  transition: background-color var(--fast), color var(--fast), transform var(--fast) var(--ease);
}
.btn:active:not(:disabled) { transform: translateY(2px); }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--blue-hover); }
.btn-outline { border-color: var(--field-border); background: var(--white); color: var(--ink); }
.btn-outline:hover { background: var(--soft); }
.btn-small { min-height: 44px; padding: 8px 13px; font-size: .9rem; }
.text-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 3px 4px;
  font-size: .91rem;
  font-weight: 720;
}
.text-btn:hover { text-decoration: underline; text-underline-offset: 4px; }

.hero {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(0, 1.04fr) minmax(0, .96fr);
  align-items: center;
  gap: clamp(16px, 3.2vw, 48px);
  min-height: 430px;
  margin: clamp(18px, 3.2vw, 42px) 0 clamp(29px, 4.5vw, 58px);
  padding: clamp(26px, 4.8vw, 68px);
  border-radius: clamp(20px, 3vw, 35px);
  background: var(--board);
  color: #fff;
}
.hero > :first-child { position: relative; z-index: 2; min-width: 0; }
.hero-label { display: inline-flex; gap: 8px; color: #efe7ff; font-size: .86rem; font-weight: 700; }
.hero-label > span { color: var(--lime); }
.hero h1 { margin-block: 13px 19px; font-size: clamp(2.72rem, 6.15vw, 6rem); line-height: .99; }
.hero h1 em { color: var(--lime); font-style: normal; }
.hero p { max-width: 48ch; color: #eee9fa; font-size: clamp(1rem, 1.3vw, 1.14rem); }
.hero-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 18px; margin-top: 25px; }
.hero-actions .btn-primary { background: var(--lime); color: var(--board-deep); }
.hero-actions .btn-primary:hover { background: #f0f8ac; }
.hero :focus-visible { outline-color: var(--lime); }
.hero-art {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 320px;
  isolation: isolate;
  animation: hero-art-in var(--quiet) var(--ease) both;
}
.art-orbit {
  position: absolute;
  inset: -13px 0;
  opacity: .35;
  background-size: 23px 23px;
  background-image: radial-gradient(circle, #a094c0 1px, transparent 1.3px);
  -webkit-mask-image: radial-gradient(ellipse, black 30%, transparent 77%);
  mask-image: radial-gradient(ellipse, black 30%, transparent 77%);
}
.art-blob {
  position: absolute;
  width: min(75%, 330px);
  aspect-ratio: 1 / .91;
  border: 1px solid #8881a8;
  border-radius: 50%;
  transform: rotate(-23deg);
}
.art-card {
  position: absolute;
  width: clamp(152px, 19vw, 222px);
  aspect-ratio: 1 / 1.26;
  border: 1px solid var(--board-deep);
  border-radius: 18px;
  box-shadow: 0 6px 0 #17133170;
}
.art-back { background: var(--coral); transform: translate(39%, -3%) rotate(17deg); }
.art-middle { background: var(--lime); transform: translate(-34%, 5%) rotate(-15deg); }
.art-front {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(13px, 1.6vw, 21px);
  transform: rotate(-3deg);
  color: var(--board);
  background: var(--lavender);
}
.art-front .eyebrow, .art-bottom { display: flex; justify-content: space-between; gap: 7px; width: 100%; font-size: clamp(.60rem, .85vw, .72rem); }
.art-front .art-atom { width: 32%; height: auto; margin-block: auto 6%; color: var(--blue); }
.art-word { font-size: clamp(1.38rem, 3vw, 2.4rem); font-weight: 830; letter-spacing: -.065em; line-height: 1.05; }
.art-front small { margin-top: 5%; font-size: clamp(.6rem, .8vw, .73rem); text-align: center; }
.art-bottom { margin-top: auto; padding-top: 5%; border-top: 1px solid #a799c4; }
.art-label {
  position: absolute;
  z-index: 2;
  padding: .57em .79em;
  border-radius: 9px;
  background: var(--white);
  color: var(--ink);
  box-shadow: 0 3px 0 #1b173772;
  font-size: clamp(.76rem, 1.1vw, .94rem);
  font-weight: 650;
}
.art-label.one { top: 3%; left: 1%; transform: rotate(-6deg); }
.art-label.two { bottom: 3%; right: -2%; transform: rotate(5deg); }
.art-label b { color: var(--green); }
.art-spark { position: absolute; color: var(--lime); font-size: 2.35rem; right: 5%; top: -1%; }
.art-dot { position: absolute; color: var(--coral); bottom: 10%; left: 8%; width: 10px; height: 10px; border: 2px solid; border-radius: 50%; }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px 20px;
  margin-bottom: 16px;
}
.section-head p { margin-top: 6px; color: var(--muted); }
.search-wrap { position: relative; width: min(100%, 320px); }
.search-wrap svg {
  position: absolute;
  pointer-events: none;
  inset: 50% auto auto 13px;
  width: 19px;
  height: 19px;
  color: var(--muted);
  transform: translateY(-50%);
}
.search-wrap input { padding-left: 41px; }
.filters { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; }
.filters-label { font-size: .9rem; font-weight: 700; color: var(--muted); }
.grade-chips, .category-filter { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.chip, .category-filter button {
  min-height: 44px;
  padding: 5px 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: .87rem;
  font-weight: 680;
}
.chip:hover, .category-filter button:hover { background: var(--soft); }
.chip.active, .category-filter button.active { border-color: #c8baed; background: var(--soft); color: var(--blue); }
.category-filter { margin-left: auto; }
.subject-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.subject-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-height: 166px;
  min-width: 0;
  padding: clamp(14px, 1.75vw, 22px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  text-align: left;
  transition: transform var(--fast) var(--ease), box-shadow var(--fast), border-color var(--fast);
}
.subject-card:active { transform: translateY(1px); }
.subject-symbol {
  display: grid;
  place-items: center;
  width: 49px;
  height: 49px;
  flex: none;
  border-radius: 13px;
  background: var(--tint, var(--lavender));
  color: var(--subject, var(--blue));
}
.subject-symbol svg { width: 30px; height: 30px; }
.subject-card h3 { margin-top: 15px; overflow-wrap: anywhere; }
.subject-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 5px;
  width: 100%;
  margin-top: auto;
  padding-top: 11px;
  color: var(--muted);
  font-size: .76rem;
}
.subject-arrow {
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  flex: none;
  border-radius: 50%;
  background: var(--soft);
  color: var(--blue);
  font-size: .95rem;
}
@media (hover: hover) and (pointer: fine) {
  .subject-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: #b6a7d8; }
}
.resume-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-block: 20px;
  padding: 13px 16px;
  border: 1px solid #c8b9ee;
  border-radius: var(--radius);
  background: var(--soft);
}
.resume-banner small { display: block; margin-top: 4px; color: var(--muted); }
.resume-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.empty {
  grid-column: 1 / -1;
  padding: 20px;
  border: 1px dashed var(--field-border);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}
.empty .btn { margin-top: 10px; }

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-block: 12px 5px;
  color: var(--muted);
  font-size: .92rem;
}
.breadcrumb button, .selection-tools button {
  min-height: 44px;
  padding: 5px 2px;
  color: var(--blue);
  font-weight: 720;
  text-align: left;
}
.breadcrumb button:hover, .selection-tools button:hover { text-decoration: underline; text-underline-offset: 3px; }
.breadcrumb .current { color: var(--ink); font-weight: 700; }
.topic-heading { display: flex; align-items: center; gap: 15px; margin-bottom: clamp(21px, 4vw, 44px); }
.topic-heading .subject-symbol { width: clamp(53px, 7vw, 76px); height: clamp(53px, 7vw, 76px); border-radius: 16px; }
.topic-heading .subject-symbol svg { width: 61%; height: 61%; }
.topic-heading h1 { overflow-wrap: anywhere; }
.topic-heading p { margin-top: 7px; color: var(--muted); }
.topic-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(325px, 370px);
  align-items: start;
  gap: clamp(18px, 2.8vw, 40px);
}
.topic-tools { display: flex; flex-wrap: wrap; gap: 10px; }
.topic-tools .search-wrap { width: 100%; }
.selection-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0 10px;
  margin-block: 8px;
  color: var(--muted);
  font-size: .88rem;
}
.selection-tools > span { font-weight: 700; }
.topic-section {
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
}
.section-title, .topic-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 13px; }
.section-title { border-radius: var(--radius) var(--radius) 0 0; background: var(--soft); font-weight: 780; }
.section-title label, .topic-row label {
  display: flex;
  align-items: center;
  flex: 1;
  min-height: 44px;
  padding-block: 5px;
  gap: 11px;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.section-count { flex: none; color: var(--muted); font-size: .8rem; font-weight: 600; }
.topic-row { border-top: 1px solid var(--line); }
.topic-row:last-child { border-radius: 0 0 var(--radius) var(--radius); }
.topic-row:has(input:checked) { background: #f8f4fd; }
.topic-row label > span { min-width: 0; }
.topic-row label small { display: block; color: var(--muted); }
.preview-btn { flex: none; min-height: 44px; padding: 5px 7px; color: var(--blue); font-size: .89rem; font-weight: 700; }
.preview-btn:hover { text-decoration: underline; text-underline-offset: 3px; }
.setup-panel {
  padding: clamp(15px, 2vw, 24px);
  border: 1px solid #c8bed9;
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow);
}
.setup-panel h2 { font-size: 1.82rem; }
.setup-panel > p { margin-top: 7px; color: var(--muted); font-size: .9rem; }
.deck-count {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 15px;
  padding: 6px 12px;
  border-radius: 10px;
  background: var(--soft);
  color: var(--blue);
  font-size: .91rem;
}
.deck-count strong { font-size: 1.84rem; font-variant-numeric: tabular-nums; }
.field { margin-block: 13px; }
.field-label { display: block; margin-bottom: 5px; font-size: .88rem; font-weight: 750; }
.segmented { display: flex; flex-wrap: wrap; gap: 4px; padding: 3px; border: 1px solid var(--line); border-radius: 11px; background: #f6f3fb; }
.segmented button {
  flex: 1 1 auto;
  min-height: 44px;
  padding: 6px 7px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  font-size: .83rem;
  font-weight: 700;
}
.segmented button:hover { color: var(--blue); }
.segmented button.active { border-color: #c8b9ee; background: var(--white); color: var(--blue); box-shadow: 0 1px 2px #27164b15; }
.difficulty-options { padding: 0; border: 0; background: transparent; }
.difficulty-options button { border-color: var(--line); color: var(--ink); }
.difficulty-options button.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.difficulty-description { margin-top: 6px; color: var(--muted); font-size: .83rem; }
.difficulty-badge {
  --level-bg: #ede6fc;
  --level-ink: #4e318e;
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 7px;
  background: var(--level-bg);
  color: var(--level-ink);
  font-weight: 750;
  line-height: 1.35;
  font-size: .77rem;
  white-space: nowrap;
}
.difficulty-badge[data-difficulty=easy] { --level-bg: #e6f5d9; --level-ink: #33592e; }
.difficulty-badge[data-difficulty=medium] { --level-bg: #f5edc8; --level-ink: #624617; }
.difficulty-badge[data-difficulty=hard] { --level-bg: #f8ded7; --level-ink: #7a3125; }

.team-inputs { display: grid; gap: 5px; margin-top: 7px; }
.team-input-row { position: relative; }
.team-input-row input { padding-left: 31px; }
.team-dot { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 50%; }
.team-input-row .team-dot { position: absolute; top: calc(50% - 5px); left: 12px; pointer-events: none; }
.toggle-field { display: flex; align-items: center; justify-content: space-between; gap: 5px; color: var(--muted); }
.toggle-field label { display: flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; }
.setup-panel > .btn { width: 100%; margin-top: 9px; }
.warning-note, .storage-note {
  padding: 7px 10px;
  border-radius: 8px;
  background: #fff0dc;
  color: #65391c;
  font-size: .86rem;
}
.mobile-setup-link { display: none; }

.game-shell { max-width: 1010px; margin-inline: auto; padding-top: clamp(10px, 2.1vw, 25px); }
.game-top { display: flex; align-items: center; justify-content: space-between; gap: 4px 12px; margin-bottom: 7px; font-size: .9rem; font-weight: 650; }
.game-top button, .play-bottom button { min-height: 44px; padding: 5px 3px; color: var(--blue); font-weight: 750; }
.game-top button:hover, .play-bottom button:hover { text-decoration: underline; text-underline-offset: 3px; }
.game-top > span { color: var(--muted); }
.scoreboard { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; margin-bottom: 15px; }
.score-pill {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 43px;
  max-width: 100%;
  min-width: min(132px, 100%);
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--white);
  font-size: .85rem;
}
.score-pill span { overflow-wrap: anywhere; }
.score-pill strong { color: var(--ink); font-size: 1.16rem; font-variant-numeric: tabular-nums; }
.score-pill.active { border-color: var(--blue); background: var(--soft); }
.game-center {
  padding: clamp(22px, 4.2vw, 52px) clamp(12px, 3.2vw, 44px);
  border: 1px solid var(--line);
  border-radius: clamp(17px, 3vw, 28px);
  background: var(--white);
  text-align: center;
}
.game-center h1 { margin: 12px auto; font-size: clamp(2rem, 5vw, 4.1rem); overflow-wrap: anywhere; }
.game-center > p { color: var(--muted); }
.ready-art, .winner-mark {
  display: grid;
  place-items: center;
  width: clamp(61px, 10vw, 90px);
  height: clamp(61px, 10vw, 90px);
  margin: 11px auto 16px;
  border-radius: 23px;
  background: var(--soft);
  color: var(--blue);
}
.winner-mark { background: var(--lime); color: var(--board); }
.ready-art svg, .winner-mark svg { width: 57%; height: 57%; }
.ready-art svg path { stroke: #fff; }
.ready-info { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px 17px; margin-top: 16px; color: var(--muted); font-size: .91rem; }
.ready-info b { color: var(--ink); }
.ready-actions { display: grid; justify-items: center; gap: 7px; margin-top: 21px; }
.start-round-button { width: min(100%, 302px); min-height: 57px; font-size: 1.1rem; }
.start-round-button svg { width: 22px; height: 22px; flex: none; }
.finish-match-button { color: var(--muted); }
.countdown {
  display: grid;
  place-items: center;
  min-height: min(55vh, 405px);
  min-height: min(55dvh, 405px);
  border-radius: clamp(17px, 3vw, 28px);
  background: var(--board);
  color: var(--lime);
  font-size: clamp(5rem, 20vw, 11rem);
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}
.countdown > span { animation: countdown-step 550ms var(--ease) both; }
.play-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 9px; color: var(--muted); }
.play-meta b { color: var(--ink); overflow-wrap: anywhere; }
.timer {
  display: inline-flex;
  align-items: center;
  flex: none;
  gap: 5px;
  min-width: 117px;
  padding: 4px 9px 4px 5px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--white);
  color: var(--blue);
  font-size: 1.46rem;
  font-variant-numeric: tabular-nums;
  font-weight: 830;
  line-height: 1;
}
.timer svg { width: 32px; height: 32px; transform: rotate(-90deg); }
.timer.urgent { background: #fff0e9; border-color: #b85d4a; color: #922d21; }
.word-stage { position: relative; isolation: isolate; margin-bottom: 11px; overflow-x: clip; }
.word-stage::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 7px 8px -6px;
  border-radius: clamp(17px, 3vw, 27px);
  background: #aea2d0;
}
.word-card {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: clamp(225px, 43vh, 480px);
  min-height: clamp(225px, 43dvh, 480px);
  padding: clamp(15px, 3.4vw, 34px);
  border: 1px solid #7c6eaa;
  border-radius: clamp(17px, 3vw, 27px);
  background: var(--board);
  color: #fff;
  touch-action: pan-y;
}
.word-card header, .word-card footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 5px 12px;
  color: #e8dffb;
  font-size: clamp(.78rem, 1.3vw, .96rem);
}
.word-card footer > span:first-child { flex: 1 1 12em; }
.word-card footer { border-top: 1px solid #796c98; padding-top: 10px; }
.word-card header span, .word-card footer span { overflow-wrap: anywhere; }
.word-card h1 {
  align-self: center;
  margin: 14px auto;
  font-size: clamp(2rem, 6.4vw, 5.55rem);
  line-height: 1.02;
  color: var(--lime);
  text-align: center;
  text-wrap: balance;
  overflow-wrap: anywhere;
}
.card-symbol { width: 32px; height: 32px; }
.card-in { animation: card-arrive var(--normal) var(--ease) both; }
.card-guessed { animation: card-answer var(--card-exit) var(--ease) both; --answer-direction: 1; }
.card-skipped { animation: card-answer var(--card-exit) var(--ease) both; --answer-direction: -1; }

.play-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 13px; }
.play-actions button {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 3px 8px;
  min-height: 53px;
  min-height: clamp(52px, 7dvh, 70px);
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: 13px;
  font-size: clamp(1rem, 1.85vw, 1.36rem);
  font-weight: 800;
  line-height: 1.2;
  transition: transform var(--fast) var(--ease), background-color var(--fast);
}
.play-actions button:active:not(:disabled) { transform: translateY(2px); }
.play-actions button small { font-variant-numeric: tabular-nums; font-weight: 750; }
.play-actions .skip-action { background: var(--white); border-color: var(--field-border); color: var(--ink); }
.skip-action:hover:not(:disabled) { background: #fae5df; }
.guess-action { background: #dbee84; color: #24301a; }
.guess-action:hover:not(:disabled) { background: #d0e768; }
.play-bottom, .key-help {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 0 14px;
  margin-top: 3px;
  color: var(--muted);
  text-align: center;
  font-size: .88rem;
}
.play-bottom > span { padding-block: 5px; }
.key-help { font-size: .81rem; }
.round-result { display: grid; justify-items: center; gap: 7px; padding: 19px 10px 21px; text-align: center; }
.round-result h1 { font-size: clamp(1.92rem, 4.5vw, 3.85rem); }
.result-number { color: var(--blue); font-size: clamp(3.25rem, 10vw, 6rem); font-weight: 850; font-variant-numeric: tabular-nums; line-height: 1; }
.result-stats { display: flex; justify-content: center; flex-wrap: wrap; gap: 5px 14px; color: var(--muted); font-size: .86rem; }
.result-stats strong { color: var(--ink); }
.review-list { padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); }
.review-row { display: flex; align-items: start; justify-content: space-between; gap: 8px 15px; padding-block: 10px; border-bottom: 1px solid var(--line); }
.review-row:last-child { border: 0; }
.review-word { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.review-word > span { font-weight: 720; }
.review-row small { display: block; color: var(--muted); }
.review-row select { width: auto; max-width: 48%; flex: none; font-size: .92rem; }
.review-definition { margin-top: 4px; }
.review-definition summary { min-height: 37px; padding-block: 7px; color: var(--blue); cursor: pointer; font-size: .85rem; }
.review-definition p { padding: 9px; border-radius: 8px; background: var(--soft); font-size: .89rem; }
.review-actions, .final-buttons { display: flex; justify-content: center; flex-wrap: wrap; gap: 9px; margin: 15px 0 0; }
.final-scores { display: grid; gap: 6px; max-width: 530px; margin: 16px auto 0; }
.final-score { display: flex; justify-content: space-between; gap: 8px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 10px; text-align: left; overflow-wrap: anywhere; }
.final-score.leader { border-color: #8e9e39; background: #eef4c6; }
body[data-view=game] .footer { display: none; }

dialog {
  width: min(650px, calc(100% - 22px));
  max-height: min(88vh, 840px);
  max-height: min(88dvh, 840px);
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid #beb2d0;
  border-radius: var(--radius);
  background: var(--white);
  color: var(--ink);
  box-shadow: 0 20px 70px #1b153c42;
}
dialog::backdrop { background: #211939b8; }
dialog[open] { animation: dialog-arrive var(--normal) var(--ease) both; }
body:has(dialog[open]) { overflow: hidden; }
.dialog-header {
  position: sticky;
  z-index: 2;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 15px;
  border-bottom: 1px solid var(--line);
  background: var(--white);
}
.dialog-header h2 { font-size: clamp(1.35rem, 3.5vw, 2rem); }
.dialog-close { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 10px; background: var(--soft); color: var(--blue); font-size: 1.6rem; }
.dialog-content { padding: 15px clamp(13px, 3vw, 26px) 24px; }
.dialog-content > p { margin-bottom: 12px; color: var(--muted); }
.dialog-content h3 { margin: 20px 0 9px; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
.rules-list { margin: 0; padding-left: 26px; }
.rules-list li { margin-bottom: 10px; padding-left: 3px; }
.rules-list li::marker { color: var(--blue); font-weight: 800; }
.rules-list b, .rules-example small { display: block; }
.rules-example { padding: 11px 13px; border-radius: 10px; background: var(--soft); }
.rules-example small { color: var(--muted); }
.source-list, .definition-list { display: grid; gap: 7px; }
.source-item { padding: 8px; border-bottom: 1px solid var(--line); font-size: .87rem; }
.source-item h3 { margin: 0 0 7px; }
.source-item strong { display: block; overflow-wrap: anywhere; }
.source-item a, .definition-sources a { display: block; width: fit-content; padding: 8px 0; }
.definition-item { border: 1px solid var(--line); border-radius: 10px; }
.definition-item summary {
  min-height: 44px;
  padding: 11px 12px;
  border-radius: 9px;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.definition-item summary:focus-visible { outline-offset: -3px; }
.definition-item[open] summary { background: var(--soft); color: var(--blue); border-radius: 9px 9px 0 0; }
.definition-item .difficulty-badge { margin-left: 7px; }
.definition-body { padding: 10px 12px; overflow-wrap: anywhere; }
.definition-body a { display: inline-flex; align-items: center; min-height: 38px; font-size: .86rem; }
.definition-sources a { display: flex; min-height: 38px; }
.dictionary-controls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; margin-bottom: 10px; }
.dictionary-controls > input { grid-column: 1 / -1; }
.dictionary-controls select { font-size: .9rem; }
.dictionary-count { margin-bottom: 7px; color: var(--muted); font-size: .88rem; }
.dictionary-entry { margin-bottom: 9px; }
.dictionary-entry > small { display: block; margin-bottom: 3px; color: var(--muted); }
.practice-card { padding: clamp(13px, 3vw, 23px); border: 1px solid #c8bed9; border-radius: 15px; background: var(--soft); }
.practice-card h3 { margin: 9px 0 5px; font-size: clamp(1.55rem, 5vw, 2.35rem); overflow-wrap: anywhere; }
.practice-progress { color: var(--muted); font-size: .87rem; }
.practice-answer { padding: 12px; margin-top: 12px; border-radius: 10px; background: var(--white); }

.toast {
  position: fixed;
  z-index: 30;
  bottom: max(17px, env(safe-area-inset-bottom, 0px));
  left: 50%;
  width: max-content;
  max-width: calc(100vw - 28px);
  padding: 11px 15px;
  transform: translate(-50%, 8px);
  opacity: 0;
  pointer-events: none;
  border-radius: 10px;
  background: var(--board);
  color: #fff;
  text-align: center;
  transition: transform var(--fast) var(--ease), opacity var(--fast);
}
.toast.visible { transform: translate(-50%, 0); opacity: 1; }
#confetti { position: fixed; z-index: 31; inset: 0; pointer-events: none; overflow: hidden; }
.confetti-piece {
  position: absolute;
  top: -12px;
  width: 8px;
  height: 13px;
  border-radius: 2px;
  animation: confetti-drop 2.1s cubic-bezier(.37, .2, .55, .9) both;
}
.hidden { display: none !important; }

@keyframes hero-art-in {
  from { opacity: .55; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes card-arrive {
  from { opacity: .65; transform: translateY(7px) scale(.993); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes card-answer {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: .35; transform: translateX(calc(var(--answer-direction) * 13px)); }
}
@keyframes dialog-arrive {
  from { opacity: .65; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes countdown-step {
  from { opacity: .45; transform: scale(.93); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes confetti-drop {
  0% { opacity: 0; transform: translate(0, 0); }
  12%, 64% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--drift, 20px), 100vh) rotate(120deg); }
}

@media (max-width: 1100px) {
  .category-filter { margin-left: 0; }
  .subject-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 880px) {
  .hero { min-height: 350px; }
  .hero-art { min-height: 269px; }
  .art-label.one { left: -3%; }
  .art-label.two { right: -4%; }
  .subject-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .topic-layout { grid-template-columns: minmax(0, 1fr) minmax(295px, 320px); }
}
@media (min-width: 721px) {
  .setup-panel { position: sticky; top: 84px; max-height: calc(100vh - 97px); overflow: auto; }
}
@media (max-width: 720px) {
  .topic-layout { grid-template-columns: 1fr; }
  .setup-panel { margin-top: 4px; }
  .mobile-setup-link { display: flex; align-items: center; flex-wrap: wrap; gap: 5px 9px; margin-block: 7px 10px; }
  .team-inputs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  html { scroll-padding-top: 71px; }
  .header-inner { justify-content: space-between; gap: 7px; min-height: 60px; }
  .brand { font-size: 1.45rem; }
  .brand > svg { width: 32px; height: 32px; margin-right: 0; }
  nav { gap: 4px; }
  nav .nav-play, .circle-help { display: none; }
  nav button { padding-inline: 5px; font-size: .83rem; }
  .hero { grid-template-columns: 1fr; gap: 6px; margin-top: 13px; padding: 20px 17px 12px; }
  .hero h1 { margin-bottom: 12px; }
  .hero-actions { margin-top: 15px; }
  .hero-art { min-height: 210px; margin: 0 5px; }
  .art-card { width: clamp(127px, 30vw, 168px); border-radius: 13px; }
  .art-label.one { top: 7%; left: 0; }
  .art-label.two { bottom: 4%; right: 0; }
  .art-blob { width: min(71%, 240px); }
  .art-spark { font-size: 1.58rem; right: 8%; top: 2%; }
  .art-dot { bottom: 7%; }
  .section-head { align-items: start; flex-direction: column; }
  .section-head .search-wrap { width: 100%; }
  .filters, .grade-chips { gap: 4px; }
  .filters-label { width: 100%; }
  .chip, .category-filter button { padding-inline: 7px; }
  .subject-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .subject-card { min-height: 134px; }
  .subject-card h3 { margin-top: 10px; font-size: 1.02rem; }
  .subject-symbol { width: 40px; height: 40px; border-radius: 10px; }
  .subject-symbol svg { width: 25px; height: 25px; }
  .subject-meta { align-items: end; font-size: .72rem; }
  .subject-arrow { width: 18px; height: 18px; font-size: .76rem; }
  .topic-heading { align-items: start; }
  .topic-heading h1 { font-size: clamp(1.74rem, 7vw, 2.36rem); }
  .topic-heading p { font-size: .91rem; }
  .section-count { font-size: .73rem; }
  .topic-row label, .section-title label { gap: 7px; }
  .topic-row label small { font-size: .78rem; }
  .topic-row, .section-title { padding-inline: 8px; }
  .game-top { font-size: .8rem; }
  .score-pill { min-width: 0; }
  .word-card { min-height: clamp(204px, 36vh, 330px); min-height: clamp(204px, 36dvh, 330px); }
  .key-help { display: none; }
  .review-row select { padding-inline: 5px; }
  .source-item { font-size: .81rem; }
  .dictionary-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #dictionary-subject { grid-column: 1 / -1; }
}
@media (max-width: 374px) {
  :root { --gutter: 12px; }
  .brand { font-size: 1.32rem; }
  .brand > svg { width: 27px; height: 27px; }
  nav button { padding-inline: 3px; font-size: .78rem; }
  .hero h1 { font-size: clamp(1.91rem, 10.8vw, 2.48rem); }
  .hero-label { font-size: .76rem; }
  .hero-art { margin-inline: 0; }
  .art-label { font-size: .69rem; }
  .subject-card { padding: 12px 9px; }
  .subject-meta { font-size: .72rem; }

}
@media (pointer: coarse) {
  .key-help { display: none; }
}
@media (orientation: landscape) and (max-height: 590px) {
  body[data-view=game]:has(.game-shell:is([data-phase=playing], [data-phase=paused], [data-phase=countdown])) .header { display: none; }
  .game-shell { padding-top: 0; }
  .game-top, .scoreboard { margin-bottom: 3px; }
  .score-pill { min-height: 36px; padding-block: 2px; }
  .timer svg { width: 28px; height: 28px; }
  .word-card { min-height: clamp(122px, 37dvh, 210px); padding-block: 9px; }
  .word-card h1 { font-size: clamp(1.8rem, 9dvh, 3rem); }
  .word-card footer { padding-top: 4px; }
  .word-stage { margin-bottom: 7px; }
  .play-actions { margin-top: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .confetti-piece { display: none; }
}

