@font-face { font-family: 'Instrument Serif'; font-style: italic; font-weight: 400; font-display: swap; src: url('/assets/fonts/instrument-serif-italic-latin.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 100 900; font-display: swap; src: url('/assets/fonts/inter-latin.woff2') format('woff2'); }

:root {
  --ink: #070a1f; --panel: rgba(12, 16, 44, 0.78); --panel-2: rgba(20, 26, 66, 0.86); --line: rgba(255, 231, 168, 0.22);
  --gold: #ffd36b; --gold-2: #ffe7a8; --cream: #f3ead6; --muted: #aab1d8; --coral: #ff5a3c; --mint: #7fffc2; --blue: #8fc8ff;
  --serif: 'Instrument Serif', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px); --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
}
[hidden] { display: none !important; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #05060f; color: var(--cream); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
body { overflow: hidden; overscroll-behavior: none; touch-action: none; }
#stage { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; outline: none; }
#overlay { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
a { color: var(--gold-2); }

.kicker { margin: 0; font: 600 12px/1.2 var(--sans); letter-spacing: .22em; text-transform: uppercase; color: var(--gold-2); opacity: .85; }
.primary { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 56px; min-width: 220px; padding: 10px 30px;
  border: 0; border-radius: 999px; background: linear-gradient(180deg, #ffe7a8, #ffc94a 55%, #e9a92c); color: #23180a; font: 650 18px/1.1 var(--sans); letter-spacing: .02em;
  box-shadow: 0 0 0 1px rgba(255, 231, 168, .5), 0 10px 40px rgba(255, 190, 80, .35), inset 0 1px 0 rgba(255, 255, 255, .6); transition: transform .15s, box-shadow .15s; }
.primary small { font: 500 12px/1.1 var(--sans); opacity: .75; letter-spacing: .04em; }
.primary:hover { transform: translateY(-1px); box-shadow: 0 0 0 1px rgba(255, 231, 168, .7), 0 14px 50px rgba(255, 190, 80, .5), inset 0 1px 0 rgba(255, 255, 255, .6); }
.primary[disabled] { opacity: .7; cursor: progress; }
.ghost { min-height: 46px; padding: 10px 20px; border-radius: 999px; border: 1px solid rgba(243, 234, 214, .3); background: rgba(10, 14, 40, .45); color: var(--cream); font: 550 15px/1 var(--sans); backdrop-filter: blur(6px); }
.ghost:hover { border-color: var(--gold-2); }
.row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ---------------------------------------------------------------- title */
#title { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 18px; padding: 24px 20px calc(48px + var(--safe-b)); text-align: center;
  background: linear-gradient(180deg, rgba(5, 6, 20, 0) 30%, rgba(5, 6, 20, .55) 62%, rgba(5, 6, 20, .9)); }
#title h1 { margin: 0; font: 400 clamp(60px, 12vw, 148px)/.86 var(--serif); font-style: italic; letter-spacing: -.01em; color: #fff4dc;
  text-shadow: 0 0 30px rgba(255, 211, 107, .45), 0 0 90px rgba(120, 150, 255, .35); }
#title .tag { margin: 0 0 6px; max-width: 34em; font: 400 clamp(18px, 2.4vw, 24px)/1.35 var(--serif); font-style: italic; color: var(--cream); opacity: .92; }
#title .home { margin-top: 6px; font: 500 13px/1 var(--sans); color: var(--muted); text-decoration: none; letter-spacing: .06em; padding: 14px; }
#title .home:hover { color: var(--gold-2); }
#best { margin: 0; font: 500 13px/1.4 var(--sans); color: var(--muted); }

/* ---------------------------------------------------------------- HUD */
#hud { position: fixed; inset: 0; pointer-events: none; }
.hud-top { position: absolute; top: calc(12px + var(--safe-t)); left: calc(14px + var(--safe-l)); right: calc(14px + var(--safe-r)); display: grid; grid-template-columns: 1fr minmax(180px, 560px) 1fr; align-items: start; gap: 12px; }
.vitals { display: flex; flex-direction: column; gap: 6px; }
#hearts { display: flex; gap: 3px; flex-wrap: wrap; max-width: 220px; }
.heart { width: 24px; height: 22px; display: inline-block; background: center/contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 22'%3E%3Cpath d='M12 21 2.6 11.6A5.6 5.6 0 0 1 12 3.7a5.6 5.6 0 0 1 9.4 7.9Z' fill='%23ff6a8a' stroke='%23ffd0d8' stroke-width='1.2'/%3E%3C/svg%3E"); filter: drop-shadow(0 0 6px rgba(255, 90, 130, .65)); transition: transform .2s; }
.heart.empty { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 22'%3E%3Cpath d='M12 21 2.6 11.6A5.6 5.6 0 0 1 12 3.7a5.6 5.6 0 0 1 9.4 7.9Z' fill='rgba(20,20,50,.55)' stroke='%23ffd0d8' stroke-opacity='.45' stroke-width='1.2'/%3E%3C/svg%3E"); filter: none; }
.heart.pop { animation: pop .35s; }
@keyframes pop { 40% { transform: scale(1.35); } }
#dodges { display: flex; gap: 4px; }
#dodges i { width: 18px; height: 5px; border-radius: 3px; background: rgba(143, 200, 255, .25); }
#dodges i.on { background: var(--blue); box-shadow: 0 0 8px rgba(143, 200, 255, .8); }
#stars { font-size: 15px; color: #fff3a8; text-shadow: 0 0 8px rgba(255, 243, 168, .9); letter-spacing: 2px; min-height: 1em; }
.song { display: flex; flex-direction: column; align-items: center; gap: 6px; }
#songbar { position: relative; width: 100%; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .13); box-shadow: 0 0 0 1px rgba(255, 231, 168, .12); }
#song-fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 3px; background: linear-gradient(90deg, #8fc8ff, #ffe7a8 60%, #ffd36b); box-shadow: 0 0 12px rgba(255, 211, 107, .6); }
#song-marks i { position: absolute; top: 50%; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; transform: rotate(45deg); background: #12183d; border: 1.5px solid var(--gold-2); }
#song-marks i.boss { border-color: var(--coral); }
#song-marks i.past { background: var(--gold); }
#section { margin: 0; font: 600 10.5px/1 var(--sans); letter-spacing: .2em; text-transform: uppercase; color: var(--muted); min-height: 1em; }
.hudbtn { pointer-events: auto; justify-self: end; width: 48px; height: 48px; border-radius: 14px; border: 1px solid rgba(243, 234, 214, .25); background: rgba(10, 14, 40, .55); font-size: 14px; letter-spacing: -2px; backdrop-filter: blur(6px); }
#lyric { position: absolute; top: calc(62px + var(--safe-t)); left: 50%; transform: translateX(-50%); width: min(92vw, 780px); margin: 0; text-align: center; font: 400 clamp(17px, 2.1vw, 23px)/1.3 var(--serif); font-style: italic; color: #fff4dc; text-shadow: 0 1px 12px rgba(5, 6, 20, .9), 0 0 2px rgba(5, 6, 20, .9); opacity: 0; transition: opacity .5s; }
#lyric.on { opacity: .92; }
#boss { position: absolute; bottom: calc(26px + var(--safe-b)); left: 50%; transform: translateX(-50%); width: min(70vw, 560px); text-align: center; }
html[data-device="touch"] #boss { bottom: auto; top: calc(104px + var(--safe-t)); width: min(86vw, 520px); }
html:not([data-device="touch"]) #hud:has(#boss:not([hidden])) #hint { bottom: calc(96px + var(--safe-b)); }
#boss-name { margin: 0 0 6px; font: 400 22px/1 var(--serif); font-style: italic; color: #ffe7c8; text-shadow: 0 0 14px rgba(255, 120, 90, .6); }
#boss .bar { height: 8px; border-radius: 4px; background: rgba(20, 10, 30, .7); box-shadow: 0 0 0 1px rgba(255, 140, 110, .35); overflow: hidden; }
#boss-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #ff4a2e, #ff9a62); transition: width .15s; }
#boss.freed #boss-fill { background: linear-gradient(90deg, #ffd36b, #fff3c0); }
#boss-sub { margin: 6px 0 0; font: 600 11px/1.2 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: #ffc2b0; }
#hint { position: absolute; left: 50%; bottom: calc(64px + var(--safe-b)); transform: translateX(-50%); margin: 0; max-width: min(92vw, 640px); padding: 11px 18px; border-radius: 999px; background: rgba(10, 14, 40, .78); border: 1px solid var(--line); font: 550 15px/1.3 var(--sans); text-align: center; backdrop-filter: blur(6px); }
#hint kbd { font: 650 12px/1 var(--sans); padding: 3px 7px; border-radius: 6px; border: 1px solid rgba(255, 231, 168, .4); background: rgba(255, 231, 168, .08); }
#banner { position: absolute; left: 50%; top: 34%; transform: translate(-50%, -50%); margin: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; animation: banner 3.4s ease forwards; width: 92vw; }
#banner-kicker { font: 650 12px/1 var(--sans); letter-spacing: .3em; text-transform: uppercase; color: var(--gold-2); }
#banner-text { font: 400 clamp(36px, 6vw, 72px)/1 var(--serif); font-style: italic; color: #fff4dc; text-shadow: 0 0 26px rgba(255, 211, 107, .55), 0 2px 14px rgba(5, 6, 20, .9); }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, -40%); } 15% { opacity: 1; transform: translate(-50%, -50%); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -54%); } }
#powers { position: absolute; left: calc(14px + var(--safe-l)); bottom: calc(18px + var(--safe-b)); display: flex; gap: 6px; flex-wrap: wrap; max-width: 46vw; }
.pw { position: relative; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-size: 18px; background: rgba(10, 14, 40, .7); border: 1.5px solid var(--c, var(--gold)); color: var(--c, var(--gold)); text-shadow: 0 0 8px currentColor; }
.pw small { position: absolute; bottom: -4px; right: -4px; font: 700 9px/1 var(--sans); padding: 2px 4px; border-radius: 6px; background: var(--c, var(--gold)); color: #12102a; text-shadow: none; }
#xp { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255, 255, 255, .06); }
#xp-fill { height: 100%; width: 0; background: linear-gradient(90deg, #ffe7a8, #ffd36b); box-shadow: 0 0 10px rgba(255, 211, 107, .8); transition: width .2s; }

/* ---------------------------------------------------------------- touch */
#touch { position: fixed; inset: 0; pointer-events: none; }
#stick-zone { position: absolute; left: 0; top: 18%; bottom: 0; width: 55%; pointer-events: auto; }
#stick-base { position: absolute; left: 0; top: 0; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; border: 2px solid rgba(243, 234, 214, .25); background: rgba(10, 14, 40, .25); pointer-events: none; }
#stick-knob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: rgba(255, 231, 168, .35); border: 2px solid rgba(255, 231, 168, .6); }
.tb { position: absolute; pointer-events: auto; display: grid; place-items: center; align-content: center; gap: 1px; width: 70px; height: 70px; border-radius: 50%; border: 1.5px solid rgba(243, 234, 214, .35); background: rgba(10, 14, 40, .55); backdrop-filter: blur(4px); touch-action: none; user-select: none; -webkit-user-select: none; }
.tb b { font-size: 24px; line-height: 1; color: var(--gold-2); }
.tb span { font: 650 10px/1 var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--cream); opacity: .85; }
.tb.big { width: 96px; height: 96px; right: calc(22px + var(--safe-r)); bottom: calc(30px + var(--safe-b)); border-color: rgba(255, 211, 107, .7); box-shadow: 0 0 24px rgba(255, 211, 107, .25); }
.tb.big b { font-size: 34px; }
.tb.big[data-state="recall"] { border-color: var(--blue); }
#btn-dodge { right: calc(132px + var(--safe-r)); bottom: calc(24px + var(--safe-b)); }
#btn-well { right: calc(34px + var(--safe-r)); bottom: calc(138px + var(--safe-b)); }
html[data-device="touch"] #powers { bottom: calc(150px + var(--safe-b)); max-width: 60vw; }
html[data-device="touch"] #hint { bottom: calc(150px + var(--safe-b)); }

/* ---------------------------------------------------------------- dialogs */
#cards, #pause, #howto, #end, #nogl, .noscript { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: calc(20px + var(--safe-t)) 16px calc(20px + var(--safe-b)); overflow-y: auto; text-align: center; background: radial-gradient(ellipse at 50% 40%, rgba(16, 20, 60, .55), rgba(4, 5, 16, .86)); backdrop-filter: blur(3px); touch-action: pan-y; }
#cards h2, #pause h2, #howto h2, #end h2 { margin: 0; font: 400 clamp(30px, 4.6vw, 52px)/1.05 var(--serif); font-style: italic; color: #fff4dc; text-shadow: 0 0 22px rgba(255, 211, 107, .35); }
#card-list { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin-top: 6px; }
.card { position: relative; width: 250px; min-height: 300px; padding: 22px 18px 18px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; border-radius: 20px;
  background: linear-gradient(180deg, rgba(30, 36, 86, .92), rgba(12, 16, 44, .94)); border: 1.5px solid color-mix(in srgb, var(--c) 60%, transparent); box-shadow: 0 0 0 1px rgba(255, 255, 255, .04), 0 18px 50px rgba(0, 0, 0, .45), 0 0 34px color-mix(in srgb, var(--c) 18%, transparent);
  transition: transform .16s, box-shadow .16s; animation: deal .45s backwards; }
.card:nth-child(2) { animation-delay: .07s; } .card:nth-child(3) { animation-delay: .14s; }
@keyframes deal { from { opacity: 0; transform: translateY(26px) scale(.96); } }
.card:hover, .card:focus-visible { transform: translateY(-6px); box-shadow: 0 0 0 1px rgba(255, 255, 255, .06), 0 24px 60px rgba(0, 0, 0, .5), 0 0 50px color-mix(in srgb, var(--c) 40%, transparent); outline: none; border-color: var(--c); }
.card .glyph { width: 70px; height: 70px; border-radius: 50%; display: grid; place-items: center; font-size: 34px; color: var(--c); border: 1.5px solid color-mix(in srgb, var(--c) 70%, transparent); background: radial-gradient(circle, color-mix(in srgb, var(--c) 28%, transparent), transparent 70%); text-shadow: 0 0 14px var(--c); }
.card .head { display: flex; flex-direction: column; align-items: center; gap: 7px; }
.card .tag { font: 650 10.5px/1 var(--sans); letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
.card .name { font: 400 29px/1 var(--serif); font-style: italic; color: #fff4dc; }
.card .pips { display: flex; gap: 5px; } .card .pips i { width: 16px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .16); } .card .pips i.on { background: var(--c); box-shadow: 0 0 6px var(--c); }
.card .text { font: 450 15px/1.4 var(--sans); color: #e4e6f6; }
.card .badge { margin-top: auto; font: 650 11px/1.25 var(--sans); letter-spacing: .06em; color: #12102a; background: var(--gold); border-radius: 999px; padding: 6px 10px; }
.card .badge.new { background: var(--mint); }
.card .key { position: absolute; top: 10px; left: 12px; font: 650 11px/1 var(--sans); color: var(--muted); }
#cards .keys { margin: 4px 0 0; font: 500 12px/1 var(--sans); color: var(--muted); }
html[data-device="touch"] #cards .keys { visibility: hidden; }
#pause-build { margin: 0; color: var(--muted); font: 500 14px/1.4 var(--sans); max-width: 30em; }
.opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 4px 18px; width: min(92vw, 440px); margin: 6px 0; padding: 12px 16px; border: 1px solid var(--line); border-radius: 16px; text-align: left; }
.opts legend { padding: 0 6px; font: 650 11px/1 var(--sans); letter-spacing: .2em; text-transform: uppercase; color: var(--gold-2); }
.opts label { display: flex; align-items: center; gap: 10px; min-height: 44px; font: 500 15px/1.2 var(--sans); cursor: pointer; }
.opts input { width: 20px; height: 20px; accent-color: var(--gold); }
#howto { text-align: left; }
#howto > * { max-width: 680px; width: 100%; }
#howto p { margin: 0; color: #dfe2f4; font: 450 15px/1.5 var(--sans); }
#howto table { border-collapse: collapse; width: 100%; font: 450 14px/1.35 var(--sans); }
#howto th, #howto td { padding: 8px 10px; border-bottom: 1px solid rgba(255, 231, 168, .12); text-align: left; vertical-align: top; }
#howto thead th { font: 650 11px/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--gold-2); }
#howto .primary { align-self: center; width: auto; }
#end-stats { margin: 0; max-width: 34em; color: #dfe2f4; font: 450 16px/1.5 var(--sans); }
#end-build { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; max-width: 560px; }
#end-build .pw { width: auto; height: auto; padding: 6px 10px 6px 8px; border-radius: 999px; display: inline-flex; gap: 6px; font: 550 13px/1 var(--sans); color: var(--cream); text-shadow: none; }
#end-build .pw b { color: var(--c); font-size: 16px; text-shadow: 0 0 8px var(--c); }
#end-build .const { border-color: var(--gold); background: rgba(255, 211, 107, .12); }
#gate { max-width: 520px; padding: 16px 20px; border-radius: 18px; border: 1px solid rgba(127, 255, 194, .35); background: rgba(10, 30, 40, .6); }
#gate h3 { margin: 6px 0; font: 400 34px/1 var(--serif); font-style: italic; color: #d8fff0; }
#gate p { margin: 0; color: #cfeee4; font: 450 15px/1.5 var(--sans); }
#gate .kicker { color: var(--mint); }
#fade { position: fixed; inset: 0; background: #05060f; opacity: 0; pointer-events: none; transition: opacity .6s; }
#fade.on { opacity: 1; }
#nogl h1, .noscript h1 { margin: 0; font: 400 64px/1 var(--serif); font-style: italic; color: #fff4dc; }
#nogl p, .noscript p { max-width: 32em; font: 450 16px/1.5 var(--sans); }

@media (max-width: 720px) {
  .hud-top { grid-template-columns: auto 1fr auto; }
  .heart { width: 19px; height: 18px; }
  #card-list { flex-direction: column; align-items: center; gap: 10px; }
  .card { width: min(92vw, 420px); min-height: 0; flex-direction: row; flex-wrap: wrap; text-align: left; align-items: center; padding: 14px 16px; gap: 6px 12px; }
  .card .glyph { width: 52px; height: 52px; font-size: 26px; }
  .card .head { flex: 1; align-items: flex-start; gap: 4px; }
  .card .name { font-size: 25px; }
  .card .text { flex-basis: 100%; font-size: 14px; }
  .card .badge { margin-top: 0; }
  .card .key { display: none; }
  #lyric { top: calc(56px + var(--safe-t)); }
  #boss { bottom: auto; top: calc(110px + var(--safe-t)); width: min(86vw, 520px); }
}
@media (max-height: 520px) and (orientation: landscape) {
  #card-list { flex-wrap: nowrap; }
  .card { min-height: 0; width: 210px; padding: 14px 12px; gap: 6px; }
  .card .glyph { width: 48px; height: 48px; font-size: 24px; }
  .card .name { font-size: 22px; }
  .card .text { font-size: 13px; }
  #cards h2 { font-size: 26px; }
  #title { gap: 10px; padding-bottom: calc(18px + var(--safe-b)); }
  #title h1 { font-size: 64px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  #banner { animation: none; }
}
