/* Sirensong — the look. Deep water, thin gold, glass panels. */
:root {
  --ink: #050a12;
  --ink-2: #0a1420;
  --pearl: #f5efe2;
  --pearl-dim: rgba(245, 239, 226, 0.62);
  --gold: #e8c98a;
  --gold-2: #c99a52;
  --line: rgba(232, 201, 138, 0.18);
  --glass: rgba(9, 17, 26, 0.76);
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--pearl);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ------------------------------------------------------------------ stage */
.game {
  position: relative;
  height: 100svh;
  min-height: 480px;
  overflow: hidden;
  background: radial-gradient(120% 90% at 50% 0%, #0b1a28 0%, #04080e 70%);
  user-select: none;
  -webkit-user-select: none;
}

#stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px clamp(12px, 3vw, 28px) 18px;
  background: linear-gradient(to bottom, rgba(3, 7, 12, 0.86), rgba(3, 7, 12, 0.35) 62%, rgba(3, 7, 12, 0));
  pointer-events: none;
  transition: opacity .35s ease;
}
.hud.dim { opacity: 0; }
.hud > * { pointer-events: auto; }
.hud-left { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.hud-kicker {
  font-size: 9.5px;
  letter-spacing: .20em;
  color: var(--gold);
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hud-chapter {
  font-family: var(--serif);
  font-size: clamp(13px, 1.5vw, 16px);
  color: var(--pearl);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 40vw;
}

.course { display: flex; align-items: center; gap: 9px; }
.course-bar {
  width: clamp(90px, 22vw, 240px);
  height: 5px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.10);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.05);
}
.course-fill {
  height: 100%;
  width: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #7fe3d4, #e8c98a 62%, #ff9d6e);
  transition: width .18s linear, background .3s;
  box-shadow: 0 0 12px rgba(232, 201, 138, .55);
}
.course-fill.low { background: linear-gradient(90deg, #ff6b5e, #ff9d6e); }
.course-num {
  font: 600 12px/1 var(--sans);
  color: var(--pearl);
  min-width: 26px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.course-label {
  font-size: 8.5px;
  letter-spacing: .18em;
  color: rgba(245, 239, 226, .45);
}

.hud-right { display: flex; align-items: center; gap: 12px; }
.hud-score, .hud-acc { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.hud-score span, .hud-acc span {
  font: 600 15px/1 var(--sans);
  font-variant-numeric: tabular-nums;
}
.hud-score small, .hud-acc small {
  font-size: 8px;
  letter-spacing: .16em;
  color: rgba(245, 239, 226, .42);
}
.icon-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(8, 14, 21, .55);
  color: var(--pearl);
  font-size: 12px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all .2s ease;
  backdrop-filter: blur(6px);
}
.icon-btn:hover { border-color: rgba(232, 201, 138, .55); background: rgba(232, 201, 138, .12); }
.icon-btn.off { color: rgba(245, 239, 226, .35); }

/* ---------------------------------------------------------------- screens */
.screen {
  position: absolute;
  inset: 0;
  z-index: 9;
  display: none;
  align-items: center;
  justify-content: center;
  padding: clamp(14px, 3vw, 32px);
  background:
    radial-gradient(90% 70% at 50% 30%, rgba(10, 26, 38, .72), rgba(2, 5, 9, .90) 78%),
    rgba(2, 5, 9, .55);
  backdrop-filter: blur(9px) saturate(1.05);
  animation: screenIn .38s cubic-bezier(.2, .8, .2, 1) both;
  overflow-y: auto;
}
.screen.on { display: flex; }

@keyframes screenIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.panel {
  position: relative;
  width: min(560px, 100%);
  padding: clamp(22px, 3.4vw, 38px);
  border-radius: 20px;
  border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(15, 26, 38, .93), rgba(7, 13, 20, .95));
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .9), inset 0 1px 0 rgba(255, 255, 255, .06);
  animation: panelIn .42s cubic-bezier(.2, .8, .2, 1) both;
}
.panel.wide { width: min(880px, 100%); }
.panel.narrow { width: min(420px, 100%); }
@keyframes panelIn {
  from { opacity: 0; transform: translateY(14px) scale(.985); }
  to { opacity: 1; transform: none; }
}
.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(70% 50% at 50% 0%, rgba(232, 201, 138, .10), transparent 70%);
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 9.5px;
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--gold);
}
.panel h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(21px, 2.6vw, 29px);
  margin: 0 0 12px;
  line-height: 1.18;
}
.hint {
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--pearl-dim);
  margin: 0 0 16px;
}

