:root {
  color-scheme: dark;
  font-family: "Inter", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  --night: #090f25;
  --ink: #111e41;
  --cream: #f8efd9;
  --blue-white: #d1dbf2;
  --gold: #f6d681;
  --line: rgb(207 222 255 / .21);
  --glass: rgb(8 16 37 / .88);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; }
body { color: var(--cream); background: var(--night); }
button, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
a { color: inherit; }
button:focus-visible, a:focus-visible { outline: 2px solid #a9efff; outline-offset: 5px; }
kbd { font: 500 .85em/1.25 ui-monospace, "Cascadia Mono", Consolas, monospace; }

.exhibit { position: relative; width: 100%; height: 100%; isolation: isolate; overflow: hidden; }
#scene {
  position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: none;
  background: radial-gradient(ellipse at 75% 30%, #233f69, #101d41 46%, #080f27 82%);
  outline: none;
}
[data-mode="paint"] #scene { cursor: crosshair; }
[data-mode="roam"] #scene { cursor: grab; }
[data-mode="roam"] #scene:active { cursor: grabbing; }
.shade {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgb(5 10 25 / .76), transparent 19%, transparent 80%, rgb(5 9 24 / .86)),
    linear-gradient(92deg, rgb(6 10 26 / .84) 0%, rgb(7 13 31 / .66) 24%, rgb(8 13 32 / .14) 54%, transparent 77%);
}
[data-mode]:not([data-mode="home"]) .shade {
  background: linear-gradient(180deg, rgb(5 10 25 / .69), transparent 18%, transparent 80%, rgb(5 10 25 / .72));
}

.header {
  position: absolute; z-index: 2; top: 0; left: 0; right: 0; min-height: 74px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  margin: 0 clamp(20px, 4.75vw, 80px); border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex; align-items: center; gap: 13px; white-space: nowrap;
  text-decoration: none; font-size: 14px; font-weight: 600; letter-spacing: .14em;
}
.brand-star { color: var(--gold); font-size: 24px; line-height: 1; text-shadow: 0 0 18px rgb(250 208 103 / .32); }
.nav { display: flex; align-items: center; gap: clamp(10px, 2.3vw, 35px); }
.text-button { background: transparent; border: 0; min-height: 42px; padding: 0 4px; color: var(--blue-white); font-size: 13px; white-space: nowrap; }
.text-button:hover, .text-button:focus-visible { color: var(--cream); }
.question {
  display: inline-grid; place-items: center; width: 15px; height: 15px; margin-left: 4px;
  border: 1px solid rgb(210 228 255 / .48); border-radius: 50%; font: 10px/1 sans-serif;
}

.hero { position: absolute; z-index: 1; left: clamp(24px, 7vw, 118px); top: 50%; transform: translateY(-42%); width: min(88vw, 485px); }
.genre { color: var(--gold); margin: 0 0 14px; font-size: 12px; line-height: 1.7; letter-spacing: .18em; }
h1, h2, .hero-line { font-family: "Noto Serif CJK SC", "Songti SC", SimSun, serif; }
h1 { font-size: clamp(76px, 9.1vw, 148px); font-weight: 700; line-height: .97; letter-spacing: -.015em; margin: 0; }
.hero-line { font-size: clamp(20px, 2.1vw, 31px); line-height: 1.45; margin: 21px 0 7px; color: var(--cream); }
.intro { max-width: 330px; color: var(--blue-white); margin: 0 0 26px; font-size: 14px; line-height: 1.9; }
.enter {
  display: inline-flex; align-items: center; gap: 32px; justify-content: space-between;
  min-height: 52px; padding: 0 19px; border-radius: 4px; border: 1px solid #ffe8a7;
  background: #f4da94; color: #1b2034; font-weight: 700; font-size: 14px;
  box-shadow: 0 7px 26px rgb(0 0 0 / .2); transition: background-color 160ms ease;
}
.enter span { font-size: 20px; line-height: 1; }
.enter:enabled:hover { background: #fce7ac; }
#load-error { color: #ffdad4; margin-top: 14px; font-size: 13px; line-height: 1.65; }

.home-footer {
  position: absolute; inset: auto clamp(20px, 4.75vw, 80px) 0; min-height: 67px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line);
  color: var(--blue-white); font-size: 12px;
}
.home-footer p { margin: 0; }
.home-footer p > span { white-space: nowrap; }
.key-preview { display: flex; gap: 16px; }
.key-preview kbd { display: inline-block; min-width: 18px; margin-right: 2px; padding: 2px 3px; text-align: center; border: 1px solid var(--line); border-radius: 3px; }
[data-mode]:not([data-mode="home"]) .hero, [data-mode]:not([data-mode="home"]) .home-footer { display: none; }

