@font-face { font-family: 'Galmuri11'; src: url('../fonts/Galmuri11.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Galmuri11'; font-weight: bold; src: url('../fonts/Galmuri11-Bold.woff2') format('woff2'); font-display: swap; }

:root {
  --ink: #1a1020;
  --paper: #fff6e0;
  --sun: #ffd23a;
  --coral: #ff6a4a;
  --sea: #2fb6c8;
  --deep: #123a5a;
  --panel: #2a1e3a;
  --panel-hi: #3d2c55;
  --gold: #ffd23a;
  --gold-hi: #fff3a0;
  --safe-top: env(safe-area-inset-top, 0px);   /* ui.js overrides with ?safetop=N */
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  background: var(--ink);
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
body { font-family: 'Galmuri11', monospace; color: var(--paper); word-break: keep-all; overflow-wrap: break-word; }   /* Korean words never split mid-word (ADV-17) */

#app { position: fixed; inset: 0; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; }

.hidden { display: none !important; }

.hud-btn {
  position: absolute; top: max(8px, var(--safe-top)); right: max(8px, env(safe-area-inset-right, 0px));   /* ui.js moves it under the xp bar during a run; side notch (PH-10) */
  width: 40px; height: 40px;
  font-family: inherit; font-weight: bold; font-size: 14px;
  color: var(--paper); background: rgba(26, 16, 32, .55);
  border: 2px solid var(--paper); border-radius: 4px;
  z-index: 5;
}

.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px;
  padding: max(24px, calc(var(--safe-top) + 12px)) 16px max(24px, calc(env(safe-area-inset-bottom, 0px) + 12px));
  text-align: center;
  z-index: 10;
  overflow-y: auto;
  justify-content: flex-start;   /* centred by the auto margins below, and still scrollable when taller than the screen */
}
.screen > :first-child { margin-top: auto; }
.screen > :last-child { margin-bottom: auto; }
.screen.dim { background: rgba(14, 8, 24, .86); }   /* .78 let level-up text / numbers show through (ADV-08) */
#screen-title, #screen-select {
  background:
    linear-gradient(180deg, #2fb6c8 0%, #6fd6d6 45%, #f1d9a0 46%, #e8c98a 100%);
}
#screen-title::before {
  content: ''; position: absolute; left: 50%; top: 18%; width: 120px; height: 120px; margin-left: -60px;
  background: radial-gradient(circle, #ffe98a 0 45%, #ffd23a 46% 60%, transparent 61%);
  image-rendering: pixelated; z-index: -1;
}

h2 { font-size: 22px; font-weight: bold; color: var(--paper); text-shadow: 2px 2px 0 var(--ink); }
.glow { color: var(--sun); }

.logo { line-height: 1; text-shadow: 3px 3px 0 var(--ink), -1px -1px 0 var(--ink); }
.logo-top { font-size: 64px; font-weight: bold; color: var(--sun); letter-spacing: 4px;
  text-shadow: 4px 4px 0 var(--ink), -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink), 0 6px 0 #c0571e; }
.logo-bottom { margin-top: 8px; font-size: 24px; font-weight: bold; color: var(--paper); letter-spacing: 6px;
  text-shadow: 2px 2px 0 var(--ink), -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink); }
