:root {
  color-scheme: dark;
  font-family: ui-rounded, "Trebuchet MS", system-ui, sans-serif;
  color: #f6eedc;
  background: #111c2b;
  --line: #b6a98657;
  --ink: #202e41;
  --gold: #f7cd84;
}
* { box-sizing: border-box; }
body { margin: 0; background: radial-gradient(ellipse at 22% 6%, #293e52 0%, #1a2939 60%, #131e2c 100%); min-height: 100vh; }
[hidden] { display: none !important; }
button, select, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, select:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid #87cbe7; outline-offset: 3px; }
.shell { max-width: 1540px; margin: auto; padding: clamp(16px, 3.2vw, 48px); }
.header, .tower-toolbar, .floor-top, .materials, .round-bar, .dialog-buttons { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.header { margin-bottom: clamp(12px, 2.8vh, 28px); }
.header h1 { margin: 0; font-family: Georgia, 'Times New Roman', serif; letter-spacing: -.035em; font-size: clamp(30px, 4vw, 52px); line-height: 1.05; }
.eyebrow { margin: 0 0 5px; color: var(--gold); text-transform: uppercase; letter-spacing: .15em; font-size: .76rem; font-weight: 900; }
.class-tools, #chapters, .floor-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.class-tools label { font-size: .9rem; }
select, .quiet, #chapters button {
  padding: .62rem .8rem; border: 1px solid var(--line); border-radius: .62rem;
  color: #f8ecd4; background: #22344a; font-weight: 750; text-align: center;
}
.quiet:hover, #chapters button:hover { background: #344e6a; }
#chapters button {
  position: relative;
  padding-left: 16px;
  border-inline-start: 3px solid var(--chapter);
  text-align: left;
  background: var(--chapter-wash);
}
#chapters button span, #chapters button small { display: block; }
#chapters button small { color: var(--chapter); font-size: .7rem; margin-top: 3px; font-weight: 650; }
#chapters button[aria-pressed="true"] { background: var(--chapter-paper); color: #233146; border-color: var(--chapter); }
#chapters button[aria-pressed="true"] small { color: var(--chapter-deep); }
.tower-toolbar { margin-bottom: 12px; flex-wrap: wrap; }
.stage { display: grid; grid-template-columns: minmax(0, 1.67fr) minmax(345px, 1fr); gap: clamp(12px, 1.7vw, 26px); }
.stage > * { min-height: clamp(420px, 68vh, 710px); }
#towerViewport { border: 1px solid #7289a099; box-shadow: 0 22px 42px #0a132466; }
.floor-card {
  display: flex; flex-direction: column; padding: clamp(20px, 2.75vw, 42px);
  color: var(--ink); border: 1px solid var(--chapter); border-top: 5px solid var(--chapter); border-radius: 15px;
  background: linear-gradient(150deg, #fffbef 0%, var(--chapter-paper) 76%);
  box-shadow: 0 22px 42px #0a132466;
}
.floor-top .eyebrow { color: var(--chapter-deep); letter-spacing: .115em; }
#floorNumber { margin: 4px 0 0; color: #526175; font-size: .84rem; font-weight: 720; }
.floor-card h2 { font-family: Georgia, 'Times New Roman', serif; margin: clamp(18px, 3.7vh, 38px) 0 12px; font-size: clamp(26px, 2.7vw, 41px); line-height: 1.02; letter-spacing: -.037em; text-wrap: balance; }
.focus { margin: 0; white-space: pre-line; color: #425168; font-size: clamp(.95rem, 1.32vw, 1.14rem); line-height: 1.48; }
.step {
  display: grid; place-items: center; width: 36px; height: 36px;
  border: 1px solid var(--chapter); border-radius: 8px; background: #fffcf3; color: var(--ink); font-size: 1.1rem;
}
.step:disabled { opacity: .4; }
.floor-actions { margin-top: auto; padding-top: 24px; }
.variants { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; padding: 4px; border-radius: 12px; background: #62667418; }
.variants button { min-height: 46px; border: 1px solid transparent; border-radius: 9px; background: transparent; color: #314158; font-weight: 850; }
.variants button[aria-pressed="true"] { background: #fffdf5; border-color: var(--chapter); box-shadow: 0 2px 4px #4d3f2822; }
.variants span { color: #346740; font-weight: 900; }
[data-play], .primary {
  border: 1px solid #b8862b; border-radius: 10px; background: linear-gradient(#ffdc92, #f0b23c);
  color: #241a0b; font-weight: 900; padding: .82rem 1rem;
}
[data-play] { width: 100%; margin: 12px 0; font-size: 1.15rem; }
[data-play] span { margin-left: 7px; font-size: .85em; }
[data-play] { background: var(--chapter-deep); border-color: var(--chapter-deep); color: #fff9ed; }
[data-play]:hover { filter: brightness(1.18); }
.primary:hover { background: #ffdb8d; }
.materials a { color: #254f73; text-underline-offset: .18em; font-size: .9rem; font-weight: 800; padding: .2rem 0; }
.notice { margin: .55rem 0; color: #f8d492; }
.round-screen { display: grid; grid-template-rows: auto minmax(0, 1fr); width: 100%; height: 100vh; background: #101926; }
.round-bar { padding: 6px clamp(10px, 2vw, 26px); border-bottom: 1px solid var(--line); }
.round-bar .quiet { white-space: nowrap; padding: .4rem .65rem; }
.round-bar strong { text-align: center; }
.round-bar span { font-size: .85rem; color: #f3cf8e; }
iframe { width: 100%; height: 100%; border: 0; }
dialog { max-width: min(520px, calc(100vw - 28px)); min-width: min(370px, calc(100vw - 28px)); padding: 24px; background: #1f3146; border: 1px solid #ad9866; border-radius: 15px; color: #fff1d6; }
dialog::backdrop { background: #0b1421b8; }
dialog h2 { margin-top: 0; }
dialog label, dialog input { display: block; width: 100%; margin-bottom: 8px; }
dialog input { padding: .6rem; border: 1px solid #b3a385; border-radius: 6px; }
.form-error { color: #ffbfac; }
.form-error:empty { display: none; }
.dialog-buttons { justify-content: flex-end; margin-top: 16px; }
.summary-teams { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.summary-teams p { margin: 0; padding: 13px; background: #314864; border-radius: 8px; }
.summary-teams strong { display: block; margin-bottom: .3rem; }
@media (max-width: 850px) {
  .stage { grid-template-columns: minmax(0, 1fr); }
  .stage > #towerViewport { min-height: 450px; }
  .stage > .floor-card { min-height: 330px; }
}
@media (max-width: 480px) {
  .header { align-items: flex-start; flex-direction: column; }
  .stage > #towerViewport { min-height: 400px; }
  .class-tools label { display: none; }
  .summary-open { flex-basis: 100%; }
}

@media (min-width: 851px) and (max-height: 740px) {
  .shell { padding-block: 20px; }
  .header { margin-bottom: 13px; }
  .header h1 { font-size: 40px; }
  .stage > * { min-height: max(390px, calc(100vh - 180px)); }
  .floor-card { padding: 22px; }
  .floor-card h2 { margin-top: 18px; font-size: clamp(27px, 2.6vw, 38px); }
  .floor-actions { padding-top: 16px; }
}

.powers-guide header { display:flex; align-items:center; justify-content:space-between; gap:16px; }
.powers-guide h2,.powers-guide h3 { color:#f1d29a; }
.powers-guide header h2 { margin:0; }
.powers-guide p { line-height:1.35; margin:9px 0 0; }
.frost-guide { border-top:1px solid #ffffff30; padding-top:13px; }
.frost-guide [role="group"] { display:flex; flex-wrap:wrap; gap:7px; margin-top:8px; }
.frost-guide button { border:1px solid #ffffff38; background:#152640; color:#f2f5ff; border-radius:6px; padding:7px 10px; }
.frost-guide button[aria-pressed="true"] { background:#efcf99; color:#1c2332; }
