/* ============================================================
   MATCH FIVE: DAWNBREAKER — styles
   ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }

@font-face {
  font-family: 'Jersey 10';
  src: url('assets/fonts/jersey10.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}

:root {
  --gold: #e8c766;
  --gold-dim: #a08434;
  --ink: #0d0b14;
  --panel: rgba(16, 13, 28, .88);
  --panel-edge: rgba(232, 199, 102, .35);
  --serif: Georgia, 'Times New Roman', serif;
  --pix: 'Jersey 10', monospace;
}

html, body { height: 100%; overflow: hidden; background: var(--ink); }
body {
  font-family: var(--pix);
  letter-spacing: .02em;
  color: #e8e4f0;
}

#app { position: fixed; inset: 0; }

.screen { position: absolute; inset: 0; display: none; }
.screen.active { display: flex; }

button { cursor: pointer; font-family: inherit; }

/* ---------------- shared HUD buttons ---------------- */
.hud-btn {
  background: rgba(0,0,0,.5); color: #fff; border: 1px solid rgba(255,255,255,.25);
  border-radius: 8px; padding: 6px 11px; font-size: 15px; z-index: 40;
}
.hud-btn:hover { border-color: var(--gold); }
.hud-corner { position: absolute; top: 12px; right: 12px; display: flex; gap: 8px; z-index: 40; }

/* ---------------- title ---------------- */
#scr-title { flex-direction: column; align-items: center; justify-content: center; }
#title-bg {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; filter: brightness(.75);
}
#scr-title::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 40%, transparent 30%, rgba(5,3,12,.85) 100%);
}
.title-stack { position: relative; z-index: 2; text-align: center; }
.title-kicker {
  font-family: var(--serif); letter-spacing: .55em; font-size: 15px;
  color: var(--gold); text-transform: uppercase; text-shadow: 0 2px 8px #000;
}
.title-main {
  font-family: var(--serif); font-size: clamp(48px, 8vw, 92px); font-weight: 700;
  letter-spacing: .06em; margin: 6px 0 2px;
  background: linear-gradient(180deg, #fff8e0 0%, var(--gold) 55%, #8a6a1e 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 14px rgba(0,0,0,.9)) drop-shadow(0 0 30px rgba(232,199,102,.35));
}
.title-sub {
  font-family: var(--serif); font-style: italic; color: #cbbfd8;
  font-size: 17px; margin-bottom: 42px; text-shadow: 0 2px 6px #000;
}
.title-btns { display: flex; flex-direction: column; gap: 14px; align-items: center; }
.title-btn {
  font-family: var(--serif); font-size: 21px; letter-spacing: .12em;
  color: #f4ecd7; background: linear-gradient(180deg, rgba(60,45,20,.9), rgba(28,20,10,.92));
  border: 1px solid var(--gold-dim); border-radius: 4px;
  padding: 13px 64px; min-width: 300px; transition: all .18s;
  text-transform: uppercase;
}
.title-btn:hover {
  border-color: var(--gold); color: #fff;
  box-shadow: 0 0 24px rgba(232,199,102,.35), inset 0 0 12px rgba(232,199,102,.15);
  transform: translateY(-1px);
}
.title-foot {
  position: absolute; bottom: 16px; width: 100%; text-align: center;
  font-size: 12px; color: rgba(255,255,255,.45); z-index: 2; letter-spacing: .08em;
}

/* ---------------- loading ---------------- */
#scr-loading { align-items: center; justify-content: center; background: var(--ink); }
#load-progress { font-family: var(--serif); font-size: 20px; color: var(--gold); letter-spacing: .1em; }

/* ---------------- VN ---------------- */
#scr-vn { background: #000; cursor: pointer; overflow: hidden; }
.vn-bg {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; opacity: 0; transition: opacity .7s ease;
}
.vn-bg.show { opacity: 1; }
#vn-sprites { position: absolute; inset: 0; pointer-events: none; }
.vn-sprite {
  position: absolute; bottom: 0; height: 86%; max-width: 44vw;
  object-fit: contain; object-position: bottom;
  transition: opacity .25s ease, transform .25s ease, filter .3s ease;
  filter: drop-shadow(0 8px 24px rgba(0,0,0,.7));
}
#vn-left  { left: 2vw;  transform-origin: bottom; }
#vn-right { right: 2vw; }
.vn-sprite.dim { filter: brightness(.45) drop-shadow(0 8px 24px rgba(0,0,0,.7)); transform: scale(.97); }
.vn-sprite.off { opacity: 0; visibility: hidden; }

#vn-box {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: 3vh; width: min(920px, 92vw); min-height: 128px;
  background: linear-gradient(180deg, rgba(14,11,26,.92), rgba(8,6,18,.96));
  border: 1px solid var(--panel-edge); border-radius: 10px;
  padding: 40px 30px 22px; z-index: 10;
  box-shadow: 0 12px 40px rgba(0,0,0,.7);
}
#vn-name {
  position: absolute; top: -17px; left: 22px;
  font-size: 21px; letter-spacing: .06em;
  color: var(--namecol, var(--gold));
  background: linear-gradient(180deg, #241d38, #151024);
  border: 1px solid var(--namecol, var(--gold-dim));
  border-radius: 6px; padding: 5px 18px;
  text-shadow: 0 1px 3px #000;
}
#vn-text { font-size: 24px; line-height: 1.5; min-height: 3.3em; text-shadow: 0 1px 2px #000; }
#vn-box.narration #vn-text { font-style: italic; color: #beb4d4; }
#vn-next {
  position: absolute; right: 18px; bottom: 10px; color: var(--gold);
  animation: bob 1s ease-in-out infinite; visibility: hidden; font-size: 14px;
}
@keyframes bob { 50% { transform: translateY(4px); } }

