/* ==================================================================
   BAKUNAWA ISLES · CARTOON 2.5D SKIN
   Hand-drawn, high-resolution mobile game look.
   Layout stays in style.css; this file replaces the visual language.
   ================================================================== */

:root {
  --ivory: #FFF2D6;
  --gold: #FFC247;
  --green: #4FA65B;
  --teal: #1C8C86;
  --night: #0B2B44;
  --terra: #E0603F;
  --brown: #4A2A18;
  --deep: #071E2B;
  --cream: #FFF8E8;
  --parchment: #F9E7C2;
  --parchment-2: #F0D6A6;
  --panel-edge: #3A2116;
  --wood: #7B4A2A;
  --flag-blue: #0038A8;
  --flag-red: #CE1126;
  --flag-yellow: #FCD116;
  --font-display: "Baloo 2", "Trebuchet MS", system-ui, sans-serif;
  --font-body: "Nunito", "Trebuchet MS", system-ui, sans-serif;
  --font-num: "Baloo 2", "Trebuchet MS", system-ui, sans-serif;
  --pixel-shadow: 0 4px 0 rgba(26, 12, 6, 0.35);
  --cartoon-shadow: 0 5px 0 rgba(30, 14, 7, 0.34), 0 14px 30px rgba(0, 0, 0, 0.26);
}

html, body {
  background: #071e2b;
  color: var(--cream);
  font-family: var(--font-body);
}

img { image-rendering: auto; }
button { font-family: var(--font-display); }