/* title */
.title-screen { background: radial-gradient(85% 65% at 50% 42%, rgba(10, 26, 38, .35), rgba(2, 5, 9, .86) 80%); }
.st-wrap {
  text-align: center;
  width: min(760px, 100%);
  animation: panelIn .6s cubic-bezier(.2, .8, .2, 1) both;
}
.wordmark {
  margin: 6px 0 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(38px, 10.4vw, 104px);
  line-height: .92;
  letter-spacing: .085em;
  color: #fbf5e6;
  text-shadow: 0 0 42px rgba(232, 201, 138, .30), 0 2px 0 rgba(0, 0, 0, .35);
}
.wordmark em {
  display: block;
  margin-top: 12px;
  font-family: var(--sans);
  font-style: normal;
  font-size: clamp(9px, 1.5vw, 12px);
  letter-spacing: .46em;
  text-transform: uppercase;
  color: rgba(232, 201, 138, .82);
}
.tagline {
  margin: 20px auto 0;
  max-width: 440px;
  font-size: clamp(12.5px, 1.6vw, 14.5px);
  line-height: 1.7;
  color: var(--pearl-dim);
}
.title-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin: 26px 0 0;
}
.title-stats {
  display: flex;
  justify-content: center;
  gap: clamp(20px, 5vw, 52px);
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid rgba(232, 201, 138, .12);
}
.title-stats div { display: flex; flex-direction: column; gap: 3px; }
.title-stats b {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 20px;
  color: var(--pearl);
  font-variant-numeric: tabular-nums;
}
.title-stats span { font-size: 9.5px; letter-spacing: .13em; text-transform: uppercase; color: rgba(245, 239, 226, .40); }

/* buttons */
.btn {
  appearance: none;
  border: 1px solid rgba(232, 201, 138, .30);
  background: rgba(255, 255, 255, .03);
  color: var(--pearl);
  font: 500 13px/1 var(--sans);
  letter-spacing: .06em;
  padding: 13px 22px;
  border-radius: 99px;
  cursor: pointer;
  transition: transform .16s ease, background .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.btn:hover { transform: translateY(-1px); border-color: rgba(232, 201, 138, .62); background: rgba(232, 201, 138, .09); }
.btn:active { transform: translateY(0) scale(.99); }
.btn.primary {
  background: linear-gradient(180deg, #f3ddb0, #c99a52);
  color: #20160a;
  border-color: rgba(255, 240, 205, .55);
  font-weight: 600;
  box-shadow: 0 10px 30px -12px rgba(232, 201, 138, .65), inset 0 1px 0 rgba(255, 255, 255, .55);
}
.btn.primary:hover { box-shadow: 0 14px 38px -12px rgba(232, 201, 138, .85), inset 0 1px 0 rgba(255, 255, 255, .6); }
.btn.ghost { border-color: rgba(255, 255, 255, .12); background: transparent; color: var(--pearl-dim); }
.btn.ghost:hover { color: var(--pearl); background: rgba(255, 255, 255, .06); }
.btn.small { padding: 9px 16px; font-size: 12px; }
.stack { display: flex; flex-direction: column; gap: 9px; }
.stack .btn { width: 100%; }

/* chapters */
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.panel-head h2 { margin: 0; }
.chapter-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 8px;
}
.ch {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 11px;
  border: 1px solid rgba(255, 255, 255, .09);
  background: rgba(255, 255, 255, .025);
  color: var(--pearl);
  font: 600 12px/1 var(--sans);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all .18s ease;
  overflow: hidden;
}
.ch:hover { border-color: rgba(232, 201, 138, .55); background: rgba(232, 201, 138, .10); transform: translateY(-2px); }
.ch .dots { display: flex; gap: 2px; }
.ch .dots i {
  width: 3px; height: 3px; border-radius: 50%;
  background: rgba(255, 255, 255, .16);
  display: block;
}
.ch .dots i.on { background: var(--gold); box-shadow: 0 0 5px rgba(232, 201, 138, .9); }
.ch.locked { color: rgba(245, 239, 226, .22); cursor: default; background: rgba(255, 255, 255, .012); }
.ch.locked:hover { transform: none; border-color: rgba(255, 255, 255, .09); background: rgba(255, 255, 255, .012); }
.ch.act-start { border-color: rgba(232, 201, 138, .34); }
.ch.act-2 { background: rgba(157, 123, 255, .05); }
.ch.act-3 { background: rgba(159, 224, 189, .05); }
.ch.act-4 { background: rgba(255, 122, 94, .06); }
.ch.current { box-shadow: 0 0 0 1px rgba(232, 201, 138, .7), 0 0 24px -6px rgba(232, 201, 138, .8); }
.chapter-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, .07);
}
.chapter-foot .hint { margin: 0; max-width: 60%; }