.play-ui { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.play-ui button, .play-ui select { pointer-events: auto; }
.view-actions { position: absolute; top: 90px; right: clamp(20px, 4.75vw, 80px); }
.glass-button {
  border: 1px solid var(--line); background: var(--glass); border-radius: 5px;
  min-height: 39px; padding: 0 12px; color: var(--blue-white); font-size: 12px;
}
.glass-button:hover { color: var(--cream); border-color: rgb(207 222 255 / .52); }
.glass-button kbd { margin-left: 7px; opacity: .76; }
.reticle {
  display: none; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 8px; height: 8px; border: 1px solid rgb(249 237 203 / .82); border-radius: 50%;
  box-shadow: 0 0 7px #04091a;
}
[data-locked="true"][data-mode="roam"] .reticle { display: block; }
.placement-ghost { position: absolute; z-index: -1; transform: translate(-50%, -50%); opacity: .66; pointer-events: none; }
[data-mode="paint"][data-tool="place"] #scene:focus-visible ~ .play-ui .reticle { display: block; }
.controls { position: absolute; bottom: max(25px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); text-align: center; width: max-content; max-width: calc(100% - 28px); }
.mode-hint {
  display: inline-block; margin: 0 0 9px; padding: 6px 11px; border-radius: 5px;
  background: rgb(9 15 36 / .80); color: var(--blue-white); font-size: 12px; line-height: 1.5; white-space: nowrap;
}
.dock { display: flex; flex-wrap: wrap; gap: 9px; justify-content: center; }
.mode-switch, .paint-tools { display: flex; align-items: center; background: var(--glass); padding: 4px; border: 1px solid var(--line); border-radius: 7px; box-shadow: 0 7px 28px rgb(0 0 0 / .3); }
.mode-switch button { min-height: 37px; min-width: 67px; padding: 0 10px; white-space: nowrap; border: 0; border-radius: 3px; color: var(--blue-white); background: transparent; font-size: 13px; }
.mode-switch button[aria-pressed="true"] { background: #edcf83; color: #171e34; font-weight: 700; }
.mode-switch button:not([aria-pressed="true"]):hover { background: #233355; }
.mode-switch kbd { opacity: .66; margin-left: 3px; }
.paint-tools { flex-wrap: wrap; justify-content: center; padding-inline: 7px; gap: 7px; }
.painting-switch, .paint-actions { display: flex; align-items: center; gap: 4px; }
.painting-switch { padding-right: 7px; border-right: 1px solid var(--line); }
.painting-switch button, .template-picker {
  min-height: 34px; padding: 0 8px; border: 1px solid #384967; border-radius: 4px;
  background: #13213d; color: var(--blue-white); font: inherit; font-size: 12px; white-space: nowrap;
}
.painting-switch button[aria-pressed="true"] { color: var(--cream); background: #253654; border-color: #ac935d; }
.painting-switch button:hover { background: #293c5f; }
.template-picker { cursor: pointer; padding-right: 4px; }
.template-picker:focus-visible { outline: 2px solid #a9efff; outline-offset: 3px; }
.palette { display: flex; gap: 4px; }
.swatch {
  width: 27px; height: 32px; padding: 0; display: grid; place-items: center;
  background: transparent; border: 1px solid transparent; border-radius: 4px;
}
.swatch::before { content: ""; width: 14px; height: 14px; border-radius: 50%; background: var(--swatch); }
.swatch[aria-pressed="true"] { border-color: rgb(208 225 250 / .67); background: #22304b; }
.undo { font-size: 12px; white-space: nowrap; color: var(--blue-white); padding: 0 4px; min-height: 35px; background: transparent; border: 0; }
.undo:enabled:hover { color: var(--gold); }
.tool-button { padding: 0 8px; min-height: 34px; background: transparent; border: 1px solid transparent; border-radius: 4px; white-space: nowrap; color: var(--blue-white); font-size: 12px; }
.tool-button:enabled:hover { color: var(--cream); background: #233355; }
.design-button { color: var(--gold); border-color: rgb(246 214 129 / .36); }
.design-button > [aria-hidden] { font-size: 16px; line-height: 1; vertical-align: -.02em; }
.touch-pad { position: absolute; bottom: 111px; left: 15px; display: grid; grid-template-columns: repeat(3, 37px); gap: 4px; }
.touch-pad button { width: 37px; height: 37px; background: var(--glass); border: 1px solid var(--line); border-radius: 4px; font-size: 18px; touch-action: none; }
.touch-pad button:first-child { grid-column: 2; }
.touch-pad button:nth-child(2) { grid-column: 1; }

dialog {
  width: min(92vw, 510px); max-height: 84vh; color: var(--cream); background: #121d38;
  border: 1px solid #52617b; border-radius: 8px; padding: clamp(18px, 5vw, 34px);
  box-shadow: 0 18px 90px rgb(4 7 23 / .8);
}
dialog::backdrop { background: rgb(5 9 23 / .72); }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-bottom: 13px; border-bottom: 1px solid var(--line); }
.dialog-heading h2 { margin: 0; font-size: 27px; line-height: 1.2; }
.close { width: 36px; height: 36px; border: 0; background: transparent; font-size: 26px; line-height: 1; }
dialog p, dialog dd { color: var(--blue-white); font-size: 14px; line-height: 1.9; }
.instructions { margin-bottom: 0; }
.instructions > div + div { margin-top: 14px; }
.instructions dt { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.instructions dd { margin: 0; }
.source-link { display: inline-block; margin-top: 6px; color: var(--gold); font-size: 13px; text-underline-offset: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

.star-editor { width: min(94vw, 795px); max-height: min(90dvh, 700px); background: #111d38; }
.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.04fr); gap: clamp(22px, 3vw, 39px); margin-top: 20px; align-items: start; }
.editor-figure { margin: 0; }
.editor-stage {
  display: grid; place-items: center; aspect-ratio: 1; position: relative; isolation: isolate;
  overflow: hidden; border: 1px solid #354765; border-radius: 5px;
  background: radial-gradient(circle, #18315a, #0a132b 78%);
}
.editor-stage::before, .editor-stage::after {
  content: ""; position: absolute; z-index: -1; pointer-events: none; inset: 14%;
  border: 1px solid rgb(154 195 246 / .12); border-radius: 50%;
}
.editor-stage::after { inset: 28%; }
#design-preview { display: block; width: 100%; height: auto; touch-action: none; }
#design-preview:focus-visible { outline: 2px solid #a1d7ec; outline-offset: -4px; }
[data-color-mode="free"] #design-preview { cursor: crosshair; }
.editor-figure figcaption { margin-top: 10px; color: var(--blue-white); min-height: 32px; font-size: 12px; line-height: 1.6; }
.editor-fieldset { min-width: 0; padding: 0; margin: 0 0 14px; border: 0; }
.editor-fieldset legend, .editor-range > span { margin-bottom: 7px; padding: 0; font-size: 13px; color: var(--cream); font-weight: 600; }
.template-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.template-choice {
  display: flex; justify-content: flex-start; align-items: center; gap: 5px;
  padding: 2px 6px 2px 2px; min-height: 44px; min-width: 0;
  border: 1px solid #344564; border-radius: 4px; color: var(--blue-white); background: #0d1830;
  text-align: left; white-space: nowrap; font-size: 12px;
}
.template-choice canvas { display: block; width: clamp(33px, 6vw, 43px); height: auto; }
.template-choice[aria-pressed="true"], .template-choice:hover { border-color: #ac935d; color: var(--cream); background: #202c47; }
.editor-range { display: block; margin-bottom: 13px; }
.editor-range > span { display: flex; justify-content: space-between; align-items: baseline; }
.editor-range output { color: var(--gold); font-size: 12px; font-variant-numeric: tabular-nums; }
.editor-range input[type="range"] { display: block; width: 100%; margin: 0; accent-color: var(--gold); cursor: pointer; }
.editor-color { margin-bottom: 0; }
.editor-tabs { display: flex; gap: 5px; margin-bottom: 9px; }
.editor-tabs button, .part-button {
  background: #0d1830; border: 1px solid #344564; border-radius: 4px;
  min-height: 32px; padding: 4px 8px; font-size: 12px; color: var(--blue-white); white-space: nowrap;
}
.editor-tabs button[aria-pressed="true"] { background: #f1d691; border-color: #f1d691; color: #151d31; font-weight: 700; }
.part-button[aria-pressed="true"] { background: #263454; border-color: #ad965f; color: var(--cream); }
.color-tools, .part-controls, .free-controls { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-height: 39px; }
.reset-template:enabled { color: var(--gold); border-color: rgb(246 214 129 / .43); }
.reset-template:enabled:hover { background: #253654; }
.part-list { display: flex; flex-wrap: wrap; gap: 4px; }
.part-controls input[type="color"], .free-controls input[type="color"] { width: 31px; height: 31px; padding: 3px; cursor: pointer; background: #14233f; border: 1px solid #647494; border-radius: 4px; }
.free-controls { gap: 6px 8px; color: var(--blue-white); font-size: 12px; }
.brush-range { display: flex; align-items: center; gap: 5px; margin: 0; }
.brush-range > span { margin: 0; font: inherit; }
.brush-range input[type="range"] { width: 53px; }
.editor-footer { display: flex; justify-content: flex-end; border-top: 1px solid var(--line); padding-top: 13px; margin-top: 12px; }
.editor-footer .enter { min-height: 43px; gap: 20px; }

@media (max-width: 760px) {
  .header { min-height: 60px; }
  .view-actions { top: 74px; }
  .hero { top: auto; bottom: max(99px, 12vh); transform: none; }
  .shade { background: linear-gradient(180deg, rgb(5 10 25 / .74), transparent 23%, rgb(7 11 28 / .22) 40%, rgb(5 9 24 / .88) 83%); }
  .key-preview { display: none; }
  .home-footer { min-height: 57px; }
}
@media (max-width: 420px) {
  .header { margin-inline: 15px; }
  .brand { gap: 8px; letter-spacing: .05em; font-size: 12px; }
  .brand-star { font-size: 20px; }
  .nav { gap: 5px; }
  .text-button { font-size: 11px; min-height: 40px; }
  .question { display: none; }
  h1 { font-size: clamp(65px, 18vw, 84px); }
  .intro { margin-bottom: 18px; font-size: 13px; }
  .mode-hint { font-size: 10px; }
  .dock { gap: 5px; }
  .paint-tools { padding-inline: 5px; gap: 4px; }
  .painting-switch { padding-right: 4px; }
}
@media (max-width: 355px) {
  .painting-switch { border-right: 0; padding-right: 0; }
}
@media (max-width: 620px) {
  .star-editor { padding: 14px; }
  .star-editor .dialog-heading { padding-bottom: 5px; }
  .star-editor .dialog-heading h2 { font-size: 22px; }
  .editor-layout { grid-template-columns: minmax(0, 1fr); gap: 9px; margin-top: 10px; }
  .editor-stage { max-width: min(224px, 29dvh); margin-inline: auto; }
  .editor-figure figcaption { min-height: 0; margin-top: 4px; text-align: center; }
}
@media (max-height: 540px) and (min-width: 500px) {
  .hero { top: 50%; bottom: auto; transform: translateY(-39%); }
  .header { min-height: 46px; }
  .view-actions { top: 57px; }
  .genre { margin-bottom: 5px; }
  h1 { font-size: clamp(56px, 15vh, 82px); }
  .hero-line { margin: 7px 0 4px; }
  .intro { margin-bottom: 12px; }
  .enter { min-height: 42px; }
  .home-footer { min-height: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
