/* ============ MATHFABLE — ADVENTURE WORLD ============ */
/* Styles for the overworld screen only. Loaded after style.css; touches no existing selectors. */

#screen-overworld { gap: 10px; }

#ow-wrap {
  position: relative;
  display: flex; justify-content: center;
  background: #0d0a1e;
  border: 2px solid rgba(255,255,255,.14);
  border-radius: 16px;
  padding: 8px 0;
  overflow: hidden;
  /* Full-bleed: break out of the 520px #app cap so the canvas can upscale
     past 1× on larger displays (owResize picks the integer scale). */
  width: 100vw; max-width: 100vw;
  margin-left: 50%; transform: translateX(-50%);
}
#ow-canvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border-radius: 6px;
  touch-action: none;
}

/* ---------- speech box (Pokémon-style, bottom of the view) ---------- */
/* parchment "narrator" textbox — the storybook speaks on paper, not on night sky */
#ow-dialog {
  position: absolute; left: 10px; right: 10px; bottom: 10px;
  background: linear-gradient(180deg,#f6ecd9,#e9d9b8);
  border: 2px solid #b98a3e;
  border-radius: 12px;
  padding: 8px 12px 6px;
  cursor: pointer;
  color: #3b2a20;
  box-shadow: 0 4px 14px rgba(0,0,0,.45);
  z-index: 4;
}
#ow-dialog-name { font-size: 12px; font-weight: bold; color: #8a5a12; margin-bottom: 2px; }
#ow-dialog-text { font-size: 15px; line-height: 1.3; min-height: 20px; color: #3b2a20; }
.ow-dialog-hint { text-align: right; font-size: 10px; color: #9a7648; animation: pulse 1.2s infinite; }

/* ---------- avatar picker (first entry) ---------- */
#ow-picker {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10,6,26,.9);
  z-index: 6;
}
.ow-picker-card {
  background: rgba(30,20,64,.97);
  border: 2px solid rgba(255,255,255,.2);
  border-radius: 18px;
  padding: 14px 16px;
  text-align: center;
  max-width: 300px;
}
.ow-picker-card h3 { margin-bottom: 10px; font-size: 17px; }
.ow-avatar-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.ow-avatar {
  font-size: 28px; padding: 6px 4px;
  background: rgba(255,255,255,.1);
  border: 2px solid transparent;
  border-radius: 12px;
  transition: transform .08s;
}
.ow-avatar:active { transform: scale(.92); }
.ow-avatar:hover { border-color: #fde047; }

/* ---------- touch controls (thumb-sized d-pad + Ⓐ) ---------- */
#ow-controls {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 0 6px;
}
#ow-dpad {
  display: grid;
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(2, 52px);
  gap: 4px;
}
#ow-dpad button {
  font-size: 20px; color: #fff;
  background: linear-gradient(180deg,#4f46e5,#3730a3);
  border-bottom: 3px solid #1e1b6e;
  border-radius: 12px;
  touch-action: none;
  user-select: none; -webkit-user-select: none;
}
#ow-dpad button:active { transform: scale(.93); background: #4f46e5; }
#ow-dpad button[data-dir="up"]    { grid-column: 2; grid-row: 1; }
#ow-dpad button[data-dir="left"]  { grid-column: 1; grid-row: 2; }
#ow-dpad button[data-dir="right"] { grid-column: 3; grid-row: 2; }
#ow-dpad button[data-dir="down"]  { grid-column: 2; grid-row: 2; }
#ow-a {
  width: 72px; height: 72px;
  font-size: 26px; font-weight: bold; color: #fff;
  background: linear-gradient(180deg,#f59e0b,#ea580c);
  border-bottom: 4px solid #9a3412;
  border-radius: 50%;
  touch-action: none;
  user-select: none; -webkit-user-select: none;
}
#ow-a:active { transform: scale(.93); }

/* ---------- wild battle (low-pressure: no timer, no hearts) ---------- */
#ow-battle {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: rgba(255,255,255,.08);
  border: 2px solid rgba(255,255,255,.14);
  border-radius: 18px;
  padding: 14px 12px;
  text-align: center;
}
.owb-creature { font-size: 64px; line-height: 1.05; filter: drop-shadow(0 6px 7px rgba(0,0,0,.5)); animation: bob 2s ease-in-out infinite; }
.owb-creature.boss { font-size: 76px; filter: drop-shadow(0 0 10px rgba(248,113,113,.8)) drop-shadow(0 6px 7px rgba(0,0,0,.5)); animation: bob 1.4s ease-in-out infinite; }
#owb-name { font-size: 16px; font-weight: bold; color: #a7f3d0; }
#owb-speech { font-size: 14px; color: #e9d5ff; min-height: 18px; }
#owb-viz { max-height: 30vh; }
#owb-problem { font-size: 32px; font-weight: bold; letter-spacing: 2px; min-height: 38px; }
#owb-problem .typed { color: #fde047; border-bottom: 4px solid #fde047; padding: 0 2px; min-width: 20px; display: inline-block; }
#owb-problem.wrongshake { animation: shakeS .3s; color: #fca5a5; }
#owb-dots { display: flex; gap: 8px; }
#owb-msg { font-size: 13px; color: #fbcfe8; min-height: 18px; font-weight: 600; }
#owb-keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; max-width: 300px; }
.owb-actions { width: 100%; display: flex; }