/* brief */
.brief-num {
  font-family: var(--serif);
  color: var(--gold);
  margin-right: 12px;
  font-size: .72em;
}
.brief-story {
  font-family: var(--serif);
  font-size: clamp(15px, 1.9vw, 18px);
  line-height: 1.6;
  margin: 0 0 8px;
  color: var(--pearl);
}
.brief-story.dim { color: var(--pearl-dim); font-size: clamp(13.5px, 1.7vw, 16px); }
.brief-tip {
  margin: 18px 0 22px;
  font-size: 10.5px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: rgba(232, 201, 138, .7);
}
.brief-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* how */
.how-list { margin: 4px 0 18px; padding-left: 18px; }
.how-list li { font-size: 13.5px; line-height: 1.65; color: var(--pearl-dim); margin-bottom: 9px; }
.how-list b { color: var(--pearl); font-weight: 600; }

/* result */
.result { text-align: center; }
.rank {
  font-family: var(--serif);
  font-size: clamp(64px, 12vw, 96px);
  line-height: 1;
  color: var(--gold);
  text-shadow: 0 0 50px rgba(232, 201, 138, .45);
  margin: 6px 0 2px;
}
.rank.fail { color: #ff8d7c; text-shadow: 0 0 46px rgba(255, 110, 90, .4); }
.stars { display: flex; gap: 8px; justify-content: center; margin: 4px 0 14px; }
.stars i {
  width: 15px; height: 15px;
  background: rgba(255, 255, 255, .14);
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  display: block;
}
.stars i.on { background: var(--gold); filter: drop-shadow(0 0 7px rgba(232, 201, 138, .8)); animation: starPop .4s cubic-bezier(.2, 1.6, .4, 1) both; }
.stars i:nth-child(2) { animation-delay: .1s; }
.stars i:nth-child(3) { animation-delay: .2s; }
@keyframes starPop { from { transform: scale(.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.result h2 { margin-bottom: 6px; }
.result-note { font-size: 12.5px; color: var(--pearl-dim); min-height: 18px; margin: 0 0 18px; }
.result-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .07);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 22px;
}
.result-grid div {
  background: rgba(6, 12, 19, .92);
  padding: 12px 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.result-grid b { font: 600 16px/1 var(--sans); font-variant-numeric: tabular-nums; }
.result-grid span { font-size: 8.5px; letter-spacing: .15em; text-transform: uppercase; color: rgba(245, 239, 226, .42); }
.result .brief-actions { justify-content: center; }

/* toast */
.toast {
  position: absolute;
  left: 50%;
  bottom: calc(14% + 22px);
  transform: translate(-50%, 12px);
  z-index: 12;
  padding: 9px 16px;
  border-radius: 99px;
  border: 1px solid rgba(232, 201, 138, .3);
  background: rgba(8, 14, 21, .92);
  font-size: 11.5px;
  letter-spacing: .08em;
  color: var(--gold);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* --------------------------------------------------------------- article */
.article {
  max-width: 860px;
  margin: 0 auto;
  padding: clamp(30px, 6vw, 72px) clamp(18px, 5vw, 40px) 80px;
  background: linear-gradient(to bottom, #050a12, #04070c);
}
.crumbs { font-size: 11px; letter-spacing: .06em; color: rgba(245, 239, 226, .40); margin-bottom: 18px; }
.crumbs a { color: rgba(232, 201, 138, .78); text-decoration: none; }
.crumbs a:hover { color: var(--gold); }
.article h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(24px, 3.4vw, 38px);
  line-height: 1.22;
  margin: 0 0 18px;
  color: #fbf6e9;
}
.article h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(19px, 2.4vw, 25px);
  margin: 38px 0 12px;
  color: var(--pearl);
}
.article h3 { font-size: 14px; margin: 20px 0 6px; color: var(--gold); font-weight: 600; letter-spacing: .01em; }
.article p { font-size: 14.5px; line-height: 1.75; color: rgba(245, 239, 226, .74); margin: 0 0 14px; }
.article .lede { font-size: 16px; color: rgba(245, 239, 226, .88); }
.article .howto { padding-left: 20px; margin: 0 0 18px; }
.article .howto li { font-size: 14px; line-height: 1.7; color: rgba(245, 239, 226, .74); margin-bottom: 8px; }
.article .howto b, .article .howto strong { color: var(--pearl); }
.article table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0 18px;
  font-size: 13px;
}
.article th, .article td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  color: rgba(245, 239, 226, .74);
  vertical-align: top;
}
.article th { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); }
.article kbd {
  font: 11px/1 ui-monospace, Menlo, monospace;
  border: 1px solid rgba(255, 255, 255, .18);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 2px 5px;
  color: var(--pearl);
}
.article .tags { display: flex; flex-wrap: wrap; gap: 7px; margin: 20px 0; }
.article .tags span {
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 6px 10px;
  border-radius: 99px;
  border: 1px solid rgba(232, 201, 138, .22);
  color: rgba(232, 201, 138, .8);
}
.article .src { font-size: 12px; color: rgba(245, 239, 226, .40); margin-top: 26px; }
.article .src a { color: rgba(232, 201, 138, .8); }

/* -------------------------------------------------------------- responsive */
@media (max-width: 760px) {
  .hud { padding: 9px 12px 14px; gap: 8px; }
  .hud-chapter { font-size: 12px; max-width: 44vw; }
  .hud-acc { display: none; }
  .course-label { display: none; }
  .course-bar { width: 74px; }
  .chapter-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
  .chapter-foot { flex-direction: column; align-items: stretch; }
  .chapter-foot .hint { max-width: 100%; }
  .article table { display: block; overflow-x: auto; white-space: nowrap; }
}

@media (max-width: 420px) {
  .icon-btn { width: 28px; height: 28px; }
  .hud-score span { font-size: 13px; }
  .panel { padding: 20px 16px; border-radius: 16px; }
  .result-grid { grid-template-columns: repeat(3, 1fr); }
  .title-stats { gap: 16px; }
  .title-stats b { font-size: 17px; }
}

@media (max-height: 560px) and (orientation: landscape) {
  .st-wrap { transform: scale(.92); }
  .title-stats { display: none; }
  .panel { padding: 18px 22px; }
  .how-list li { margin-bottom: 5px; font-size: 12.5px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
