/* ═══════════════════════════════════════════════════════════════════════════
   Aiko - Guardian of Sakura
   All of the game's 2D presentation. The 3D lives on the canvas underneath;
   everything you read, press or watch fill up is plain HTML sitting on top.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --ink: #2a1c33;
  --paper: #fff7fb;
  --pink: #ff87b2;
  --pink-deep: #e2497f;
  --gold: #ffc861;
  --leaf: #6fcf97;
  --sky: #7fc8ff;
  --plum: #3a2450;
  --night: #150f1e;
  --shadow: 0 12px 34px rgba(28, 12, 40, .38);
  --round: 18px;
  --ui: 'Segoe UI', system-ui, -apple-system, 'Hiragino Sans', 'Noto Sans JP', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: var(--night); color: var(--paper);
  font-family: var(--ui);
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

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

.hide { display: none !important; }

/* ═════════════════════════════════════════════════════════════════ boot ══ */

#boot {
  position: fixed; inset: 0; z-index: 90;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .2rem;
  background: radial-gradient(120% 90% at 50% 20%, #3b2350 0%, #150f1e 70%);
  transition: opacity .5s ease;
}
#boot.gone { opacity: 0; pointer-events: none; }
.boot-mark { font-size: 4rem; animation: bob 3s ease-in-out infinite; filter: drop-shadow(0 6px 16px rgba(255,135,178,.55)); }
#boot h1 { margin: .4rem 0 0; font-size: 3.6rem; letter-spacing: .22em; font-weight: 300; }
#boot p { margin: 0 0 1.6rem; letter-spacing: .34em; text-transform: uppercase; font-size: .7rem; opacity: .65; }
.boot-bar { width: min(300px, 60vw); height: 5px; border-radius: 99px; background: rgba(255,255,255,.13); overflow: hidden; }
.boot-bar i { display: block; height: 100%; width: 0; border-radius: 99px;
  background: linear-gradient(90deg, var(--pink), var(--gold)); transition: width .35s ease; }
#boot-status { margin-top: .8rem; font-size: .78rem; opacity: .6; }

@keyframes bob { 0%,100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-10px) rotate(4deg); } }

/* ══════════════════════════════════════════════════════════════════ HUD ══ */

#hud { position: fixed; inset: 0; z-index: 20; pointer-events: none; }

.hud-topleft  { position: absolute; top: 14px; left: 16px; display: flex; flex-direction: column; gap: 8px; }
.hud-topright { position: absolute; top: 14px; right: 16px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.hud-left     { position: absolute; top: 46%; left: 16px; transform: translateY(-50%); max-width: 260px; }

.hearts { display: flex; gap: 4px; font-size: 1.5rem; line-height: 1; filter: drop-shadow(0 3px 5px rgba(0,0,0,.5)); }
.hearts span { transition: transform .18s ease, opacity .18s ease; }
.hearts span.empty { opacity: .3; transform: scale(.82); filter: grayscale(1); }
.hearts span.pop { animation: pop .4s ease; }
@keyframes pop { 40% { transform: scale(1.45); } }

.energy { width: 132px; height: 8px; border-radius: 99px; background: rgba(20,10,30,.55);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); overflow: hidden; }
.energy i { display: block; height: 100%; width: 100%;
  background: linear-gradient(90deg, #7ee8c8, #7fc8ff); transition: width .1s linear; }

.powerups { display: flex; gap: 6px; }
.powerups div { position: relative; width: 34px; height: 34px; border-radius: 10px; font-size: 1.1rem;
  display: grid; place-items: center; background: rgba(24,14,34,.6); box-shadow: inset 0 0 0 1px rgba(255,255,255,.2); }
.powerups div i { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--gold); border-radius: 99px; }

.counters { display: flex; gap: 10px; background: rgba(24,14,34,.5); backdrop-filter: blur(7px);
  padding: 7px 12px; border-radius: 99px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.14); font-size: .92rem; }
.counters b { font-weight: 600; margin-left: 3px; }
.counters span { display: flex; align-items: center; }
.counters span.bump { animation: bump .35s ease; }
@keyframes bump { 40% { transform: scale(1.3); color: var(--gold); } }

#minimap { border-radius: 50%; background: rgba(18,10,26,.5); box-shadow: inset 0 0 0 2px rgba(255,255,255,.2), var(--shadow); }

.objectives { display: flex; flex-direction: column; gap: 5px; font-size: .84rem; }
.objectives div { display: flex; gap: 7px; align-items: baseline; padding: 6px 11px; border-radius: 12px;
  background: rgba(24,14,34,.5); backdrop-filter: blur(7px); box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
  animation: slidein .35s ease; }
