/* THE LONG ROAD UP — full-screen PS1 RPG shell */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; background: #10150c; overflow: hidden;
  font-family: Georgia, "Times New Roman", serif; color: #f0e6cf;
  touch-action: none; overscroll-behavior: none; }
.hidden { display: none !important; }
.dim { color: #b9ac8d; font-size: 0.92em; }
button { font-family: inherit; cursor: pointer; }

/* ---------- key gate ---------- */
#view-key { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(120% 100% at 50% 0%, #2b3a24 0%, #141a10 70%); padding: 20px; }
.key-card { max-width: 340px; text-align: center; }
.key-art { font-size: 54px; }
.key-card h1 { margin: 6px 0 10px; font-size: 30px; letter-spacing: 0.5px; color: #ffd98a; }
.key-card input { width: 100%; padding: 13px; font-size: 17px; border-radius: 10px; border: 2px solid #6a7a52;
  background: #0e130a; color: #f0e6cf; text-align: center; margin: 14px 0 10px; }
.bigbtn { display: block; width: 100%; padding: 13px 16px; margin: 8px 0; font-size: 17px; font-weight: bold;
  border-radius: 12px; border: 2px solid #8a6f3c; background: linear-gradient(#7d5f27, #5d451c); color: #ffe9b0; }
.bigbtn.ghost { background: #232b1a; border-color: #4a5738; color: #cfc39f; }
.bigbtn:disabled { opacity: 0.45; }

/* ---------- game frame ---------- */
#view-game { position: fixed; inset: 0; }
#arena-wrap { position: absolute; inset: 0; overflow: hidden; background: #2b3a24; }
#arena-holder { position: absolute; inset: 0; }
#arena-holder canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; }

/* NPC name labels + float text (engine-created) */
.npc-label { position: absolute; left: 0; top: 0; padding: 1px 8px; border-radius: 8px; pointer-events: none;
  background: rgba(10, 12, 6, 0.55); color: #ffe9b0; font-size: 12.5px; font-weight: bold; white-space: nowrap; z-index: 5; }
.npc-label.ally { color: #a8e6a1; }
.float-text { position: absolute; left: 0; top: 0; font-weight: 900; font-size: 17px; pointer-events: none;
  text-shadow: 0 2px 3px rgba(0,0,0,0.8); z-index: 6; white-space: nowrap; }
.float-text.dmg { color: #ffe9c0; }
.float-text.crit { color: #ffd25a; font-size: 22px; }
.float-text.heal { color: #86ff9a; }
.float-text.hurt { color: #ff8a7a; }

/* ---------- top HUD ---------- */
#topbar { position: absolute; top: 0; left: 0; right: 0; z-index: 10; display: flex; justify-content: space-between;
  align-items: flex-start; padding: calc(6px + env(safe-area-inset-top)) 10px 4px; pointer-events: none;
  background: linear-gradient(rgba(8,10,5,0.55), transparent); }
.tb-left { display: flex; align-items: center; gap: 8px; }
#hud-level { font-weight: bold; color: #ffd98a; font-size: 16px; text-shadow: 0 1px 3px #000; }
.bars { width: 118px; display: flex; flex-direction: column; gap: 2px; }
.bar { position: relative; height: 13px; border-radius: 6px; background: rgba(0,0,0,0.55); border: 1px solid rgba(255,233,176,0.35); overflow: hidden; }
.bar > div { height: 100%; transition: width 0.18s; }
.bar.hp > div { background: linear-gradient(#e05252, #a52a2a); }
.bar.mana { height: 10px; }
.bar.mana > div { background: linear-gradient(#5aa8e8, #2a5aa5); }
.bar.xp { height: 4px; border: none; background: rgba(0,0,0,0.4); }
.bar.xp > div { background: #ffd25a; width: 0%; }
.bar span { position: absolute; inset: 0; font-size: 9.5px; line-height: 13px; text-align: center; color: #fff; text-shadow: 0 1px 2px #000; font-family: monospace; }
.bar.mana span { line-height: 10px; }
#hud-gold { font-weight: bold; color: #ffe9b0; text-shadow: 0 1px 3px #000; font-size: 15px; }
.tb-right { display: flex; gap: 6px; pointer-events: auto; align-items: center; }
#btn-pack { width: 40px; height: 40px; border-radius: 50%; border: 2px solid rgba(255,233,176,0.5);
  background: rgba(14,18,9,0.72); font-size: 19px; }
.camseg { display: flex; border-radius: 9px; overflow: hidden; border: 1px solid rgba(255,233,176,0.4); }
.camseg .seg-btn { padding: 7px 9px; font-size: 12px; background: rgba(14,18,9,0.72); color: #cfc39f; border: none; }
.camseg .seg-btn.active { background: #7d5f27; color: #ffe9b0; font-weight: bold; }
#hud-quest-name { position: absolute; top: calc(52px + env(safe-area-inset-top)); left: 0; right: 0; z-index: 9;
  text-align: center; font-size: 13px; letter-spacing: 2px; color: rgba(255,233,176,0.75); text-shadow: 0 1px 3px #000; pointer-events: none; }
#hud-objective { position: absolute; top: calc(72px + env(safe-area-inset-top)); left: 12px; right: 12px; z-index: 9;
  text-align: center; font-size: 14.5px; font-weight: bold; color: #ffeec2; text-shadow: 0 1px 4px #000; pointer-events: none; }

/* compass */
#obj-compass { position: absolute; top: calc(104px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  z-index: 9; text-align: center; pointer-events: none; }
#obj-arrow { font-size: 21px; color: #ffc95e; text-shadow: 0 0 7px rgba(255,180,60,0.8), 0 1px 3px #000; display: inline-block; }
#obj-dist { font-size: 11.5px; color: #ffeec2; text-shadow: 0 1px 3px #000; font-weight: bold; }
#obj-edge { position: absolute; z-index: 9; pointer-events: none; width: 30px; height: 30px; }
#obj-edge-arrow { font-size: 24px; color: #ffc95e; text-shadow: 0 0 8px rgba(255,180,60,0.9), 0 1px 3px #000; }
#hit-vignette { position: absolute; inset: 0; pointer-events: none; z-index: 8; opacity: 0;
  background: radial-gradient(ellipse at center, transparent 52%, rgba(200,30,20,0.55) 100%); }

#ctx-prompt { position: absolute; left: 50%; bottom: 238px; transform: translateX(-50%); z-index: 11;
  padding: 7px 16px; border-radius: 999px; background: rgba(20, 26, 12, 0.88); border: 2px solid #ffd25a;
  color: #ffeec2; font-weight: bold; font-size: 16px; pointer-events: none; box-shadow: 0 3px 14px rgba(0,0,0,0.5); }
#toast { position: absolute; left: 50%; bottom: 292px; transform: translateX(-50%); z-index: 30; max-width: 86%;
  padding: 9px 15px; border-radius: 12px; background: rgba(16, 20, 9, 0.92); border: 1.5px solid #8a6f3c;
  color: #ffeec2; font-size: 14.5px; text-align: center; box-shadow: 0 4px 16px rgba(0,0,0,0.55); }

/* ---------- controls: one right hand ---------- */
#joy { position: absolute; right: 22px; bottom: calc(24px + env(safe-area-inset-bottom)); width: 128px; height: 128px;
  border-radius: 50%; background: rgba(12, 16, 7, 0.4); border: 2px solid rgba(255, 233, 176, 0.35); z-index: 12; touch-action: none; }
#joy-knob { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; border-radius: 50%;
  transform: translate(-50%, -50%); background: radial-gradient(circle at 35% 30%, #6a7a52, #39482a);
  border: 2px solid rgba(255, 233, 176, 0.55); box-shadow: 0 3px 10px rgba(0,0,0,0.5); }
#btn-cluster { position: absolute; right: 14px; bottom: calc(168px + env(safe-area-inset-bottom)); z-index: 12;
  width: 168px; height: 168px; }
#btn-cluster button { position: absolute; border-radius: 50%; border: 2px solid rgba(255,233,176,0.5);
  background: rgba(14, 18, 9, 0.75); color: #ffeec2; font-weight: bold; box-shadow: 0 3px 10px rgba(0,0,0,0.45); }
#btn-attack { right: 0; bottom: 0; width: 84px; height: 84px; font-size: 33px; background: rgba(94, 52, 20, 0.85); }
#btn-attack.ctx { font-size: 15.5px; background: rgba(38, 84, 34, 0.9); border-color: #ffd25a; }
#btn-guard { right: 92px; bottom: 6px; width: 62px; height: 62px; font-size: 25px; overflow: hidden; }
#btn-guard::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: var(--cd, 0%);
  background: rgba(0,0,0,0.55); pointer-events: none; }
#btn-guard.guarding { border-color: #9fd8ff; box-shadow: 0 0 18px rgba(120, 200, 255, 0.9); background: rgba(30, 70, 110, 0.85); }
#btn-spell { right: 78px; bottom: 78px; width: 56px; height: 56px; font-size: 23px; }
#btn-potion { right: 6px; bottom: 94px; width: 54px; height: 54px; font-size: 15px; }
#btn-cam { right: 142px; bottom: 84px; width: 42px; height: 42px; font-size: 17px; opacity: 0.85; }
#spell-strip { position: absolute; right: 12px; bottom: calc(346px + env(safe-area-inset-bottom)); z-index: 13;
  display: flex; flex-direction: column; gap: 8px; }
.spell-btn { position: relative; overflow: hidden; width: 128px; padding: 10px 8px; border-radius: 12px;
  border: 2px solid rgba(150, 190, 255, 0.6); background: rgba(16, 26, 44, 0.88); color: #dceeff;
  font-size: 19px; text-align: left; }
.spell-btn span { font-size: 12.5px; font-weight: bold; margin-left: 5px; vertical-align: middle; }
.spell-btn .cd { position: absolute; left: 0; right: 0; bottom: 0; height: 0%; background: rgba(0,0,0,0.55); pointer-events: none; }

/* ---------- dialogue ---------- */
#dialogue { position: absolute; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 40;
  background: rgba(14, 17, 8, 0.94); border: 2px solid #8a6f3c; border-radius: 14px; padding: 12px 15px 9px;
  box-shadow: 0 6px 22px rgba(0,0,0,0.6); cursor: pointer; }
#dlg-who { color: #ffd98a; font-weight: bold; font-size: 15px; margin-bottom: 3px; }
#dlg-text { font-size: 16.5px; line-height: 1.42; min-height: 46px; }
#dlg-next { text-align: right; color: #b9ac8d; font-size: 12.5px; margin-top: 2px; }

/* ---------- panels ---------- */
#panel { position: absolute; inset: 0; z-index: 50; background: rgba(5, 7, 3, 0.66); display: flex;
  align-items: center; justify-content: center; padding: 16px; }
#panel-body { width: 100%; max-width: 430px; max-height: 86%; overflow-y: auto; background: #1d2413;
  border: 2px solid #8a6f3c; border-radius: 16px; padding: 18px; box-shadow: 0 10px 34px rgba(0,0,0,0.7); }
#panel-body h2 { margin: 2px 0 8px; color: #ffd98a; font-size: 22px; }
#panel-body h3 { margin: 14px 0 4px; color: #ffd98a; font-size: 16.5px; }
.offer { border: 1px solid #55603c; border-radius: 12px; padding: 10px 12px; margin: 10px 0; background: rgba(255,255,255,0.03); }
.offer p { margin: 5px 0; }
.shoprow { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.07); }
.shopinfo { flex: 1; }
.buybtn { padding: 9px 13px; border-radius: 10px; border: 2px solid #8a6f3c; background: #4c3a17; color: #ffe9b0; font-weight: bold; font-size: 15px; }
.buybtn:disabled { opacity: 0.4; }
.boon { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; padding: 13px; margin: 8px 0;
  border-radius: 13px; border: 2px solid #8a6f3c; background: linear-gradient(#2c2410, #1d2413); color: #f0e6cf; font-size: 16px; }
.boon-ic { font-size: 29px; }