.key {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  color: #3a2116;
  background: linear-gradient(#fff8e8, #f3d99d);
  border: 2px solid #6b3d1f;
  border-radius: 7px;
  box-shadow: 0 2px 0 rgba(58, 33, 22, 0.28);
  padding: 2px 6px;
}

/* ------------------------------------------------------------------
   Title screen
   ------------------------------------------------------------------ */

#title { background: #071e2b; }

.title-bg {
  filter: saturate(1.05) contrast(1.02);
  animation: sea-breathe 42s ease-in-out infinite alternate;
}

.title-shade {
  background:
    linear-gradient(180deg, rgba(3, 12, 28, 0.34) 0%, rgba(3, 12, 28, 0) 22%, rgba(3, 12, 28, 0) 48%, rgba(3, 12, 28, 0.72) 86%, rgba(3, 12, 28, 0.96) 100%),
    radial-gradient(ellipse at 50% 38%, rgba(3, 12, 28, 0) 30%, rgba(3, 12, 28, 0.44) 100%);
}

.title-content {
  padding: max(1.4vh, 8px) 16px 54px;
}

.title-art-wrap {
  width: min(600px, 80vw, calc(58vh * 1.284));
  margin-top: max(0.6vh, 3px);
  filter: drop-shadow(0 10px 0 rgba(4, 10, 24, 0.35)) drop-shadow(0 18px 28px rgba(4, 10, 24, 0.4));
  animation: title-drift 19s ease-in-out infinite;
}

.title-art { width: 100%; height: auto; }

.flag-line {
  margin-top: 2px;
  padding: 5px 12px 5px 7px;
  background: rgba(255, 246, 222, 0.94);
  border: 2px solid #ffc247;
  border-radius: 999px;
  box-shadow: 0 3px 0 rgba(26, 12, 6, 0.3);
  color: #3a2116;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.flag { border-radius: 2px; box-shadow: 0 1px 0 rgba(0,0,0,.2); }
.flag-line span { color: #3a2116; font-family: var(--font-display); font-size: 12px; font-weight: 800; }

.title-gloss {
  margin: 6px 0 0;
  color: #ffe7b0;
  font-family: var(--font-body);
  font-size: clamp(11px, 1vw, 14px);
  font-weight: 600;
  text-shadow: 0 2px 0 rgba(3, 10, 22, 0.6);
}
.title-tag {
  margin: 3px auto 0;
  max-width: min(640px, 92vw);
  color: #fff8e8;
  font-family: var(--font-display);
  font-size: clamp(18px, 2vw, 25px);
  font-weight: 700;
  line-height: 1.15;
  text-shadow: 0 3px 0 rgba(3, 10, 22, 0.65);
}

.title-actions { margin-top: 12px; }

.pixel-button {
  width: min(340px, 78vw);
  padding: 14px 24px 15px;
  background: linear-gradient(180deg, #ffe686 0%, #ffc247 52%, #f59a2b 100%);
  border: 3px solid #4a2a18;
  border-radius: 18px;
  color: #3a2116;
  font-family: var(--font-display);
  font-size: clamp(18px, 2vw, 23px);
  font-weight: 800;
  letter-spacing: 0.01em;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.45);
  box-shadow: 0 7px 0 #a75a1e, 0 14px 22px rgba(0, 0, 0, 0.3), inset 0 3px 0 rgba(255, 255, 255, 0.45);
  transition: transform 90ms ease, box-shadow 90ms ease, filter 90ms ease;
}
.pixel-button:hover { filter: brightness(1.05); }
.pixel-button:active,
.pixel-button.pressed {
  transform: translateY(6px);
  box-shadow: 0 2px 0 #a75a1e, 0 5px 10px rgba(0, 0, 0, 0.3), inset 0 3px 0 rgba(255, 255, 255, 0.35);
  filter: brightness(0.96);
}
.pixel-button:disabled { opacity: 0.62; cursor: wait; }

.text-button {
  margin-top: 10px;
  color: #ffe7b0;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-shadow: 0 2px 0 rgba(3, 10, 22, 0.6);
}

.title-save-note { color: #ffd98a; font-size: 11px; font-weight: 700; }
.title-controls { margin-top: 9px; color: #e8d7b7; font-size: 11px; gap: 7px 12px; }
.title-controls b { color: #fff5d8; }
.title-small { color: #cdbfa6; font-size: 9.5px; line-height: 1.55; max-width: 660px; }
.title-foot { color: #b9ab93; font-size: 9px; }
.title-foot .dot { color: var(--gold); }

.sound-toggle {
  background: rgba(7, 30, 43, 0.72);
  border: 2px solid #ffc247;
  border-radius: 999px;
  color: #fff2d6;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px);
}

/* ------------------------------------------------------------------
   HUD
   ------------------------------------------------------------------ */

.hud-strip {
  background:
    linear-gradient(180deg, rgba(123, 74, 42, 0.98) 0%, rgba(74, 42, 24, 0.98) 100%);
  border: 3px solid #2a150d;
  border-radius: 20px;
  box-shadow: 0 6px 0 rgba(18, 8, 4, 0.4), 0 14px 30px rgba(0, 0, 0, 0.24), inset 0 2px 0 rgba(255, 226, 172, 0.25);
  padding: 8px clamp(9px, 1.4vw, 16px);
  min-height: 74px;
}

.portrait-wrap {
  border-radius: 50%;
  border: 3px solid var(--gold);
  background: radial-gradient(circle at 50% 30%, #ffe9b8, #e9b86b);
  box-shadow: 0 3px 0 rgba(18, 8, 4, 0.35), inset 0 2px 0 rgba(255,255,255,.4);
  overflow: hidden;
}
.portrait { object-fit: cover; object-position: 50% 18%; }

.hero-name { color: #fff8e8; font-size: clamp(15px, 1.5vw, 19px); text-shadow: 0 2px 0 rgba(20, 8, 4, 0.4); }
.level {
  font-family: var(--font-num);
  color: #2a150d;
  background: var(--gold);
  border-radius: 999px;
  padding: 1px 7px;
  font-size: clamp(9px, 0.8vw, 11px);
  box-shadow: 0 2px 0 rgba(18, 8, 4, 0.3);
}
.hero-class { color: #f1dfbe; font-family: var(--font-body); font-size: 10px; font-weight: 700; }
.hero-class em { color: #d8bd8c; font-size: 9px; }
.badge-mini img { width: 16px; height: 16px; }

.exp-bar, .bar {
  background: rgba(24, 10, 5, 0.66);
  border: 2px solid rgba(28, 12, 6, 0.72);
  border-radius: 999px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.45);
  padding: 1px;
  height: 9px;
}
.exp-bar span { border-radius: 999px; background: linear-gradient(90deg, #ffe07a, #ffb02e); }
.bar > span { border-radius: 999px; }
.bar.hp > span { background: linear-gradient(90deg, #ff7a57, #d63b2c); }
.bar.sp > span { background: linear-gradient(90deg, #6be7d7, #1c8c86); }
.exp-label, .exp-num, .vital-num { color: #ffe7b0; font-family: var(--font-num); font-size: 8px; }
.vital-icon { width: clamp(15px, 1.5vw, 19px); filter: drop-shadow(0 2px 0 rgba(20, 8, 4, 0.3)); }

.area-tag { border-left: 2px solid rgba(255, 226, 172, 0.22); }
.area-tag b { color: #fff8e8; font-size: 14px; }
.area-tag span { color: #e3c898; font-family: var(--font-body); font-size: 8px; font-weight: 700; }
.area-tag img { filter: drop-shadow(0 2px 0 rgba(20, 8, 4, 0.3)); }

.rank { border-left: 2px solid rgba(255, 226, 172, 0.22); }
.rank span { color: #ffd265; font-family: var(--font-display); font-size: 9px; letter-spacing: 0.08em; }
.rank img { filter: drop-shadow(0 2px 0 rgba(20, 8, 4, 0.3)); }

.piloncito { border-left: 2px solid rgba(255, 226, 172, 0.22); }
.piloncito img { filter: drop-shadow(0 2px 0 rgba(20, 8, 4, 0.3)); }
.piloncito span { color: #ffd265; font-family: var(--font-num); font-size: 11px; }
.piloncito b { color: #fff8e8; }

.hud-icon-btn {
  background: linear-gradient(180deg, #fff6df, #f0d29a);
  border: 2px solid #4a2a18;
  border-radius: 12px;
  color: #3a2116;
  font-family: var(--font-display);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.03em;
  min-height: 34px;
  box-shadow: 0 3px 0 #7d4a25, inset 0 2px 0 rgba(255, 255, 255, 0.55);
  transition: transform 70ms ease, box-shadow 70ms ease;
}
.hud-icon-btn img { filter: drop-shadow(0 1px 0 rgba(255,255,255,.5)); }
.hud-icon-btn:hover { filter: brightness(1.04); }
.hud-icon-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #7d4a25; }
.hud-icon-btn.auto-btn { width: 44px; color: #6b3d1f; }
.hud-icon-btn.auto-btn.auto-on {
  background: linear-gradient(180deg, #8ef0b2, #37b46a);
  border-color: #14522c;
  color: #08331a;
  box-shadow: 0 3px 0 #14522c, inset 0 2px 0 rgba(255, 255, 255, 0.4);
}
.hud-icon-btn.square { width: 34px; }
.hud-icon-btn.wide { width: 44px; }

.quest-strip {
  background: linear-gradient(180deg, rgba(255, 248, 232, 0.97), rgba(244, 219, 178, 0.97));
  border: 2px solid #6b3d1f;
  border-left: 7px solid var(--gold);
  border-radius: 12px;
  color: #3a2116;
  font-size: clamp(10px, 0.9vw, 12px);
  font-weight: 700;
  box-shadow: 0 3px 0 rgba(26, 12, 6, 0.28);
}
.quest-kicker { color: #a55818; font-family: var(--font-display); font-size: 8px; letter-spacing: 0.08em; }

.event-bar {
  background: linear-gradient(180deg, #12566b, #0b3b4d);
  border: 2px solid #06202b;
  border-left: 7px solid var(--flag-yellow);
  border-radius: 12px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3), inset 0 2px 0 rgba(130, 226, 220, 0.2);
  color: #fff2d6;
  font-family: var(--font-body);
  font-size: 8px;
  font-weight: 700;
}
.event-kicker { color: #ffd265; font-family: var(--font-display); }
.event-name { color: #fff8e8; font-family: var(--font-display); font-size: clamp(11px, 1vw, 14px); }
.event-clock-label { color: #9fd8d0; }
.event-clock { color: #ffd265; font-family: var(--font-num); }
.event-small { color: #d7eee8; }

/* ------------------------------------------------------------------
   Toast / prompt
   ------------------------------------------------------------------ */

.toast {
  background: linear-gradient(180deg, #fff8e8, #f4dab4);
  border: 3px solid #6b3d1f;
  border-radius: 16px;
  color: #3a2116;
  font-weight: 700;
  box-shadow: 0 5px 0 rgba(26, 12, 6, 0.3), 0 12px 24px rgba(0, 0, 0, 0.2);
}

.interact-prompt {
  background: linear-gradient(180deg, #12566b, #0b3b4d);
  border: 3px solid #ffd265;
  border-radius: 999px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.32);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  padding: 8px 14px;
}
.prompt-dot { border-radius: 50%; background: #ffd265; }

/* ------------------------------------------------------------------
   Dialogue
   ------------------------------------------------------------------ */

.dialog {
  background:
    linear-gradient(180deg, #fff8e8 0%, #f7e3bd 64%, #efd09c 100%);
  border: 3px solid #6b3d1f;
  border-radius: 20px;
  color: #3a2116;
  box-shadow: 0 6px 0 rgba(26, 12, 6, 0.34), 0 18px 36px rgba(0, 0, 0, 0.28), inset 0 3px 0 rgba(255, 255, 255, 0.5);
  padding: 36px 26px 20px 23%;
}
.dialog::before {
  content: "";
  position: absolute;
  left: 3.4%;
  top: 9%;
  bottom: 9%;
  width: 15.5%;
  border-radius: 14px;
  background: linear-gradient(180deg, #1c8c86, #0e5b58);
  border: 2px solid #3a2116;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.2);
}
.speaker-icon {
  left: 4.6%;
  top: 12%;
  width: 13%;
  height: 38%;
  border-radius: 12px;
  border: 2px solid #ffd265;
  background: #fff2d6;
}
.speaker-icon.creature { background: #fff2d6; }
.speaker-name { color: #b85b14; font-family: var(--font-display); font-size: clamp(16px, 1.5vw, 20px); }
.speaker-name span { color: #7b5b3a; font-family: var(--font-body); font-size: 10px; font-weight: 700; }
.dialog-text { color: #3a2116; font-family: var(--font-body); font-size: clamp(12px, 1.1vw, 14.5px); font-weight: 600; line-height: 1.5; }
.dialog-cursor { background: #1c8c86; border-radius: 2px; }
.dialog-next { color: #1c8c86; font-family: var(--font-display); font-size: 10px; font-weight: 800; }

/* ------------------------------------------------------------------
   Buttons, loaders, overlays
   ------------------------------------------------------------------ */

.loading { background: rgba(3, 12, 22, 0.78); }
.loading-box {
  background: linear-gradient(180deg, #fff8e8, #f4dab4);
  border: 3px solid #6b3d1f;
  border-radius: 22px;
  color: #3a2116;
  box-shadow: var(--cartoon-shadow);
}
.loading-glyph img { filter: drop-shadow(0 3px 0 rgba(58,33,22,.2)); }
.loading-box p { color: #3a2116; font-family: var(--font-display); font-weight: 700; }
.loading-bar { background: rgba(58, 33, 22, 0.2); border-radius: 999px; border: 1px solid rgba(58,33,22,.4); }
.loading-bar span { background: linear-gradient(90deg, #ffe07a, #ff9e2e); border-radius: 999px; }

/* ------------------------------------------------------------------
   Skill slots
   ------------------------------------------------------------------ */

.skill-dock { gap: 8px; }
.skill-edit {
  background: linear-gradient(180deg, #fff6df, #f0d29a);
  border: 2px solid #4a2a18;
  color: #3a2116;
  border-radius: 50%;
  font-family: var(--font-display);
  font-size: 7px;
  font-weight: 800;
  box-shadow: 0 3px 0 #7d4a25;
}
.skill-edit:active { transform: translateY(2px); box-shadow: 0 1px 0 #7d4a25; }
.skill-slot {
  background: radial-gradient(circle at 40% 28%, #2aa89f, #0e5b58 72%);
  border: 3px solid #4a2a18;
  box-shadow: 0 4px 0 rgba(26, 12, 6, 0.4), inset 0 2px 0 rgba(255, 255, 255, 0.2);
  background-size: 72%;
  background-position: center;
  background-repeat: no-repeat;
}
.skill-slot[data-slot="0"] { background-image: url("assets/art/skill_bolo.webp"); }
.skill-slot[data-slot="1"] { background-image: url("assets/art/skill_whirl.webp"); }
.skill-slot[data-slot="2"] { background-image: url("assets/art/skill_heal.webp"); }
.skill-slot[data-slot="3"] { background-image: url("assets/art/skill_dash.webp"); }
.skill-slot .skill-glyph { display: none; }
.skill-slot .skill-cost {
  right: 2px;
  bottom: 1px;
  min-width: 13px;
  padding: 0 3px;
  border-radius: 999px;
  background: rgba(7, 22, 28, 0.78);
  color: #ffe07a;
  font-family: var(--font-num);
  font-size: 7px;
  text-align: center;
}
.skill-slot .skill-cd { background: rgba(5, 18, 24, 0.78); font-family: var(--font-num); font-size: 12px; }
.skill-slot.cooling { border-color: #7d8a75; filter: saturate(0.45); }
.skill-slot:active { transform: scale(0.9); }
.skill-slot.no-sp { opacity: 0.5; }

.view-btn {
  position: absolute;
  z-index: 24;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 3px solid #4a2a18;
  background: linear-gradient(180deg, #fff6df, #f0d29a);
  color: #3a2116;
  font-family: var(--font-display);
  font-size: 7px;
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 0 #7d4a25, 0 8px 16px rgba(0,0,0,.2);
  cursor: pointer;
  touch-action: manipulation;
}
.view-btn:active { transform: translateY(calc(-50% + 3px)); box-shadow: 0 1px 0 #7d4a25; }
body.dialog-open .view-btn,
body.codex-open .view-btn,
body.help-open .view-btn,
body.event-open .view-btn,
body.tithe-open .view-btn,
body.reward-open .view-btn,
body.skill-open .view-btn { display: none; }

/* ------------------------------------------------------------------
   Touch controls
   ------------------------------------------------------------------ */

.run-btn, .action-btn {
  background: linear-gradient(180deg, #fff6df, #f0d29a);
  border: 3px solid #4a2a18;
  color: #3a2116;
  font-family: var(--font-display);
  font-weight: 800;
  box-shadow: 0 4px 0 #7d4a25, 0 8px 16px rgba(0,0,0,.2);
}
.action-btn {
  width: 72px;
  height: 72px;
  border-color: #ffd265;
  background: linear-gradient(180deg, #ffd86a, #ff9e2e);
  color: #3a2116;
  font-size: 10px;
}
.action-btn.ready { border-color: #fff2d6; }
.action-btn.is-on { background: linear-gradient(180deg, #8ef0b2, #37b46a); color: #0a3a1e; }
.run-btn[aria-pressed="true"] { background: linear-gradient(180deg, #8ef0b2, #37b46a); color: #0a3a1e; }
.run-btn:active, .action-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #7d4a25; }

/* ------------------------------------------------------------------
   Codex
   ------------------------------------------------------------------ */

.codex-overlay { background: rgba(4, 14, 19, 0.62); }
.codex-page {
  width: min(470px, 43vw, calc(90vh * 0.667));
  aspect-ratio: 2 / 3;
  filter: drop-shadow(0 8px 0 rgba(26, 12, 6, 0.34)) drop-shadow(0 24px 40px rgba(0, 0, 0, 0.35));
}
.codex-banner {
  top: 5.4%;
  left: 10.5%;
  width: 79%;
  height: 13.5%;
  background: transparent;
  color: #4a2a18;
  padding: 0 2px;
  gap: 2px;
}
.codex-title span { color: #4a2a18; font-family: var(--font-display); letter-spacing: 0.06em; text-shadow: 0 1px 0 rgba(255,255,255,.35); }
.codex-title em { color: #1c8c86; font-family: var(--font-body); font-weight: 700; }
.codex-arrow {
  background: linear-gradient(180deg, #fff6df, #f0d29a);
  border: 2px solid #6b3d1f;
  border-radius: 50%;
  color: #3a2116;
  box-shadow: 0 2px 0 rgba(58,33,22,.25);
  font-family: var(--font-display);
  font-weight: 800;
}
.codex-arrow:hover { filter: brightness(1.05); }
.codex-close {
  top: -42px;
  right: 0;
  width: 34px;
  height: 34px;
  background: linear-gradient(180deg, #fff6df, #f0d29a);
  border: 2px solid #6b3d1f;
  border-radius: 50%;
  color: #3a2116;
  box-shadow: 0 3px 0 rgba(58,33,22,.25);
  font-family: var(--font-display);
}
.codex-body { top: 20.4%; left: 9.8%; right: 10.2%; bottom: 21%; }
.codex-index button {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid #a57d4a;
  background: rgba(255,255,255,.35);
}
.codex-index button.unlocked { background: #1c8c86; border-color: #145e5a; }
.codex-index button.current { background: #ffc247; border-color: #a55818; }
.codex-word { color: #146b67; font-family: var(--font-display); font-weight: 800; }
.codex-gloss { color: #a55818; font-family: var(--font-display); font-weight: 700; letter-spacing: 0.08em; }
.codex-rule { height: 3px; background: linear-gradient(90deg, #1c8c86, #ffc247); border-radius: 999px; opacity: 0.9; }
.codex-note { color: #3a2116; font-family: var(--font-body); font-weight: 600; }
.codex-locked { color: #7a5b3a; }
.codex-locked .lock-mark { color: #c39a5e; }
.codex-seal span { color: #3a2116; font-family: var(--font-body); font-size: clamp(7px, .6vw, 8px); font-weight: 800; }
.codex-seal.mixed span { color: #a55818; }
.codex-legend { color: #7a5b3a; font-weight: 700; }

/* ------------------------------------------------------------------
   Skill book, event, tithe, help, reward
   ------------------------------------------------------------------ */

.skill-book-card,
.event-card,
.help-panel,
.reward-card {
  background: linear-gradient(180deg, #fff8e8 0%, #f7e3bd 70%, #efd09c 100%);
  border: 3px solid #6b3d1f;
  border-radius: 22px;
  color: #3a2116;
  box-shadow: var(--cartoon-shadow);
  clip-path: none;
}
.skill-book-head,
.event-panel-head,
.help-head {
  background: linear-gradient(180deg, #1c8c86, #0e5b58);
  color: #fff8e8;
  font-family: var(--font-display);
  font-weight: 800;
  border-radius: 16px 16px 0 0;
  border-bottom: 2px solid #3a2116;
}
.event-close {
  background: rgba(255, 246, 222, 0.92);
  border: 2px solid #3a2116;
  border-radius: 50%;
  color: #3a2116;
  font-family: var(--font-display);
  font-weight: 800;
}
.event-card h2, .help-head, .reward-card h2, .skill-book-head {
  font-family: var(--font-display);
  color: #146b67;
}
.event-card h2 { color: #146b67; font-weight: 800; }
.event-story, .help-body p, .reward-note, .event-source, .event-pack { font-family: var(--font-body); font-weight: 600; }
.event-story { color: #3a2116; }
.event-time-line { color: #a55818; font-family: var(--font-display); font-weight: 700; }
.event-goal-label span, .event-wallet, .event-source, .event-pack, .event-note { color: #7a5b3a; }
.event-goal-label b { color: #146b67; font-family: var(--font-num); }
.event-meter { background: rgba(58,33,22,.16); border: 2px solid rgba(58,33,22,.35); border-radius: 999px; padding: 1px; height: 10px; }
.event-meter span { border-radius: 999px; background: linear-gradient(90deg, #ffe07a, #ff9e2e); }
.event-meter.world span { background: linear-gradient(90deg, #6be7d7, #1c8c86); }
.event-reward { color: #146b67; font-weight: 700; }
.event-go, .help-close, .reward-close, .skill-book-done {
  background: linear-gradient(180deg, #ffe686, #ffc247 52%, #f59a2b);
  border: 3px solid #4a2a18;
  border-radius: 14px;
  color: #3a2116;
  font-family: var(--font-display);
  font-weight: 800;
  box-shadow: 0 4px 0 #a75a1e, inset 0 2px 0 rgba(255,255,255,.4);
}
.event-go:hover, .help-close:hover, .reward-close:hover { filter: brightness(1.04); }
.event-go:active, .help-close:active, .reward-close:active { transform: translateY(3px); box-shadow: 0 1px 0 #a75a1e; }
.event-panel-head, .help-head, .skill-book-head { margin: 0 -18px 12px; }
.event-panel-head { margin: 0 -24px 12px; }

.tithe-option { background: rgba(255, 246, 222, 0.66); border: 2px solid #b58a52; border-radius: 14px; }
.tithe-option:hover { border-color: #1c8c86; background: #fff8e8; }
.tithe-amount { color: #a55818; font-family: var(--font-num); }
.tithe-name { color: #146b67; font-family: var(--font-display); }
.tithe-hint { color: #7a5b3a; font-family: var(--font-body); font-weight: 600; }
.tithe-balance b { color: #a55818; }

.reward-chest { image-rendering: auto; filter: drop-shadow(0 6px 0 rgba(58,33,22,.25)); }
.reward-kicker { color: #a55818; font-family: var(--font-display); }
.reward-card h2 { color: #146b67; }
.reward-rarity { font-family: var(--font-display); }
.reward-close { width: 100%; padding: 10px 12px; }

.skill-book-note, .skill-choice span, .help-note { color: #7a5b3a; font-weight: 600; }
.skill-edit-slot { background: rgba(255,246,222,.7); border: 3px solid #b58a52; }
.skill-edit-slot.sel { border-color: #1c8c86; background: #e9f6df; }
.skill-choice { background: rgba(255,246,222,.7); border: 2px solid #b58a52; border-radius: 12px; }
.skill-choice b { color: #146b67; font-family: var(--font-display); }
.skill-choice:hover { border-color: #1c8c86; }

.help-body b { color: #146b67; }
.help-note { border-top: 2px solid rgba(58,33,22,.16); }

/* ------------------------------------------------------------------
   Responsive adjustments
   ------------------------------------------------------------------ */

@media (max-width: 860px) {
  .hud-strip { border-radius: 16px; }
  .codex-page { width: min(470px, calc(88vh * 0.667)); }
  .view-btn { width: 42px; height: 42px; left: 6px; }
}

@media (max-width: 560px) {
  .title-art-wrap { width: 88vw; margin-left: 0; margin-right: 0; }
  .title-tag { font-size: 17px; }
  .title-gloss { font-size: 10.5px; }
  .title-small { font-size: 9px; }
  .hud-strip { border-radius: 14px; }
  .portrait-wrap { border-width: 2px; }
  .dialog { border-radius: 16px; padding: 34px 16px 14px 24%; }
  .dialog::before { left: 3.6%; width: 15%; }
  .speaker-icon { left: 4.6%; width: 12.5%; }
  .codex-page { width: min(94vw, calc(86vh * 0.667)); }
  .view-btn { width: 38px; height: 38px; font-size: 6px; left: 5px; }
  .hud-icon-btn { min-height: 30px; border-radius: 10px; }
  .pixel-button { padding: 12px 20px 13px; border-radius: 16px; }
  .action-btn { width: 64px; height: 64px; }
}

@media (max-height: 540px) and (orientation: landscape) {
  .title-art-wrap { width: min(430px, 48vw); }
  .dialog { border-radius: 14px; }
  .codex-page { width: min(400px, calc(92vh * 0.667)); }
  .view-btn { width: 36px; height: 36px; top: 52%; }
}


/* Compact HUD on narrow phones */
@media (max-width: 600px) {
  .hud { padding-left: 5px; padding-right: 5px; }
  .hud-strip {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto auto;
    grid-template-areas:
      "portrait name coin buttons"
      "portrait class class buttons"
      "exp exp exp exp"
      "vitals vitals vitals vitals";
    gap: 2px 6px;
    align-items: center;
    min-height: 0;
    padding: 7px 8px;
    border-radius: 14px;
  }
  .who { display: contents; }
  .portrait-wrap { grid-area: portrait; width: 42px; height: 42px; align-self: center; }
  .who-top { grid-area: name; align-self: end; padding: 0; }
  .hero-class { grid-area: class; align-self: start; font-size: 8px; }
  .exp-line { grid-area: exp; margin-top: 1px; }
  .vitals { grid-area: vitals; display: flex; flex-direction: row; gap: 10px; max-width: none; min-width: 0; }
  .vital { flex: 1 1 0; min-width: 0; }
  .piloncito { grid-area: coin; align-self: center; padding-left: 0; border-left: 0; }
  .hud-buttons { grid-area: buttons; margin-left: 0; align-self: center; gap: 3px; }
  .hud-icon-btn { min-height: 28px; padding: 0 4px; font-size: 7px; border-radius: 9px; }
  .hud-icon-btn.square { width: 28px; }
  .hud-icon-btn.auto-btn { width: 33px; }
  .hud-icon-btn.wide { width: 33px; }
  .hud-icon-btn img { width: 17px; height: 17px; }
  .hud-icon-btn span { display: none; }
  .portrait { object-fit: cover; }
  .exp-bar { width: auto; flex: 1 1 auto; height: 6px; }
  .bar { height: 7px; }
  .vital-num { display: block; min-width: 16px; font-size: 7px; }
  .exp-num { font-size: 7px; }
  .hero-name { font-size: 12.5px; }
  .hero-class em { display: none; }
  .hero-class .level-inline { display: inline; }
  .who-top .level { display: none; }
  .rank, .area-tag { display: none; }
  .quest-strip { margin-top: 3px; }
  .event-bar { margin-top: 3px; }
}

.title-controls b.key, .title-controls .key { color: #3a2116; text-shadow: none; }
.codex-seal img { width: clamp(30px, 3.2vw, 40px); }
.codex-seal span { font-size: 9px; }
.codex-legend { font-size: 8px; }


/* Help reads as a full field card, with the HUD out of its way */
.help-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
}
.help-panel {
  width: min(460px, 92vw);
  padding: 56px 28px 22px;
  margin: auto;
}
.help-head { font-size: 16px; }
.help-body p { font-size: 12px; line-height: 1.55; }
.help-note { font-size: 10px !important; }
body.help-open .hud { opacity: 0; pointer-events: none; }
