:root {
  --ink:#243b38; --muted:#637a71; --green:#326b58;
  --pale:#e9f0eb; --line:#d8e4db;
}
* { box-sizing:border-box }
html { background:var(--pale) }
body {
  margin:0; color:var(--ink);
  font:14px/1.4 system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  overscroll-behavior:none;
  -webkit-tap-highlight-color:transparent;
  /* No long-press text selection anywhere in the game. */
  -webkit-touch-callout:none;
  -webkit-user-select:none;
  user-select:none;
}
button { font:inherit; cursor:pointer; touch-action:manipulation }
button:disabled { opacity:.44; cursor:default }
button:focus-visible,input:focus-visible,#map:focus-visible,.partyRow:focus-visible {
  outline:3px solid #c46a3e; outline-offset:2px;
}
#app {
  width:min(100%,580px); margin:auto;
  padding:env(safe-area-inset-top) 12px calc(15px + env(safe-area-inset-bottom));
}
header {
  display:flex; justify-content:space-between; align-items:flex-end;
  gap:10px; padding:11px 2px 10px;
}
.kicker { color:#708b78; font-size:10px; font-weight:850; letter-spacing:.14em }
h1 { margin:1px 0 0; font-size:23px; line-height:1; letter-spacing:-.5px }
#location { color:var(--muted); text-align:right; font-size:11px }
#mapFrame {
  position:relative; overflow:hidden; border:3px solid white;
  border-radius:19px; background:#9bc6a0; box-shadow:0 9px 26px #263d3126;
  -webkit-user-select:none; user-select:none; -webkit-touch-callout:none;
  touch-action:none;
}
#mapFrame * {
  -webkit-user-select:none; user-select:none; -webkit-touch-callout:none;
}
#map {
  display:block; width:100%; height:auto; aspect-ratio:16/14;
  touch-action:none; cursor:pointer;
}
#areaPlate {
  position:absolute; z-index:5; top:9px; left:9px; padding:6px 9px;
  border-radius:8px; background:#f8faf2ed; color:#3e6254;
  font-size:10px; font-weight:850; letter-spacing:.08em; pointer-events:none;
}
#trainer {
  position:absolute; z-index:3; width:6.8%; height:11.2%;
  transform:translate(-50%,-62%); pointer-events:none;
  filter:drop-shadow(0 3px 2px #263d3148);
}
#trainer svg {
  display:block; width:100%; height:100%; overflow:visible;
}
#trainer .pose { display:none }
#trainer[data-facing="down"] .pose-down,
#trainer[data-facing="up"] .pose-up,
#trainer[data-facing="left"] .pose-left,
#trainer[data-facing="right"] .pose-right { display:inline }
#trainer .leg-l,#trainer .leg-r,#trainer .arm-l,#trainer .arm-r,#trainer .upper {
  transform-box:fill-box; transform-origin:center top;
}
#trainer.walking .leg-l { animation:step-l .28s ease-in-out infinite alternate }
#trainer.walking .leg-r { animation:step-r .28s ease-in-out infinite alternate }
#trainer.walking .arm-l { animation:swing-l .28s ease-in-out infinite alternate }
#trainer.walking .arm-r { animation:swing-r .28s ease-in-out infinite alternate }
#trainer.walking .upper { animation:step-bob .28s ease-in-out infinite alternate }
@keyframes step-l { from { transform:translateY(0) rotate(-6deg) } to { transform:translateY(-2.2px) rotate(7deg) } }
@keyframes step-r { from { transform:translateY(-2.2px) rotate(7deg) } to { transform:translateY(0) rotate(-6deg) } }
@keyframes swing-l { from { transform:rotate(10deg) } to { transform:rotate(-10deg) } }
@keyframes swing-r { from { transform:rotate(-10deg) } to { transform:rotate(10deg) } }
@keyframes step-bob { from { transform:translateY(0) } to { transform:translateY(-1.6px) } }
#follower {
  position:absolute; z-index:2; width:8%; height:10%; object-fit:contain;
  image-rendering:pixelated; transform:translate(-50%,-57%);
  filter:drop-shadow(0 4px 2px #263d3150); pointer-events:none;
}
#follower[hidden] { display:none }
#follower { filter:drop-shadow(0 6px 3px #1c392d40) }
#followerHeart {
  position:absolute; z-index:4; transform:translate(-50%,-140%);
  color:#e86a8a; font-size:22px; font-weight:900; pointer-events:none;
  opacity:0; text-shadow:0 0 8px #ffffff;
}
#followerHeart.show { animation:heartFloat .9s ease-out }
@keyframes heartFloat {
  from { opacity:0; transform:translate(-50%,-100%) scale(.6) }
  30% { opacity:1; transform:translate(-50%,-160%) scale(1.2) }
  to { opacity:0; transform:translate(-50%,-220%) scale(1) }
}
/* Damage number floating over the hit Pokemon in battle. */
#dmgNumber {
  position:absolute; z-index:6; display:none; pointer-events:none;
  font-size:26px; font-weight:900; color:#c8544c;
  text-shadow:0 1px 0 #ffffff,0 0 8px #ffffff;
}
#dmgNumber.show { display:block; animation:dmgFloat .9s ease-out forwards }
@keyframes dmgFloat {
  from { opacity:1; transform:translate(-50%,0) }
  to { opacity:0; transform:translate(-50%,-30px) }
}
/* Map overlays: destinations, toasts, and the Ash offer. */
#destinations {
  position:absolute; z-index:5; bottom:8px; left:8px; right:8px;
  display:flex; justify-content:space-between; pointer-events:none;
}
#destinations span {
  padding:4px 8px; border-radius:8px; background:#f8faf2d9;
  color:#3e6254; font-size:11px; font-weight:800;
}
#notice, #chatOffer, #startup {
  position:absolute; left:8px; right:8px; bottom:8px; z-index:6;
  padding:9px 11px; border-radius:10px; background:#142c29e6; color:#f7f6ee;
  font-size:12px; font-weight:600; box-shadow:0 8px 20px #081b1640;
}
#notice { pointer-events:none; display:none }
#notice.show { display:block }
#chatOffer[hidden], #startup:not(.show) { display:none }
#startup.show { display:block }
.chatOfferButtons { display:flex; gap:8px; margin-top:8px }
.chatOfferButtons button {
  flex:1; padding:8px; border:1px solid #dce8dd; border-radius:9px;
  background:#f0f6f0; color:var(--ink); font-weight:800;
}
/* Cards: team and supplies. */
#cards { display:grid; grid-template-columns:1fr 1fr; gap:10px; margin-top:8px }
.card {
  padding:10px 12px; border:1px solid var(--line); border-radius:14px;
  background:#fbfcf8;
}
.card h2 { margin:0 0 6px; font-size:14px }
.cardHint { margin:0 0 6px; color:var(--muted); font-size:11px }
#party { display:grid; gap:5px; max-height:265px; overflow:auto }
.partyRow {
  display:flex; align-items:center; gap:8px; padding:6px 8px;
  border:1px solid #dce8dd; border-radius:11px; background:#f0f6f0;
}
.partyRow.following { background:#e0eee2 }
.partyRow.fainted { background:#f3eded }
.partyRow.dropTarget { border-color:#3c8c69; background:#d3ebda }
.partyRow.dragSource { opacity:.4 }
.partyRow img { width:34px; height:34px; object-fit:contain; flex:none; pointer-events:none }
.partyInfo { min-width:0; flex:1 }
.partyInfo b { font-size:13px }
.partyInfo small { display:block; color:var(--muted); font-size:10px; overflow-wrap:anywhere }
.partyRow.fainted .partyInfo b { color:#a15151 }
.partyControls { display:flex; flex-direction:column; gap:2px; flex:none }
.partyControls button {
  width:26px; height:20px; padding:0; border:1px solid #dce8dd;
  border-radius:6px; background:#ffffff; font-size:11px; line-height:1;
}
.xpTrack { height:6px; margin:3px 0; overflow:hidden; border-radius:8px; background:#dce6e3 }
.xpFill { height:100%; background:#64af78 }
#supplies { font-size:13px; line-height:1.5 }
#shop { margin-top:8px }
#openMart {
  width:100%; padding:9px 10px; border:1px solid #2d5c46; border-radius:10px;
  background:#326b58; color:#ffffff; font-weight:800;
}
#settings {
  display:flex; flex-wrap:wrap; gap:6px 12px; align-items:center;
  padding:10px 2px 4px; font-size:12px; color:var(--muted);
}
#settings button {
  border:0; background:none; color:#326b58; font-weight:700;
  text-decoration:underline; padding:2px 0;
}
#settings input { width:16px; height:16px; vertical-align:-3px }
#dragGhost {
  position:fixed; z-index:30; display:none; padding:6px 10px;
  border:1px solid #71a883; border-radius:9px; background:#f7fcf5;
  box-shadow:0 12px 25px #20392b45; font-size:12px;
  font-weight:800; pointer-events:none;
}
/* Overlays and modals. */
.overlay {
  position:fixed; z-index:10; inset:0; display:none;
  align-items:center; justify-content:center; padding:12px; background:#142c29df;
}
.overlay.open { display:flex }
.modal {
  width:min(100%,485px); max-height:94dvh; overflow:auto; padding:16px;
  border:1px solid white; border-radius:18px; background:#fbfcf8;
  box-shadow:0 24px 75px #081b1680;
}
.modal h2 { margin:0 0 4px; font-size:22px }
.modal p { margin:0 0 13px; color:var(--muted); font-size:13px }
#starterChoices { display:grid; gap:8px }
.starterChoice {
  display:flex; align-items:center; gap:10px; width:100%; min-height:75px;
  padding:6px 10px; border:1px solid #dce8dd; border-radius:11px;
  background:#f0f6f0; color:var(--ink); text-align:left;
}
.starterChoice img { width:65px; height:65px; object-fit:contain; flex:none }
.starterChoice b { display:block; font-size:15px }
.starterChoice small { color:var(--muted); font-size:11px }
#giftSprite { display:block; width:110px; height:110px; margin:0 auto; object-fit:contain }
#dexList { overflow:auto; max-height:60dvh; display:grid; gap:6px; margin:10px 0 }
.dexRow {
  display:flex; align-items:center; gap:10px; padding:6px 8px;
  border:1px solid #dce8dd; border-radius:11px; background:#f0f6f0;
}
.dexRow img { width:44px; height:44px; object-fit:contain; flex:none }
.dexRow button {
  margin-left:auto; padding:10px 12px; min-height:40px;
  border:1px solid #dce8dd; border-radius:9px; background:#ffffff;
  font-weight:800; flex:none;
}
#dexSwap { margin:8px 0 }
#dexTeamPicker { display:grid; gap:6px }
#martItems { display:grid; gap:8px; margin:10px 0 }
.martRow {
  display:flex; align-items:center; gap:10px; padding:8px;
  border:1px solid #dce8dd; border-radius:11px; background:#f0f6f0;
}
.martRow button {
  margin-left:auto; padding:9px 12px; border:1px solid #2d5c46;
  border-radius:9px; background:#326b58; color:#ffffff; font-weight:800;
}
/* Battle. */
#battleVisual {
  position:relative; height:220px; overflow:hidden; border:1px solid #e8eee5;
  border-radius:13px;
  background:
    radial-gradient(ellipse at 74% 68%,#dae5c4 0 13%,transparent 13.5%),
    radial-gradient(ellipse at 28% 91%,#d8e2be 0 21%,transparent 21.5%),
    linear-gradient(170deg,#b7d8d4 0 52%,#dce8d5 52% 66%,#89b493 66%);
}
#battleVisual.coast {
  background:
    radial-gradient(ellipse at 74% 68%,#e4e5d0 0 13%,transparent 13.5%),
    radial-gradient(ellipse at 28% 91%,#e4e5d0 0 21%,transparent 21.5%),
    linear-gradient(170deg,#a7cfda 0 52%,#e2e4cf 52% 66%,#8cbeb1 66%);
}
#battleVisual.mountain {
  background:
    radial-gradient(ellipse at 74% 68%,#d9dfce 0 13%,transparent 13.5%),
    radial-gradient(ellipse at 28% 91%,#d9dfce 0 21%,transparent 21.5%),
    linear-gradient(170deg,#b5d0cb 0 52%,#d7dfd0 52% 66%,#a0b3a1 66%);
}
.combatant {
  position:absolute; z-index:2; display:block; object-fit:contain;
  image-rendering:pixelated; filter:drop-shadow(0 10px 6px #273d3440);
  transform-origin:center bottom;
}
#mySprite { left:5%; bottom:5%; width:41%; height:76% }
#foeSprite { right:7%; top:1%; width:36%; height:68% }
.combatant.idle { animation:breathe 5.2s ease-in-out infinite }
#foeSprite.idle { animation-delay:-2.4s }
@keyframes breathe {
  0%,100% { transform:translateY(0) scale(1) }
  50% { transform:translateY(-1px) scale(1.006) }
}
.combatant.faint {
  opacity:0; transform:translateY(40px) scale(.65);
  transition:opacity .38s,transform .38s; animation:none;
}
#moveCanvas {
  position:absolute; z-index:5; inset:0; width:100%; height:100%;
  pointer-events:none;
}
.battleStats { display:grid; grid-template-columns:1fr 1fr; gap:12px; margin:9px 2px 7px }
.side { color:#6b8677; font-size:10px; font-weight:850; letter-spacing:.07em }
.monName { font-size:13px; font-weight:850 }
.hpTrack { height:9px; margin:5px 0 3px; overflow:hidden; border-radius:8px; background:#dde7df }
.hpFill { height:100%; background:#64af78; transition:width .3s,background-color .3s }
.hpFill.mid { background:#d9a84e }
.hpFill.low { background:#d18067 }
.hpText { font-size:11px; color:var(--muted) }
#battleText { min-height:39px; padding:7px 2px 5px; font-size:13px; font-weight:750 }
#turnHint { font-size:12px; color:var(--muted); margin-bottom:4px }
#learnOffer { margin:8px 0 }
#rewards { display:none; max-height:190px; overflow:auto; margin:4px 0 9px; padding:8px; border:1px solid var(--line); border-radius:11px; background:#f0f6f0 }
#rewards.show { display:block }
.rewardRow { padding:4px 0; font-size:12px }
.rewardRow b { display:block }
.rewardCounter { font-size:11px; color:var(--muted) }
#actions { display:grid; grid-template-columns:1fr 1fr; gap:7px }
.action {
  padding:9px 10px; border:1px solid #2d5c46; border-radius:11px;
  background:#326b58; color:#ffffff; font-weight:800; text-align:left;
}
.action.secondary { background:#e4eee7; color:#315348; border-color:#dce8dd }
.action.wide { grid-column:1/-1; text-align:center }
.action small { display:block; font-size:10px; font-weight:500; opacity:.86 }
.action:active:not(:disabled) { filter:brightness(.9) }
.typeTag {
  display:inline-block; padding:1px 7px; border-radius:20px;
  color:#ffffff; font-size:10px; font-weight:800; vertical-align:1px;
}
/* Short screens: compact the battle box so all buttons fit. */
@media(max-height:710px) {
  .modal { padding:12px }
  #battleVisual { height:min(22dvh,150px) }
  #rewards { max-height:145px }
  #battleText { min-height:28px; padding:4px 2px 2px }
  #turnHint { font-size:11px }
  #actions { gap:5px }
  .action { padding:6px 8px; font-size:12px }
  .action small { font-size:9px }
  .battleStats { font-size:12px }
}
/* Phones: lock the page, supplies above the map, team below it. */
@media(max-width:640px) {
  html,body { height:100%; overflow:hidden; overscroll-behavior:none }
  #app { display:flex; flex-direction:column; height:100dvh; overflow:hidden; justify-content:space-between }
  #app { position:relative }
  #app > header,
  #settings, #cards .card { flex-shrink:0 }
  #mapFrame { flex:none; width:100% }
  #map { display:block; width:100%; height:auto; aspect-ratio:16 / 14; touch-action:none; -webkit-touch-callout:none }
  #app > header { order:1; padding:6px 2px 2px; flex-wrap:nowrap; gap:6px; align-items:center }
  .kicker { display:none }
  #openPokedex, #openTravel { padding:5px 7px; font-size:11px; white-space:nowrap }
  #location { font-size:10px }
  h1 { font-size:17px }
  #cards { display:contents }
  @media(max-width:360px) {
    #app > header { gap:4px }
    h1 { font-size:15px }
    #location { font-size:9px }
    #openPokedex, #openTravel { padding:5px 6px; font-size:10px }
    .card { padding:8px 10px }
  }
  #cards .card:nth-child(1) { order:7 }
  #cards .card:nth-child(2) { order:2 }
  #mapFrame { order:3 }
  #notice, #chatOffer, #startup {
    bottom:8px;
    -webkit-user-select:none; user-select:none; -webkit-touch-callout:none;
  }
  #notice { pointer-events:none }
  #settings { order:8; padding:0 2px; font-size:11px; gap:4px 10px }
  #settings input { width:15px; height:15px }
  .card { padding:8px 12px }
  .card h2 { margin-bottom:4px }
  .cardHint { display:none }
  #party {
    display:flex; gap:6px; max-height:none;
    overflow-x:auto; overflow-y:hidden;
    scroll-snap-type:x mandatory; -webkit-overflow-scrolling:touch;
    padding-bottom:2px;
  }
  .partyRow {
    flex:0 0 200px; min-height:44px; scroll-snap-align:start;
    touch-action:pan-x;
  }
  .partyRow img { width:30px; height:30px }
  .partyRow .xpTrack { display:none }
  .partyRow .partyInfo { min-width:0 }
  .partyRow .partyInfo .typeTag { display:none }
  .partyRow .partyInfo small { white-space:nowrap; overflow:hidden; text-overflow:ellipsis }
  .partyRow .partyInfo small:not(:first-of-type) { display:none }
  .partyControls button { width:22px; height:18px }
  #supplies { display:flex; flex-wrap:wrap; gap:2px 10px; line-height:1.35; font-size:11px }
  #supplies br { display:none }
  #shop { margin-top:4px }
  #openMart { padding:6px 8px; font-size:12px }
}
/* Small Saved note in the header, shown briefly after saving. */
#savedNote {
  font-size:11px; font-weight:800; color:#3c8c69; opacity:0;
  transition:opacity .3s;
}
#savedNote.show { opacity:1 }
/* Team menu: big tappable buttons instead of tiny row buttons. */
.teamMenuBtn {
  display:block; width:100%; min-height:48px; margin:6px 0; padding:10px 12px;
  border:1px solid #dce8dd; border-radius:11px; background:#f0f6f0;
  color:var(--ink); font-size:15px; font-weight:800; text-align:left;
}
.teamMenuBtn:disabled { opacity:.45 }
.teamMenuBtn small { display:block; font-size:11px; font-weight:500; color:var(--muted) }
#teamMenuBody img { width:90px; height:90px; object-fit:contain }
