:root {
  --bg: #1b2a1b;
  --panel: rgba(20, 24, 32, 0.88);
  --panel-solid: #1d2230;
  --text: #f2f4f8;
  --muted: #a6adbb;
  --accent: #ffcb05;
  --danger: #e5484d;
  --radius: 12px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  user-select: none; -webkit-user-select: none;
  touch-action: none;
}

canvas#game { position: fixed; inset: 0; display: block; }

.hidden { display: none !important; }

/* ---------- joystick ---------- */
#joyzone { position: fixed; left: 0; top: 56px; bottom: 0; width: 50%; z-index: 2; touch-action: none; }
#joy-base {
  display: none; position: fixed; width: 110px; height: 110px; border-radius: 50%;
  background: rgba(255,255,255,0.12); border: 2px solid rgba(255,255,255,0.35);
  z-index: 3; pointer-events: none;
}
#joy-knob {
  position: absolute; left: 30px; top: 30px; width: 50px; height: 50px; border-radius: 50%;
  background: rgba(255,255,255,0.55);
}

/* ---------- shared bits ---------- */
.btn {
  font: inherit; color: var(--text); background: #2c3346; border: 1px solid #44506a;
  border-radius: 10px; padding: 8px 14px; cursor: pointer; font-weight: 600;
}
.btn:hover { background: #36405a; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--accent); color: #1a1a1a; border-color: #d4a800; }
.btn.danger { background: #4a2024; border-color: var(--danger); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.pill { display: inline-block; background: rgba(255,255,255,0.12); border-radius: 999px; padding: 4px 10px; font-size: 13px; font-weight: 600; }
.pill.gold { background: #8a6d00; color: #fff3b0; }
.type { display: inline-block; font-size: 10px; text-transform: uppercase; font-weight: 700; color: #fff;
  padding: 1px 6px; border-radius: 6px; margin-left: 3px; text-shadow: 0 1px 1px rgba(0,0,0,0.4); vertical-align: middle; }
kbd { font: 600 10px ui-monospace, monospace; background: rgba(0,0,0,0.35); border-radius: 4px; padding: 1px 4px; margin-left: 4px; }
.bar { height: 8px; background: rgba(255,255,255,0.15); border-radius: 4px; overflow: hidden; margin: 4px 0; }
.bar > div { height: 100%; background: #4cd964; transition: width 0.15s; }
.bar.xp { height: 4px; }
.bar.xp > div { background: #4aa3ff; }
.bar.small { height: 5px; width: 90px; }
.muted { color: var(--muted); }
.center { text-align: center; justify-content: center; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; align-items: center; }

/* ---------- world HUD ---------- */
#hud { position: fixed; inset: 0; z-index: 5; pointer-events: none; }
.hud-top {
  position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 10px max(12px, env(safe-area-inset-left));
  background: linear-gradient(rgba(10,14,22,0.55), transparent);
}
.hud-top > * { pointer-events: auto; }
.area-pill { display: flex; flex-direction: column; background: rgba(20,24,32,0.78); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px; padding: 6px 12px; line-height: 1.2; backdrop-filter: blur(6px); }
.area-pill b { font-size: 14px; }
.area-pill small { font-size: 11px; color: var(--accent); }
.hud-right { display: flex; align-items: center; gap: 6px; }
.hud-right .pill { background: rgba(20,24,32,0.78); border: 1px solid rgba(255,255,255,0.12); padding: 6px 10px; }

.party-bar {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: max(12px, env(safe-area-inset-bottom));
  display: flex; gap: 6px; padding: 6px; pointer-events: auto;
  background: rgba(20,24,32,0.78); border: 1px solid rgba(255,255,255,0.12); border-radius: 16px; backdrop-filter: blur(6px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.slot { position: relative; width: 62px; padding: 4px 4px 6px; font: inherit; color: var(--text); cursor: pointer; touch-action: none;
  background: rgba(255,255,255,0.06); border: 2px solid transparent; border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; transition: transform 0.12s, border-color 0.12s; }
.slot:hover { transform: translateY(-3px); border-color: rgba(255,255,255,0.3); }
.slot.lead { border-color: var(--accent); background: rgba(255,203,5,0.12); }
.slot.fainted img { filter: grayscale(1) brightness(0.6); }
.slot img { width: 60px; height: 60px; image-rendering: pixelated; margin: -8px 0 -10px; }
.slot kbd { position: absolute; top: 3px; left: 3px; margin: 0; }
.slot-lv { font-size: 11px; font-weight: 700; }
.slot .bar { display: block; width: 100%; margin: 0; }
.slot .bar.hp { height: 5px; }
.slot .bar.xp { height: 3px; }
.slot .bar i { display: block; height: 100%; background: #4cd964; transition: width 0.2s; }
.slot .bar.xp i { background: #4aa3ff; }
.lead-tag { position: absolute; top: -9px; left: 50%; transform: translateX(-50%); background: var(--accent); color: #1a1a1a;
  font-size: 9px; font-weight: 800; padding: 1px 6px; border-radius: 6px; letter-spacing: 0.04em; }

/* ---------- post-battle XP ---------- */
.xp-row { display: flex; gap: 10px; align-items: center; background: #262c3c; border-radius: 12px; padding: 8px 12px; transition: background 0.3s; }
.xp-row.leveled { background: linear-gradient(90deg, rgba(255,203,5,0.18), #262c3c); }
.xp-row img { width: 64px; height: 64px; image-rendering: pixelated; }
.xp-info { flex: 1; min-width: 0; }
.xp-head { display: flex; gap: 8px; align-items: baseline; }
.xp-head .lv { color: var(--muted); font-size: 13px; }
.xp-head .gain { margin-left: auto; color: #7cc4ff; font-weight: 700; }
.bar.xp.big { height: 10px; border-radius: 5px; }
.bar.xp.big > div { transition: none; background: linear-gradient(90deg, #4aa3ff, #7cd1ff); }
.xp-foot { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.lvup { color: var(--accent); font-weight: 800; }

/* ---------- toasts ---------- */
#toasts { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); z-index: 20;
  display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; width: min(92vw, 460px); }
body.stadium-battle #toasts { top: max(150px, 22vh); }
.toast { background: var(--panel); border: 1px solid rgba(255,255,255,0.15); border-radius: 10px; padding: 8px 14px;
  font-size: 14px; text-align: center; transition: opacity 0.4s, transform 0.4s; }
.toast.out { opacity: 0; transform: translateY(-8px); }

/* ---------- modals ---------- */
#modal-root { position: fixed; inset: 0; z-index: 30; display: none; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.55); padding: 16px; }
#modal-root.open { display: flex; }
.modal { background: var(--panel-solid); border: 1px solid #3a4258; border-radius: 16px; padding: 18px;
  width: min(100%, 480px); max-height: 100%; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.5); user-select: text; }
.modal.wide { width: min(100%, 760px); }
.modal h2 { margin: 0 0 8px; font-size: 20px; }
.modal h3 { margin: 16px 0 8px; font-size: 15px; color: var(--muted); }
.modal p { line-height: 1.45; }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal img.big { display: block; margin: 0 auto; width: 140px; height: 140px; image-rendering: pixelated; }
.help { margin-top: 14px; font-size: 13px; color: var(--muted); line-height: 1.5; background: rgba(255,255,255,0.05); padding: 10px; border-radius: 10px; }

.starter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.starter { font: inherit; color: var(--text); background: #262c3c; border: 2px solid #3a4258; border-radius: 14px;
  padding: 10px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.starter:hover { border-color: var(--accent); }
.starter img { width: 96px; height: 96px; image-rendering: pixelated; }

.list { display: flex; flex-direction: column; gap: 8px; }
.mon-card { display: flex; gap: 10px; align-items: flex-start; background: #262c3c; border-radius: 12px; padding: 8px; flex: 1; text-align: left; }
.mon-card.fainted { opacity: 0.5; }
.mon-card img { width: 72px; height: 72px; image-rendering: pixelated; flex-shrink: 0; }
.mon-info { flex: 1; min-width: 0; }
.mon-title { font-size: 15px; }
.mon-title span { color: var(--muted); font-size: 13px; }
.mon-sub { font-size: 12px; color: var(--muted); }
.moves { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-top: 6px; }
.move-chip { display: inline-flex; flex-direction: column; border-left: 4px solid; background: rgba(255,255,255,0.05);
  border-radius: 6px; padding: 3px 8px; font-size: 13px; }
.move-chip small { color: var(--muted); font-size: 11px; }

.pick { font: inherit; color: var(--text); background: transparent; border: 2px solid transparent; border-radius: 14px;
  padding: 0; cursor: pointer; display: flex; align-items: center; gap: 8px; text-align: left; position: relative; }
.pick:hover:not(:disabled) { border-color: #556; }
.pick.on { border-color: var(--accent); }
.pick:disabled { cursor: default; }
.list > .pick:not(:has(.mon-card)) { background: #262c3c; padding: 8px; }
.pick .order { position: absolute; top: 6px; left: 6px; z-index: 1; background: var(--accent); color: #111; font-weight: 800;
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; }
.gym-team { display: flex; gap: 10px; flex-wrap: wrap; }
.gym-team .mini { display: flex; flex-direction: column; align-items: center; background: #262c3c; border-radius: 10px; padding: 4px 10px; }
.gym-team img { width: 64px; height: 64px; image-rendering: pixelated; }

.evo { display: flex; align-items: center; justify-content: center; gap: 12px; font-size: 28px; }
.evo img { width: 110px; height: 110px; image-rendering: pixelated; }
.evo img.glow { animation: glow 1s infinite alternate; }
@keyframes glow { from { filter: brightness(1); } to { filter: brightness(2.2) drop-shadow(0 0 12px #fff); } }

/* ---------- battle HUD ---------- */
#battle-hud { position: fixed; inset: 0; z-index: 5; pointer-events: none; }
.bh-top { position: absolute; top: max(8px, env(safe-area-inset-top)); left: 8px; right: 8px; display: flex; justify-content: space-between; gap: 8px; }
.bh-card { background: linear-gradient(160deg, rgba(34,40,56,0.92), rgba(16,19,28,0.92)); border-radius: 14px; padding: 8px 12px;
  width: min(46vw, 300px); border: 1px solid rgba(255,255,255,0.08); border-left: 4px solid #4aa3ff;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.06); }
.bh-card.enemy { border-left: 1px solid rgba(255,255,255,0.08); border-right: 4px solid #ff5a5a; text-align: right; }
.bh-card.enemy .bh-name, .bh-card.enemy .bh-label { justify-content: flex-end; }
.bh-card .bar { height: 10px; border-radius: 5px; background: rgba(0,0,0,0.45); box-shadow: inset 0 1px 2px rgba(0,0,0,0.5); }
.bh-card .hpfill { border-radius: 5px; background-image: linear-gradient(180deg, rgba(255,255,255,0.35), rgba(255,255,255,0) 60%) !important; background-blend-mode: overlay; }
.bh-card .bar.cd, .bh-card .bar.xp { height: 4px; }
.bh-name { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bh-sub { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.bh-label { font-size: 11px; color: var(--muted); margin-top: 2px; display: flex; align-items: center; gap: 4px; }
.bar.cd { height: 4px; }
.cdbar { background: #9ec5ff !important; }
.cdbar.ready { background: #fff !important; }
.dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; border: 1.5px solid #222;
  background: linear-gradient(180deg, #ff5a5a 0 45%, #222 45% 55%, #fff 55%); box-shadow: 0 0 0 1px rgba(255,255,255,0.2); }
.dot.out { filter: grayscale(1) brightness(0.5); }

/* card layout: portrait + body */
.bh-card { display: flex; gap: 8px; align-items: center; position: relative; overflow: hidden; }
.bh-card.enemy { flex-direction: row-reverse; }
.bh-card::before { content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(80% 120% at 0% 0%, rgba(74,163,255,0.18), transparent 60%); }
.bh-card.enemy::before { background: radial-gradient(80% 120% at 100% 0%, rgba(255,90,90,0.18), transparent 60%); }
.bh-portrait { width: 56px; height: 56px; image-rendering: pixelated; flex: none; margin: -6px -4px;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.5)); }
.bh-card.enemy .bh-portrait { transform: scaleX(-1); }
.bh-body { flex: 1; min-width: 0; position: relative; }
.bh-lv { color: var(--muted); font-size: 12px; }

/* HP bar with a delayed damage trail */
.bar.hp { position: relative; }
.bar.hp > .hptrail, .bar.hp > .hpfill { position: absolute; left: 0; top: 0; bottom: 0; }
.bar.hp > .hptrail { background: #ffdf6b; transition: width 0.5s ease-out 0.35s; border-radius: 5px; }
.bar.hp > .hpfill { transition: width 0.12s, background-color 0.3s; }

/* status chips */
.bh-chips { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px; min-height: 0; }
.bh-card.enemy .bh-chips { justify-content: flex-end; }
.chip { font-size: 9.5px; font-weight: 700; padding: 1px 5px; border-radius: 999px; background: rgba(255,255,255,0.12); letter-spacing: 0.02em; }
.chip.up { background: rgba(76,217,100,0.25); color: #9ff0ad; }
.chip.down { background: rgba(255,59,48,0.25); color: #ffaba5; }
.chip.warn { background: #ffe066; color: #5a4300; animation: blink 0.4s steps(2) infinite; }
.chip.brawler { background: rgba(192,48,40,0.35); color: #ffc9c4; }
@keyframes blink { 50% { opacity: 0.55; } }

/* hit shake and low-HP pulse */
.bh-card.hit { animation: card-hit 0.32s ease-out; }
@keyframes card-hit {
  0% { transform: translateX(0); box-shadow: 0 0 0 2px rgba(255,255,255,0.8), 0 6px 18px rgba(0,0,0,0.35); }
  20% { transform: translateX(-5px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); }
  100% { transform: translateX(0); }
}
.bh-card.low { animation: low-pulse 0.9s ease-in-out infinite; }
.bh-card.low.hit { animation: card-hit 0.32s ease-out, low-pulse 0.9s ease-in-out infinite; }
@keyframes low-pulse { 50% { border-color: rgba(255,59,48,0.9); } }
#battle-hud.danger::before { content: ''; position: fixed; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 120px rgba(255,30,30,0.45); animation: danger 0.9s ease-in-out infinite; will-change: opacity; }
@keyframes danger { 50% { opacity: 0.45; } }

/* effectiveness badge on move buttons */
.mv-eff { position: absolute; right: 6px; bottom: 6px; font-size: 11px; font-weight: 800; padding: 1px 6px; border-radius: 999px; text-shadow: none; }
.mv-eff.good { background: #ffd84a; color: #4a3500; box-shadow: 0 0 8px rgba(255,216,74,0.7); }
.mv-eff.bad { background: rgba(0,0,0,0.45); color: #ccc; }
.mv-eff.none { background: #3a3a3a; color: #ff8a80; }

.bh-controls { position: absolute; right: max(10px, env(safe-area-inset-right)); bottom: max(10px, env(safe-area-inset-bottom));
  display: flex; gap: 8px; align-items: flex-end; pointer-events: auto; }
.bh-moves { display: grid; grid-template-columns: repeat(2, minmax(120px, 160px)); gap: 6px; }
.move-btn { position: relative; overflow: hidden; font: inherit; color: #fff; text-align: left; cursor: pointer;
  background: radial-gradient(120% 90% at 0% 0%, color-mix(in srgb, var(--c) 85%, #fff) 0%, var(--c) 35%, color-mix(in srgb, var(--c) 45%, #000) 100%);
  border: 2px solid color-mix(in srgb, var(--c) 50%, #fff); border-radius: 14px; padding: 10px 12px; display: flex; flex-direction: column;
  min-height: 62px; touch-action: none; text-shadow: 0 1px 2px rgba(0,0,0,0.6);
  box-shadow: 0 4px 0 color-mix(in srgb, var(--c) 40%, #000), 0 8px 16px rgba(0,0,0,0.35); transition: transform 0.06s, box-shadow 0.06s; }
.move-btn::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(255,255,255,0.22), rgba(255,255,255,0) 45%); pointer-events: none; }
.move-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 color-mix(in srgb, var(--c) 40%, #000), 0 4px 8px rgba(0,0,0,0.35); }
.move-btn:not(.cooling)::after { animation: mv-ready 1.6s ease-in-out infinite; }
@keyframes mv-ready { 50% { opacity: 0.35; } }
.mv-kind { position: relative; align-self: flex-start; margin-top: 3px; font-size: 10px; font-weight: 700; letter-spacing: 0.02em;
  padding: 1px 6px; border-radius: 999px; background: rgba(0,0,0,0.3); }
.mv-kind.contact { background: rgba(255,255,255,0.9); color: #b0261f; text-shadow: none; }
.move-btn b { font-size: 14px; position: relative; }
.move-btn small { font-size: 11px; opacity: 0.9; position: relative; }
.move-btn kbd { position: absolute; top: 6px; right: 6px; }
.move-btn.cooling { filter: saturate(0.35) brightness(0.85); }
.cdfill { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: rgba(0,0,0,0.55); pointer-events: none; }
.bh-actions { display: flex; flex-direction: column; gap: 6px; }
.bh-actions .btn { position: relative; overflow: hidden; min-width: 96px; padding: 10px 12px; touch-action: none; }

@media (max-width: 640px) {
  .bh-moves { grid-template-columns: repeat(2, minmax(96px, 1fr)); }
  .move-btn { min-height: 52px; padding: 8px 10px; }
  .move-btn b { font-size: 13px; }
  .bh-actions .btn { min-width: 72px; padding: 8px; font-size: 13px; }
  .bh-actions kbd, .move-btn kbd { display: none; }
  .bh-card { padding: 6px 8px; }
  .bh-portrait { width: 40px; height: 40px; }
  .slot { width: 50px; }
  .slot img { width: 48px; height: 48px; margin: -6px 0 -8px; }
  .slot kbd { display: none; }
  .party-bar { gap: 4px; padding: 4px; left: auto; right: max(8px, env(safe-area-inset-right)); transform: none; }
  .moves { grid-template-columns: 1fr; }
}

/* ---------- items, Poké Center, Mart, Pokédex ---------- */
.small { font-size: 12px; }
.btn.xs { padding: 2px 8px; font-size: 11px; border-radius: 8px; }
.ok-note { background: rgba(76,217,100,0.12); border: 1px solid rgba(76,217,100,0.35); border-radius: 10px; padding: 8px 12px; color: #b9f5c6; }
.slot-item, .pc-item { position: absolute; top: 3px; right: 4px; color: #7cd1ff; font-size: 13px; text-shadow: 0 0 6px rgba(124,209,255,0.8); }
.share-tag { font-size: 11px; color: #7cd1ff; border: 1px solid rgba(124,209,255,0.5); border-radius: 6px; padding: 0 5px; }
.tdot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-left: 3px; vertical-align: middle; }

.pc-party { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.pc-slot { position: relative; aspect-ratio: 1; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font: inherit; color: var(--text); }
.pc-slot.filled { background: #2a3146; border: 2px solid #4a5574; cursor: pointer; }
.pc-slot.filled:hover { border-color: var(--danger); }
.pc-slot.filled img { width: 80%; height: 80%; image-rendering: pixelated; margin-bottom: -6px; }
.pc-slot.filled small { font-weight: 700; font-size: 11px; }
.pc-slot.empty { border: 2px dashed #3a4258; color: #4a5574; font-size: 22px; }
.pc-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.seg { display: inline-flex; background: #262c3c; border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { font: inherit; font-size: 12px; color: var(--muted); background: none; border: 0; padding: 5px 10px; border-radius: 8px; cursor: pointer; }
.seg button.on { background: #3a4258; color: var(--text); }
.pc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; margin-top: 8px; }
.pc-card { position: relative; background: #262c3c; border: 2px solid transparent; border-radius: 14px; padding: 6px 8px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; text-align: center; transition: transform 0.1s, border-color 0.1s; }
.pc-card:hover { transform: translateY(-2px); border-color: #556; }
.pc-card.in { border-color: var(--accent); background: linear-gradient(180deg, rgba(255,203,5,0.14), #262c3c 60%); }
.pc-card img { width: 76px; height: 76px; image-rendering: pixelated; margin: -4px 0 -8px; }
.pc-card b { font-size: 13px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-card small { color: var(--muted); font-size: 11px; }
.pc-card .bar { display: block; width: 100%; height: 4px; margin: 2px 0; }
.pc-card .bar > span { display: block; height: 100%; }
.pc-badge { position: absolute; top: 5px; left: 6px; background: var(--accent); color: #111; font-weight: 800; font-size: 11px;
  width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; }

.bag { display: flex; gap: 8px; flex-wrap: wrap; }
.bag-item { display: flex; align-items: center; gap: 8px; background: #262c3c; border-radius: 10px; padding: 6px 12px; font-size: 14px; }
.bag-item .icon, .shop-icon { color: #7cd1ff; }
.shop { display: flex; flex-direction: column; gap: 8px; }
.shop-item { display: flex; align-items: center; gap: 12px; background: #262c3c; border-radius: 14px; padding: 10px 14px; }
.shop-icon { font-size: 30px; width: 44px; height: 44px; display: grid; place-items: center; background: rgba(124,209,255,0.1); border-radius: 12px; flex-shrink: 0; }
.shop-info { flex: 1; min-width: 0; }
.shop-info p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.shop-buy { display: flex; flex-direction: column; gap: 4px; }

.dex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.dex-card { position: relative; background: #262c3c; border-radius: 12px; padding: 6px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.dex-card small { color: var(--muted); font-size: 10px; align-self: flex-start; }
.dex-card img { width: 64px; height: 64px; image-rendering: pixelated; margin: -6px 0 -6px; }
.dex-card b { font-size: 12px; }
.dex-card.seen img { filter: saturate(0.3) opacity(0.75); }
.dex-card.unknown img { filter: brightness(0) opacity(0.2); }
.dex-card.unknown b { color: var(--muted); }
.dex-card.caught { background: linear-gradient(180deg, rgba(255,203,5,0.12), #262c3c 70%); }
.dex-ball { position: absolute; top: 4px; right: 6px; color: #e2524a; font-size: 12px; }

@media (max-width: 640px) {
  .pc-party { grid-template-columns: repeat(3, 1fr); }
  .pc-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  .shop-item { flex-wrap: wrap; }
}

/* ---------- moves ---------- */
.move-list { display: flex; flex-direction: column; gap: 6px; }
.move-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: #262c3c; border-radius: 10px; padding: 6px 10px;
  font: inherit; color: var(--text); border: 2px solid transparent; text-align: left; }
.move-row .move-chip { flex: 1; background: none; }
.pick-move { cursor: pointer; }
.pick-move:hover { border-color: var(--accent); }
.move-row.locked { opacity: 0.6; }
.dot-new { display: inline-grid; place-items: center; min-width: 16px; height: 16px; border-radius: 8px; background: var(--accent); color: #111; font-size: 10px; font-weight: 800; padding: 0 4px; }
.pc-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; margin-top: 2px; }
.xp-moves { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 2px; font-size: 12px; }
.new-move { color: var(--accent); font-weight: 700; }

.hud-right .pill, .area-pill b { white-space: nowrap; }
@media (max-width: 480px) {
  .hud-top { gap: 4px; padding-left: 8px; padding-right: 8px; }
  .hud-right { gap: 4px; }
  .hud-right .pill { padding: 5px 7px; font-size: 12px; }
  .hud-right .btn { padding: 6px 10px; font-size: 13px; }
  .area-pill { padding: 4px 8px; }
  .area-pill b { font-size: 12px; }
}

/* ---------- Pokémon summary ---------- */
.card-link { cursor: pointer; border-radius: 12px; border: 2px solid transparent; }
.card-link:hover { border-color: #556; }
.mon-sub.held { color: #7cd1ff; }
.sum-top { display: flex; gap: 14px; align-items: center; background: #262c3c; border-radius: 14px; padding: 10px 14px; }
.sum-top img { width: 120px; height: 120px; image-rendering: pixelated; flex-shrink: 0; }
.sum-stats { display: grid; grid-template-columns: auto auto 1fr; gap: 6px 12px; align-items: center; background: #262c3c; border-radius: 12px; padding: 10px 14px; font-size: 14px; }
.sum-stats > span:nth-child(3n+1) { color: var(--muted); }
.sum-stats b { text-align: right; }
.sum-stats .bar { margin: 0; }
.sum-item { display: flex; align-items: center; gap: 12px; background: #262c3c; border-radius: 14px; padding: 10px 14px; }
@media (max-width: 480px) {
  .sum-top img { width: 88px; height: 88px; }
}

/* short landscape phones: keep the battle cards compact */
@media (max-height: 450px) {
  .bh-portrait { width: 40px; height: 40px; }
  .bh-card { padding: 5px 8px; }
  .bh-label { display: none; }
  .bh-card.enemy .bh-label { display: flex; }
}

/* ---------- building interiors ---------- */
.interact-btn { position: absolute; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  pointer-events: auto; padding: 14px 22px; font-size: 16px; font-weight: 700; border-radius: 999px;
  box-shadow: 0 6px 0 rgba(0,0,0,0.3), 0 10px 24px rgba(0,0,0,0.35); animation: pop-in 0.18s ease-out; touch-action: none; }
.interact-btn span { font-size: 18px; }
@keyframes pop-in { from { transform: translateX(-50%) scale(0.7); opacity: 0; } }

/* ---------- Pokédex stats ---------- */
.dex-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 8px; }
.dex-stat { background: #262c3c; border-radius: 12px; padding: 8px 10px; display: flex; flex-direction: column; }
.dex-stat b { font-size: 20px; }
.dex-stat span { font-size: 11px; color: var(--muted); }
.dex-stat.big { background: linear-gradient(135deg, #3a2f0b, #262c3c); }
.dex-stat.big b { color: var(--accent); font-size: 24px; }
.dex-stat.gold b { color: #ffd76a; }
.dex-progress { position: relative; height: 18px; border-radius: 9px; background: #1a1f2b; overflow: hidden; display: flex; margin-bottom: 8px; }
.dex-progress i { display: block; height: 100%; background: linear-gradient(90deg, #ffcb05, #ffe680); }
.dex-progress i.seen { background: rgba(255,255,255,0.18); }
.dex-progress span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; text-shadow: 0 1px 2px #000; }
.dex-filter { margin-bottom: 8px; flex-wrap: wrap; }
.dex-card.legend { box-shadow: inset 0 0 0 2px rgba(255,215,106,0.55); }
.dex-card.legend.caught { background: linear-gradient(180deg, rgba(255,215,106,0.3), #262c3c 75%); }
@media (max-width: 640px) { .dex-stats { grid-template-columns: repeat(2, 1fr); } }

/* ---------- battle: ball picker and PP ---------- */
.ball-row { display: flex; gap: 4px; }
.ball-row .ball-btn { flex: 1; white-space: nowrap; }
.ball-row .bicon { font-size: 16px; text-shadow: 0 0 2px #fff; }
.ball-row .ball-next { min-width: 0 !important; padding: 8px 10px !important; }
.mv-pp { position: relative; font-size: 10px; font-weight: 700; opacity: 0.85; margin-top: 2px; }
.mv-pp.low { color: #ffb3a7; opacity: 1; }
.move-btn.empty { filter: grayscale(1) brightness(0.6); }

/* ---------- Pokémon League ---------- */
.debug-note { background: rgba(255,203,5,0.12); border: 1px dashed rgba(255,203,5,0.6); color: #ffe48a; border-radius: 10px; padding: 6px 10px; font-size: 12px; }
.league-result { border-radius: 14px; padding: 14px; font-size: 18px; font-weight: 800; display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.league-result small { font-size: 12px; font-weight: 500; color: var(--muted); }
.league-result.champ { background: linear-gradient(135deg, #5a4300, #2a2f45); color: #ffd84a; }
.league-result.out { background: #3a2026; color: #ffb3a7; }
.league-next { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  background: linear-gradient(135deg, #2b2350, #262c3c); border: 1px solid rgba(201,162,39,0.5); border-radius: 14px; padding: 10px 12px; }
.league-next h3 { margin: 2px 0 0; }
.bracket { display: flex; gap: 10px; overflow-x: auto; padding: 8px 2px 4px; margin-top: 8px; }
.bk-col { flex: 0 0 auto; width: 118px; display: flex; flex-direction: column; }
.bk-col.now .bk-title { color: var(--accent); }
.bk-title { font-size: 11px; font-weight: 700; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.04em; }
.bk-list { display: flex; flex-direction: column; justify-content: space-around; flex: 1; gap: 4px; }
.bk-match { background: #20263a; border-radius: 8px; overflow: hidden; border: 1px solid #2f3750; }
.bk-match.mine { border-color: #ffcb05; box-shadow: 0 0 0 1px rgba(255,203,5,0.4); }
.bk-match.champ { padding: 8px; text-align: center; font-size: 13px; background: linear-gradient(135deg, #5a4300, #20263a); }
.bk-slot { font-size: 11px; padding: 3px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bk-slot + .bk-slot { border-top: 1px solid #2f3750; }
.bk-slot.win { color: #fff; font-weight: 700; background: rgba(123,224,123,0.12); }
.bk-slot.lose { color: #6f778c; text-decoration: line-through; }
.bk-slot.me { color: #ffcb05; }
.bk-title small { display: block; font-weight: 500; text-transform: none; letter-spacing: 0; color: #9aa3b8; }
#hud-bike.on { background: #ffcb05; color: #222; box-shadow: 0 0 0 2px rgba(255,203,5,0.4); }

/* =====================================================================
   UI refresh: menus, HUD, start screen, shop, toasts (battle HUD untouched)
   ===================================================================== */
:root {
  --panel: rgba(18, 22, 36, 0.86);
  --panel-solid: #161b2c;
  --card: #20263b;
  --card-2: #283050;
  --line: rgba(255, 255, 255, 0.09);
  --red: #e2524a;
  --glass: blur(10px) saturate(1.2);
}

/* buttons */
.btn { background: linear-gradient(180deg, #333c58, #262d45); border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 2px 0 rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.08); transition: transform 0.08s, filter 0.15s; }
.btn:hover:not(:disabled) { filter: brightness(1.15); background: linear-gradient(180deg, #333c58, #262d45); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.primary { background: linear-gradient(180deg, #ffd84a, #f5b800); color: #2a1f00; border-color: #c99600; text-shadow: none; }
.btn.danger { background: linear-gradient(180deg, #8a2a30, #5c1c21); border-color: #e5484d; }
.pill.gold { background: linear-gradient(180deg, #b38a00, #7a5d00); color: #fff3b0; }

/* poké ball glyph used around the UI */
.pb { display: inline-block; width: 16px; height: 16px; border-radius: 50%; vertical-align: -3px; margin-right: 6px; flex: none;
  background: linear-gradient(180deg, var(--red) 0 46%, #1a1a1a 46% 56%, #f4f4f4 56%);
  box-shadow: inset 0 0 0 1.5px #1a1a1a; position: relative; }
.pb::after { content: ''; position: absolute; left: 50%; top: 50%; width: 5px; height: 5px; transform: translate(-50%, -50%);
  background: #fff; border: 1.5px solid #1a1a1a; border-radius: 50%; }

/* ---------- modals ---------- */
#modal-root { background: radial-gradient(circle at 50% 30%, rgba(10,14,28,0.62), rgba(4,6,14,0.86)); }
.modal { background: linear-gradient(180deg, #1b2136, #141929); border: 1px solid rgba(255,255,255,0.1); border-radius: 22px;
  padding: 0 20px 20px; box-shadow: 0 30px 80px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.06);
  animation: modal-in 0.22s cubic-bezier(.2,.9,.3,1.2); scrollbar-width: thin; scrollbar-color: #3a4466 transparent; }
@keyframes modal-in { from { transform: translateY(14px) scale(0.97); opacity: 0; } }
.modal::-webkit-scrollbar { width: 8px; }
.modal::-webkit-scrollbar-thumb { background: #3a4466; border-radius: 8px; }
.modal-head { position: sticky; top: 0; z-index: 3; margin: 0 -20px 12px; padding: 16px 20px 12px;
  background: linear-gradient(180deg, #1b2136 75%, rgba(27,33,54,0)); }
.modal-head::before { content: ''; position: absolute; left: 20px; right: 20px; top: 0; height: 3px; border-radius: 0 0 3px 3px;
  background: linear-gradient(90deg, var(--red), var(--accent)); }
.modal h2 { font-size: 22px; font-weight: 800; letter-spacing: -0.01em; margin: 0; }
.modal h3 { color: #c9d1e6; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; }
.modal-head .btn { width: 38px; height: 38px; padding: 0; border-radius: 50%; display: grid; place-items: center; }
.modal > :first-child:not(.modal-head) { margin-top: 20px; }

/* cards */
.mon-card, .xp-row, .shop-item, .bag-item, .pc-card, .dex-card, .gym-team .mini, .dex-stat {
  background: linear-gradient(180deg, var(--card-2), var(--card)); border: 1px solid var(--line); }
.mon-card { border-radius: 16px; padding: 10px; }
.card-link .mon-card { transition: transform 0.12s, border-color 0.12s; cursor: pointer; }
.card-link .mon-card:hover { transform: translateY(-2px); border-color: rgba(255,203,5,0.5); }
.move-chip { background: rgba(255,255,255,0.045); border-radius: 8px; }
.type { border-radius: 999px; padding: 1px 7px; box-shadow: inset 0 -1px 0 rgba(0,0,0,0.25); }
.help { background: rgba(255,255,255,0.04); border: 1px solid var(--line); border-radius: 14px; }

/* ---------- start screen ---------- */
.title-hero { display: flex; align-items: center; gap: 16px; margin: 22px 0 16px; }
.logo-ball { width: 64px; height: 64px; flex: none; border-radius: 50%; position: relative; animation: wobble 2.4s ease-in-out infinite;
  background: linear-gradient(180deg, var(--red) 0 46%, #1a1a1a 46% 56%, #f4f4f4 56%); box-shadow: inset 0 0 0 4px #1a1a1a, 0 10px 24px rgba(226,82,74,0.35); }
.logo-ball::after { content: ''; position: absolute; left: 50%; top: 50%; width: 18px; height: 18px; transform: translate(-50%, -50%);
  background: #fff; border: 4px solid #1a1a1a; border-radius: 50%; }
@keyframes wobble { 0%, 70%, 100% { transform: rotate(0); } 76% { transform: rotate(-14deg); } 84% { transform: rotate(10deg); } 92% { transform: rotate(-5deg); } }
.logo { margin: 0; font-size: 34px; font-weight: 900; letter-spacing: -0.02em; line-height: 1;
  background: linear-gradient(180deg, #ffe680, #ffcb05 55%, #e0a000); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 0 #2a4a9a) drop-shadow(0 3px 6px rgba(0,0,0,0.4)); }
.logo span { display: block; font-size: 16px; letter-spacing: 0.3em; text-transform: uppercase; color: #9fc0ff; -webkit-text-fill-color: #9fc0ff; filter: none; margin-top: 6px; }
.title-hero p { margin: 8px 0 0; color: #c9d1e6; }
.starter { position: relative; overflow: hidden; border: 2px solid rgba(255,255,255,0.08); border-radius: 18px; padding: 12px 10px 14px;
  background: radial-gradient(120% 80% at 50% 0%, color-mix(in srgb, var(--c) 35%, transparent), var(--card) 70%);
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s; }
.starter:hover { transform: translateY(-4px); border-color: var(--c); box-shadow: 0 12px 30px color-mix(in srgb, var(--c) 35%, transparent); }
.starter small { align-self: flex-start; color: var(--muted); font-size: 11px; }
.starter img { width: 112px; height: 112px; margin: -6px 0 -4px; animation: bob 1.8s ease-in-out infinite; animation-delay: var(--d); filter: drop-shadow(0 6px 4px rgba(0,0,0,0.35)); }
@keyframes bob { 50% { transform: translateY(-6px); } }
.starter b { font-size: 16px; }
.starter .choose { margin-top: 6px; font-size: 12px; font-weight: 800; color: #1a1a1a; background: var(--c); border-radius: 999px; padding: 3px 14px;
  opacity: 0; transform: translateY(4px); transition: 0.15s; }
.starter:hover .choose { opacity: 1; transform: none; }
.controls h4 { margin: 0 0 8px; color: #fff; }
.controls p { margin: 8px 0 0; }
.ctl-grid { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.ctl-grid span { white-space: nowrap; }
.ctl-grid kbd, .controls kbd { background: #2e3654; border: 1px solid #46507a; border-bottom-width: 3px; color: #fff; padding: 1px 6px; margin: 0 2px 0 0; border-radius: 6px; font-size: 11px; }

/* ---------- world HUD ---------- */
.hud-top { background: linear-gradient(rgba(8,10,20,0.6), transparent); }
.area-pill { flex-direction: row; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 6px 14px 6px 8px; backdrop-filter: var(--glass); box-shadow: 0 6px 18px rgba(0,0,0,0.25); }
.area-pill > span:last-child { display: flex; flex-direction: column; line-height: 1.15; }
.area-ico { width: 34px; height: 34px; display: grid; place-items: center; font-size: 19px; border-radius: 12px; background: rgba(255,255,255,0.08); }
.hud-status { display: flex; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  backdrop-filter: var(--glass); box-shadow: 0 6px 18px rgba(0,0,0,0.25); overflow: hidden; }
.hud-status span { padding: 8px 12px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.hud-status span + span { border-left: 1px solid var(--line); }
#hud-money { color: #ffe27a; }
.menu-btn { display: inline-flex; align-items: center; border-radius: 14px; padding: 8px 14px;
  background: linear-gradient(180deg, #e8625a, #b9362f); border-color: #ff8a80; }
.hud-icon { border-radius: 14px; padding: 7px 10px; }
#hud-bike.on { background: linear-gradient(180deg, #ffd84a, #f5b800); color: #222; box-shadow: 0 0 14px rgba(255,203,5,0.6); }

.party-bar { background: var(--panel); border-radius: 20px; padding: 7px; gap: 7px; backdrop-filter: var(--glass);
  box-shadow: 0 12px 30px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.06); }
.slot { border-radius: 14px; border: 2px solid rgba(255,255,255,0.06);
  background: radial-gradient(110% 80% at 50% 0%, color-mix(in srgb, var(--c) 40%, transparent), rgba(255,255,255,0.04) 75%); }
.slot.lead { border-color: var(--accent); box-shadow: 0 0 14px rgba(255,203,5,0.45); }
.slot.fainted { filter: grayscale(0.9); opacity: 0.7; }
.slot img { filter: drop-shadow(0 3px 2px rgba(0,0,0,0.35)); }
.lead-tag { box-shadow: 0 2px 6px rgba(0,0,0,0.4); }


/* ---------- toasts ---------- */
.toast { display: flex; align-items: center; gap: 8px; text-align: left; background: rgba(18,22,36,0.94);
  border: 1px solid rgba(255,255,255,0.12); border-left: 4px solid var(--accent); border-radius: 12px; padding: 9px 14px 9px 10px;
  box-shadow: 0 10px 26px rgba(0,0,0,0.35); animation: toast-in 0.25s cubic-bezier(.2,.9,.3,1.3); font-weight: 600; }
.toast::before { content: ''; flex: none; width: 14px; height: 14px; border-radius: 50%;
  background: linear-gradient(180deg, var(--red) 0 46%, #1a1a1a 46% 56%, #f4f4f4 56%); box-shadow: inset 0 0 0 1.5px #1a1a1a; }
@keyframes toast-in { from { transform: translateY(-10px) scale(0.96); opacity: 0; } }

/* ---------- trainer menu ---------- */
.trainer-card { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 18px; margin-bottom: 12px;
  background: linear-gradient(120deg, #3a1e2a, #23294a 55%, #1d3350); border: 1px solid rgba(255,255,255,0.1); }
.tc-ava { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: rgba(255,255,255,0.08); flex: none; }
.tc-ava .pb { width: 30px; height: 30px; margin: 0; }
.tc-ava .pb::after { width: 9px; height: 9px; }
.tc-stats { flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.tc-stats span { display: flex; flex-direction: column; }
.tc-stats b { font-size: 16px; }
.tc-stats small { font-size: 11px; color: var(--muted); }
.tabs { display: flex; gap: 4px; background: rgba(0,0,0,0.25); border-radius: 14px; padding: 4px; margin-bottom: 12px; position: sticky; top: 66px; z-index: 2; }
.tabs button { flex: 1; font: inherit; font-size: 13px; font-weight: 700; color: var(--muted); background: none; border: 0; padding: 8px 6px; border-radius: 10px; cursor: pointer; }
.tabs button.on { background: linear-gradient(180deg, #3a4466, #2c3452); color: #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.3); }
.bag { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.bag-item { border-radius: 14px; padding: 10px 12px; align-items: center; }
.bag-item > span:nth-child(2) { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.bag-item small { color: var(--muted); font-size: 11px; line-height: 1.3; }
.bag-item .icon { font-size: 24px; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; background: rgba(255,255,255,0.06); flex: none; }
.bag-item .qty { font-weight: 800; color: #ffe27a; }
.bag-item.none { opacity: 0.5; }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.badge-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 3px; padding: 12px 8px; border-radius: 16px;
  background: var(--card); border: 1px dashed rgba(255,255,255,0.15); opacity: 0.65; }
.badge-card.got { opacity: 1; border: 1px solid color-mix(in srgb, var(--c) 60%, transparent);
  background: radial-gradient(100% 80% at 50% 0%, color-mix(in srgb, var(--c) 30%, transparent), var(--card) 75%); }
.badge-gem { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; font-size: 18px;
  background: rgba(255,255,255,0.08); color: var(--muted); }
.badge-card.got .badge-gem { background: radial-gradient(circle at 35% 30%, #fff8, var(--c) 55%, color-mix(in srgb, var(--c) 60%, #000)); color: #fff;
  box-shadow: 0 0 16px color-mix(in srgb, var(--c) 60%, transparent); text-shadow: 0 1px 2px rgba(0,0,0,0.5); }
.badge-card b { font-size: 13px; }
.badge-card small { font-size: 11px; color: var(--muted); }

/* ---------- shop ---------- */
.shop { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.shop-item { border-radius: 18px; align-items: flex-start; flex-wrap: wrap; }
.shop-icon { width: 52px; height: 52px; font-size: 32px; border-radius: 16px; background: rgba(255,255,255,0.06); }
.shop-buy { flex-direction: row; flex-wrap: wrap; width: 100%; padding-left: 64px; }

@media (max-width: 640px) {
  .title-hero { margin-top: 14px; }
  .logo { font-size: 26px; }
  .logo-ball { width: 46px; height: 46px; }
  .tc-stats { grid-template-columns: repeat(2, 1fr); }
  .hud-status span { padding: 6px 8px; font-size: 12px; }
  .area-ico { width: 28px; height: 28px; font-size: 16px; }
  .shop-buy { padding-left: 0; }
}

/* ---------- Town Map ---------- */
.modal.map-modal { width: min(100%, 1180px); height: min(100%, 860px); display: flex; flex-direction: column; overflow: hidden; padding-bottom: 16px; }
.map-wrap { flex: 1; min-height: 0; display: flex; gap: 12px; }
.map-stage { position: relative; flex: 1; min-width: 0; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); background: #0d1220; }
.map-canvas { display: block; touch-action: none; cursor: grab; }
.map-canvas:active { cursor: grabbing; }
.map-tools { position: absolute; right: 10px; top: 10px; display: flex; flex-direction: column; gap: 6px; }
.map-tools .btn { width: 38px; height: 38px; padding: 0; font-size: 18px; border-radius: 12px; }
.map-hint { position: absolute; left: 10px; bottom: 10px; font-size: 11px; color: #c9d1e6; background: rgba(14,18,32,0.75); padding: 4px 10px; border-radius: 999px; pointer-events: none; }
.map-side { width: 250px; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.map-legend { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 8px; font-size: 11px; color: var(--muted); background: rgba(255,255,255,0.04); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.map-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.map-places { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding-right: 2px; }
.map-place { display: flex; align-items: center; gap: 10px; text-align: left; font: inherit; color: var(--text); cursor: pointer;
  background: linear-gradient(180deg, var(--card-2), var(--card)); border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: 12px; padding: 7px 10px; }
.map-place:hover { filter: brightness(1.15); }
.map-place b { display: block; font-size: 13px; }
.map-place small { font-size: 11px; color: var(--muted); }
.mp-ico { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 50%; font-weight: 800; font-size: 13px; background: var(--c); color: #1a1a1a; }
.map-place.done .mp-ico { background: #ffd700; }
@media (max-width: 760px), (max-height: 500px) {
  .map-side { display: none; }
}
.move-key { flex: none; width: 24px; height: 24px; border-radius: 8px; display: grid; place-items: center; font-weight: 800; font-size: 12px;
  background: #2e3654; border: 1px solid #46507a; border-bottom-width: 3px; }
.move-order { display: inline-flex; gap: 3px; }
.move-order .btn { min-width: 28px; }

/* ---------- gym dialogue box ---------- */
#modal-root.dialog-root { align-items: flex-end; background: linear-gradient(transparent 50%, rgba(4,6,14,0.55)); backdrop-filter: none; }
.modal.dialog { width: min(100%, 760px); padding: 16px 20px 14px; margin-bottom: max(8px, env(safe-area-inset-bottom)); border: 3px solid #e8edf7;
  background: linear-gradient(180deg, #1d2440, #141a2e); border-radius: 18px; position: relative; cursor: pointer; animation: dlg-in 0.18s ease-out; }
@keyframes dlg-in { from { transform: translateY(20px); opacity: 0; } }
.dlg-who { position: absolute; top: -15px; left: 18px; background: var(--accent); color: #2a1f00; font-weight: 800; font-size: 13px;
  padding: 3px 12px; border-radius: 999px; box-shadow: 0 3px 8px rgba(0,0,0,0.35); }
.dlg-text { margin: 8px 0 4px; font-size: 17px; line-height: 1.5; min-height: 52px; }
.dlg-next { position: absolute; right: 14px; bottom: 10px; padding: 3px 10px; font-size: 12px; animation: dlg-bob 0.9s ease-in-out infinite; }
@keyframes dlg-bob { 50% { transform: translateY(3px); } }
.dlg-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-top: 8px; }
.dlg-choices .btn { padding: 10px 12px; text-align: left; }
.gym-team .mini.secret { width: 74px; height: 92px; justify-content: center; background: linear-gradient(180deg, #2b2350, #1d2236); border: 1px dashed rgba(201,162,39,0.6); }
.gym-team .mini.secret span { font-size: 34px; font-weight: 900; color: #c9a227; text-shadow: 0 0 12px rgba(201,162,39,0.6); }
.league-warn { width: 100%; margin: 4px 0 0; }

/* sound options */
.sound-panel { background: rgba(255,255,255,0.04); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-bottom: 10px; }
.sound-panel h4 { margin: 0; width: 100%; }
.sound-panel label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.sound-panel input[type=range] { accent-color: var(--accent); width: 140px; }
.region-tag { position: absolute; top: 6px; right: 8px; z-index: 1; font-size: 10px; font-weight: 800; padding: 1px 7px; border-radius: 999px; background: #3d7be0; color: #fff; }

/* ---------- arena-fighter controls ---------- */
.bh-fight { display: flex; flex-direction: column; gap: 6px; }
.bh-fight .btn { position: relative; overflow: hidden; min-width: 112px; padding: 9px 12px; touch-action: none; text-align: left; }
.bh-fight .btn > * { position: relative; }
.ult-btn .ultfill { position: absolute !important; left: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(90deg, rgba(255,203,5,0.25), rgba(255,203,5,0.55)); transition: width 0.2s; }
.ult-btn.ready { background: linear-gradient(90deg, #ff5f6d, #ffc371, #7cf, #b28cff); background-size: 300% 100%; animation: ult-shine 1.6s linear infinite; color: #1a1a1a; text-shadow: none; box-shadow: 0 0 18px rgba(255,203,5,0.8); }
@keyframes ult-shine { to { background-position: 300% 0; } }
.bh-card .bar.meter { height: 5px; background: rgba(0,0,0,0.45); }
.bh-card .meterfill { height: 100%; width: 0; border-radius: 5px; background: linear-gradient(90deg, #ffcb05, #ff8a3d); transition: width 0.2s; }
.bh-card .meterfill.full { background: linear-gradient(90deg, #ff5f6d, #ffc371, #7cf, #b28cff); background-size: 300% 100%; animation: ult-shine 1.6s linear infinite; box-shadow: 0 0 8px rgba(255,203,5,0.8); }
@media (max-width: 640px) { .bh-fight .btn { min-width: 84px; padding: 7px 8px; font-size: 12px; } .bh-fight kbd { display: none; } }