.objectives div.done { opacity: .55; }
.objectives div.done span { text-decoration: line-through; }
.objectives div.optional { border-left: 3px solid var(--sky); }
.objectives div.locked { opacity: .5; }
.objectives div.locked i { opacity: .75; font-style: normal; }
.objectives b { color: var(--gold); font-variant-numeric: tabular-nums; font-size: .78rem; }
@keyframes slidein { from { opacity: 0; transform: translateX(-16px); } }

#pause-btn { position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  pointer-events: auto; width: 42px; height: 42px; border: 0; border-radius: 50%; cursor: pointer;
  background: rgba(24,14,34,.5); color: var(--paper); font-size: .8rem; backdrop-filter: blur(7px);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); }
#pause-btn:hover { background: rgba(60,30,80,.7); }

.timer { position: absolute; top: 62px; left: 50%; transform: translateX(-50%);
  font-size: .78rem; opacity: .55; font-variant-numeric: tabular-nums; }

.banner { position: absolute; top: 26%; left: 0; right: 0; text-align: center; opacity: 0; }
.banner.show { animation: banner 4.2s ease forwards; }
.banner b { display: block; font-size: .74rem; letter-spacing: .4em; text-transform: uppercase; color: var(--gold); }
.banner span { display: block; font-size: 2.6rem; font-weight: 300; letter-spacing: .05em;
  text-shadow: 0 6px 24px rgba(0,0,0,.6); }
.banner i { display: block; font-size: .95rem; opacity: .72; font-style: italic; }
@keyframes banner {
  0% { opacity: 0; transform: translateY(18px); }
  14% { opacity: 1; transform: translateY(0); }
  76% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-12px); }
}

.toasts { position: absolute; bottom: 96px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px; }
.toasts div { padding: 8px 16px; border-radius: 99px; font-size: .86rem; white-space: nowrap;
  background: rgba(24,14,34,.72); backdrop-filter: blur(7px);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.16), var(--shadow); animation: toast 3s ease forwards; }
.toasts div.good { box-shadow: inset 0 0 0 1px rgba(111,207,151,.6), var(--shadow); }
.toasts div.warn { box-shadow: inset 0 0 0 1px rgba(255,200,97,.6), var(--shadow); }
@keyframes toast { 0% { opacity: 0; transform: translateY(14px) scale(.94); }
  12%,80% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-8px); } }

.prompt { position: absolute; bottom: 22%; left: 50%; transform: translateX(-50%);
  padding: 8px 16px; border-radius: 99px; font-size: .88rem; background: rgba(24,14,34,.66);
  backdrop-filter: blur(7px); box-shadow: inset 0 0 0 1px rgba(255,255,255,.2); animation: pulse 1.8s ease-in-out infinite; }
.prompt kbd { background: var(--paper); color: var(--ink); border-radius: 6px; padding: 1px 7px;
  font: 600 .8rem var(--ui); margin-right: 5px; }
@keyframes pulse { 50% { transform: translateX(-50%) translateY(-4px); } }

.hint { position: absolute; bottom: 15%; left: 50%; transform: translateX(-50%); font-size: .82rem;
  opacity: .8; text-shadow: 0 2px 8px #000; }

.bossbar { position: absolute; top: 84px; left: 50%; transform: translateX(-50%); width: min(460px, 78vw); text-align: center; }
.bossbar b { font-size: 1.15rem; letter-spacing: .06em; }
.bossbar span { display: block; font-size: .72rem; letter-spacing: .26em; text-transform: uppercase; opacity: .66; }
.boss-track { margin-top: 6px; height: 10px; border-radius: 99px; background: rgba(20,10,30,.6);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.22); overflow: hidden; }
.boss-track i { display: block; height: 100%; width: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--pink-deep), var(--gold)); transition: width .4s ease; }
.bossbar em { display: block; margin-top: 6px; font-size: .82rem; font-style: normal; color: var(--gold); }

.dialogue { position: absolute; left: 50%; bottom: 5%; transform: translateX(-50%);
  width: min(660px, 92vw); display: flex; gap: 14px; padding: 16px 18px; pointer-events: auto;
  border-radius: var(--round); background: rgba(20,12,30,.86); backdrop-filter: blur(12px);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.16), var(--shadow); animation: slideup .28s ease; }
