:root {
  color-scheme: dark;
  --ink: #06142b;
  --navy: #0a2144;
  --blue: #183b78;
  --cyan: #65e5f3;
  --mint: #7af0c3;
  --violet: #aa79ff;
  --coral: #ff6f91;
  --gold: #f8d879;
  --cream: #fff7dc;
  --line: rgba(248, 216, 121, 0.4);
  --panel: rgba(6, 20, 43, 0.86);
}

* { box-sizing: border-box; }
html { min-height: 100%; overflow-x: hidden; background: var(--ink); }
body {
  min-height: 100%; margin: 0; color: var(--cream);
  font-family: Inter, "Hiragino Sans", "Yu Gothic", sans-serif;
  background:
    radial-gradient(circle at 20% 5%, rgba(101, 229, 243, 0.12), transparent 27rem),
    radial-gradient(circle at 82% 15%, rgba(170, 121, 255, 0.15), transparent 30rem),
    linear-gradient(155deg, #07162f, #030b1a 68%);
}
button, a { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, canvas:focus-visible { outline: 3px solid var(--gold); outline-offset: 4px; }

.masthead {
  width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 20px 0 12px;
  display: flex; align-items: center; justify-content: space-between;
}
.masthead a { color: #b9ccec; text-decoration: none; font-weight: 800; letter-spacing: .04em; }
.masthead button, .reset {
  border: 1px solid rgba(255,255,255,.2); border-radius: 999px; color: var(--cream);
  background: rgba(255,255,255,.06); padding: 9px 15px; cursor: pointer;
}

main { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding-bottom: 56px; }
.intro { margin: 22px 0 24px; text-align: center; }
.eyebrow { margin: 0 0 8px; color: var(--cyan); font: 800 12px/1.2 ui-monospace, monospace; letter-spacing: .28em; }
.intro h1 {
  margin: 0; font-family: "Hiragino Mincho ProN", "Yu Mincho", serif; font-size: clamp(38px, 6vw, 76px);
  line-height: .95; letter-spacing: -.04em; text-shadow: 0 0 30px rgba(101,229,243,.16);
}
.intro h1 span { color: var(--gold); }
.intro > p:last-child { margin: 14px 0 0; color: #adbedc; font-weight: 700; }

.game-layout { display: grid; grid-template-columns: minmax(0, 720px) 1fr; gap: 26px; align-items: start; }
.game-column { min-width: 0; }
.hud {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; overflow: hidden;
  border: 1px solid var(--line); border-bottom: 0; border-radius: 24px 24px 0 0;
  background: rgba(248,216,121,.15);
}
.hud div { padding: 10px 14px; background: rgba(6,20,43,.96); min-width: 0; }
.hud span { display: block; color: #849bc1; font: 700 10px/1.2 ui-monospace, monospace; letter-spacing: .16em; }
.hud strong { display: block; margin-top: 4px; font: 900 clamp(14px,2vw,20px)/1 ui-monospace, monospace; white-space: nowrap; }
#combo { color: var(--cyan); }
#shield { color: var(--coral); letter-spacing: .1em; }

.game-shell {
  position: relative; isolation: isolate; overflow: hidden; border: 1px solid var(--line);
  border-radius: 0 0 24px 24px; background: #07152e; box-shadow: 0 28px 80px rgba(0,0,0,.4);
}
canvas { display: block; width: 100%; height: auto; aspect-ratio: 540 / 760; touch-action: none; cursor: crosshair; }
.start-panel {
  position: absolute; z-index: 4; inset: 0; display: grid; align-content: center; justify-items: center;
  padding: 40px; text-align: center; background: linear-gradient(rgba(3,11,26,.25), rgba(3,11,26,.88));
  backdrop-filter: blur(2px);
}
.start-panel[hidden] { display: none; }
.start-kicker { margin: 0 0 12px; color: var(--cyan); font: 800 11px/1.2 ui-monospace, monospace; letter-spacing: .25em; }
.start-panel h2 { max-width: 500px; margin: 0; font-family: "Hiragino Mincho ProN", serif; font-size: clamp(28px, 5vw, 48px); line-height: 1.2; }
.start-panel > p:not(.start-kicker) { max-width: 460px; color: #c8d5ec; line-height: 1.8; }
.start-panel button {
  width: min(360px, 90%); min-height: 58px; border: 1px solid rgba(255,255,255,.7); border-radius: 999px;
  background: linear-gradient(110deg, var(--cyan), var(--mint), var(--gold)); color: #07152e;
  font-weight: 1000; cursor: pointer; box-shadow: 0 12px 35px rgba(101,229,243,.24);
}
.start-panel .share { margin-top: 10px; background: #05070e; color: white; }
.flash { position: absolute; z-index: 3; inset: 0; pointer-events: none; opacity: 0; background: white; mix-blend-mode: screen; }
.flash.is-on { animation: flash .24s ease-out; }
@keyframes flash { 0% { opacity: .68; } 100% { opacity: 0; } }
.live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.prism-console {
  margin-top: 12px; display: grid; grid-template-columns: 130px minmax(0,1fr) auto; gap: 12px; align-items: center;
  padding: 14px 16px; border: 1px solid rgba(101,229,243,.3); border-radius: 18px;
  background: linear-gradient(105deg, rgba(18,53,101,.8), rgba(8,24,52,.94));
}
.prism-copy span { display: block; color: #8ba7cf; font: 700 9px/1.2 ui-monospace, monospace; letter-spacing: .13em; }
.prism-copy strong { display: block; margin-top: 3px; color: var(--cyan); font: 900 18px/1 ui-monospace, monospace; }
progress { width: 100%; height: 16px; border: 0; border-radius: 99px; overflow: hidden; background: #07142c; }
progress::-webkit-progress-bar { background: #07142c; border-radius: 99px; }
progress::-webkit-progress-value { background: linear-gradient(90deg, var(--cyan), var(--violet), var(--coral), var(--gold)); border-radius: 99px; }
progress::-moz-progress-bar { background: linear-gradient(90deg, var(--cyan), var(--violet), var(--coral), var(--gold)); }
#prism-fire {
  min-height: 46px; border: 1px solid rgba(248,216,121,.7); border-radius: 999px; padding: 0 20px;
  background: linear-gradient(105deg, #fff2b2, #d5a5ff); color: #101939; font-weight: 1000; cursor: pointer;
}
#prism-fire:disabled { opacity: .36; cursor: not-allowed; filter: saturate(.3); }
#prism-fire:not(:disabled) { animation: readyPulse 1s ease-in-out infinite alternate; }
@keyframes readyPulse { to { box-shadow: 0 0 24px rgba(248,216,121,.5); transform: translateY(-1px); } }
.hint { margin: 12px 4px 0; color: #adbedc; text-align: center; font-weight: 700; }

.mission {
  border: 1px solid rgba(255,255,255,.12); border-top: 4px solid var(--gold); border-radius: 24px;
  padding: 26px; background: linear-gradient(160deg, rgba(13,39,79,.88), rgba(5,15,33,.92));
  box-shadow: 0 25px 70px rgba(0,0,0,.25);
}
.mission-kicker { margin: 0; color: var(--gold); font: 800 10px/1.2 ui-monospace, monospace; letter-spacing: .22em; }
.mission h2 { margin: 8px 0 22px; font-size: 24px; }
.mission ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; }
.mission li { display: grid; grid-template-columns: 42px 1fr; gap: 12px; align-items: start; }
.mission li > span {
  position: relative; isolation: isolate; display: grid; place-items: center; width: 42px; height: 42px;
  color: var(--gold); font: 800 11px ui-monospace, monospace;
}
.mission li > span::before { content: ""; position: absolute; z-index: -1; inset: 6px; border: 1px solid var(--line); transform: rotate(45deg); }
.mission strong { color: var(--cream); }
.mission li p, .keyboard, .save-note { margin: 4px 0 0; color: #98acd0; font-size: 13px; line-height: 1.65; }
.keyboard { margin-top: 22px; padding: 12px; border-left: 2px solid var(--cyan); background: rgba(101,229,243,.06); }
.records { margin: 24px 0 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 1px; overflow: hidden; border: 1px solid rgba(255,255,255,.1); border-radius: 14px; background: rgba(255,255,255,.1); }
.records div { padding: 13px; background: rgba(5,15,33,.92); }
.records dt { color: #7f96bd; font-size: 11px; }
.records dd { margin: 4px 0 0; color: var(--gold); font-weight: 900; }
.reset { width: 100%; }
.save-note { margin-top: 12px; font-size: 11px; }
footer { padding: 28px 16px 42px; border-top: 1px solid rgba(255,255,255,.08); color: #7f96bd; text-align: center; font-size: 12px; }

body.capture .masthead, body.capture .intro, body.capture .mission, body.capture footer, body.capture [data-account] { display: none !important; }
body.capture main { width: 100%; height: 100vh; padding: 0; }
body.capture .game-layout { display: block; height: 100%; }
body.capture .game-column { height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; }
body.capture .hud { border-radius: 0; border-left: 0; border-right: 0; }
body.capture .game-shell { min-height: 0; border: 0; border-radius: 0; }
body.capture canvas { width: 100%; height: 100%; object-fit: contain; }
body.capture .prism-console { margin: 0; border-radius: 0; border-left: 0; border-right: 0; }
body.capture .hint { margin: 0; min-height: 58px; padding: 14px 24px; display: grid; place-items: center; background: #06142b; }

@media (max-width: 900px) {
  main { width: min(720px, calc(100% - 20px)); }
  .game-layout { grid-template-columns: 1fr; }
  .mission { margin-top: 10px; }
}

@media (max-width: 520px) {
  .masthead { width: calc(100% - 20px); padding-top: 12px; }
  main { width: 100%; padding: 0 8px 36px; }
  .intro { margin: 12px 0 14px; }
  .intro h1 { font-size: 36px; }
  .intro > p:last-child { font-size: 13px; }
  .hud div { padding: 9px 7px; }
  .hud span { font-size: 8px; letter-spacing: .08em; }
  .hud strong { font-size: 13px; }
  .game-shell { border-radius: 0 0 16px 16px; }
  canvas { max-height: 58vh; object-fit: contain; }
  .start-panel { padding: 24px 20px; }
  .start-panel h2 { font-size: 27px; }
  .start-panel > p:not(.start-kicker) { font-size: 13px; line-height: 1.65; }
  .start-panel button { min-height: 52px; }
  .prism-console { grid-template-columns: 82px minmax(0,1fr); padding: 10px; gap: 8px; }
  #prism-fire { grid-column: 1 / -1; min-height: 48px; }
  .hint { font-size: 12px; }
  .mission { margin: 10px 0 0; padding: 20px; border-radius: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