#vn-choices {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; gap: 14px; z-index: 20; width: min(560px, 90vw);
}
.vn-choice-btn {
  background: linear-gradient(180deg, rgba(38,30,60,.96), rgba(20,15,36,.97));
  border: 1px solid var(--gold-dim); border-radius: 8px;
  color: #f0e9d8; padding: 14px 22px; text-align: left;
  display: flex; flex-direction: column; gap: 4px; transition: all .15s;
}
.vn-choice-btn:hover {
  border-color: var(--gold); transform: translateX(4px);
  box-shadow: 0 0 20px rgba(232,199,102,.25);
}
.vc-label { font-size: 22px; }
.vc-note { font-size: 16px; color: #9d92b8; }

#vn-banner {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(10,7,20,.88), rgba(3,2,8,.97));
  font-family: var(--serif); font-size: clamp(30px, 5vw, 54px); color: var(--gold);
  letter-spacing: .14em; text-align: center; padding: 0 5vw;
  opacity: 0; visibility: hidden; transition: opacity .8s; z-index: 30;
  text-shadow: 0 0 40px rgba(232,199,102,.5), 0 4px 10px #000;
}
#vn-banner.show { opacity: 1; visibility: visible; }

#note-toast {
  position: fixed; top: 26px; left: 50%; transform: translate(-50%, -80px);
  background: rgba(20,16,36,.95); border: 1px solid var(--gold);
  border-radius: 8px; padding: 10px 26px; color: var(--gold); font-size: 15px;
  transition: transform .4s cubic-bezier(.2,1.4,.4,1); z-index: 90; pointer-events: none;
}
#note-toast.show { transform: translate(-50%, 0); }

/* ---------------- pixelated art ---------------- */
.pixelated { image-rendering: pixelated; }

/* ---------------- battle ---------------- */
#scr-battle { overflow: hidden; }
#battle-bg {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; filter: brightness(.42) saturate(.85);
  image-rendering: pixelated;
}
.battle-layout {
  position: relative; z-index: 2; display: flex; width: 100%; height: 100%;
  align-items: center; justify-content: center; gap: clamp(10px, 2vw, 34px);
  padding: 20px;
}

.panel {
  background: linear-gradient(180deg, rgba(34,28,54,.94), rgba(20,16,36,.96));
  border: 2px solid #0e0a1c; border-radius: 4px; padding: 18px;
  box-shadow: 0 0 0 2px #4a4168, 6px 6px 0 rgba(0,0,0,.45);
}