@media (max-width: 380px) {
  #ow-dpad { grid-template-columns: repeat(3, 46px); grid-template-rows: repeat(2, 46px); }
  #ow-a { width: 62px; height: 62px; }
  .owb-creature { font-size: 52px; }
  #owb-problem { font-size: 27px; }
}

/* ---------- header buttons (Bag / Emojidex) ---------- */
.ow-head-btns { margin-left: auto; display: flex; gap: 6px; }

/* ---------- menu overlays: Bag · Trader · Emojidex ---------- */
.ow-panel {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10, 6, 26, .82);
  padding: 12px;
}
.ow-panel-card {
  background: rgba(30, 20, 64, .98);
  border: 2px solid rgba(255, 255, 255, .18);
  border-radius: 18px;
  padding: 12px 14px 14px;
  width: 100%; max-width: 460px; max-height: 88vh; overflow-y: auto;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .5);
}
.ow-panel-card.wide { max-width: 520px; }
.ow-panel-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.ow-panel-head h3 { font-size: 19px; margin: 0; }
.ow-panel-head .coin-chip { margin-left: auto; }
.ow-x {
  font-size: 15px; width: 30px; height: 30px; border-radius: 50%;
  background: rgba(255, 255, 255, .12); color: #fff; border: none; flex: none;
}
.ow-x:active { transform: scale(.9); }
.ow-empty { text-align: center; color: #c4b5fd; padding: 22px 8px; line-height: 1.5; }
.ow-panel-foot { margin-top: 12px; text-align: center; }

/* bag */
.ow-bag-cat { font-size: 13px; font-weight: bold; color: #fde047; margin: 10px 0 5px; }
.ow-bag-grid { display: flex; flex-direction: column; gap: 6px; }
.ow-bag-item, .ow-shop-item {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 12px; padding: 7px 9px;
}
.bi-emoji { font-size: 26px; flex: none; width: 30px; text-align: center; }
.bi-info { flex: 1; min-width: 0; font-size: 14px; line-height: 1.25; }
.bi-info small { display: block; color: #c4b5fd; font-size: 11.5px; }
.bi-x { color: #fbbf24; font-size: 12px; font-weight: bold; }
.bi-use {
  flex: none; font-size: 13px; font-weight: bold; color: #fff;
  background: linear-gradient(180deg, #22c55e, #16a34a);
  border: none; border-bottom: 3px solid #14532d; border-radius: 10px;
  padding: 7px 12px; min-width: 52px;
}
.bi-use.flex { background: linear-gradient(180deg, #a78bfa, #7c3aed); border-bottom-color: #4c1d95; }
.bi-use:active { transform: scale(.93); }

/* trader */
.ow-shop-grid { display: flex; flex-direction: column; gap: 6px; }

/* emojidex */
.ow-dex-bar { height: 12px; border-radius: 8px; background: rgba(255, 255, 255, .1); overflow: hidden; margin-bottom: 4px; }
.ow-dex-bar > div { height: 100%; background: linear-gradient(90deg, #f472b6, #fbbf24, #34d399); transition: width .4s; }
.ow-dex-pct { text-align: center; font-size: 12.5px; color: #e9d5ff; margin-bottom: 8px; }
.ow-dex-ms { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 10px; }
.ow-dex-ms span {
  font-size: 11px; padding: 3px 8px; border-radius: 20px;
  background: rgba(255, 255, 255, .07); color: #c4b5fd; border: 1px solid rgba(255, 255, 255, .1);
}
.ow-dex-ms span.done { background: rgba(52, 211, 153, .22); color: #a7f3d0; border-color: rgba(52, 211, 153, .5); }
.ow-dex-cat { font-size: 13px; font-weight: bold; color: #fde047; margin: 12px 0 6px; }
.ow-dex-cat small { color: #c4b5fd; font-weight: normal; }
.ow-dex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: 5px; }
.de {
  font-size: 21px; text-align: center; padding: 4px 0;
  background: rgba(255, 255, 255, .05); border-radius: 9px;
  filter: grayscale(1); opacity: .45;
}
.de.got { filter: none; opacity: 1; background: rgba(253, 224, 71, .12); }
