/* Critter Quest. One look for every screen: parchment panels with dark pixel outlines on a deep plum
   night, chunky buttons, and the game canvas on top. Pixel borders are box-shadows, so the corners
   step like pixel art and every color can be tinted. */
/* Pixel fonts, kept in fonts/ so the game works offline. Both are SIL Open Font License, see fonts/. */
@font-face { font-family: "Tiny5"; src: url(../fonts/tiny5-latin.woff2) format("woff2"); font-display: block; }
@font-face { font-family: "Jersey 10"; src: url(../fonts/jersey10-latin.woff2) format("woff2"); font-display: block; }
:root {
  --p: 3px;
  --ink: #2b1d2a;
  --ink-2: #5a4350;
  --paper: #fff6e2;
  --paper-2: #f3e2bf;
  --paper-3: #e6cc9c;
  --wood: #b9773f;
  --wood-2: #8a5230;
  --gold: #f6c453;
  --gold-2: #d99a2b;
  --night: #1b1424;
  --night-2: #2a2140;
  --night-3: #3b2f5a;
  --night-4: #54477a;
  --cream: #fff8e8;
  --red: #e8573f;
  --blue: #3f86d8;
  --green: #4fb35a;
  --hp-hi: #5ad46a;
  --hp-mid: #f2c230;
  --hp-lo: #ec4a3c;
  --font: "Tiny5", "Trebuchet MS", "Segoe UI", sans-serif;
  --deck-h: clamp(196px, 26dvh, 240px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
html, body { margin: 0; height: 100%; background: var(--night); overflow: hidden; touch-action: none; overscroll-behavior: none; }
body { font-family: var(--font); color: var(--ink); -webkit-font-smoothing: antialiased; }
img { -webkit-user-drag: none; user-drag: none; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; touch-action: manipulation; }
img.px-img, .px-img { image-rendering: pixelated; image-rendering: crisp-edges; }
[hidden] { display: none !important; }

/* ---------- pixel frames ---------- */
.px {
  --k: var(--ink); --hi: rgba(255, 255, 255, 0.55); --lo: rgba(120, 70, 30, 0.22); --bg: var(--paper);
  background: var(--bg);
  box-shadow:
    0 calc(-1 * var(--p)) 0 0 var(--k), 0 var(--p) 0 0 var(--k), calc(-1 * var(--p)) 0 0 0 var(--k), var(--p) 0 0 0 var(--k),
    inset 0 var(--p) 0 0 var(--hi), inset 0 calc(-1 * var(--p)) 0 0 var(--lo),
    0 calc(var(--p) * 2.5) 0 0 rgba(10, 4, 16, 0.35);
  margin: var(--p);
}
.px.dark { --bg: var(--night-2); --hi: rgba(255, 255, 255, 0.12); --lo: rgba(0, 0, 0, 0.3); --k: #0d0814; color: var(--cream); }
.px.flat { box-shadow: 0 calc(-1 * var(--p)) 0 0 var(--k), 0 var(--p) 0 0 var(--k), calc(-1 * var(--p)) 0 0 0 var(--k), var(--p) 0 0 0 var(--k), inset 0 var(--p) 0 0 var(--hi), inset 0 calc(-1 * var(--p)) 0 0 var(--lo); }

.btn {
  --bg: var(--paper); --hi: rgba(255, 255, 255, 0.7); --lo: rgba(110, 60, 20, 0.28);
  position: relative; display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 14px;
  font-size: 19px; font-weight: 600; line-height: 1.05; text-align: left;
  transition: transform 0.06s, filter 0.1s;
}
.btn.px { box-shadow:
    0 calc(-1 * var(--p)) 0 0 var(--k), 0 var(--p) 0 0 var(--k), calc(-1 * var(--p)) 0 0 0 var(--k), var(--p) 0 0 0 var(--k),
    inset 0 var(--p) 0 0 var(--hi), inset 0 calc(-2 * var(--p)) 0 0 var(--lo),
    0 calc(var(--p) * 2) 0 0 rgba(10, 4, 16, 0.4); }
.btn:active, .btn.pressed { transform: translateY(2px); filter: brightness(0.95); }
.btn.focus { outline: none; --k: #000; }
.btn.focus::after { content: ''; position: absolute; inset: -9px; border: 3px solid var(--gold); pointer-events: none; animation: pulse 0.9s ease-in-out infinite; }
.btn[disabled], .btn.off { filter: grayscale(0.7) brightness(0.85); opacity: 0.7; }
.btn .sub { display: block; font-size: 14px; font-weight: 500; color: var(--ink-2); margin-top: 3px; }
.btn .grow { flex: 1; min-width: 0; }
.btn .tag { font-size: 15px; color: var(--ink-2); white-space: nowrap; }
.btn img { width: 32px; height: 32px; image-rendering: pixelated; flex: none; }
.btn.center { justify-content: center; text-align: center; }
.btn.gold { --bg: var(--gold); --lo: rgba(140, 70, 0, 0.35); }
.btn.green { --bg: #7fd27a; --lo: rgba(20, 90, 20, 0.35); }
.btn.red { --bg: #f2876c; --lo: rgba(130, 30, 10, 0.35); }
.btn.blue { --bg: #8cc0f2; --lo: rgba(20, 60, 120, 0.35); }
.btn.dark { --bg: var(--night-3); --hi: rgba(255, 255, 255, 0.18); --lo: rgba(0, 0, 0, 0.35); --k: #0d0814; color: var(--cream); }
.btn.dark .sub, .btn.dark .tag { color: #cbbfe6; }
@keyframes pulse { 50% { opacity: 0.35; } }

/* ---------- layout ---------- */
#app { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--night); }
#stage { position: relative; flex: 1; min-height: 0; overflow: hidden; background: #0e0a14; }
#game { position: absolute; left: 0; top: 0; display: block; image-rendering: pixelated; image-rendering: crisp-edges; }
#deck {
  position: relative; height: calc(var(--deck-h) + var(--safe-b)); padding-bottom: var(--safe-b); flex: none;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(120, 90, 180, 0.22), transparent 60%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.025) 0 6px, transparent 6px 12px),
    linear-gradient(#251b36, #160f20);
  border-top: 3px solid #0d0814; box-shadow: inset 0 2px 0 #71608477;
  display: flex; align-items: center; justify-content: space-between; padding-left: max(18px, var(--safe-l)); padding-right: max(18px, var(--safe-r));
}
#pad-zone, #btn-zone { position: relative; display: flex; align-items: center; justify-content: center; }
#btn-zone { flex-direction: column; gap: 18px; align-items: flex-end; }
#dpad { position: relative; width: 168px; height: 168px; touch-action: none; }
#dpad span {
  position: absolute; width: 58px; height: 58px; background: #3f3456;
  box-shadow: 0 -3px 0 0 #0d0814, 0 3px 0 0 #0d0814, -3px 0 0 0 #0d0814, 3px 0 0 0 #0d0814, inset 0 3px 0 rgba(255,255,255,0.18), inset 0 -5px 0 rgba(0,0,0,0.35), 0 7px 0 0 rgba(0,0,0,0.35);
}
#dpad span::after { content: ''; position: absolute; left: 50%; top: 50%; border: 9px solid transparent; transform: translate(-50%, -50%); }
#dpad .u { left: 55px; top: 0; } #dpad .u::after { border-bottom-color: #a99bcc; margin-top: -5px; }
#dpad .d { left: 55px; bottom: 0; } #dpad .d::after { border-top-color: #a99bcc; margin-top: 5px; }
#dpad .l { left: 0; top: 55px; } #dpad .l::after { border-right-color: #a99bcc; margin-left: -5px; }
#dpad .r { right: 0; top: 55px; } #dpad .r::after { border-left-color: #a99bcc; margin-left: 5px; }
#dpad i { position: absolute; left: 55px; top: 55px; width: 58px; height: 58px; background: #3f3456; box-shadow: inset 0 3px 0 rgba(255,255,255,0.1); }
#dpad i::after { content: ''; position: absolute; inset: 18px; border-radius: 50%; background: #2a2140; box-shadow: inset 0 2px 0 rgba(0,0,0,0.4); }
#dpad[data-dir="up"] .u, #dpad[data-dir="down"] .d, #dpad[data-dir="left"] .l, #dpad[data-dir="right"] .r { background: #6a58a0; transform: translateY(2px); }
#dpad[data-dir="up"] .u::after { border-bottom-color: var(--gold); } #dpad[data-dir="down"] .d::after { border-top-color: var(--gold); }
#dpad[data-dir="left"] .l::after { border-right-color: var(--gold); } #dpad[data-dir="right"] .r::after { border-left-color: var(--gold); }
#ab { position: relative; width: 168px; height: 128px; }
.round {
  position: absolute; width: 74px; height: 74px; border-radius: 50%; font-size: 26px; font-weight: 700; color: #fff;
  text-shadow: 0 2px 0 rgba(0,0,0,0.35);
  box-shadow: 0 0 0 3px #0d0814, inset 0 4px 0 rgba(255,255,255,0.35), inset 0 -7px 0 rgba(0,0,0,0.28), 0 7px 0 0 rgba(0,0,0,0.4);
  transition: transform 0.05s;
}
.round.a { right: 0; top: 0; background: var(--red); }
.round.b { left: 0; bottom: 0; background: var(--blue); }
.round.on, .pill.on { transform: translateY(3px); filter: brightness(1.15); }
.pill {
  height: 36px; padding: 0 18px; border-radius: 18px; font-size: 15px; font-weight: 700; letter-spacing: 2px; color: var(--cream);
  background: #3f3456; box-shadow: 0 0 0 3px #0d0814, inset 0 3px 0 rgba(255,255,255,0.15), inset 0 -4px 0 rgba(0,0,0,0.3), 0 5px 0 rgba(0,0,0,0.35);
}
#deck-panel { position: absolute; inset: 0; padding: 12px max(12px, var(--safe-r)) calc(12px + var(--safe-b)) max(12px, var(--safe-l)); display: none; flex-direction: column; gap: 10px; }

/* Battles in portrait swap the pad for the battle panel. */
body.battle #pad-zone, body.battle #btn-zone { visibility: hidden; }
body.battle #deck-panel { display: flex; }

/* Phones held sideways and desktops: the stage fills the screen and controls float over it. */
body.wide #deck { position: absolute; inset: 0; height: auto; background: none; border: 0; box-shadow: none; pointer-events: none; padding: 0; }
body.wide #pad-zone { position: absolute; left: max(14px, var(--safe-l)); bottom: max(14px, var(--safe-b)); pointer-events: auto; opacity: 0.88; }
body.wide #btn-zone { position: absolute; right: max(14px, var(--safe-r)); bottom: max(14px, var(--safe-b)); pointer-events: auto; opacity: 0.88; }
body.wide #menu-btn { position: fixed; right: max(14px, var(--safe-r)); top: max(10px, var(--safe-t)); }
body.wide #dpad { transform: scale(0.82); transform-origin: left bottom; }
body.wide #ab { transform: scale(0.82); transform-origin: right bottom; }
body.wide #deck-panel { top: auto; height: auto; pointer-events: auto; flex-direction: row; align-items: flex-end; }
body.desktop #pad-zone, body.desktop #btn-zone { display: none; }

/* ---------- HUD ---------- */
#hud { position: absolute; left: 0; right: 0; top: 0; display: flex; justify-content: space-between; align-items: flex-start; padding: max(8px, var(--safe-t)) max(8px, var(--safe-r)) 0 max(8px, var(--safe-l)); pointer-events: none; gap: 8px; }
.hud-left, .hud-right { display: flex; gap: 8px; align-items: center; }
body.wide .hud-right { margin-right: 108px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px; font-size: 16px; font-weight: 600; color: var(--cream);
  background: rgba(27, 20, 36, 0.78); box-shadow: 0 -2px 0 0 #0d0814, 0 2px 0 0 #0d0814, -2px 0 0 0 #0d0814, 2px 0 0 0 #0d0814, inset 0 2px 0 rgba(255,255,255,0.1);
  margin: 2px; white-space: nowrap;
}
.chip img { width: 20px; height: 20px; image-rendering: pixelated; }
.chip .ico { font-size: 14px; display: inline-flex; align-items: center; }
.pix-ico { image-rendering: pixelated; vertical-align: middle; }
#hud-place { transition: opacity 0.4s; }
#banner {
  position: absolute; left: 50%; top: 22%; transform: translateX(-50%); padding: 10px 26px 12px; font-size: 26px; font-weight: 700; color: var(--cream);
  background: rgba(27, 20, 36, 0.85); text-shadow: 0 3px 0 #0d0814; letter-spacing: 1px; white-space: nowrap; pointer-events: none;
  box-shadow: 0 -3px 0 0 #0d0814, 0 3px 0 0 #0d0814, -3px 0 0 0 #0d0814, 3px 0 0 0 #0d0814, inset 0 3px 0 rgba(255,255,255,0.12), inset 0 -3px 0 var(--gold-2);
  animation: banner 2.4s ease forwards;
}
#banner small { display: block; font-size: 14px; font-weight: 500; color: #cbbfe6; text-align: center; margin-top: 2px; letter-spacing: 2px; text-transform: uppercase; }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, -12px); } 12% { opacity: 1; transform: translate(-50%, 0); } 80% { opacity: 1; } 100% { opacity: 0; } }
#toast { position: absolute; left: 50%; top: 56px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; z-index: 6; }
/* in battle the foe card fills the top, so news drops in between the two creatures */
body.battle #toast { top: 38%; }
#toast .t { display: flex; align-items: center; gap: 8px; padding: 6px 14px; font-size: 16px; font-weight: 600; animation: toast 2.6s ease forwards; white-space: nowrap; }
#toast .t img { width: 24px; height: 24px; image-rendering: pixelated; }
@keyframes toast { 0% { opacity: 0; transform: translateY(-10px); } 10%, 85% { opacity: 1; transform: none; } 100% { opacity: 0; } }

/* ---------- dialog and choices ---------- */
#layer { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
#layer > * { pointer-events: auto; }
.dialog {
  position: absolute; left: 50%; bottom: max(10px, var(--safe-b)); transform: translateX(-50%); width: min(640px, calc(100% - 22px));
  min-height: 96px; padding: 14px 18px 16px; font-size: 19px; line-height: 1.35; font-weight: 500; cursor: pointer;
}
body.wide:not(.desktop) .dialog { width: min(560px, calc(100% - 380px)); }
.dialog .name {
  position: absolute; left: 12px; top: -22px; padding: 3px 12px 4px; font-size: 16px; font-weight: 700; color: var(--cream);
  background: var(--wood); box-shadow: 0 -3px 0 0 var(--ink), 0 3px 0 0 var(--ink), -3px 0 0 0 var(--ink), 3px 0 0 0 var(--ink), inset 0 3px 0 rgba(255,255,255,0.25);
}
.dialog .text { min-height: 52px; white-space: pre-wrap; }
.dialog .next { position: absolute; right: 14px; bottom: 6px; width: 0; height: 0; border: 7px solid transparent; border-top: 9px solid var(--wood-2); animation: bob 0.7s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(3px); } }
.choices { position: absolute; right: max(12px, var(--safe-r)); display: flex; flex-direction: column; gap: 9px; min-width: 150px; max-width: min(360px, calc(100% - 24px)); max-height: 70%; overflow-y: auto; padding: 6px; }
.choices.grid { display: grid; grid-template-columns: 1fr 1fr; }
.choices.solo { left: 50%; right: auto; transform: translateX(-50%); bottom: 20px; width: min(420px, calc(100% - 24px)); max-width: none; }
.choices .btn { min-height: 50px; }

/* In a battle the dialog moves into the panel. */
.battle-msg { position: relative; flex: none; min-height: 78px; padding: 12px 16px 14px; font-size: 19px; line-height: 1.32; font-weight: 500; }
.battle-msg .text { white-space: pre-wrap; }
.battle-msg .next { position: absolute; right: 12px; bottom: 6px; width: 0; height: 0; border: 7px solid transparent; border-top: 9px solid var(--wood-2); animation: bob 0.7s ease-in-out infinite; }
.battle-cmds { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 4px; align-content: start; }
.battle-cmds .btn { min-height: 60px; font-size: 21px; justify-content: center; text-align: center; }
.battle-cmds .btn.fight { grid-column: span 2; min-height: 66px; font-size: 24px; }
.battle-cmds.moves .btn { justify-content: flex-start; text-align: left; font-size: 18px; min-height: 64px; }
.battle-cmds.moves .btn .type { display: inline-block; font-size: 12px; font-weight: 700; color: #fff; padding: 1px 6px; margin-top: 4px; text-transform: uppercase; letter-spacing: 1px; }
.battle-cmds .back { grid-column: span 2; min-height: 44px; font-size: 17px; }
.battle-cmds.list { grid-template-columns: 1fr; }
.battle-cmds.list .btn { justify-content: flex-start; text-align: left; min-height: 54px; font-size: 18px; }
.team-dots { display: flex; gap: 8px; justify-content: center; padding: 10px 0; }
.team-dots i { width: 16px; height: 16px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 2px #0d0814, inset 0 -3px 0 rgba(0,0,0,0.25); }
.team-dots i.out { background: #5a5068; } .team-dots i.empty { background: transparent; box-shadow: 0 0 0 2px #4a3f5e; }
body.wide .battle-msg { flex: 1; max-width: 560px; }
body.wide .battle-cmds { flex: none; width: min(380px, 46%); }
body.wide .battle-cmds:empty { display: none; }

/* ---------- battle cards ---------- */
#battle-hud { position: absolute; inset: 0; pointer-events: none; }
.card { position: absolute; width: min(220px, 58%); padding: 8px 12px 10px; color: var(--ink); }
.card.foe { left: max(10px, var(--safe-l)); top: max(12px, var(--safe-t)); }
.card.me { right: max(10px, var(--safe-r)); bottom: 14px; }
body.wide .card.me { bottom: 112px; }
.card .row { display: flex; align-items: baseline; gap: 6px; }
.card .nm { font-size: 18px; font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .lv { font-size: 15px; font-weight: 600; color: var(--ink-2); }
.card .meta { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.type-chip { display: inline-block; font-size: 11px; font-weight: 700; color: #fff; padding: 1px 6px 2px; text-transform: uppercase; letter-spacing: 1px; text-shadow: 0 1px 0 rgba(0,0,0,0.3); }
.status-chip { display: inline-block; font-size: 11px; font-weight: 700; color: #fff; padding: 1px 6px 2px; text-transform: uppercase; letter-spacing: 1px; background: #8a7aa8; }
.status-chip.burn { background: #e0663a; } .status-chip.sleep { background: #7a7a96; } .status-chip.dizzy { background: #b07ae0; }
.hpbar { flex: 1; height: 12px; background: #3a2d40; position: relative; box-shadow: 0 0 0 2px var(--ink); }
.hpbar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--hp-hi); box-shadow: inset 0 3px 0 rgba(255,255,255,0.35), inset 0 -3px 0 rgba(0,0,0,0.15); }
.hpbar i.mid { background: var(--hp-mid); } .hpbar i.lo { background: var(--hp-lo); }
.hpbar b { position: absolute; left: -26px; top: -2px; font-size: 11px; font-weight: 700; color: var(--wood-2); }
.card .hpnum { font-size: 15px; font-weight: 600; text-align: right; margin-top: 4px; }
.xpbar { height: 5px; background: #d9c39a; margin-top: 5px; position: relative; }
.xpbar i { position: absolute; left: 0; top: 0; bottom: 0; background: #4f9de8; transition: width 0.6s; }
.card .balls { display: flex; gap: 4px; margin-top: 6px; }
.card .balls i { width: 10px; height: 10px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 2px var(--ink); }
.card .balls i.out { background: #8a8094; }

/* ---------- sheets (full screen menus) ---------- */
#sheets { position: fixed; inset: 0; pointer-events: none; z-index: 20; }
.sheet {
  position: absolute; inset: 0; pointer-events: auto; display: flex; flex-direction: column; color: var(--cream);
  background:
    linear-gradient(180deg, #1b1224e8 0%, #1b1224f7 46%, #16101d 100%),
    url('../art/objects/title_art.png') center 42% / cover no-repeat, var(--night);
  animation: sheetIn 0.18s ease-out;
  padding-top: var(--safe-t);
}
.sheet.closing { animation: sheetOut 0.14s ease-in forwards; }
@keyframes sheetIn { from { opacity: 0; transform: translateY(18px); } }
@keyframes sheetOut { to { opacity: 0; transform: translateY(18px); } }
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 12px max(14px, var(--safe-r)) 10px max(14px, var(--safe-l)); flex: none; }
.sheet-head h1 { margin: 0; font-size: 26px; font-weight: 700; flex: 1; text-shadow: 0 3px 0 #0d0814; letter-spacing: 0.5px; }
.sheet-head .x { width: 48px; height: 48px; min-height: 48px; justify-content: center; font-size: 22px; padding: 0; }
.sheet-body { flex: 1; overflow-y: auto; padding: 6px max(16px, var(--safe-r)) calc(24px + var(--safe-b)) max(16px, var(--safe-l)); -webkit-overflow-scrolling: touch; touch-action: pan-y; }
.sheet-body > * { max-width: 720px; margin-left: auto; margin-right: auto; }
.sheet-foot { flex: none; display: flex; gap: 12px; padding: 10px max(16px, var(--safe-r)) calc(14px + var(--safe-b)) max(16px, var(--safe-l)); justify-content: center; }
.sheet-foot .btn { flex: 1; max-width: 340px; justify-content: center; }
.section-title { font-size: 15px; font-weight: 600; color: #b9acd9; letter-spacing: 2px; text-transform: uppercase; margin: 18px auto 10px; }
.stack { display: flex; flex-direction: column; gap: 14px; }

/* pause menu */
.menu-top { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 12px 16px; margin-bottom: 16px; }
.menu-top .stat { display: flex; align-items: center; gap: 6px; font-size: 18px; font-weight: 600; }
.menu-top .stat img { width: 26px; height: 26px; image-rendering: pixelated; }
.menu-top .tokens { display: flex; gap: 6px; margin-left: auto; }
.menu-top .tokens img { width: 30px; height: 30px; image-rendering: pixelated; }
.menu-top .tokens img.miss { filter: grayscale(1) brightness(0.45); opacity: 0.6; }
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.menu-grid .btn { flex-direction: column; align-items: center; justify-content: center; text-align: center; min-height: 104px; font-size: 20px; gap: 6px; }
.menu-grid .btn img { width: 48px; height: 48px; }
.menu-grid .btn .sub { margin: 0; }
.party-strip { display: flex; gap: 8px; justify-content: center; margin: 0 auto 14px; }
.party-strip .mini { width: 52px; height: 52px; display: flex; align-items: center; justify-content: center; }
.party-strip .mini img { width: 48px; height: 48px; image-rendering: pixelated; }

/* creature cards */
.mon { display: grid; grid-template-columns: 64px 1fr; gap: 4px 12px; align-items: center; padding: 10px 14px 12px; min-height: 86px; cursor: pointer; text-align: left; width: calc(100% - 6px); }
.mon .pic { grid-row: span 2; width: 64px; height: 64px; display: flex; align-items: center; justify-content: center; }
.mon .pic img { width: 64px; height: 64px; image-rendering: pixelated; }
.mon .top { display: flex; align-items: baseline; gap: 8px; }
.mon .nm { font-size: 20px; font-weight: 700; flex: 1; }
.mon .lv { font-size: 16px; font-weight: 600; color: var(--ink-2); }
.mon .bar { display: flex; align-items: center; gap: 8px; }
.mon .bar .hpbar { height: 11px; }
.mon .bar .num { font-size: 15px; font-weight: 600; min-width: 64px; text-align: right; }
.mon.lead { --bg: #fff1c9; }
.mon.fainted { --bg: #e8d8cf; }
.mon.fainted .pic img { filter: grayscale(1); opacity: 0.6; }
.mon .badge { font-size: 12px; font-weight: 700; color: #fff; background: var(--wood); padding: 1px 6px; letter-spacing: 1px; }

/* creature detail */
.detail-hero { display: flex; gap: 16px; align-items: center; padding: 14px 16px; }
.detail-hero .pic { width: 112px; height: 112px; flex: none; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at 50% 70%, rgba(255,255,255,0.7), transparent 70%); }
.detail-hero .pic img { width: 96px; height: 96px; image-rendering: pixelated; }
.detail-hero h2 { margin: 0 0 4px; font-size: 26px; }
.detail-hero p { margin: 6px 0 0; font-size: 16px; color: var(--ink-2); line-height: 1.3; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding: 12px 14px; text-align: center; }
.stat-grid b { display: block; font-size: 22px; }
.stat-grid span { font-size: 13px; color: var(--ink-2); text-transform: uppercase; letter-spacing: 1px; }
.moves { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.move { padding: 10px 12px; font-size: 17px; font-weight: 600; }
.move .sub { font-size: 13px; font-weight: 500; color: var(--ink-2); margin-top: 4px; display: flex; gap: 6px; align-items: center; }
.row-btns { display: flex; gap: 12px; flex-wrap: wrap; }
.row-btns .btn { flex: 1; justify-content: center; min-width: 140px; }

/* bag and shop */
.item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; min-height: 70px; width: calc(100% - 6px); text-align: left; }
.item img { width: 48px; height: 48px; image-rendering: pixelated; flex: none; }
.item .grow { flex: 1; min-width: 0; }
.item .nm { font-size: 19px; font-weight: 700; }
.item .about { font-size: 14px; color: var(--ink-2); margin-top: 3px; line-height: 1.25; }
.item .count { font-size: 20px; font-weight: 700; min-width: 44px; text-align: right; }
.item .price { display: flex; align-items: center; gap: 4px; font-size: 18px; font-weight: 700; white-space: nowrap; }
.item .price img { width: 22px; height: 22px; }
.qty { display: flex; align-items: center; gap: 10px; justify-content: center; margin: 18px auto; }
.qty .btn { width: 56px; justify-content: center; font-size: 26px; padding: 0; }
.qty .n { font-size: 30px; font-weight: 700; min-width: 70px; text-align: center; }
.wallet { display: flex; align-items: center; gap: 6px; font-size: 20px; font-weight: 700; }
.wallet img { width: 26px; height: 26px; image-rendering: pixelated; }

/* dex */
.dex-head { display: flex; gap: 16px; justify-content: center; font-size: 17px; margin-bottom: 12px; color: #d8cdf0; }
.dex-head b { color: var(--gold); }
.dex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 12px; }
.dex-cell { display: flex; flex-direction: column; align-items: center; padding: 6px 4px 8px; min-height: 108px; justify-content: space-between; }
.dex-cell img { width: 64px; height: 64px; image-rendering: pixelated; }
.dex-cell img.seen { filter: brightness(0) opacity(0.55); }
.dex-cell .no { font-size: 12px; color: var(--ink-2); align-self: flex-start; padding-left: 4px; }
.dex-cell .nm { font-size: 14px; font-weight: 700; }
.dex-cell.unknown { --bg: #d9c8a6; }
.dex-cell.unknown .q { font-size: 34px; font-weight: 700; color: rgba(90, 60, 40, 0.4); height: 64px; display: flex; align-items: center; }
.evo { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; padding: 10px; }
.evo .step { display: flex; flex-direction: column; align-items: center; font-size: 14px; font-weight: 600; }
.evo .step img { width: 56px; height: 56px; image-rendering: pixelated; }
.evo .arrow { font-size: 13px; color: var(--ink-2); text-align: center; }
.where { font-size: 16px; line-height: 1.4; padding: 12px 14px; }

/* travel */
.place { display: flex; align-items: center; gap: 14px; padding: 12px 14px; min-height: 78px; width: calc(100% - 6px); text-align: left; }
.place .pin img { width: 32px; height: 32px; image-rendering: pixelated; }
.place .pin { width: 44px; height: 44px; flex: none; display: flex; align-items: center; justify-content: center; font-size: 26px; background: var(--paper-2); box-shadow: 0 0 0 2px var(--ink); }
.place .nm { font-size: 21px; font-weight: 700; }
.place .sub { font-size: 14px; color: var(--ink-2); margin-top: 3px; }
.place.here { --bg: #fff1c9; }

/* settings */
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 16px; min-height: 64px; width: calc(100% - 6px); font-size: 19px; font-weight: 600; }
.toggle .sw { width: 58px; height: 30px; background: #b8a88a; position: relative; box-shadow: 0 0 0 3px var(--ink); flex: none; }
.toggle .sw::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; background: var(--paper); box-shadow: inset 0 -3px 0 rgba(0,0,0,0.2); transition: left 0.15s; }
.toggle.on .sw { background: var(--green); }
.toggle.on .sw::after { left: 31px; }
.toggle .sub { display: block; font-size: 14px; font-weight: 500; color: var(--ink-2); margin-top: 2px; }

/* ---------- title ---------- */
#title { position: fixed; inset: 0; z-index: 15; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: calc(8vh + var(--safe-t)) 20px calc(28px + var(--safe-b)); pointer-events: none; }
#title > * { pointer-events: auto; }
.logo { text-align: center; animation: logoIn 0.9s cubic-bezier(.2,1.4,.4,1) both; }
.logo h1 {
  margin: 0; font-size: clamp(46px, 13vw, 88px); line-height: 0.95; font-weight: 700; color: var(--gold); letter-spacing: 1px;
  text-shadow: 0 4px 0 #b36a1c, 0 8px 0 #2b1d2a, 4px 0 0 #2b1d2a, -4px 0 0 #2b1d2a, 0 -4px 0 #2b1d2a, 4px 4px 0 #2b1d2a, -4px 4px 0 #2b1d2a, 4px 8px 0 #2b1d2a, -4px 8px 0 #2b1d2a, 0 14px 18px rgba(0,0,0,0.45);
}
.logo .sub { display: inline-block; margin-top: 18px; padding: 5px 14px 6px; font-size: clamp(15px, 4vw, 20px); font-weight: 600; color: var(--cream); background: rgba(27, 20, 36, 0.75); letter-spacing: 2px; box-shadow: 0 -3px 0 0 #0d0814, 0 3px 0 0 #0d0814, -3px 0 0 0 #0d0814, 3px 0 0 0 #0d0814; }
@keyframes logoIn { from { opacity: 0; transform: translateY(-30px) scale(0.9); } }
.title-menu { width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; animation: fadeUp 0.6s 0.4s ease both; }
.title-menu .btn { justify-content: center; text-align: center; min-height: 62px; font-size: 22px; }
.title-menu .save { font-size: 14px; font-weight: 500; color: var(--ink-2); display: block; margin-top: 4px; }
.title-foot { font-size: 13px; color: rgba(255, 248, 232, 0.6); margin-top: 6px; text-align: center; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } }
body.wide #title { flex-direction: row; align-items: center; justify-content: space-around; padding: 20px max(40px, var(--safe-r)) 20px max(40px, var(--safe-l)); }
body.wide .logo h1 { font-size: clamp(44px, 8vw, 84px); }

/* boot */
#boot { position: fixed; inset: 0; z-index: 30; background: var(--night); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; transition: opacity 0.4s; }
#boot.done { opacity: 0; pointer-events: none; }
.boot-logo { font-size: 34px; font-weight: 700; color: var(--gold); text-shadow: 0 4px 0 #2b1d2a; }
.boot-bar { width: 180px; height: 14px; background: #2a2140; box-shadow: 0 0 0 3px #0d0814; }
.boot-bar i { display: block; height: 100%; width: 0; background: var(--gold); transition: width 0.2s; }

/* screen wipe between the world and a battle */
#wipe { position: fixed; inset: 0; z-index: 12; pointer-events: none; }
.msg-slot > .battle-msg:not(:first-child) { position: absolute; left: 0; right: 0; top: 0; bottom: 0; }
body.wide .msg-slot { flex: 1; max-width: 560px; }
body.wide .battle-msg { max-width: none; }
.hplbl { font-size: 12px; font-weight: 700; color: var(--wood-2); margin-left: 2px; }
.battle-msg { min-height: 92px; }
.msg-slot { min-height: 92px !important; }
.deck-team { display: flex; justify-content: center; gap: 10px; padding: 6px 0 0; }
.deck-team img { width: 44px; height: 44px; image-rendering: pixelated; filter: drop-shadow(0 2px 0 rgba(0,0,0,0.4)); }
.deck-team img.out { filter: grayscale(1) brightness(0.6); }
.deck-team img.active { animation: hop 0.8s ease-in-out infinite; }
@keyframes hop { 50% { transform: translateY(-4px); } }
#deck-panel:has(.battle-cmds) .deck-team { display: none; }
body.wide .deck-team { display: none; }
.px { color: var(--ink); }
.px.dark, .btn.dark { color: var(--cream); }
.menu-top { color: var(--cream); }
.party-strip .mini img.fainted { filter: grayscale(1); opacity: 0.6; }
#deck-panel:has(.battle-cmds.moves) .msg-slot { display: none; }
.battle-cmds.moves .btn { min-height: 66px; }
.battle-cmds .back { min-height: 46px !important; }
.battle-cmds:not(.moves):not(.list) { grid-template-columns: repeat(3, 1fr); }
.battle-cmds:not(.moves):not(.list) .btn.fight { grid-column: span 3; }
.battle-cmds:not(.moves):not(.list) .btn { min-height: 58px; font-size: 20px; padding: 6px 8px; }
.battle-cmds.moves { grid-template-columns: 1fr 1fr; }
/* The four main battle commands stay visible without scrolling on short portrait screens. */
body.portrait.battle #deck { --deck-h: clamp(246px, 29dvh, 272px); }
body.portrait .battle-cmds:not(.moves):not(.list) {
  grid-template-columns: 1fr 1fr; gap: 9px;
}
body.portrait .battle-cmds:not(.moves):not(.list) .btn { grid-column: auto; min-height: 49px; }
/* battle panel when the phone is held sideways or on a desktop */
body.wide #deck-panel { top: auto; bottom: 0; left: 0; right: 0; height: auto; gap: 12px; align-items: flex-end;
  padding: 8px max(10px, var(--safe-r)) max(8px, var(--safe-b)) max(10px, var(--safe-l));
  background: linear-gradient(rgba(16, 10, 24, 0), rgba(16, 10, 24, 0.8) 40%); }
body.wide .msg-slot { min-height: 84px !important; }
body.wide .battle-msg { min-height: 84px; }
body.wide .battle-cmds, body.wide .battle-cmds:not(.moves):not(.list) { width: min(380px, 48%); grid-template-columns: 1fr 1fr !important; gap: 9px; padding: 3px; }
body.wide .battle-cmds .btn, body.wide .battle-cmds:not(.moves):not(.list) .btn { min-height: 46px; font-size: 18px; grid-column: auto !important; }
body.wide .battle-cmds.moves .btn { min-height: 52px; font-size: 16px; }
body.wide .battle-cmds .back { grid-column: span 2 !important; min-height: 38px !important; }
/* picking a move sideways: the four moves run in one row across the bottom, so nothing covers the HP card */
body.wide #deck-panel:has(.battle-cmds.moves) .msg-slot { display: none; }
body.wide .battle-cmds.moves { width: 100%; max-width: 980px; margin: 0 auto; grid-template-columns: repeat(4, 1fr) 76px !important; }
body.wide .battle-cmds.moves .back { grid-column: auto !important; min-height: 52px !important; justify-content: center; }
body.wide .card.me { bottom: 132px; }
body.wide .msg-slot { flex: 1 1 auto !important; }
/* Tiny5 is a single bold pixel face; no fake bolding, and a little larger everywhere */
body { font-synthesis: none; font-size: 17px; }
.logo h1, .boot-logo { font-family: "Jersey 10", var(--font); font-weight: 400; letter-spacing: 2px; }
.logo h1 { font-size: clamp(64px, 19vw, 120px); line-height: 0.82; }
body.wide .logo h1 { font-size: clamp(60px, 11vw, 116px); }
.boot-logo { font-size: 48px; }
.sheet-head h1 { font-family: "Jersey 10", var(--font); font-weight: 400; font-size: 36px; letter-spacing: 1px; }
body.scene-title #deck { display: none; }
body.desktop #btn-zone { display: flex; }
body.desktop #ab { display: none; }
body.desktop #menu-btn { opacity: 1; }
.sheet-head .x { font-size: 28px; }
/* the HUD and menu button grow with the map on big desktop windows (--ui is set in main.js) */
body.desktop #hud, body.desktop #menu-btn { zoom: var(--ui, 1); }