@keyframes slideup { from { opacity: 0; transform: translate(-50%, 20px); } }
.dlg-face { width: 62px; height: 62px; flex: none; border-radius: 16px; font-size: 2rem;
  display: grid; place-items: center; background: linear-gradient(160deg, #ffb0cd, #ffd9a0); }
.dlg-body { flex: 1; min-width: 0; }
.dlg-body b { color: var(--gold); font-size: .96rem; }
.dlg-body p { margin: 4px 0 0; font-size: 1rem; line-height: 1.5; min-height: 2.6em; }
.dlg-next { position: absolute; right: 16px; bottom: 10px; font-size: .72rem; opacity: .5; animation: pulse 1.6s infinite; }

.damage { position: absolute; inset: 0; opacity: 0; pointer-events: none;
  background: radial-gradient(120% 80% at 50% 50%, transparent 45%, rgba(226,73,127,.75) 100%); }
.damage.on { animation: hurt .5s ease; }
@keyframes hurt { 0% { opacity: 0; } 18% { opacity: 1; } 100% { opacity: 0; } }

/* ════════════════════════════════════════════════════════════════ touch ══ */

#touch { position: fixed; inset: 0; z-index: 25; pointer-events: none; }
.stick { position: absolute; left: 5%; bottom: 8%; width: 120px; height: 120px; border-radius: 50%;
  pointer-events: auto; background: rgba(255,255,255,.09); box-shadow: inset 0 0 0 2px rgba(255,255,255,.22); }
.stick i { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px;
  border-radius: 50%; background: rgba(255,255,255,.34); }
.touch-buttons { position: absolute; right: 5%; bottom: 8%; display: flex; align-items: flex-end; gap: 12px; }
.tbtn { pointer-events: auto; width: 62px; height: 62px; border: 0; border-radius: 50%; cursor: pointer;
  background: rgba(255,255,255,.14); color: var(--paper); font-size: 1.2rem;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.26); }
.tbtn:active { background: rgba(255,135,178,.5); }
.tbtn-big { width: 84px; height: 84px; font-size: 1.5rem; }

/* ════════════════════════════════════════════════════════════ screens ══ */

.screens { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 4vh 3vw;
  background: rgba(14,8,22,.62); backdrop-filter: blur(10px); overflow: auto; }

.panel { width: min(430px, 92vw); padding: 30px 32px; text-align: center;
  border-radius: 26px; background: linear-gradient(165deg, rgba(56,32,74,.96), rgba(28,16,40,.97));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.14), var(--shadow); animation: panelin .3s ease; }
.panel-wide { width: min(720px, 94vw); }
@keyframes panelin { from { opacity: 0; transform: translateY(18px) scale(.97); } }

.panel h1 { margin: .2rem 0 0; font-size: 4rem; font-weight: 300; letter-spacing: .2em; }
.panel h2 { margin: 0 0 .3rem; font-size: 1.7rem; font-weight: 500; }
.panel .sub { margin: 0 0 1.2rem; font-size: .9rem; opacity: .72; line-height: 1.55; }
.crest { font-size: 3.4rem; animation: bob 4s ease-in-out infinite; }
.tagline { margin: 0 0 1.6rem; letter-spacing: .3em; text-transform: uppercase; font-size: .7rem; opacity: .6; }
.footnote { margin: 1.4rem 0 0; font-size: .68rem; opacity: .4; }

.menu { display: flex; flex-direction: column; gap: 9px; }
.menu-row { display: flex; gap: 9px; justify-content: center; margin-top: 1.2rem; flex-wrap: wrap; }

.btn { padding: 12px 20px; border: 0; border-radius: 13px; cursor: pointer; font: 500 1rem var(--ui);
  color: var(--paper); background: rgba(255,255,255,.1);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); transition: transform .12s ease, background .15s ease; }