/* player panel */
#player-panel { width: clamp(240px, 22vw, 320px); display: flex; flex-direction: column; gap: 12px; }
.party-row { display: flex; gap: 10px; align-items: center; }
.portrait {
  width: 54px; height: 54px; border-radius: 3px; object-fit: cover; object-position: top;
  border: 2px solid #0e0a1c; box-shadow: 0 0 0 1px var(--gold-dim);
  background: #201a33; image-rendering: pixelated;
}
.party-name { font-size: 22px; color: #f4ecd7; }
.party-sub { font-size: 15px; color: #9d92b8; }

.bar-label { display: flex; justify-content: space-between; font-size: 15px; color: #b6abcf; margin-bottom: 3px; letter-spacing: .05em; }
.bar { height: 16px; border-radius: 2px; background: #17122a; overflow: hidden; border: 2px solid #0e0a1c; box-shadow: 0 0 0 1px #4a4168; }
.bar-fill { height: 100%; border-radius: 0; transition: width .4s ease; }
#p-hp   { background: linear-gradient(90deg, #2f9e5f, #4ade80); }
#p-mana { background: linear-gradient(90deg, #2451c4, #60a5fa); }
#p-star { background: linear-gradient(90deg, #7e22ce, #c084fc); }
#p-shield { color: #facc15; font-size: 13px; min-height: 16px; }
#p-status { color: #ff9d5c; font-size: 13px; min-height: 16px; }

#skills { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.skill-btn {
  display: flex; align-items: center; gap: 10px; text-align: left;
  background: rgba(255,255,255,.05); border: 2px solid #0e0a1c;
  box-shadow: 0 0 0 1px #3a3454;
  border-radius: 3px; padding: 8px 10px; color: #cfc7e2;
  opacity: .55; transition: all .18s;
}
.skill-btn.ready { opacity: 1; box-shadow: 0 0 0 1px #60a5fa; background: rgba(96,165,250,.1); }
.skill-btn.ready:hover { background: rgba(96,165,250,.22); transform: translateX(2px); }
.skill-btn.ult.ready { box-shadow: 0 0 0 1px var(--gold), 0 0 14px rgba(232,199,102,.3); background: rgba(232,199,102,.12); }
.skill-btn.ult.ready:hover { background: rgba(232,199,102,.22); }
.sk-icon { font-size: 22px; width: 28px; text-align: center; }
.sk-body { flex: 1; display: flex; flex-direction: column; }
.sk-body b { font-size: 17px; color: #f0e9d8; }
.sk-body small { font-size: 13px; color: #9d92b8; line-height: 1.2; }
.sk-cost { font-size: 16px; color: #b6abcf; white-space: nowrap; }

/* board */
#board-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; }
#board {
  position: relative; width: min(62vh, 40vw, 560px); aspect-ratio: 1;
  background: rgba(12,9,24,.8); border: 2px solid #0e0a1c;
  border-radius: 4px; overflow: hidden; touch-action: none;
  box-shadow: 0 0 0 2px #4a4168, 6px 6px 0 rgba(0,0,0,.45), inset 0 0 60px rgba(0,0,0,.5);
}
.gem {
  position: absolute; top: 0; left: 0; box-sizing: border-box;
  transition: transform .32s cubic-bezier(.3,.9,.4,1.08);
  will-change: transform;
}
.gem svg, .gem img { width: 100%; height: 100%; display: block; filter: drop-shadow(0 3px 5px rgba(0,0,0,.55)); }
.gem.sel svg, .gem.sel img { filter: drop-shadow(0 0 10px #fff) drop-shadow(0 0 18px var(--gold)); transform: scale(1.1); }
.gem.pop { animation: gempop .3s forwards; }
@keyframes gempop {
  40% { transform: scale(1.25); filter: brightness(2); }
  100% { transform: scale(0); opacity: 0; }
}
.gem.pop svg, .gem.pop img { filter: brightness(1.8) drop-shadow(0 0 14px #fff); }

.combo-text {
  position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%);
  font-family: var(--serif); font-size: 42px; color: var(--gold); font-weight: 700;
  text-shadow: 0 0 24px rgba(232,199,102,.8), 0 3px 6px #000;
  animation: comboAnim 1s forwards; pointer-events: none; z-index: 5;
}
@keyframes comboAnim {
  0% { transform: translate(-50%, -50%) scale(.4); opacity: 0; }
  25% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
  75% { opacity: 1; }
  100% { transform: translate(-50%, -80%) scale(1); opacity: 0; }
}

/* enemy panel */
#enemy-panel { width: clamp(260px, 26vw, 380px); display: flex; flex-direction: column; gap: 10px; align-items: center; }
#enemy-name { font-family: var(--serif); font-size: 19px; color: #f4d7d7; text-align: center; text-shadow: 0 1px 3px #000; }
#enemy-hp-wrap { width: 100%; }
#enemy-hp { background: linear-gradient(90deg, #a11d3c, #ef4468); }
#enemy-shield { color: #facc15; font-size: 13px; min-height: 16px; text-align: center; }
#enemy-img {
  width: 100%; max-height: 44vh; object-fit: contain;
  filter: drop-shadow(0 10px 30px rgba(0,0,0,.8));
  animation: idle 3.2s ease-in-out infinite;
  transition: opacity 1s, filter .3s;
}
@keyframes idle { 50% { transform: translateY(-8px); } }
#enemy-img.hit { animation: hitflash .35s; }
@keyframes hitflash {
  0% { filter: brightness(3) saturate(0) drop-shadow(0 0 20px #fff); transform: translateX(6px); }
  40% { transform: translateX(-6px); }
  100% { filter: drop-shadow(0 10px 30px rgba(0,0,0,.8)); transform: none; }
}
#enemy-img.lunge { animation: lunge .26s; }
@keyframes lunge { 40% { transform: translateX(-34px) scale(1.04); } }
#enemy-img.dead { opacity: 0; filter: brightness(4) blur(8px); }
#enemy-intent {
  background: rgba(12,9,24,.7); border: 2px solid #0e0a1c;
  box-shadow: 0 0 0 1px rgba(255,120,120,.35);
  border-radius: 3px; padding: 7px 14px; font-size: 17px; color: #f3c6c6;
}
#enemy-img.pixelated { image-rendering: pixelated; }
.intent-icon { font-size: 15px; }

/* battle banners & fx */
#battle-fx { position: absolute; inset: 0; z-index: 20; pointer-events: none; }
.floater {
  position: absolute; transform: translateX(-50%); font-weight: 700; font-size: 19px;
  text-shadow: 0 2px 4px #000, 0 0 12px currentColor;
  animation: floatup 1.4s ease-out forwards; pointer-events: none; z-index: 25; white-space: nowrap;
}
.floater.big { font-size: 27px; }
@keyframes floatup {
  0% { opacity: 0; margin-top: 8px; }
  12% { opacity: 1; }
  75% { opacity: 1; }
  100% { opacity: 0; margin-top: -66px; }
}

.battle-banner {
  position: absolute; left: 50%; top: 16%; transform: translate(-50%, -50%) scale(.7);
  font-family: var(--serif); font-size: clamp(26px, 3.6vw, 44px); font-weight: 700;
  letter-spacing: .1em; opacity: 0; transition: all .25s; z-index: 30;
  pointer-events: none; text-align: center; white-space: nowrap;
}
.battle-banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.battle-banner.gold { color: var(--gold); text-shadow: 0 0 30px rgba(232,199,102,.9), 0 3px 8px #000; }
.battle-banner.purple { color: #d8b4fe; text-shadow: 0 0 30px rgba(192,132,252,.9), 0 3px 8px #000; }
.battle-banner.plain { color: #e8e4f0; font-size: clamp(17px, 2vw, 24px); font-family: inherit; font-weight: 400; letter-spacing: .02em; text-shadow: 0 2px 6px #000; background: rgba(0,0,0,.55); padding: 10px 24px; border-radius: 10px; white-space: normal; max-width: 70vw; }

.shake { animation: screenshake .4s; }
@keyframes screenshake {
  0%, 100% { transform: none; }
  20% { transform: translate(-10px, 4px); }
  40% { transform: translate(8px, -5px); }
  60% { transform: translate(-6px, 3px); }
  80% { transform: translate(4px, -2px); }
}

/* ---------------- help overlay ---------------- */
#help-overlay {
  position: fixed; inset: 0; background: rgba(4,3,10,.9); z-index: 80;
  display: none; align-items: center; justify-content: center; cursor: pointer;
}
#help-overlay.show { display: flex; }
.help-card {
  background: var(--panel); border: 1px solid var(--panel-edge); border-radius: 14px;
  padding: 28px 34px; max-width: 560px; width: 92vw;
}
.help-card h2 { font-family: var(--serif); color: var(--gold); margin-bottom: 14px; letter-spacing: .08em; }
.help-card p { font-size: 14px; color: #cfc7e2; line-height: 1.6; margin-bottom: 12px; }
.help-gem-row { display: flex; align-items: center; gap: 12px; font-size: 14px; margin-bottom: 6px; }
.help-gem { width: 34px; height: 34px; flex: none; }
.help-gem svg { width: 100%; height: 100%; }

/* ---------------- defeat / end ---------------- */
#scr-defeat, #scr-end {
  flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: radial-gradient(ellipse at center, #1a0f1e 0%, #050308 80%);
  text-align: center;
}
.big-serif { font-family: var(--serif); font-size: clamp(38px, 6vw, 64px); letter-spacing: .12em; }
#scr-defeat .big-serif { color: #b04a5a; text-shadow: 0 0 40px rgba(176,74,90,.5); }
#scr-end .big-serif { color: var(--gold); text-shadow: 0 0 40px rgba(232,199,102,.5); }
.end-sub { color: #9d92b8; font-size: 17px; max-width: 620px; line-height: 1.7; padding: 0 4vw; }

/* ---------------- overworld (fullscreen) ---------------- */
#scr-world { background: #101018; }
#world-canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  image-rendering: pixelated;
}
#world-touch { position: absolute; inset: 0; touch-action: none; }

/* pixel-flavored HUD chrome */
.pixelbox {
  background: linear-gradient(180deg, rgba(34,28,54,.92), rgba(22,17,38,.94));
  border: 2px solid #0e0a1c;
  box-shadow: 0 0 0 2px #4a4168, 3px 3px 0 rgba(0,0,0,.45);
  border-radius: 3px;
}
#hud-top {
  position: absolute; top: 14px; left: 14px; z-index: 20;
  display: flex; gap: 10px; align-items: flex-start;
}
#hud-char {
  position: relative; padding: 4px;
  background: linear-gradient(180deg, rgba(34,28,54,.92), rgba(22,17,38,.94));
  border: 2px solid #0e0a1c; box-shadow: 0 0 0 2px #4a4168, 3px 3px 0 rgba(0,0,0,.45);
  border-radius: 3px;
}
#hud-portrait { width: 52px; height: 39px; image-rendering: pixelated; display: block; background: #17122a; }
#hud-level {
  position: absolute; right: -7px; bottom: -7px; min-width: 20px; height: 20px;
  background: #17122a; border: 2px solid var(--gold-dim); border-radius: 50%;
  color: var(--gold); font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
#hud-bars { display: flex; flex-direction: column; gap: 5px; padding-top: 2px; }
.hud-bar {
  position: relative; width: 190px; height: 15px;
  background: #17122a; border: 2px solid #0e0a1c;
  box-shadow: 0 0 0 1px #4a4168; border-radius: 2px; overflow: hidden;
}
.hud-bar i { position: absolute; inset: 0; width: 100%; transition: width .4s; }
.hud-bar.hp i { background: linear-gradient(180deg, #5fdf85, #2f9e5f); }
.hud-bar.mp i { background: linear-gradient(180deg, #6fb1ff, #2451c4); }
.hud-bar.xp i { background: linear-gradient(180deg, #ffd76a, #b8862a); }
.hud-bar.xp { height: 11px; }
.hud-bar span {
  position: absolute; inset: 0; display: flex; align-items: center; padding-left: 6px;
  font-size: 13px; letter-spacing: .04em; color: #fff;
  text-shadow: 1px 1px 0 rgba(0,0,0,.8); font-family: var(--pix); white-space: nowrap;
}
#hud-shadows {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%); z-index: 20;
  font-size: 21px; color: var(--gold);
  letter-spacing: .08em; text-shadow: 0 2px 4px #000;
}
#hud-actions {
  position: absolute; left: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 20;
  display: flex; gap: 8px;
}
.hud-act {
  width: 46px; height: 46px; font-size: 21px;
  background: linear-gradient(180deg, rgba(34,28,54,.92), rgba(22,17,38,.94));
  border: 2px solid #0e0a1c; box-shadow: 0 0 0 2px #4a4168, 3px 3px 0 rgba(0,0,0,.45);
  border-radius: 3px; color: #e8e4f0;
}
.hud-act:hover { box-shadow: 0 0 0 2px var(--gold-dim), 3px 3px 0 rgba(0,0,0,.45); }
#world-hint {
  position: absolute; bottom: calc(16px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  font-size: 16px; color: #b9aecf; z-index: 20; text-shadow: 0 1px 3px #000;
  background: rgba(10,8,20,.55); padding: 4px 14px; border-radius: 10px; white-space: nowrap;
}
#world-atk {
  display: none; position: fixed; right: 22px; bottom: calc(26px + env(safe-area-inset-bottom));
  width: 76px; height: 76px; border-radius: 50%; font-size: 30px;
  background: rgba(232,199,102,.16); border: 2px solid var(--gold-dim); color: var(--gold);
  z-index: 30; touch-action: none;
}
@media (pointer: coarse) {
  #world-atk { display: block; }
  #world-hint { display: none; }
}

/* ---- sketch panels ---- */
#world-panel {
  position: absolute; inset: 0; z-index: 40;
  background: rgba(6,4,14,.62);
  display: flex; align-items: center; justify-content: center;
}
#world-panel[hidden] { display: none; }
#world-panel-box {
  width: min(560px, 94vw); max-height: 86vh; overflow-y: auto;
  background: linear-gradient(180deg, rgba(36,30,58,.97), rgba(20,16,36,.98));
  border: 2px solid #0e0a1c; box-shadow: 0 0 0 2px #4a4168, 6px 6px 0 rgba(0,0,0,.5);
  border-radius: 4px; padding: 18px 20px 12px;
}
#world-panel-title { font-family: var(--serif); font-size: 21px; color: var(--gold); letter-spacing: .08em; margin-bottom: 14px; }
.panel-note { margin-top: 12px; font-size: 13px; color: #7d7398; text-align: center; letter-spacing: .04em; }
.panel-blurb { font-size: 15px; color: #b9aecf; line-height: 1.5; margin-top: 12px; }

.gear-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.gear-slot {
  display: grid; grid-template-columns: 34px 1fr; grid-auto-rows: min-content;
  align-items: center; column-gap: 8px; padding: 8px 10px; cursor: pointer;
  background: rgba(255,255,255,.04); border: 2px solid #0e0a1c;
  box-shadow: 0 0 0 1px #4a4168; border-radius: 3px; min-height: 52px;
}
.gear-slot:hover { box-shadow: 0 0 0 1px var(--gold-dim); }
.gear-slot .gs-icon { grid-row: 1 / span 2; font-size: 24px; text-align: center; }
.gear-slot b { font-size: 16px; color: #f0e9d8; }
.gear-slot small { font-size: 13px; color: #9d92b8; }
.gear-slot.empty { opacity: .55; cursor: default; }
.gear-slot.empty b { font-style: italic; font-weight: 400; }
.gs-swap { grid-column: 2; color: var(--gold) !important; }
.bag-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 10px; }
.bag-slot {
  height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 18px; background: rgba(255,255,255,.03);
  border: 2px solid #0e0a1c; box-shadow: 0 0 0 1px #3a3454; border-radius: 3px;
}
.bag-slot small { font-size: 11px; color: #9d92b8; text-align: center; line-height: 1.1; }
.bag-slot.empty { opacity: .4; }

.card-row { display: flex; gap: 10px; justify-content: center; }
.comp-card {
  width: 130px; padding: 12px 8px 10px; text-align: center;
  background: linear-gradient(180deg, #2c2547, #1d1834);
  border: 2px solid #0e0a1c; box-shadow: 0 0 0 2px var(--gold-dim), 3px 3px 0 rgba(0,0,0,.45);
  border-radius: 6px; display: flex; flex-direction: column; gap: 5px; align-items: center;
}
.comp-card .cc-icon { font-size: 34px; height: 44px; display: flex; align-items: center; }
.comp-card b { font-size: 15px; color: #f0e9d8; }
.comp-card small { font-size: 12.5px; color: #9d92b8; line-height: 1.25; }
.comp-card.unknown { opacity: .6; box-shadow: 0 0 0 2px #3a3454, 3px 3px 0 rgba(0,0,0,.45); }
.comp-card.unknown .cc-icon { color: #4a4168; font-family: var(--serif); }

.skill-list { display: flex; flex-direction: column; gap: 6px; }
.skill-line {
  display: flex; gap: 10px; align-items: center; padding: 7px 10px;
  background: rgba(255,255,255,.04); border: 2px solid #0e0a1c;
  box-shadow: 0 0 0 1px #4a4168; border-radius: 3px;
}
.skill-line.locked { opacity: .5; }
.sl-icon { font-size: 19px; width: 26px; text-align: center; }
.sl-body { flex: 1; display: flex; flex-direction: column; }
.sl-body b { font-size: 16px; color: #f0e9d8; display: inline; }
.sl-body em { font-size: 9.5px; color: var(--gold-dim); font-style: normal; letter-spacing: .08em; text-transform: uppercase; margin-left: 6px; }
.sl-body small { font-size: 13px; color: #9d92b8; }
.sl-state { font-size: 14px; }

@media (max-width: 700px) {
  .hud-bar { width: 128px; }
  .hud-bar span { font-size: 8px; }
  #hud-portrait { width: 40px; height: 30px; }
  #hud-shadows { top: auto; bottom: calc(72px + env(safe-area-inset-bottom)); left: 14px; transform: none; font-size: 13px; }
  #hud-actions { bottom: calc(14px + env(safe-area-inset-bottom)); }
  .hud-act { width: 42px; height: 42px; }
  .card-row { flex-wrap: wrap; }
}

/* FF-style encounter transition */
#encounter-fx {
  position: fixed; inset: 0; z-index: 95; pointer-events: none;
  background: #000; opacity: 0; visibility: hidden;
}
#encounter-fx.flash {
  visibility: visible;
  animation: encFlash .5s steps(1) forwards;
}
@keyframes encFlash {
  0% { opacity: 1; background: #fff; }
  20% { opacity: 0; }
  40% { opacity: 1; background: #fff; }
  60% { opacity: 0; }
  100% { opacity: 0; }
}
#encounter-fx.iris {
  visibility: visible; opacity: 1; background: #000;
  clip-path: circle(0% at 50% 50%);
  animation: encIris .55s ease-in forwards;
}
@keyframes encIris {
  from { clip-path: circle(0% at 50% 50%); }
  to   { clip-path: circle(120% at 50% 50%); }
}
#encounter-fx.out {
  visibility: visible; opacity: 1; background: #000;
  animation: encOut .5s ease-out forwards;
}
@keyframes encOut { from { opacity: 1; } to { opacity: 0; } }

/* ============================================================
   MOBILE
   ============================================================ */

/* ---- portrait phones & tablets: battle stacks vertically ---- */
@media (max-width: 900px) and (orientation: portrait) {
  .battle-layout {
    flex-direction: column; justify-content: flex-start; align-items: center;
    gap: 8px; padding: 8px 8px calc(10px + env(safe-area-inset-bottom));
    overflow-y: auto;
  }
  #enemy-panel {
    order: -1; width: 100%; max-width: 560px;
    display: grid; grid-template-columns: 88px 1fr;
    gap: 4px 12px; padding: 10px 92px 10px 10px; align-items: center;
  }
  #enemy-img { grid-column: 1; grid-row: 1 / span 3; width: 88px; max-height: 118px; }
  #enemy-name { grid-column: 2; font-size: 15px; text-align: left; }
  #enemy-hp-wrap { grid-column: 2; }
  #enemy-shield { text-align: left; }
  #enemy-intent { grid-column: 2; font-size: 12px; padding: 5px 8px; justify-self: start; }
  #board { width: min(94vw, 54vh, 560px); }
  #player-panel { order: 1; width: 100%; max-width: 560px; padding: 8px 12px; gap: 6px; }
  #player-panel .party-row { display: none; }
  #skills { flex-direction: row; gap: 4px; margin-top: 0; }
  .skill-btn { flex-direction: column; flex: 1; padding: 5px 2px; gap: 1px; align-items: center; text-align: center; }
  .sk-icon { width: auto; font-size: 18px; }
  .sk-body { align-items: center; }
  .sk-body b { font-size: 10.5px; white-space: nowrap; }
  .sk-body small { display: none; }
  .sk-cost { font-size: 11px; }
  .bar { height: 13px; }
  .bar-label { font-size: 11px; }
  .battle-banner { top: 34%; }
  .floater { font-size: 16px; }
  .floater.big { font-size: 22px; }
}

/* ---- phones: VN, title, overlays ---- */
@media (max-width: 700px) {
  .vn-sprite { height: 58%; max-width: 58vw; }
  #vn-left { left: -8vw; }
  #vn-right { right: -8vw; }
  #vn-box {
    width: 94vw; min-height: 112px; padding: 28px 16px 24px;
    bottom: calc(1.5vh + env(safe-area-inset-bottom));
  }
  #vn-text { font-size: 16px; line-height: 1.55; min-height: 3.1em; }
  #vn-name { font-size: 14px; padding: 4px 12px; top: -15px; left: 14px; }
  #vn-choices { width: 94vw; top: 36%; }
  .vc-label { font-size: 16px; }
  .vc-note { font-size: 12px; }
  .title-main { font-size: clamp(30px, 11vw, 92px); letter-spacing: .04em; }
  .title-kicker { font-size: 12px; letter-spacing: .4em; }
  .title-btn { min-width: min(300px, 82vw); padding: 12px 20px; font-size: 18px; }
  .title-sub { font-size: 15px; padding: 0 6vw; }
  .title-foot { font-size: 10px; padding: 0 4vw; }
  .help-card { padding: 18px 20px; max-height: 84vh; overflow-y: auto; }
  .help-card p { font-size: 13px; }
  .help-gem-row { font-size: 13px; }
  .hud-btn { padding: 5px 9px; font-size: 14px; }
}

/* ---- short landscape screens (phones sideways): compact panels ---- */
@media (max-height: 560px) and (orientation: landscape) {
  .battle-layout { padding: 8px; gap: 10px; }
  .panel { padding: 10px; }
  #player-panel, #enemy-panel { max-height: 96vh; overflow-y: auto; scrollbar-width: none; }
  #player-panel::-webkit-scrollbar, #enemy-panel::-webkit-scrollbar { display: none; }
  #player-panel .party-row { display: none; }
  #player-panel { gap: 6px; }
  .sk-body small { display: none; }
  .skill-btn { padding: 5px 8px; }
  .sk-body b { font-size: 12px; }
  #enemy-img { max-height: 24vh; }
  #enemy-name { font-size: 14px; }
  #enemy-intent { font-size: 11.5px; padding: 4px 8px; }
  .bar { height: 12px; }
  .bar-label { font-size: 10.5px; }
  .vn-sprite { height: 74%; }
  #vn-box { min-height: 96px; padding: 26px 18px 20px; }
  #vn-text { font-size: 15px; min-height: 2.8em; }
}

/* cinematic walk mode: bare canvas + subtitles only */
#scr-world.cinematic #hud-top, #scr-world.cinematic #hud-actions,
#scr-world.cinematic #hud-shadows, #scr-world.cinematic #world-atk { display: none; }
#scr-world.cinematic #world-hint { font-size: 19px; color: #cfd6ea; background: rgba(8,8,18,.72); }

/* ---- Kaelora main menu ---- */
.title-kicker.kae { color: #7f92c0; letter-spacing: .5em; }
.title-main.kae {
  background: linear-gradient(180deg, #eef1fb 0%, #8a9bc4 55%, #39425f 100%);
  -webkit-background-clip: text; background-clip: text;
  filter: drop-shadow(0 4px 14px rgba(0,0,0,.95)) drop-shadow(0 0 34px rgba(122,148,210,.30));
  letter-spacing: .14em;
}
.title-sub.kae { color: #94a0bd; }
.title-btn.kae { border-color: #4c5878; color: #dfe6f6; }
.title-btn.kae:hover {
  border-color: #8fa3d4; color: #fff;
  box-shadow: 0 0 24px rgba(122,148,210,.35), inset 0 0 12px rgba(122,148,210,.15);
}
#scr-title #title-bg { filter: brightness(.48) saturate(.72); }
#dev-toggle { cursor: pointer; opacity: .45; }
#dev-toggle:hover { opacity: 1; color: var(--gold); }
#dev-menu {
  position: absolute; right: 16px; bottom: 44px; z-index: 5;
  display: flex; flex-direction: column; gap: 6px; align-items: flex-end;
}
#dev-menu[hidden] { display: none; }
.dev-label { font-size: 12px; color: #7d7398; letter-spacing: .06em; }
.title-btn.dev { min-width: 230px; padding: 7px 16px; font-size: 15px; letter-spacing: .06em; opacity: .85; }

/* native-resolution text overlay (crisp type over chunky pixels) */
#text-canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 15;
}

/* ---------- the Guild notice board ---------- */
.board-list { display: flex; flex-direction: column; gap: 10px; max-height: 52vh; overflow-y: auto; padding-right: 6px; }
.board-req {
  background: rgba(58, 46, 30, .55); border: 1px solid #6a5436; border-radius: 4px;
  padding: 10px 12px; text-align: left;
}
.board-req p { margin: 6px 0 8px; font-size: 15px; color: #d8cdb4; line-height: 1.45; }
.board-req.filled, .board-req.locked { opacity: .62; }
.br-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.br-head b { color: #ffe9a0; font-size: 17px; }
.br-rank { font-size: 13px; color: #c9a35c; letter-spacing: .06em; white-space: nowrap; }
.br-client { color: #b9aecf; font-size: 13px; }
.br-btn {
  font-family: inherit; font-size: 15px; cursor: pointer;
  background: #7a5a2a; color: #ffe9a0; border: 1px solid #c9a35c; border-radius: 3px;
  padding: 4px 14px; letter-spacing: .04em;
}
.br-btn:hover { background: #96702f; }
.br-note {
  display: inline-block; font-size: 12px; letter-spacing: .12em; color: #d88a6a;
  border: 1px solid #a05a3c; border-radius: 2px; padding: 2px 8px; transform: rotate(-2deg);
}
.board-req.locked .br-note { color: #9aa1ba; border-color: #5e5e6c; }
.board-list { scrollbar-width: thin; scrollbar-color: #6a5436 transparent; }
.board-list::-webkit-scrollbar { width: 8px; }
.board-list::-webkit-scrollbar-thumb { background: #6a5436; border-radius: 4px; }