.crew { display: flex; gap: 2px; align-items: flex-end; justify-content: center; height: 100px; }
.crew canvas { width: 92px; height: 92px; image-rendering: pixelated; animation: hop 0.9s steps(2) infinite; }
.crew canvas:nth-child(2n) { animation-delay: .45s; }
@keyframes hop { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@media (max-width: 600px) { .crew canvas { width: 46px; height: 46px; } .crew { height: 60px; } }
.tagline { font-size: 15px; color: var(--ink); background: var(--sun); padding: 4px 10px; border: 2px solid var(--ink); }
.hint { font-size: 12px; color: var(--ink); line-height: 1.6; }
.hint.small { font-size: 11px; opacity: .85; }

.btn {
  font-family: inherit; font-size: 15px; font-weight: bold;
  min-width: 180px; padding: 10px 18px;
  color: var(--ink); background: var(--paper);
  border: 3px solid var(--ink); border-radius: 0;
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn.big { background: var(--sun); font-size: 18px; min-width: 200px; }
.btn.ghost { background: transparent; color: var(--paper); border-color: var(--paper); box-shadow: none; }
.btn:disabled { opacity: .5; cursor: default; }   /* title buttons while the pictures load (PH-05) */
.btn:disabled:active { transform: none; box-shadow: 0 4px 0 var(--ink); }
#btn-quit.confirm { background: var(--coral); color: var(--ink); border-color: var(--ink); }   /* ask once more (ADV-06) */
#screen-title .btn.ghost, #screen-select .btn.ghost { color: var(--ink); border-color: var(--ink); }

.char-grid {
  display: grid; grid-template-columns: repeat(3, minmax(92px, 150px)); gap: 10px;
  width: 100%; max-width: 480px; justify-content: center;
}
@media (max-width: 340px) { .char-grid { grid-template-columns: repeat(2, minmax(92px, 150px)); } }
.char-card {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 6px; background: var(--paper); color: var(--ink);
  border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink); cursor: pointer;
  font-family: inherit;
}
.char-card:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.char-card canvas { width: 92px; height: 92px; image-rendering: pixelated; }
@media (max-width: 420px) { .char-card canvas { width: 69px; height: 69px; } }
.char-card .nm { font-size: 14px; font-weight: bold; }
.char-card .tt { font-size: 11px; color: #6a4a7a; }
.char-card .wp { font-size: 11px; background: var(--sun); padding: 1px 4px; }

.cards { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 420px; }
.card {
  display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 10px 12px; background: var(--panel); color: var(--paper);
  border: 3px solid var(--paper); box-shadow: 0 4px 0 var(--ink);
  font-family: inherit; cursor: pointer;
}
.card:active, .card.picked { background: var(--panel-hi); transform: translateY(2px); }
.card canvas { width: 54px; height: 54px; flex: 0 0 54px; image-rendering: pixelated; background: rgba(255,255,255,.08); border: 2px solid rgba(255,255,255,.25); }
.card .t { font-size: 15px; font-weight: bold; }
.card .lv { font-size: 11px; color: var(--sun); margin-left: 6px; }
.card .new { font-size: 11px; color: var(--ink); background: var(--sun); padding: 0 4px; margin-left: 6px; }
.card .d { font-size: 12px; opacity: .85; margin-top: 3px; line-height: 1.4; }

.stats { display: grid; grid-template-columns: auto auto; gap: 6px 18px; font-size: 15px; text-align: left; }
.stats .k { color: #c9b8e0; }
.stats .v { color: var(--sun); font-weight: bold; text-align: right; }
.build { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; max-width: 360px; }
.build canvas { width: 36px; height: 36px; image-rendering: pixelated; background: rgba(255,255,255,.08); }

#hint {
  position: absolute; left: 50%; bottom: max(18%, env(safe-area-inset-bottom)); transform: translateX(-50%);
  padding: 8px 14px; font-size: 14px; color: var(--paper); background: rgba(26, 16, 32, .72);
  border: 2px solid var(--paper); white-space: nowrap; z-index: 6; pointer-events: none;
  transition: opacity .6s;
}
#hint.off { opacity: 0; }

/* ---------------- WP-UI: character select ---------------- */
.select-stage { font-size: 13px; color: var(--ink); background: var(--paper); border: 2px solid var(--ink); padding: 3px 10px; }
.char-card .bn { font-size: 11px; color: #3a6a2a; line-height: 1.35; max-width: 140px; }
.char-card:focus-visible, .card:focus-visible, .btn:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; }

/* ---------------- level-up cards (3-7): slide in from the right, now -> next, pair icon, clover on the 4th ---------------- */
#screen-levelup { overflow-x: hidden; }
.card { position: relative; }
.card .ic { position: relative; flex: 0 0 54px; width: 54px; height: 54px; }
.card .ic > canvas { width: 54px; height: 54px; }
.card .pair { position: absolute; right: -8px; bottom: -8px; width: 24px; height: 24px; padding: 1px;
  background: var(--panel); border: 2px solid #8a7aa0; }
.card .pair.owned { border-color: var(--gold); background: #4a3a1a; }
.card .pair canvas { display: block; width: 18px; height: 18px; flex: none; background: none; border: 0; image-rendering: pixelated; }
.card .body { min-width: 0; }
.card .nx { font-size: 13px; color: #9fffb0; margin-top: 3px; line-height: 1.35; }
.card .clover { position: absolute; top: -9px; right: -9px; width: 26px; height: 26px; padding: 2px;
  background: #2f8a2a; border: 2px solid #a8f080; transform: rotate(8deg); }
.card .clover canvas { display: block; width: 18px; height: 18px; flex: none; background: none; border: 0; image-rendering: pixelated; }
.card.luck { border-color: #a8f080; }
.card.enter { animation-name: card-in; animation-timing-function: cubic-bezier(.2, .9, .3, 1); animation-fill-mode: both; }
@keyframes card-in { from { transform: translateX(110vw); } to { transform: translateX(0); } }
.card.picked { border-color: var(--sun); }
.card.evo { background: var(--evo-bg, var(--gold)); color: var(--ink); border-color: var(--ink); }
.card.evo .nx { color: #6a2a00; }
@media (hover: hover) { .card:hover { background: var(--panel-hi); } }

/* ---------------- pause: items, 14-row stat table, sound + settings toggles ---------------- */
.build .bi { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: #c9b8e0; }
.build .bi canvas { width: 36px; height: 36px; border: 2px solid rgba(255,255,255,.25); }
.build .bi.ready canvas { border-color: var(--gold); background: rgba(255, 210, 58, .3); animation: evo-blink .5s steps(2) infinite; }
.build .bi.evolved canvas { border-color: var(--gold); background: rgba(255, 190, 40, .25); }
.build .bi.ready span, .build .bi.evolved span { color: var(--sun); }
@keyframes evo-blink { 50% { border-color: var(--gold-hi); background: rgba(255, 210, 58, .55); } }
.stat-table { width: 100%; max-width: 300px; display: flex; flex-direction: column; gap: 1px;
  background: rgba(255,255,255,.12); border: 2px solid rgba(255,255,255,.25); padding: 2px; }
.stat-row { display: flex; justify-content: space-between; gap: 12px; padding: 2px 8px; font-size: 13px; line-height: 1.3; background: #160d22; }
.stat-row .k { color: #c9b8e0; }
.stat-row .v { color: #8a7aa0; font-weight: bold; }
.stat-row.on .v { color: var(--sun); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 380px; }
.btn.small { min-width: 0; font-size: 13px; padding: 7px 10px; box-shadow: 0 3px 0 var(--ink); }
.btn.toggle.off { background: #7a6a8a; color: #e8e0f0; }

/* ---------------- result: coin count-up, unlock notes, damage per weapon ---------------- */
.over-sub { font-size: 13px; color: #c9b8e0; margin-top: -8px; }
.over-warn { font-size: 12px; line-height: 1.4; color: var(--ink); background: #ffb0a0; border: 2px solid var(--ink); padding: 3px 8px; max-width: 340px; }   /* storage off (PH-12) */
.stats .v.coin { color: var(--sun); }
.stats .v.coin span.done { text-shadow: 0 0 6px rgba(255, 210, 58, .8); }
.unlocks { display: flex; flex-direction: column; gap: 4px; }
.unlock { font-size: 14px; font-weight: bold; color: var(--ink); background: var(--sun); border: 2px solid var(--ink); padding: 4px 10px;
  animation: unlock-pop .5s steps(3) both; }
@keyframes unlock-pop { from { transform: scale(1.3); } to { transform: scale(1); } }
.dmg-table { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 3px; font-size: 13px; text-align: left; }
.dmg-head { display: grid; grid-template-columns: 1fr 96px 40px; gap: 6px; font-size: 11px; color: #c9b8e0; padding: 0 2px; }
.dmg-head span:nth-child(n+2) { text-align: right; }
.dmg-row { display: grid; grid-template-columns: 26px minmax(0, 1fr) 96px 40px; gap: 6px; align-items: center;
  padding: 2px; background: #241a30; border: 1px solid rgba(255,255,255,.12); }   /* opaque: no numbers behind (ADV-08) */
.dmg-row.evo { border-color: var(--gold); }
.dmg-row .ic canvas { display: block; width: 24px; height: 24px; image-rendering: pixelated; }
.dmg-row .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dmg-row .sum { position: relative; height: 18px; background: rgba(14, 8, 24, .6); }
.dmg-row .sum i { position: absolute; left: 0; top: 0; bottom: 0; background: #c0571e; }
.dmg-row .sum b { position: relative; display: block; text-align: right; padding-right: 4px; line-height: 18px; color: var(--paper); text-shadow: 1px 1px 0 var(--ink); }
.dmg-row .pc { text-align: right; color: var(--sun); font-weight: bold; }
.dmg-none { font-size: 12px; color: #8a7aa0; text-align: center; }
@media (max-height: 700px) { .screen { gap: 10px; } .stat-row { font-size: 12px; padding: 1px 8px; } }
/* phone held sideways (PH-11): the main button stays in sight at the bottom while the tall table scrolls under it */
@media (max-height: 500px) { #btn-resume, #btn-retry { position: sticky; bottom: 6px; z-index: 2; } }