.btn:hover { background: rgba(255,255,255,.2); transform: translateY(-2px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .35; cursor: not-allowed; transform: none; }
.btn-primary { background: linear-gradient(135deg, var(--pink), var(--pink-deep)); color: #fff;
  box-shadow: 0 8px 22px rgba(226,73,127,.4); }
.btn-primary:hover { background: linear-gradient(135deg, #ff9dc0, #ee5a8e); }
.btn-quiet { background: transparent; opacity: .68; font-size: .9rem; }

/* ────────────────────────────────────────────────────────── level grid ── */

.level-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.level-card { position: relative; padding: 16px; text-align: left; border: 0; border-radius: 18px; cursor: pointer;
  color: var(--paper); font: inherit; overflow: hidden; min-height: 132px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.16); transition: transform .14s ease; }
.level-card:hover:not(:disabled) { transform: translateY(-4px); }
.level-card:disabled { cursor: not-allowed; filter: grayscale(.85) brightness(.6); }
.level-card b { display: block; font-size: 1.02rem; }
.level-card em { display: block; font-size: .74rem; font-style: normal; opacity: .72; margin-top: 2px; }
.level-card .num { position: absolute; top: 10px; right: 14px; font-size: 2.4rem; font-weight: 700; opacity: .18; }
.level-card .stat { margin-top: 10px; font-size: .78rem; display: flex; gap: 10px; flex-wrap: wrap; opacity: .92; }
.level-card .lock { position: absolute; inset: 0; display: grid; place-items: center; font-size: .82rem;
  background: rgba(10,6,16,.88); backdrop-filter: blur(3px); text-align: center; padding: 12px;
  line-height: 1.7; border-radius: 18px; }

/* ─────────────────────────────────────────────────────────── settings ── */

.settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px 22px; text-align: left; }
.settings label { display: flex; align-items: center; gap: 10px; font-size: .88rem; }
.settings label input[type=range] { flex: 1; accent-color: var(--pink); }
.settings label select { flex: none; margin-left: auto; padding: 6px 10px; border-radius: 9px; border: 0;
  background: rgba(255,255,255,.12); color: var(--paper); font: inherit; font-size: .84rem; }
.settings output { width: 2.4rem; text-align: right; font-variant-numeric: tabular-nums; opacity: .7; font-size: .8rem; }
.settings .check { accent-color: var(--pink); }

/* ─────────────────────────────────────────── how to play / journal ── */

.keys { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px 20px;
  text-align: left; margin-bottom: 1.2rem; }
.keys div { display: flex; align-items: baseline; gap: 8px; font-size: .86rem; }
.keys span { opacity: .74; }
kbd { background: rgba(255,255,255,.15); border-radius: 6px; padding: 2px 8px; font: 600 .78rem var(--ui);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.24); white-space: nowrap; }

.journal { text-align: left; display: grid; gap: 16px; }
.journal h3 { margin: 0 0 6px; font-size: .74rem; letter-spacing: .24em; text-transform: uppercase; color: var(--gold); }
.journal .row { display: flex; flex-wrap: wrap; gap: 8px; }
.journal .chip { display: flex; align-items: center; gap: 7px; padding: 8px 13px; border-radius: 12px;
  font-size: .84rem; background: rgba(255,255,255,.09); box-shadow: inset 0 0 0 1px rgba(255,255,255,.14); }
.journal .chip.off { opacity: .32; }
.journal .chip i { font-style: normal; font-size: 1.1rem; }
.journal .chip small { display: block; opacity: .62; font-size: .72rem; }

/* ──────────────────────────────────────────────────────────── results ── */

.tally { display: grid; gap: 8px; margin-bottom: 1.3rem; }
.tally div { display: flex; justify-content: space-between; padding: 9px 14px; border-radius: 12px;
  background: rgba(255,255,255,.08); font-size: .92rem; animation: slidein .3s ease backwards; }
.tally div:nth-child(2) { animation-delay: .1s; }
.tally div:nth-child(3) { animation-delay: .2s; }
.tally div:nth-child(4) { animation-delay: .3s; }
.tally b { color: var(--gold); font-variant-numeric: tabular-nums; }

.panel-ability { background: linear-gradient(165deg, rgba(96,48,120,.97), rgba(40,20,58,.97)); }

.credits { display: grid; gap: 14px; text-align: center; font-size: .9rem; line-height: 1.6; max-height: 54vh; overflow: auto; }
.credits h3 { margin: 0; font-size: .72rem; letter-spacing: .26em; text-transform: uppercase; color: var(--gold); }
.credits p { margin: 0; opacity: .82; }

/* ═════════════════════════════════════════════════════════════════ fade ══ */

.fade { position: fixed; inset: 0; z-index: 60; background: #0d0714; opacity: 0;
  pointer-events: none; transition: opacity .38s ease; }
.fade.on { opacity: 1; }

/* ═══════════════════════════════════════════════════════════════ small ══ */

@media (max-width: 640px) {
  .hud-left { display: none; }
  #minimap { width: 104px; height: 104px; }
  .panel { padding: 24px 20px; }
  .panel h1 { font-size: 3rem; }
  .banner span { font-size: 1.9rem; }
  .dialogue { gap: 10px; padding: 13px; }
  .dlg-face { width: 48px; height: 48px; font-size: 1.5rem; }
  .counters { font-size: .8rem; gap: 7px; padding: 6px 10px; }
}

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