/* ============================================================
   HOLLOWMERE STYLES — the look of the menus and buttons
   ============================================================ */

:root {
  --cream: #fff8ec;
  --ink: #3d2c22;
  --soft-ink: #7d6656;
  --leaf: #58b05a;
  --leaf-dark: #3e8a42;
  --sky: #5fb2f0;
  --wood: #8a5a3b;
  --panel: rgba(255, 248, 236, 0.92);
  --shadow: 0 6px 0 rgba(61, 44, 34, 0.18), 0 10px 30px rgba(61, 44, 34, 0.18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #9fd3f2;
  color: var(--ink);
  /* The emoji fonts: the computer's own first. Noto (from Google Fonts) only fills in
     emoji an older computer doesn't have, like 🪵 and 🪨 on Windows 10. */
  font-family: "Fredoka", "Segoe UI", system-ui, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

#game, #game canvas, .labels {
  position: fixed;
  inset: 0;
}

#game canvas {
  display: block;
  touch-action: none;
  cursor: grab;
}

#game canvas:active { cursor: grabbing; }

.labels { pointer-events: none; }

/* ---------- Join screen ---------- */

.join {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow-y: auto;
  background:
    radial-gradient(circle at 20% 15%, rgba(255, 255, 255, 0.55), transparent 40%),
    linear-gradient(180deg, #7cc4f2 0%, #bfe6f7 55%, #9fd57a 55%, #7cbf5a 100%);
}

.join-card {
  width: min(640px, 100%);
  padding: 26px 28px 20px;
  border-radius: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
  text-align: center;
}

.join-card h1 {
  margin: 0;
  font-size: clamp(2.4rem, 6vw, 3.4rem);
  font-weight: 700;
  color: var(--leaf-dark);
  letter-spacing: 1px;
}

.tagline { margin: 2px 0 18px; color: var(--soft-ink); font-size: 1.1rem; }

.join-body {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 20px;
  align-items: center;
  text-align: left;
}

@media (max-width: 560px) {
  .join-body { grid-template-columns: 1fr; }
  .preview { margin: 0 auto; }
}

.preview {
  width: 200px;
  height: 230px;
  border-radius: 22px;
  background: radial-gradient(circle at 50% 75%, #e6f4d6, #cde9f5 70%);
}

.join-options { display: flex; flex-direction: column; gap: 12px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-weight: 600; font-size: 0.95rem; color: var(--soft-ink); }

.field input {
  font: inherit;
  font-size: 1.25rem;
  padding: 10px 14px;
  border: 3px solid #e3d5c2;
  border-radius: 14px;
  background: white;
  color: var(--ink);
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}

.field input:focus { border-color: var(--leaf); }

.choices { display: flex; flex-wrap: wrap; gap: 8px; }

.swatches .choice {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid white;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.15);
}

.words .choice {
  padding: 8px 12px;
  border: 0;
  border-radius: 12px;
  background: #efe3d1;
  font-size: 0.95rem;
}

.choice.selected { outline: 4px solid var(--leaf); outline-offset: 1px; }
.words .choice.selected { background: #dff0d5; }

.play-btn {
  margin-top: 22px;
  width: 100%;
  padding: 16px;
  border: 0;
  border-radius: 18px;
  background: var(--leaf);
  color: white;
  font-size: 1.4rem;
  font-weight: 600;
  box-shadow: 0 6px 0 var(--leaf-dark);
  transition: transform 0.06s;
}

.play-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--leaf-dark); }
.play-btn:disabled { opacity: 0.7; }

.join-error { min-height: 1.3em; margin: 10px 0 0; color: #c0392b; font-weight: 500; }
/* "Did you mean…?" when a name is new: friendly, not red */
.join-error.friendly { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 14px; background: #fff4d6; color: #6b4a12; }
.join-error.friendly span { flex-basis: 100%; }
/* "Welcome back! Tap your name" buttons */
.welcome-back { display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; color: var(--soft-ink); }
.welcome-names { display: flex; flex-wrap: wrap; gap: 6px; }
.welcome-name { padding: 7px 12px; border: 0; border-radius: 999px; background: #e7f4dc; color: #2f5a22; font: inherit; font-weight: 600; cursor: pointer; }
.welcome-name:hover { background: #d4ecc2; }

/* ---------- In-game HUD ---------- */

.hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.hud button { pointer-events: auto; }

.place-box, .players, .help {
  position: absolute;
  padding: 8px 14px;
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.top-left {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

.place-box {
  position: static;
  font-size: 1.15rem;
  font-weight: 600;
}

.pedia-btn {
  padding: 10px 16px;
  border: 0;
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
  font-size: 1.1rem;
  font-weight: 600;
}

.pedia-btn:active { transform: translateY(2px); }

.top-buttons { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* The white flash while you fly in the balloon. */
.fly-fade {
  position: fixed;
  inset: 0;
  background: #fffaf0;
  opacity: 0;
  pointer-events: none;
  z-index: 5;
}

.clock {
  min-width: 6.5em;
  text-align: center;
}

.charm-count {
  padding: 8px 14px;
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
  font-size: 1.05rem;
  font-weight: 600;
}

/* During a battle, the valley's buttons and name tags step aside. */
body.in-battle .hud, body.in-battle .labels, body.in-battle .met-card { display: none; }

/* The buttons that appear near creatures (and at the fountain) */
.action-row {
  position: absolute;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
}

.action-btn {
  padding: 14px 24px;
  border: 0;
  border-radius: 20px;
  background: var(--leaf);
  color: white;
  font-size: 1.25rem;
  font-weight: 600;
  box-shadow: 0 6px 0 var(--leaf-dark);
  animation: bob-in 0.3s cubic-bezier(0.3, 1.6, 0.6, 1);
  white-space: nowrap;
}

.action-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--leaf-dark); }
.battle-btn { background: #e0644f; box-shadow: 0 6px 0 #a8432f; }
.battle-btn:active { box-shadow: 0 2px 0 #a8432f; }
.wish-btn { background: linear-gradient(135deg, #b48cff, #ff8fc8); box-shadow: 0 6px 0 #8a5fc0; }
.wish-btn small { opacity: 0.85; font-size: 0.8rem; }

.action-btn kbd {
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.3);
  font: inherit;
  font-size: 0.9rem;
}

@keyframes bob-in {
  from { transform: translateY(20px) scale(0.8); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

@media (max-width: 560px) {
  .action-row { flex-direction: column; align-items: stretch; bottom: 190px; }
}

.toast {
  position: fixed;
  z-index: 45;
  pointer-events: none;
  left: 50%;
  top: 30%;
  transform: translate(-50%, 10px);
  padding: 10px 18px;
  border-radius: 14px;
  background: rgba(61, 44, 34, 0.9);
  color: var(--cream);
  font-size: 1.1rem;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

.players {
  top: max(14px, env(safe-area-inset-top));
  right: 14px;
  min-width: 140px;
  font-size: 0.95rem;
}

.player-row { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.player-row::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--dot);
  box-shadow: 0 0 0 2px white;
}

.help {
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 28px);
  font-size: 0.95rem;
  text-align: center;
  transition: opacity 1.5s;
}

.help.faded { opacity: 0; }

.zone-banner {
  position: absolute;
  top: 18%;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  color: white;
  text-shadow: 0 3px 0 rgba(61, 44, 34, 0.35), 0 0 24px rgba(61, 44, 34, 0.35);
  opacity: 0;
  white-space: nowrap;
}

.zone-banner.show { animation: banner 3.5s ease-in-out forwards; }
.banner-title { font-size: clamp(2rem, 5vw, 3.2rem); font-weight: 700; }
.banner-subtitle { font-size: 1.2rem; font-weight: 500; }

@keyframes banner {
  0% { opacity: 0; transform: translate(-50%, 10px); }
  15% { opacity: 1; transform: translate(-50%, 0); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

.emotes {
  position: absolute;
  right: 14px;
  bottom: 14px;
  display: grid;
  grid-template-columns: repeat(3, 52px);
  gap: 8px;
}

.emote-btn {
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
  font-size: 1.6rem;
  transition: transform 0.08s;
}

.emote-btn:active { transform: scale(0.9); }

/* Touch controls only appear on iPads and phones */
.joystick, .jump-btn { display: none; }

body.touch .joystick {
  display: block;
  position: absolute;
  left: max(24px, env(safe-area-inset-left));
  bottom: max(24px, env(safe-area-inset-bottom));
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: rgba(255, 248, 236, 0.35);
  border: 3px solid rgba(255, 255, 255, 0.7);
  pointer-events: auto;
  touch-action: none;
}

.stick {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 66px;
  height: 66px;
  margin: -33px 0 0 -33px;
  border-radius: 50%;
  background: var(--cream);
  box-shadow: var(--shadow);
}

body.touch .jump-btn {
  display: block;
  position: absolute;
  right: 18px;
  bottom: 140px;
  width: 84px;
  height: 84px;
  border: 0;
  border-radius: 50%;
  background: var(--leaf);
  color: white;
  font-size: 2.2rem;
  box-shadow: 0 6px 0 var(--leaf-dark);
  touch-action: none;
}

body.touch .help { bottom: auto; top: 70px; }

/* ---------- Labels floating in the 3D world ---------- */

.nametag {
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  border: 3px solid var(--tag-color);
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
}

.emote-bubble {
  padding: 4px 8px;
  border-radius: 16px;
  background: white;
  box-shadow: var(--shadow);
  font-size: 1.9rem;
  line-height: 1.2;
}

.emote-bubble.pop { animation: pop 0.35s cubic-bezier(0.3, 1.6, 0.6, 1); }

@keyframes pop {
  from { transform: scale(0.2); }
  to { transform: scale(1); }
}

.creature-tag {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3px 10px 4px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.12);
  white-space: nowrap;
  line-height: 1.15;
}

.creature-tag b { font-size: 0.95rem; }
.creature-tag span { font-size: 0.75rem; font-weight: 600; color: var(--element-color); }

.mood-bubble {
  font-size: 1.5rem;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.25));
}

.mood-bubble.sleepy { animation: drift 2.4s ease-in-out infinite; }
.mood-bubble.pop { animation: pop 0.35s cubic-bezier(0.3, 1.6, 0.6, 1); }

@keyframes drift {
  0%, 100% { transform: translate(0, 0); opacity: 0.6; }
  50% { transform: translate(4px, -8px); opacity: 1; }
}

/* ---------- The "you met a creature" card ---------- */

.met-card {
  position: fixed;
  z-index: 15;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: min(340px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  overflow-y: auto;
  padding: 0 18px 16px;
  border-radius: 24px;
  background: var(--cream);
  box-shadow: var(--shadow);
}

.met-card.pop-in { animation: slide-in 0.4s cubic-bezier(0.3, 1.4, 0.6, 1); }
.met-card.celebrate { box-shadow: 0 0 0 4px #ffd43b, var(--shadow); }

@keyframes slide-in {
  from { transform: translate(40px, -50%); opacity: 0; }
  to { transform: translate(0, -50%); opacity: 1; }
}

.met-ribbon {
  margin: 0 -18px 4px;
  padding: 10px;
  border-radius: 24px 24px 0 0;
  background: var(--leaf);
  color: white;
  font-weight: 600;
  text-align: center;
}

.met-ribbon.gold { background: linear-gradient(90deg, #f6b93b, #ffd43b, #f6b93b); color: #5a3d00; }
.met-ribbon.soft { background: #efe3d1; color: var(--soft-ink); }

.met-buttons { display: flex; gap: 10px; margin-top: 12px; }

.met-buttons button {
  flex: 1;
  padding: 12px;
  border: 0;
  border-radius: 14px;
  background: #efe3d1;
  font-size: 1rem;
  font-weight: 600;
}

.met-buttons .met-pedia { background: var(--leaf); color: white; }

@media (max-width: 700px) {
  .met-card { top: auto; bottom: 16px; right: 50%; transform: translateX(50%); }
  .met-card.pop-in { animation: none; }
}

/* ---------- Creature details (shared by the card and the Creaturepedia) ---------- */

.detail { text-align: center; }
.detail h2 { margin: 2px 0 8px; font-size: 1.7rem; }
.detail.rare h2 { color: #b8860b; }
.detail-number { color: var(--soft-ink); font-weight: 600; font-size: 0.9rem; }

.detail-portrait {
  display: block;
  width: 170px;
  height: 170px;
  margin: 6px auto 0;
  object-fit: contain;
}

.detail-portrait.missing, .pedia-portrait.missing {
  display: grid;
  place-items: center;
  font-size: 3rem;
  font-weight: 700;
  color: #b9ab98;
}

.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-bottom: 8px; }

.chip {
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--chip, #ccc);
  color: white;
  font-weight: 600;
  font-size: 0.9rem;
}

.chip.plain { background: #efe3d1; color: var(--ink); }

.detail p { margin: 8px 0; line-height: 1.35; text-align: left; }
.detail-description { font-size: 1.05rem; }
.detail-habitat, .detail-tip, .detail-rumor { color: var(--soft-ink); }
.detail-stats { font-size: 0.9rem; color: var(--soft-ink); }
.detail-discovered { font-weight: 600; color: #b8860b; }
.detail.unknown .detail-rumor { text-align: center; }

/* ---------- The Creaturepedia ---------- */

.pedia {
  position: fixed;
  inset: 0;
  z-index: 25;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(40, 30, 25, 0.45);
}

.pedia-panel {
  display: flex;
  flex-direction: column;
  width: min(1000px, 100%);
  height: min(680px, 100%);
  border-radius: 28px;
  background: var(--cream);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.pedia-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  background: var(--wood);
  color: var(--cream);
}

.pedia-header h2 { margin: 0; font-size: 1.5rem; }
.pedia-progress { flex: 1; opacity: 0.85; }

.pedia-close {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  color: var(--cream);
  font-size: 1.3rem;
}

.pedia-body {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 340px;
  min-height: 0;
}

.pedia-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  align-content: start;
  gap: 12px;
  padding: 16px;
  overflow-y: auto;
}

.pedia-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 6px 10px;
  border: 3px solid transparent;
  border-radius: 18px;
  background: #ece2d3;
}

.pedia-card.known { background: white; box-shadow: 0 3px 0 rgba(61, 44, 34, 0.12); }
.pedia-card.rare { border-color: #ffd43b; }
.pedia-card.selected { border-color: var(--leaf); }

.pedia-number { align-self: flex-start; font-size: 0.75rem; font-weight: 600; color: var(--soft-ink); }
.pedia-portrait { width: 86px; height: 86px; object-fit: contain; }
.pedia-name { font-weight: 600; }

.pedia-detail {
  padding: 16px 20px;
  overflow-y: auto;
  background: white;
  border-left: 3px solid #efe3d1;
}

@media (max-width: 760px) {
  .pedia-body { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
  .pedia-detail { border-left: 0; border-top: 3px solid #efe3d1; }
}

.status {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  padding: 10px 18px;
  border-radius: 14px;
  background: #3d2c22;
  color: var(--cream);
  font-weight: 500;
}

/* ---------- Choose your partner ---------- */

.starter {
  position: fixed;
  inset: 0;
  z-index: 26;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow-y: auto;
  background: rgba(40, 30, 25, 0.5);
}

.starter-panel {
  width: min(980px, 100%);
  padding: 22px 24px 26px;
  border-radius: 28px;
  background: var(--cream);
  box-shadow: var(--shadow);
  text-align: center;
  animation: pop 0.4s cubic-bezier(0.3, 1.4, 0.6, 1);
}

.starter-panel h2 { margin: 0 0 6px; font-size: 2.1rem; }
.starter-intro { max-width: 640px; margin: 0 auto 18px; color: var(--soft-ink); font-size: 1.05rem; }

.starter-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.starter-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 16px 16px;
  border: 4px solid transparent;
  border-radius: 24px;
  background: white;
  box-shadow: 0 5px 0 rgba(61, 44, 34, 0.12);
  transition: transform 0.15s, border-color 0.15s;
}

.starter-card:hover:not(:disabled) { transform: translateY(-4px); border-color: var(--element-color); }
.starter-card.picked { border-color: var(--element-color); transform: scale(1.03); }
.starter-card:disabled:not(.picked) { opacity: 0.45; }
.starter-card img { width: 150px; height: 150px; object-fit: contain; }
.starter-name { font-size: 1.6rem; font-weight: 700; }
.starter-role { color: var(--soft-ink); }
.starter-special { padding: 8px 10px; border-radius: 14px; background: #fff3d6; font-size: 0.95rem; line-height: 1.3; }
.starter-special small { color: var(--soft-ink); }

.starter-choose {
  margin-top: auto;
  width: 100%;
  padding: 12px;
  border-radius: 16px;
  background: var(--element-color);
  color: white;
  font-size: 1.15rem;
  font-weight: 600;
}

/* ---------- Your creatures (team panel) ---------- */

.team-panel {
  display: flex;
  flex-direction: column;
  width: min(1000px, 100%);
  height: min(700px, 100%);
  border-radius: 28px;
  background: var(--cream);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.team-body { flex: 1; display: grid; grid-template-columns: 1fr 390px; min-height: 0; }
.team-lists { padding: 4px 18px 18px; overflow-y: auto; }
.team-lists h3 { margin: 14px 0 8px; }
.team-lists h3 small { font-weight: 500; color: var(--soft-ink); font-size: 0.85rem; }
.team-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.den-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 12px; }
.team-tip { margin: 8px 0; color: var(--soft-ink); }

.team-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 6px;
  border: 3px solid transparent;
  border-radius: 18px;
  background: white;
  box-shadow: 0 3px 0 rgba(61, 44, 34, 0.12), inset 0 -5px 0 var(--element-color, transparent);
}

.team-card.selected { border-color: var(--leaf); }
.team-card.empty { justify-content: center; min-height: 140px; background: #ece2d3; color: var(--soft-ink); box-shadow: none; }
.team-card img { width: 86px; height: 86px; object-fit: contain; }
.team-card-sub { font-size: 0.85rem; color: var(--soft-ink); font-weight: 600; }

.leader-badge {
  position: absolute;
  top: -10px;
  padding: 2px 10px;
  border-radius: 999px;
  background: #ffd43b;
  color: #5a3d00;
  font-size: 0.8rem;
  font-weight: 700;
}

.team-detail { padding: 14px 20px; overflow-y: auto; background: white; border-left: 3px solid #efe3d1; text-align: center; }
.detail-name { margin: 4px 0; font-size: 1.6rem; }

.xp-bar, .stat i {
  position: relative;
  display: block;
  height: 16px;
  border-radius: 999px;
  background: #efe3d1;
  overflow: hidden;
}

.xp-bar i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #7fd0ff, #5fb2f0); }
.xp-bar span { position: relative; font-size: 0.75rem; font-weight: 600; line-height: 16px; }

.stats { display: grid; gap: 6px; margin: 10px 0; text-align: left; }
.stat { display: grid; grid-template-columns: 64px 1fr 70px; align-items: center; gap: 8px; font-size: 0.9rem; }
.stat i b { position: absolute; inset: 0 auto 0 0; background: #f6b93b; }
.stat em { font-style: normal; font-weight: 600; text-align: right; }

.move-list { display: grid; gap: 6px; text-align: left; }
.move-row { padding: 6px 10px; border-left: 6px solid var(--element-color, #ccc); border-radius: 10px; background: #f7f0e5; line-height: 1.25; }
.move-row b { display: block; }
.move-row small { color: var(--soft-ink); }
.move-row.special { background: #fff3d6; }
.move-row.next { border-left-color: transparent; background: transparent; }

.team-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 12px; }
.team-actions button { padding: 10px 14px; border: 0; border-radius: 14px; background: #efe3d1; font-weight: 600; }
.team-actions button[data-do="lead"], .team-actions button[data-do="add"] { background: var(--leaf); color: white; }

@media (max-width: 760px) {
  .team-body { grid-template-columns: 1fr; grid-template-rows: auto auto; overflow-y: auto; }
  .team-lists { overflow: visible; }
  .team-detail { border-left: 0; border-top: 3px solid #efe3d1; overflow: visible; }
}

/* ---------- Battles: the BATTLE REALM look ----------
   Dark see-through panels with thin glowing edges. Blue = your side,
   red = the other side, purple = a friend's creature, gold = whose turn.
   Want different colours? Change the numbers just below. */

.battle {
  --b-font: "Barlow Condensed", "Arial Narrow", "Fredoka", sans-serif; /* the bold, narrow battle font */
  --b-text: #eef2fb;
  --b-dim: #9aa6c0;
  --b-panel: rgba(10, 14, 23, 0.84);
  --b-panel-2: rgba(5, 8, 14, 0.9);
  --b-ally: #4fc3ff; /* your side */
  --b-foe: #ff4d5e; /* the other side */
  --b-friend: #b49cff; /* another Keeper's creature on your side */
  --b-gloom: #b06bff; /* Gloomy story creatures */
  --b-gold: #ffcf4a; /* whose turn it is, Specials, victory */
  --b-pink: #ff5fa8; /* Charms and picking a target */
  --b-hp-ally: linear-gradient(180deg, #8dffc9, #22d68a 45%, #10a868);
  --b-hp-foe: linear-gradient(180deg, #ffa486, #ff4d4d 45%, #c8182f);
  --b-hp-low: linear-gradient(180deg, #ffe08a, #ffb02e 45%, #d97e06);
  --b-hp-danger: linear-gradient(180deg, #ff9a9a, #ff3048 45%, #a8001e);
  --b-chunk: #fff1c8; /* the pale "how big was that hit" piece */
  --b-cut: 10px; /* how big the cut-off corners are */
  position: fixed;
  inset: 0;
  z-index: 22;
  pointer-events: none;
  font-size: 1rem;
  color: var(--b-text);
}

.battle button { pointer-events: auto; font-family: var(--b-font); color: inherit; }
.battle kbd { font-family: var(--b-font); }

/* Dark fades at the top and bottom so the HUD is easy to read over the bright arena. */
.battle-scrim { position: absolute; left: 0; right: 0; pointer-events: none; }
.battle-scrim.top { top: 0; height: 140px; background: linear-gradient(180deg, rgba(3, 5, 10, 0.62), transparent); }
.battle-scrim.bottom { bottom: 0; height: 240px; background: linear-gradient(0deg, rgba(3, 5, 10, 0.72), transparent); }

/* ----- The top: round, turn timeline, Auto and 2×, the boss bar ----- */
.battle-top {
  position: absolute;
  z-index: 1; /* (above the plates, so the "Who should…" hint is never covered) */
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
}
/* (an invisible full-width line break, so the boss bar and the hint go under the first row) */
.battle-top::after { content: ""; order: 4; flex-basis: 100%; height: 0; }

.battle-round {
  padding: 7px 16px 6px;
  clip-path: polygon(var(--b-cut) 0, 100% 0, calc(100% - var(--b-cut)) 100%, 0 100%);
  background: linear-gradient(180deg, rgba(20, 27, 42, 0.92), var(--b-panel-2));
  box-shadow: inset 0 2px 0 var(--b-gold), inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  font: 800 1.05rem/1 var(--b-font);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.battle-toggles { display: flex; gap: 6px; }

.battle-toggle {
  padding: 7px 14px 6px;
  border: 0;
  clip-path: polygon(var(--b-cut) 0, 100% 0, calc(100% - var(--b-cut)) 100%, 0 100%);
  background: linear-gradient(180deg, rgba(20, 27, 42, 0.92), var(--b-panel-2));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
  font: 700 1rem/1 var(--b-font);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.7;
  transition: opacity 0.15s, box-shadow 0.15s;
}
.battle-toggle:hover { opacity: 0.95; }
.battle-toggle.on {
  opacity: 1;
  color: #ffe9a8;
  background: linear-gradient(180deg, rgba(92, 66, 8, 0.95), rgba(36, 24, 2, 0.95));
  box-shadow: inset 0 0 0 1px var(--b-gold), inset 0 0 14px rgba(255, 207, 74, 0.45);
}

/* The turn timeline: a glowing track with a face for each creature, in turn order. */
.battle-order { flex: 1; display: flex; justify-content: center; min-width: 0; }
.order-track {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px 10px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3) 12%, rgba(255, 255, 255, 0.3) 88%, transparent) center 45% / 100% 2px no-repeat;
}
.order-slot { position: relative; display: grid; place-items: center; }
.order-slot:nth-child(n + 7) { opacity: 0.8; } /* (faces further away fade a little) */
.order-slot:nth-child(n + 11) { opacity: 0.6; }
.order-face {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 2px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, #26324a, #070a11 75%);
  border: 2px solid var(--b-ally);
  box-shadow: 0 0 10px color-mix(in srgb, var(--b-ally) 45%, transparent);
  object-fit: contain;
  font-size: 1.3rem;
  transition: transform 0.2s;
}
.order-face.wild { border-color: var(--b-foe); box-shadow: 0 0 10px color-mix(in srgb, var(--b-foe) 45%, transparent); }
.order-face.friend { border-color: var(--b-friend); box-shadow: 0 0 10px color-mix(in srgb, var(--b-friend) 45%, transparent); }
.order-face.boss { width: 48px; height: 48px; }
.order-face.now {
  width: 54px;
  height: 54px;
  border: 3px solid var(--b-gold);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.6), 0 0 18px var(--b-gold);
}
.order-now {
  position: absolute;
  bottom: -9px;
  padding: 1px 6px 0;
  clip-path: polygon(4px 0, 100% 0, calc(100% - 4px) 100%, 0 100%);
  background: var(--b-gold);
  color: #2a1a00;
  font: 800 0.62rem/1.2 var(--b-font);
  letter-spacing: 0.12em;
}
.order-gap { width: 7px; height: 7px; border-top: 2px solid rgba(255, 255, 255, 0.5); border-right: 2px solid rgba(255, 255, 255, 0.5); transform: rotate(45deg); margin: 0 2px; }

/* The big boss bar (raids, and boss stages) */
.battle-boss {
  order: 5;
  flex-basis: 100%;
  max-width: 640px;
  margin: 4px auto 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 10px;
  clip-path: polygon(14px 0, 100% 0, 100% calc(100% - 14px), calc(100% - 14px) 100%, 0 100%, 0 14px);
  background: linear-gradient(180deg, rgba(34, 10, 16, 0.9), rgba(8, 5, 10, 0.92));
  box-shadow: inset 0 0 0 1px rgba(255, 77, 94, 0.45), inset 0 2px 0 var(--b-foe);
  transition: filter 0.2s;
}
.battle-boss.current { box-shadow: inset 0 0 0 1px var(--b-gold), inset 0 2px 0 var(--b-gold); }
.battle-boss.gloomy { background: linear-gradient(180deg, rgba(36, 14, 56, 0.92), rgba(10, 5, 18, 0.92)); }
.bboss-badge {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  align-content: center;
  width: 50px;
  height: 46px;
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
  background: linear-gradient(180deg, #ff8a95, var(--b-foe) 50%, #8a0c1c);
  color: #1c0306;
  line-height: 0.9;
}
.bboss-badge small { font: 800 0.6rem var(--b-font); letter-spacing: 0.1em; text-transform: uppercase; }
.bboss-badge b { font: 800 1.35rem var(--b-font); }
.bboss-main { flex: 1; min-width: 0; }
.bboss-line { display: flex; align-items: center; gap: 7px; min-width: 0; white-space: nowrap; }
.bboss-el .el-icon { width: 20px; height: 20px; }
.bboss-name { overflow: hidden; text-overflow: ellipsis; font: italic 800 1.35rem/1 var(--b-font); letter-spacing: 0.05em; text-transform: uppercase; text-shadow: 0 0 12px rgba(255, 77, 94, 0.6); }
.bboss-tag {
  padding: 2px 8px 1px;
  clip-path: polygon(5px 0, 100% 0, calc(100% - 5px) 100%, 0 100%);
  background: var(--b-foe);
  color: #fff;
  font: 800 0.66rem/1.2 var(--b-font);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.bboss-icons { display: flex; gap: 3px; margin-left: auto; }
.bboss-hp {
  position: relative;
  height: 16px;
  margin-top: 5px;
  clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
.bboss-hp i { position: absolute; inset: 0 auto 0 0; z-index: 1; background: var(--b-hp-foe); transition: width 0.4s ease-out; }
.bboss-hp .chunk { position: absolute; inset: 0 auto 0 0; background: var(--b-chunk); transition: width 0.7s ease-in 0.5s; }
.bboss-hp.healing .chunk { transition: none; background: #7dffb5; }
/* the black lines that cut the bar into pieces */
.bboss-segs {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: repeating-linear-gradient(90deg, transparent 0 calc(100% / var(--segments, 10) - 2px), rgba(4, 6, 10, 0.85) calc(100% / var(--segments, 10) - 2px) calc(100% / var(--segments, 10)));
}
/* the gold mark: below this, the boss gets angry */
.bboss-mark { position: absolute; top: 0; bottom: 0; left: var(--enrage-at, 50%); z-index: 3; width: 3px; margin-left: -1px; background: var(--b-gold); box-shadow: 0 0 6px var(--b-gold); }
.bboss-num { margin-top: 3px; text-align: right; font: 700 0.85rem/1 var(--b-font); color: var(--b-dim); letter-spacing: 0.04em; }
.bboss-num b { color: #fff; font-size: 1rem; }
.bboss-num small { margin-left: 6px; color: #ffb3ba; font-size: 0.85rem; }
.battle-boss.enraged .bboss-hp i { animation: boss-rage 0.7s ease-in-out infinite alternate; }
.battle-boss.enraged .bboss-mark { opacity: 0.35; }
.battle-boss.out { filter: grayscale(0.8) brightness(0.7); }
.battle-boss.hit, .battle-boss.hit-big { animation: boss-hit 0.35s ease-out; }
.battle-boss.hit-big { animation-duration: 0.5s; }
@keyframes boss-rage { from { filter: brightness(1); } to { filter: brightness(1.45) saturate(1.3); } }
@keyframes boss-hit { 0%, 100% { translate: 0 0; } 20% { translate: -6px 2px; } 45% { translate: 5px -2px; } 70% { translate: -3px 1px; } }

/* "Who should Mossling use Healing Dew on?" */
.battle-hint {
  order: 6;
  max-width: 100%;
  margin: 6px auto 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 8px 7px 18px;
  clip-path: polygon(var(--b-cut) 0, 100% 0, calc(100% - var(--b-cut)) 100%, 0 100%);
  background: linear-gradient(180deg, rgba(110, 18, 66, 0.95), rgba(48, 6, 28, 0.95));
  box-shadow: inset 0 0 0 1px var(--b-pink), inset 0 0 18px rgba(255, 95, 168, 0.45);
  color: #ffe1f0;
  font-weight: 600;
  pointer-events: auto;
}
.battle-cancel { padding: 5px 12px; border: 0; background: rgba(255, 255, 255, 0.16); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35); font: 700 0.95rem var(--b-font); letter-spacing: 0.06em; text-transform: uppercase; }
.battle-hint span { min-width: 0; }
.battle-cancel { flex: 0 0 auto; }

/* ----- The plates that float over each creature ----- */
.battle-plates { transition: opacity 0.25s; }
.battle.cinematic .battle-plates { opacity: 0; } /* (hidden while a Special swoops the camera in) */
.plate {
  --side: var(--b-ally);
  position: absolute;
  left: 0;
  top: 0;
  width: 178px;
  padding: 6px 8px 6px;
  isolation: isolate;
  font: 600 0.8rem/1.15 var(--b-font);
  transition: opacity 0.4s, filter 0.2s;
}
/* (the dark angled background lives in ::before, so the turn arrow and owner tag can poke out above it) */
.plate::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  clip-path: polygon(9px 0, 100% 0, 100% calc(100% - 9px), calc(100% - 9px) 100%, 0 100%, 0 9px);
  background: linear-gradient(180deg, rgba(22, 29, 45, 0.9), rgba(6, 9, 15, 0.88));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--side) 50%, transparent), inset 0 2px 0 var(--side);
}
.plate.wild { --side: var(--b-foe); }
.plate.friend { --side: var(--b-friend); }
.plate.gloomy { --side: var(--b-gloom); }
.plate.gloomy::before { background: linear-gradient(180deg, rgba(46, 20, 72, 0.92), rgba(12, 6, 22, 0.9)); }
.plate.gloomy .plate-name { color: #e2c8ff; }
.plate.current { --side: var(--b-gold); filter: drop-shadow(0 0 7px rgba(255, 207, 74, 0.55)); }
.plate.out { opacity: 0.35; filter: grayscale(0.9); }

/* The gold arrow over whoever's turn it is */
.plate-turn {
  position: absolute;
  left: 50%;
  top: -20px;
  width: 18px;
  height: 12px;
  margin-left: -9px;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  background: linear-gradient(180deg, #fff3c4, var(--b-gold));
  display: none;
  animation: bounce 0.7s ease-in-out infinite;
}
.plate.current .plate-turn { display: block; }
@keyframes bounce {
  0%, 100% { margin-top: 0; }
  50% { margin-top: -5px; }
}

.plate-owner {
  position: absolute;
  top: -15px;
  left: 8px;
  padding: 1px 8px 0;
  clip-path: polygon(4px 0, 100% 0, calc(100% - 4px) 100%, 0 100%);
  background: var(--b-friend);
  color: #1a0f33;
  font: 800 0.68rem/1.25 var(--b-font);
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.plate-owner:empty { display: none; }

.plate-top { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.plate-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: 1.05rem; font-weight: 800; letter-spacing: 0.02em; }
/* The level badge: a little six-sided shield */
.plate-level {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  align-content: center;
  width: 27px;
  height: 25px;
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
  background: linear-gradient(180deg, color-mix(in srgb, var(--side) 55%, white), var(--side) 50%, color-mix(in srgb, var(--side) 55%, black));
  color: #050a12;
  font-weight: 800;
  font-size: 0.86rem;
  line-height: 0.85;
}
.plate-level small { font-size: 0.5rem; letter-spacing: 0.08em; text-transform: uppercase; }
.plate-el { display: grid; }
.el-icon { width: 15px; height: 15px; filter: drop-shadow(0 0 3px currentColor); }
.plate-role { font-size: 0.78rem; }
.plate-rank .iv-rank { font-size: 0.62rem; min-width: 1.3em; }

/* Health bars: the bright part drops at once, the pale "chunk" follows a moment later */
.battle .bar {
  position: relative;
  height: 12px;
  margin-top: 4px;
  clip-path: polygon(4px 0, 100% 0, calc(100% - 4px) 100%, 0 100%);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.battle .bar i { position: absolute; inset: 0 auto 0 0; z-index: 1; background: var(--b-hp-ally); transition: width 0.35s ease-out; }
.battle .bar .chunk { position: absolute; inset: 0 auto 0 0; background: var(--b-chunk); transition: width 0.6s ease-in 0.45s; }
.battle .bar.healing .chunk { transition: none; background: #7dffb5; }
.battle .bar.hp i.low { background: var(--b-hp-low); }
.battle .bar.hp i.danger { background: var(--b-hp-danger); animation: hp-danger 0.6s ease-in-out infinite alternate; }
.plate.wild .bar.hp i, .plate.wild .bar.hp i.low { background: var(--b-hp-foe); }
.battle .bar.hp span {
  position: absolute;
  inset: 0;
  z-index: 2;
  padding-right: 6px;
  text-align: right;
  font: 700 0.7rem/12px var(--b-font);
  letter-spacing: 0.04em;
  color: #fff;
  text-shadow: 0 0 2px #000, 0 1px 1px #000;
}
@keyframes hp-danger { from { filter: brightness(1); } to { filter: brightness(1.5); } }

/* The Special meter: five gold pieces (one per turn) that glow when full */
.battle .bar.energy { height: 5px; margin-top: 3px; }
.battle .bar.energy i { background: linear-gradient(90deg, #ffb52e, #ffe27a); transition: width 0.4s ease-out; }
.battle .bar.energy::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  background: repeating-linear-gradient(90deg, transparent 0 calc(20% - 2px), rgba(4, 6, 10, 0.9) calc(20% - 2px) 20%);
}
.battle .bar.energy.full i { background: linear-gradient(90deg, #ffe27a, #fff8dc, #ffe27a); animation: glow 0.9s ease-in-out infinite alternate; }
@keyframes glow {
  from { filter: brightness(1); }
  to { filter: brightness(1.5) drop-shadow(0 0 4px #ffcf4a); }
}

/* Burned, sleepy, boosts… */
.plate-icons { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px; }
.plate-icons:empty, .bboss-icons:empty { display: none; }
.bchip {
  padding: 1px 4px 0;
  clip-path: polygon(3px 0, 100% 0, calc(100% - 3px) 100%, 0 100%);
  background: rgba(255, 255, 255, 0.1);
  font: 800 0.66rem/1.3 var(--b-font);
  letter-spacing: 0.04em;
}
.bchip.pic { padding: 0 3px; font-size: 0.8rem; line-height: 1.1; }
.bchip.up { background: rgba(60, 230, 140, 0.18); color: #7dffb5; }
.bchip.down { background: rgba(255, 77, 94, 0.2); color: #ff9aa4; }
.plate-catch { margin-top: 3px; font-weight: 800; letter-spacing: 0.04em; color: #ff9fd0; text-shadow: 0 0 8px rgba(255, 95, 168, 0.7); }
.plate-catch:empty { display: none; }

.plate.targetable {
  --side: var(--b-pink);
  pointer-events: auto;
  cursor: pointer;
  animation: target-pulse 0.8s ease-in-out infinite alternate;
}
@keyframes target-pulse {
  from { filter: drop-shadow(0 0 2px rgba(255, 95, 168, 0.4)); }
  to { filter: drop-shadow(0 0 12px rgba(255, 95, 168, 1)); }
}

/* A plate jolts when its creature gets hit. (translate adds to the position the game sets.) */
.plate.hit { animation: plate-hit 0.3s ease-out; }
.plate.hit-big { animation: plate-hit 0.45s ease-out; }
.plate.hit::before, .plate.hit-big::before { animation: plate-flash 0.35s ease-out; }
@keyframes plate-hit { 0%, 100% { translate: 0 0; } 25% { translate: -5px 1px; } 55% { translate: 4px -1px; } 80% { translate: -2px 0; } }
@keyframes plate-flash { 0% { filter: brightness(2.4); } 100% { filter: brightness(1); } }

/* A giant boss uses the big bar at the top instead of its plate. */
.battle.has-boss .plate.boss:not(.targetable) { visibility: hidden; }
/* Raids have lots of creatures on your side: smaller plates. */
.battle[data-kind="raid"] .plate.player { width: 132px; padding: 4px 6px 5px; font-size: 0.72rem; }
.battle[data-kind="raid"] .plate.player .plate-role { display: none; }
.battle[data-kind="raid"] .plate.player .plate-name { font-size: 0.85rem; }

/* ----- Numbers that pop out when creatures get hit or healed ----- */
.floater {
  --fc: #ffffff; /* (the move's element colour) */
  position: absolute;
  transform: translate(-50%, 0);
  font: italic 800 2.2rem/1 var(--b-font);
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
  animation: float-up 1.25s cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
}
.floater span {
  display: inline-block;
  color: color-mix(in srgb, var(--fc) 30%, white);
  text-shadow:
    -1px -1px 0 #05070c, 1px -1px 0 #05070c, -1px 1px 0 #05070c, 1px 1px 0 #05070c,
    0 3px 0 rgba(0, 0, 0, 0.7), 0 0 14px var(--fc), 0 0 30px color-mix(in srgb, var(--fc) 60%, transparent);
  letter-spacing: 0.02em;
}
/* the little shout above the number: "Super strong!", "Lucky!" */
.floater small {
  display: block;
  width: max-content;
  margin: 0 auto 3px;
  padding: 2px 14px 1px;
  background: linear-gradient(90deg, transparent, var(--fc) 18%, var(--fc) 82%, transparent);
  color: #fff;
  font: italic 800 0.9rem/1.15 var(--b-font);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}
.floater.strong span { font-size: 2.9rem; }
.floater.strong small { background: linear-gradient(90deg, transparent, #ffb52e 18%, #ffdf6e 50%, #ffb52e 82%, transparent); color: #2a1600; text-shadow: none; }
.floater.weak span { font-size: 1.6rem; color: #c9d0dd; text-shadow: -1px -1px 0 #05070c, 1px -1px 0 #05070c, -1px 1px 0 #05070c, 1px 1px 0 #05070c, 0 2px 0 rgba(0, 0, 0, 0.7); }
.floater.weak small { background: linear-gradient(90deg, transparent, #5b6375 20%, #5b6375 80%, transparent); font-size: 0.75rem; }
/* Lucky hits (crits): bigger, and they PUNCH in */
.floater.lucky { animation: crit-punch 1.4s cubic-bezier(0.2, 0.9, 0.3, 1) forwards; }
.floater.lucky span { font-size: 3.4rem; color: #fff; }
.floater.lucky small { background: linear-gradient(90deg, transparent, #ff5fa8 18%, #ffd0e8 50%, #ff5fa8 82%, transparent); color: #3a0020; text-shadow: none; font-size: 1rem; }
.floater.heal { --fc: #44f59a; }
.floater.heal span { color: #c8ffe2; }
.floater.up, .floater.down { font-size: 1.25rem; font-style: normal; }
.floater.up { --fc: #ffcf4a; }
.floater.down { --fc: #a77bff; }
.floater.miss { --fc: #7d8699; font-size: 1.5rem; text-transform: uppercase; }
.floater.miss span { color: #dfe4ee; }
.floater.status-pop { font-size: 2rem; font-style: normal; }
.floater.status-pop span { text-shadow: none; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.7)); }
.floater-icon { margin-left: 4px; font-style: normal; font-size: 0.7em; vertical-align: 0.1em; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.7)); }

@keyframes float-up {
  0% { opacity: 0; transform: translate(-50%, 12px) scale(0.5); }
  12% { opacity: 1; transform: translate(-50%, 0) scale(1.25); }
  26% { transform: translate(-50%, -6px) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -64px) scale(0.95); }
}
@keyframes crit-punch {
  0% { opacity: 0; transform: translate(-50%, 0) scale(2.6) rotate(-8deg); }
  10% { opacity: 1; transform: translate(-50%, 0) scale(0.82) rotate(-4deg); }
  20% { transform: translate(-50%, -4px) scale(1.14) rotate(-5deg); }
  30% { transform: translate(-50%, -6px) scale(1) rotate(-4deg); }
  78% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -70px) scale(1) rotate(-4deg); }
}

.battle-flash { position: absolute; inset: 0; background: var(--flash-color, white); opacity: 0; }
.battle-flash.go { animation: flash 0.6s ease-out; }
@keyframes flash {
  0% { opacity: 0; }
  15% { opacity: 0.55; }
  100% { opacity: 0; }
}

/* ----- The dark veil while a Battle Realm finishes painting (usually it's ready before you get there) ----- */
.battle-veil {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: radial-gradient(circle at 50% 45%, #2a2140 0%, #0d0b16 70%);
  color: #e8e0ff;
  font-size: 20px;
  letter-spacing: 0.04em;
  pointer-events: auto;
}
.battle-veil[hidden] { display: none; }
.veil-swirl {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 5px solid rgba(180, 150, 255, 0.2);
  border-top-color: #b48cff;
  border-right-color: #ff8a5a;
  animation: veil-spin 0.8s linear infinite;
}
@keyframes veil-spin {
  to { transform: rotate(360deg); }
}

/* ----- Big banners: "A wild creature appears!", "Wave 2 / 3", "Round 4", Specials ----- */
.battle-banner {
  z-index: 2;
  --accent: var(--element-color, #ffcf4a);
  position: absolute;
  left: 0;
  right: 0;
  top: 32%;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.battle-banner.raid, .battle-banner.enrage { --accent: #ff4d5e; }
.battle-banner.arena { --accent: #ffcf4a; }
.battle-banner.stage, .battle-banner.wave, .battle-banner.round { --accent: #4fc3ff; }
.battle-banner.round { top: 24%; }
.bb-band {
  width: 100%;
  padding: 14px 24px 16px;
  text-align: center;
  background: linear-gradient(90deg, transparent, rgba(4, 6, 12, 0.86) 20%, rgba(4, 6, 12, 0.86) 80%, transparent);
  border-image: linear-gradient(90deg, transparent, var(--accent) 30%, var(--accent) 70%, transparent) 1;
  border-width: 2px 0;
  border-style: solid;
  animation: bb-in var(--banner-time, 1.9s) ease-out forwards;
}
.battle-banner.round .bb-band { width: min(420px, 90%); padding: 6px 20px 8px; }
.bb-kicker { font: 800 1rem/1.2 var(--b-font); letter-spacing: 0.32em; text-transform: uppercase; color: var(--accent); text-shadow: 0 0 10px var(--accent); }
.bb-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25em;
  font: italic 800 clamp(2.2rem, 6.5vw, 4.4rem)/1.02 var(--b-font);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.6), 0 0 26px var(--accent);
  animation: bb-title var(--banner-time, 1.9s) ease-out forwards;
}
.bb-title .el-icon { width: 0.8em; height: 0.8em; filter: drop-shadow(0 0 10px currentColor); }
.battle-banner.round .bb-title { font-size: clamp(1.6rem, 4vw, 2.4rem); }
.battle-banner.long .bb-title { font-size: clamp(1.5rem, 4.6vw, 3rem); flex-wrap: wrap; }
.battle-banner.special .bb-title { font-size: clamp(2rem, 5.5vw, 3.6rem); }
.bb-sub { margin-top: 4px; font: 700 1.1rem var(--b-font); letter-spacing: 0.16em; text-transform: uppercase; color: var(--b-dim); }
@keyframes bb-in {
  0% { opacity: 0; transform: scaleX(0.3); }
  10% { opacity: 1; transform: scaleX(1); }
  82% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateY(-12px); }
}
@keyframes bb-title {
  0% { opacity: 0; letter-spacing: 0.5em; }
  16% { opacity: 1; letter-spacing: 0.04em; }
  100% { letter-spacing: 0.07em; }
}

/* ----- What just happened ("Emberkit used Ember!") ----- */
.battle-message {
  position: absolute;
  left: 50%;
  bottom: 196px;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 24px);
  padding: 9px 24px;
  clip-path: polygon(var(--b-cut) 0, calc(100% - var(--b-cut)) 0, 100% 50%, calc(100% - var(--b-cut)) 100%, var(--b-cut) 100%, 0 50%);
  background: linear-gradient(180deg, rgba(16, 22, 35, 0.92), rgba(5, 8, 14, 0.92));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
  color: var(--b-text);
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
}
.battle-message:empty { display: none; }
.battle-message.pop { animation: message-pop 0.25s ease-out; }
@keyframes message-pop {
  from { transform: translateX(-50%) scale(0.85); opacity: 0.4; }
  to { transform: translateX(-50%) scale(1); opacity: 1; }
}

/* ----- Your creature's moves at the bottom ----- */
.battle-panel {
  position: absolute;
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  display: flex;
  align-items: stretch;
  gap: 10px;
  min-height: 112px;
  padding: 10px;
  clip-path: polygon(16px 0, calc(100% - 16px) 0, 100% 16px, 100% 100%, 0 100%, 0 16px);
  background: linear-gradient(180deg, rgba(14, 19, 31, 0.9), rgba(4, 6, 11, 0.94));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.09), inset 0 2px 0 rgba(79, 195, 255, 0.7);
  backdrop-filter: blur(6px);
  pointer-events: auto;
  transition: opacity 0.2s;
}
body.touch .battle-panel { backdrop-filter: none; } /* (lighter for tablets and phones) */
.battle-panel.waiting { opacity: 0.9; align-items: center; justify-content: center; min-height: 54px; }
/* (while a turn plays out there is nothing to say, so the empty bar fades away) */
.battle-panel.waiting:has(> .panel-waiting:empty) { opacity: 0; }
.panel-waiting { color: var(--b-dim); font: italic 700 1.1rem var(--b-font); letter-spacing: 0.06em; }

/* Who's choosing: a six-sided portrait, name, role and level */
.panel-who { display: flex; align-items: center; gap: 10px; min-width: 190px; }
.panel-face {
  flex: 0 0 auto;
  width: 74px;
  height: 74px;
  padding: 2px;
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
  background: linear-gradient(180deg, color-mix(in srgb, var(--element-color) 60%, white), var(--element-color));
}
.panel-portrait {
  width: 100%;
  height: 100%;
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
  background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--element-color) 40%, #1c2538), #05080e 80%);
  object-fit: contain;
}
.panel-id { min-width: 0; }
.panel-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: italic 800 1.45rem/1 var(--b-font); letter-spacing: 0.04em; text-transform: uppercase; }
.panel-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.panel-role, .panel-level {
  display: inline-block;
  padding: 2px 9px 1px;
  clip-path: polygon(5px 0, 100% 0, calc(100% - 5px) 100%, 0 100%);
  font: 800 0.8rem/1.2 var(--b-font);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.panel-role { background: var(--role-color); color: white; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.4); }
.panel-level { background: rgba(255, 255, 255, 0.12); color: var(--b-text); }

.panel-moves { flex: 1; display: grid; grid-template-columns: repeat(3, 1fr) 1.3fr; gap: 8px; }

/* Skill tiles: a round element badge, the move's name, and what it does */
.move-btn, .special-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 60px;
  padding: 8px 10px 8px 8px;
  border: 0;
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px));
  background: linear-gradient(160deg, color-mix(in srgb, var(--element-color) 26%, #121827), #090d15 72%);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--element-color) 50%, transparent), inset 0 -3px 0 color-mix(in srgb, var(--element-color) 85%, transparent);
  text-align: left;
  transition: transform 0.08s, filter 0.15s;
  overflow: hidden;
}
.move-btn:hover:not(:disabled), .special-btn:hover:not(:disabled) { filter: brightness(1.2); }
.move-btn:active:not(:disabled), .special-btn:active:not(:disabled) { transform: translateY(2px) scale(0.98); }
.move-btn:disabled { opacity: 1; cursor: default; } /* (the striped "Ready in 2" cover does the dimming) */
.move-icon {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--element-color) 45%, #1b2335), #05080e 78%);
  box-shadow: 0 0 0 2px var(--element-color), 0 0 14px color-mix(in srgb, var(--element-color) 60%, transparent);
}
.move-icon .el-icon { width: 23px; height: 23px; filter: drop-shadow(0 0 5px currentColor); }
.move-icon kbd {
  position: absolute;
  right: -6px;
  bottom: -5px;
  min-width: 17px;
  height: 17px;
  padding: 0 3px;
  background: #05080e;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 17px;
  color: #dfe6f5;
  text-align: center;
}
.move-text { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.battle .move-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 800 1.12rem/1.05 var(--b-font); letter-spacing: 0.03em; text-transform: uppercase; }
.battle .move-info { font: 600 0.84rem/1.15 var(--b-font); letter-spacing: 0.02em; color: var(--b-dim); }
.battle .move-info b { color: #fff; font-weight: 800; }

/* "Ready in 2": a dark striped cover with a big number */
.move-wait {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: repeating-linear-gradient(135deg, rgba(3, 5, 9, 0.92) 0 8px, rgba(3, 5, 9, 0.82) 8px 16px);
  color: #c9d0dd;
}
.move-wait b { font: italic 800 2rem/1 var(--b-font); color: #fff; }
.move-wait small { font: 700 0.75rem var(--b-font); letter-spacing: 0.08em; text-transform: uppercase; }

/* The Special: it fills up from the bottom, then glows gold when it's ready */
.special-btn { --energy: 0%; background: linear-gradient(160deg, #1d1b2c, #080b13 72%); }
.special-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--energy);
  background: linear-gradient(0deg, color-mix(in srgb, var(--element-color) 55%, transparent), color-mix(in srgb, var(--element-color) 12%, transparent));
  transition: height 0.4s;
}
.special-btn .move-info { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-family: "Fredoka", sans-serif; font-size: 0.74rem; font-weight: 500; letter-spacing: 0; }
.special-btn:disabled { opacity: 1; cursor: default; }
.special-btn:disabled .move-icon { filter: saturate(0.5) brightness(0.8); }
.special-btn:disabled .move-text { opacity: 0.8; }
.special-label { font: 800 0.8rem/1 var(--b-font); letter-spacing: 0.14em; color: #ffd76a; }
.special-label small { margin-left: 4px; color: #fff; }
.special-label kbd { margin-left: 4px; padding: 0 5px; background: rgba(0, 0, 0, 0.5); box-shadow: inset 0 0 0 1px rgba(255, 215, 106, 0.6); font-size: 0.72rem; color: #ffe9a8; }
.special-meter { position: absolute; left: 0; right: 0; bottom: 0; z-index: 1; height: 4px; background: rgba(255, 255, 255, 0.08); }
.special-meter i { display: block; height: 100%; background: linear-gradient(90deg, #ffb52e, #ffe27a); }

.special-btn.ready {
  background: linear-gradient(135deg, color-mix(in srgb, var(--element-color) 55%, #2a1d05), #4a3008 55%, color-mix(in srgb, var(--element-color) 45%, #120c02));
  box-shadow: inset 0 0 0 2px #ffd76a, inset 0 0 22px rgba(255, 215, 106, 0.55);
  animation: special-ready 1s ease-in-out infinite alternate;
}
.special-btn.ready .special-fill { opacity: 0.4; }
.special-btn.ready .move-icon { box-shadow: 0 0 0 2px #ffd76a, 0 0 20px #ffd76a; }
.special-btn.ready .move-info { color: #f4e3b8; }
/* a shine that sweeps across it */
.special-btn.ready::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(110deg, transparent 35%, rgba(255, 255, 255, 0.35) 50%, transparent 65%);
  animation: special-shine 1.8s ease-in-out infinite;
  pointer-events: none;
}
@keyframes special-ready {
  from { filter: brightness(1); }
  to { filter: brightness(1.25); }
}
@keyframes special-shine {
  from { transform: translateX(-110%); }
  60%, to { transform: translateX(110%); }
}

/* Charms and Run */
.panel-extra { display: flex; flex-direction: column; gap: 7px; min-width: 124px; }
.extra-btn {
  flex: 1;
  padding: 4px 8px;
  border: 0;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  background: linear-gradient(160deg, #4a1638, #17060f);
  box-shadow: inset 0 0 0 1px rgba(255, 95, 168, 0.65), inset 0 -3px 0 var(--b-pink);
  color: #ffd6ec;
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: filter 0.15s;
}
.extra-btn:hover:not(:disabled) { filter: brightness(1.2); }
.extra-btn.run { background: linear-gradient(160deg, #262d3b, #0b0e15); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25), inset 0 -3px 0 rgba(255, 255, 255, 0.35); color: #d8deea; }
.extra-btn.run.sure { background: linear-gradient(160deg, #5a1019, #1c0408); box-shadow: inset 0 0 0 1px var(--b-foe), inset 0 -3px 0 var(--b-foe); color: #ffd0d4; animation: special-ready 0.6s ease-in-out infinite alternate; }
.extra-btn:disabled { opacity: 0.4; cursor: default; }
.charm-btn b { margin-left: 2px; color: #fff; }

/* ----- The end of a battle ----- */
.battle-result {
  z-index: 3; /* (on top of everything) */
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: radial-gradient(ellipse at center, rgba(4, 6, 12, 0.5), rgba(2, 3, 6, 0.88));
  pointer-events: auto;
}
.result-card {
  --tone: #ffcf4a;
  position: relative;
  width: min(480px, 100%);
  max-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 18px 22px 20px;
  clip-path: polygon(18px 0, calc(100% - 18px) 0, 100% 18px, 100% calc(100% - 18px), calc(100% - 18px) 100%, 18px 100%, 0 calc(100% - 18px), 0 18px);
  background: linear-gradient(180deg, rgba(20, 26, 42, 0.97), rgba(5, 7, 12, 0.98));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tone) 55%, transparent), inset 0 3px 0 var(--tone);
  text-align: center;
  animation: result-in 0.45s cubic-bezier(0.3, 1.4, 0.6, 1);
}
.result-card.lost { --tone: #ff4d5e; }
.result-card.ran, .result-card.draw { --tone: #4fc3ff; }
.result-card.friend { --tone: #ff8fc8; }
.result-card > :not(.result-rays) { position: relative; }
/* light rays behind the title when you win */
.result-rays {
  position: absolute;
  left: 50%;
  top: -150px;
  width: 360px;
  height: 360px;
  margin-left: -180px;
  border-radius: 50%;
  background: repeating-conic-gradient(color-mix(in srgb, var(--tone) 32%, transparent) 0 8deg, transparent 8deg 22deg);
  mask-image: radial-gradient(circle, black 15%, transparent 68%);
  -webkit-mask-image: radial-gradient(circle, black 15%, transparent 68%);
  opacity: 0;
  animation: rays-spin 14s linear infinite;
}
.result-card.won .result-rays, .result-card.friend .result-rays { opacity: 1; }
@keyframes rays-spin { to { transform: rotate(360deg); } }
@keyframes result-in {
  from { opacity: 0; transform: scale(0.85) translateY(10px); }
  to { opacity: 1; transform: none; }
}
.result-kicker {
  margin-top: 2px;
  font: italic 800 clamp(2.4rem, 8vw, 3.6rem)/1 var(--b-font);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: linear-gradient(180deg, #fff, color-mix(in srgb, var(--tone) 70%, white) 45%, var(--tone));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.7)) drop-shadow(0 0 16px color-mix(in srgb, var(--tone) 60%, transparent));
  animation: kicker-in 0.6s cubic-bezier(0.2, 1.4, 0.5, 1) both;
}
@keyframes kicker-in {
  from { opacity: 0; transform: scale(1.8); letter-spacing: 0.3em; }
  to { opacity: 1; transform: none; }
}
.result-card h2 { margin: 6px 0 10px; font-size: 1.25rem; font-weight: 600; color: #e6ebf5; }
/* (when the title just repeats the big word, like "Victory!", it hides — screen readers still read it) */
.result-card h2.echo { position: absolute; width: 1px; height: 1px; margin: 0; overflow: hidden; clip-path: inset(50%); }
.result-card p { color: var(--b-dim); }
.result-card .result-tip {
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.05);
  box-shadow: inset 3px 0 0 var(--b-gold);
  color: var(--b-text);
  text-align: left;
}

.result-row {
  --element-color: #9aa4b8;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0;
  padding: 7px 12px 8px 8px;
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
  background: linear-gradient(90deg, color-mix(in srgb, var(--element-color) 18%, rgba(255, 255, 255, 0.04)), rgba(255, 255, 255, 0.03));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
  text-align: left;
  animation: row-in 0.4s ease-out both;
}
.result-row:nth-of-type(2) { animation-delay: 0.08s; }
.result-row:nth-of-type(3) { animation-delay: 0.16s; }
.result-row:nth-of-type(4) { animation-delay: 0.24s; }
@keyframes row-in { from { opacity: 0; transform: translateX(-14px); } }
.result-row > div { flex: 1; min-width: 0; }
.result-row img {
  flex: 0 0 auto;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--element-color) 40%, #1c2538), #05080e 80%);
  box-shadow: 0 0 0 2px var(--element-color), 0 0 12px color-mix(in srgb, var(--element-color) 50%, transparent);
  object-fit: contain;
}
.result-name { font: 800 1.15rem var(--b-font); letter-spacing: 0.04em; text-transform: uppercase; }
.result-xp { margin-left: 4px; font: 800 1rem var(--b-font); color: #8fd8ff; letter-spacing: 0.04em; }
.result-row .capped { color: #ffc46b; font-size: 0.85rem; font-weight: 600; }
/* The XP bar fills up after the battle */
.bxp { position: relative; height: 6px; margin-top: 5px; background: rgba(255, 255, 255, 0.1); clip-path: polygon(3px 0, 100% 0, calc(100% - 3px) 100%, 0 100%); }
.bxp i { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, #2f8dff, #6fe3ff); box-shadow: 0 0 8px #4fc3ff; transition: width 1.1s ease-out 0.35s; }
.bxp.full i { width: 100%; background: linear-gradient(90deg, #ffb52e, #ffe27a); }
.result-row.friend {
  padding: 10px 14px 10px 10px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--element-color) 35%, rgba(255, 255, 255, 0.05)), rgba(255, 143, 200, 0.08));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--element-color) 70%, transparent), inset 0 0 22px color-mix(in srgb, var(--element-color) 35%, transparent);
  font-size: 1.05rem;
}
.result-row.friend img { width: 70px; height: 70px; animation: friend-glow 1.4s ease-in-out infinite alternate; }
.result-row.friend b { font: 800 1.25rem var(--b-font); letter-spacing: 0.04em; text-transform: uppercase; }
@keyframes friend-glow { to { box-shadow: 0 0 0 2px var(--element-color), 0 0 26px var(--element-color); } }
.result-new {
  display: block;
  width: max-content;
  margin-bottom: 2px;
  padding: 1px 8px 0;
  clip-path: polygon(4px 0, 100% 0, calc(100% - 4px) 100%, 0 100%);
  background: #ff8fc8;
  color: #3a0020;
  font: 800 0.7rem/1.3 var(--b-font);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.level-up {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 9px 0;
  clip-path: polygon(5px 0, 100% 0, calc(100% - 5px) 100%, 0 100%);
  background: linear-gradient(180deg, #fff1b0, #ffcf4a);
  color: #3a2400;
  font: 800 0.9rem/1.3 var(--b-font);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  animation: pop-in 0.4s ease-out 0.5s both;
}
.learned { margin-top: 3px; color: #7dffb5; font-weight: 600; font-size: 0.9rem; }
.result-charms { margin: 8px 0; font: 800 1.05rem var(--b-font); letter-spacing: 0.04em; color: #ff9fd0; }
.result-stars { font-size: 2.6rem; line-height: 1; letter-spacing: 4px; color: #2c3446; }
.result-stars span.on { color: #ffcf4a; text-shadow: 0 0 14px rgba(255, 207, 74, 0.8), 0 2px 0 #9a6a00; animation: pop-in 0.4s ease-out both; }
.result-stars span.on:nth-child(2) { animation-delay: 0.15s; }
.result-stars span.on:nth-child(3) { animation-delay: 0.3s; }
.result-goals { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 12px; margin: 6px 0 10px; font-size: 0.85rem; color: var(--b-dim); }
.result-goals span.on { color: var(--b-text); font-weight: 600; }
.result-loot { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 10px 0; }
.loot-item, .loot-gear {
  padding: 4px 10px 3px;
  clip-path: polygon(5px 0, 100% 0, calc(100% - 5px) 100%, 0 100%);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
  font: 700 0.95rem var(--b-font);
  letter-spacing: 0.03em;
}
.loot-gear { box-shadow: inset 0 0 0 1px var(--rarity), inset 0 -2px 0 var(--rarity); color: var(--b-text); }
.result-continue {
  width: 100%;
  margin-top: 12px;
  padding: 13px;
  border: 0;
  clip-path: polygon(12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%, 0 12px);
  background: linear-gradient(180deg, #ffe58a, #ffbf2e 55%, #e08a00);
  color: #2a1600 !important;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: filter 0.15s;
}
.result-continue:hover { filter: brightness(1.12); }

/* Smaller screens: moves wrap into two rows */
@media (max-width: 900px) {
  .panel-who { display: none; }
  .panel-moves { grid-template-columns: repeat(3, 1fr); }
  .special-btn { grid-column: 1 / -1; min-height: 52px; }
  .battle-message { bottom: 196px; }
  .plate { width: 142px; }
}

/* Phones held upright: the timeline gets its own row, the move tiles stand up tall. */
@media (max-width: 560px) {
  .battle-top { gap: 2px 8px; }
  .battle-round { order: 0; padding: 6px 12px 5px; font-size: 0.9rem; }
  .battle-toggles { order: 1; margin-left: auto; }
  .battle-toggle { padding: 6px 10px 5px; font-size: 0.9rem; }
  .battle-order { order: 3; flex-basis: 100%; }
  .order-track { padding: 4px 8px 9px; gap: 2px; }
  .order-face { width: 32px; height: 32px; padding: 1px; }
  .order-face.boss { width: 36px; height: 36px; }
  .order-face.now { width: 42px; height: 42px; }
  .order-gap { width: 6px; height: 6px; margin: 0 1px; }
  .battle-boss { padding: 6px 10px 6px 8px; gap: 8px; }
  .bboss-badge { width: 40px; height: 37px; }
  .bboss-badge b { font-size: 1.1rem; }
  .bboss-name { font-size: 1.1rem; }
  .bboss-tag { display: none; }
  .bboss-hp { height: 12px; }
  .battle-hint { padding: 5px 6px 5px 14px; font-size: 0.9rem; }

  .battle-panel { left: max(8px, env(safe-area-inset-left)); right: max(8px, env(safe-area-inset-right)); bottom: max(8px, env(safe-area-inset-bottom)); flex-direction: column; gap: 7px; padding: 8px; }
  .panel-moves { gap: 6px; }
  .move-btn { flex-direction: column; justify-content: flex-start; gap: 5px; padding: 8px 4px 9px; text-align: center; }
  .move-btn .move-icon { width: 36px; height: 36px; }
  .move-btn .move-icon .el-icon { width: 20px; height: 20px; }
  .move-btn .move-text { align-items: center; width: 100%; }
  .move-btn .move-name { width: 100%; font-size: 0.98rem; white-space: normal; overflow-wrap: anywhere; }
  .move-btn .move-info { font-size: 0.74rem; }
  .move-wait { flex-direction: column; gap: 0; }
  .special-btn { padding: 6px 10px 7px 8px; }
  .special-btn .move-icon { width: 36px; height: 36px; }
  .panel-extra { flex-direction: row; min-width: 0; min-height: 42px; gap: 6px; }
  .extra-btn { font-size: 0.9rem; }
  .battle-message { bottom: 244px; font-size: 1rem; }
  .plate { width: 124px; padding: 4px 6px 5px; font-size: 0.7rem; }
  .plate-name { font-size: 0.85rem; }
  .plate-level { width: 23px; height: 21px; font-size: 0.74rem; }
  .plate-role, .plate-el, .wild-word { display: none; } /* (room for the name; the red edge already says "wild") */
  .battle .bar.hp { height: 10px; }
  .battle .bar.hp span { line-height: 10px; font-size: 0.62rem; }
  .floater { font-size: 1.8rem; }
  .floater.strong span { font-size: 2.3rem; }
  .floater.lucky span { font-size: 2.7rem; }
  .bb-kicker { font-size: 0.85rem; letter-spacing: 0.22em; }
  .result-card { padding: 14px 14px 16px; }
}

/* Narrow phones: slimmer name plates, so they don't pile up on top of the creatures */
@media (max-width: 420px) {
  .plate { width: 112px; padding: 3px 5px 4px; }
  .plate::before { clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px); }
  .plate-name { font-size: 0.76rem; }
  .plate-level { width: 20px; height: 18px; font-size: 0.66rem; }
  .plate-level small { display: none; }
  .plate-rank .iv-rank { font-size: 0.56rem; }
  .plate-top { gap: 3px; }
  .battle .bar.hp { height: 8px; }
  .battle .bar.hp span { line-height: 8px; font-size: 0.56rem; }
}

/* ---------- The town (Milestone 4) ---------- */

/* The storehouse bar under the top buttons */
.storage {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  width: fit-content;
  max-width: 100%;
  margin-top: 8px;
  padding: 6px 14px;
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
  font-size: 1.05rem;
  font-weight: 600;
}
.storage.bump { animation: storage-bump 0.4s cubic-bezier(0.3, 1.6, 0.6, 1); }
@keyframes storage-bump {
  from { transform: scale(1.12); }
  to { transform: scale(1); }
}

/* The gather / build / visit button */
.work-btn { background: #c9893f; box-shadow: 0 6px 0 #956127; }
.work-btn:active { box-shadow: 0 2px 0 #956127; }
.meet-btn.no-key kbd { display: none; } /* next to a building, E works the building instead */
.action-btn small { font-size: 0.8rem; letter-spacing: 1px; opacity: 0.9; }

/* "+3 🪵" floating up out of a tree */
.float-text {
  display: block;
  padding: 2px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.9);
  font-size: 1.15rem;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.12);
  animation: float-up 1.6s ease-out forwards;
}
.float-text.gain { color: var(--leaf-dark); }
@keyframes float-up {
  0% { transform: translateY(10px) scale(0.6); opacity: 0; }
  15% { transform: translateY(0) scale(1.1); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translateY(-50px) scale(1); opacity: 0; }
}

/* The label floating over each building spot */
.building-tag {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 110px;
  padding: 4px 12px 5px;
  border-radius: 12px;
  background: rgba(255, 248, 236, 0.92);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.12);
  white-space: nowrap;
  line-height: 1.15;
}
.building-tag b { font-size: 0.95rem; }
.building-tag span { font-size: 0.75rem; font-weight: 600; color: var(--soft-ink); }
.building-tag.ready { background: #fff1b8; animation: tag-glow 1.4s ease-in-out infinite; }
@keyframes tag-glow {
  50% { box-shadow: 0 3px 0 rgba(0, 0, 0, 0.12), 0 0 0 4px rgba(255, 212, 59, 0.6); }
}
.build-bar { display: block; width: 100%; height: 8px; border-radius: 4px; background: #e6d8c3; overflow: hidden; }
.build-bar em { display: block; height: 100%; background: var(--leaf); }

/* The building panel */
.building-panel {
  display: flex;
  flex-direction: column;
  width: min(620px, 100%);
  max-height: 100%;
  border-radius: 28px;
  background: var(--cream);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.building-body { padding: 4px 20px 20px; overflow-y: auto; }
.building-body h3 { margin: 14px 0 8px; }
.building-body h3 small { font-weight: 500; color: var(--soft-ink); font-size: 0.85rem; }

.need { margin: 8px 0; padding: 8px 12px; border-radius: 12px; font-weight: 500; }
.need.ok { background: #e3f4dc; color: #2f6b33; }
.need.missing { background: #fde3dc; color: #a03b25; }

.cost-list { display: flex; flex-wrap: wrap; gap: 8px; }
.cost { padding: 6px 12px; border-radius: 12px; font-weight: 600; font-size: 1.05rem; }
.cost.ok { background: #e3f4dc; color: #2f6b33; }
.cost.missing { background: #fde3dc; color: #a03b25; }
.cost-list.small { margin-top: 4px; gap: 4px; }
.cost-list.small .cost { padding: 2px 8px; font-size: 0.85rem; }

.big-go {
  padding: 12px 20px;
  border: 0;
  border-radius: 16px;
  background: var(--leaf);
  color: white;
  font-weight: 600;
  font-size: 1.1rem;
  box-shadow: 0 4px 0 var(--leaf-dark);
}
.big-go:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--leaf-dark); }
.big-go:disabled { opacity: 0.45; transform: none; }
.team-actions .big-go { padding: 14px 26px; background: var(--leaf); color: white; }

.build-progress { position: relative; height: 26px; border-radius: 13px; background: #e6d8c3; overflow: hidden; }
.build-progress i { display: block; height: 100%; background: var(--leaf); }
.build-progress span { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 600; }

.pile-row { display: flex; align-items: center; gap: 12px; }
.pile { flex: 1; display: flex; flex-wrap: wrap; gap: 10px; padding: 10px 14px; border-radius: 14px; background: #f3e9da; font-size: 1.2rem; font-weight: 600; min-height: 48px; align-items: center; }
.pile em { font-size: 0.95rem; font-weight: 500; color: var(--soft-ink); }

.worker-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.worker-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px;
  border-radius: 16px;
  background: white;
  box-shadow: 0 3px 0 rgba(61, 44, 34, 0.12);
}
.worker-card img { width: 64px; height: 64px; object-fit: contain; }
.worker-card small { color: var(--soft-ink); }
.worker-card button { margin-top: 6px; padding: 6px 10px; border: 0; border-radius: 10px; background: #efe3d1; font-weight: 600; font-size: 0.85rem; }
.worker-card.empty { justify-content: center; min-height: 120px; background: #ece2d3; color: var(--soft-ink); box-shadow: none; }

.worker-choices { display: flex; flex-wrap: wrap; gap: 10px; }
.worker-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 120px;
  padding: 8px;
  border: 3px solid transparent;
  border-radius: 16px;
  background: white;
  box-shadow: 0 3px 0 rgba(61, 44, 34, 0.12);
}
.worker-choice:hover:not(:disabled) { border-color: var(--leaf); }
.worker-choice:disabled { opacity: 0.45; }
.worker-choice img { width: 56px; height: 56px; object-fit: contain; }
.worker-choice small { color: var(--leaf-dark); font-weight: 600; }

.craft-list { display: flex; flex-direction: column; gap: 10px; }
.craft-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 16px; background: white; box-shadow: 0 3px 0 rgba(61, 44, 34, 0.12); }
.craft-icon { font-size: 2.2rem; }
.craft-info { flex: 1; display: flex; flex-direction: column; line-height: 1.25; }
.craft-info small { color: var(--soft-ink); }
.craft-side { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.craft-side small { color: var(--soft-ink); white-space: nowrap; }


@media (max-width: 560px) {
  .storage { font-size: 0.95rem; gap: 2px 8px; padding: 5px 10px; }
  .pile-row { flex-direction: column; align-items: stretch; }
  .craft-row { flex-wrap: wrap; }
}

/* The little tool bubble over things you can gather */
.gather-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 248, 236, 0.9);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.15);
  font-size: 1.1rem;
}

/* ---------- Raids and the Arena ---------- */
.soft-btn { padding: 12px 18px; border: 0; border-radius: 16px; background: #efe3d1; font-weight: 600; font-size: 1rem; }
.soft-btn:disabled { opacity: 0.55; }
.landmark-tag.ready { background: #e9dcff; }

.raid-group { padding: 4px 14px 14px; border-radius: 20px; background: #efe6ff; }
.raid-members { display: flex; flex-direction: column; gap: 8px; }
.raid-member { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 6px 12px; border-radius: 14px; background: white; box-shadow: 0 3px 0 rgba(61, 44, 34, 0.1); }
.raid-member.me { outline: 3px solid var(--leaf); }
.raid-member.empty { justify-content: center; color: var(--soft-ink); background: rgba(255, 255, 255, 0.5); box-shadow: none; }
.raid-member .big-go { margin-left: auto; padding: 8px 16px; font-size: 1rem; }
.raid-leader { font-size: 0.8rem; font-weight: 600; color: #8a6a00; }
.raid-team { display: flex; gap: 4px; margin-left: auto; }
.raid-team img { width: 40px; height: 40px; object-fit: contain; }

.boss-list { display: flex; flex-direction: column; gap: 10px; }
.boss-card { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: 3px solid transparent; border-radius: 18px; background: white; box-shadow: 0 3px 0 rgba(61, 44, 34, 0.12); }
.boss-card.picked { border-color: var(--element-color); }
.boss-card.locked { opacity: 0.7; background: #f1ece6; }
.boss-face { width: 76px; height: 76px; object-fit: contain; flex-shrink: 0; }
.boss-info { flex: 1; display: flex; flex-direction: column; gap: 2px; line-height: 1.25; }
.boss-info b { font-size: 1.15rem; }
.boss-name { display: flex; align-items: center; gap: 6px; }
.boss-info small { color: var(--soft-ink); }
.boss-info .boss-tip { color: #6a4fa0; font-weight: 500; }
.boss-info .boss-prize { color: var(--leaf-dark); font-weight: 600; }
.element-chip { display: inline-block; padding: 1px 8px; border-radius: 10px; background: var(--element-color); color: white; font-size: 0.75rem; font-weight: 600; }
.boss-card .big-go, .boss-card .soft-btn { flex-shrink: 0; padding: 10px 14px; font-size: 0.95rem; }

.raid-pill {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 12px);
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 16px;
  border-radius: 999px;
  background: rgba(233, 220, 255, 0.95);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.12);
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
}

.invite { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgba(40, 30, 25, 0.35); }
.invite-card { width: min(420px, 100%); padding: 22px; border-radius: 26px; background: var(--cream); box-shadow: var(--shadow); text-align: center; animation: pop-in 0.3s ease-out; }
.invite-title { font-size: 1.35rem; font-weight: 600; }
@keyframes pop-in { from { transform: scale(0.8); opacity: 0; } }

@media (max-width: 560px) {
  .boss-card { flex-wrap: wrap; }
  .boss-face { width: 56px; height: 56px; }
  .raid-pill { top: auto; bottom: 150px; font-size: 0.85rem; }
}


/* ---------- Homes, decorating and the Town Hall (Milestone 7) ---------- */
.home-tag { background: rgba(255, 240, 246, 0.94); }
.hall-tag { background: rgba(236, 246, 255, 0.94); }

.style-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.style-card { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 8px; border: 3px solid transparent; border-radius: 18px; background: white; box-shadow: 0 3px 0 rgba(61, 44, 34, 0.12); font: inherit; color: inherit; }
.style-card.picked { border-color: var(--leaf); background: #eef9ea; }
.style-card:disabled:not(.picked) { opacity: 0.5; }
.style-card small { color: var(--soft-ink); }
.style-icon { font-size: 2rem; }

.swatch-row { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 40px; height: 40px; border: 3px solid white; border-radius: 50%; background: var(--swatch); box-shadow: 0 2px 0 rgba(61, 44, 34, 0.25); }
.swatch.picked { outline: 3px solid var(--ink); outline-offset: 2px; }

.level-list { display: flex; flex-direction: column; gap: 10px; }
.level-row { padding: 12px 14px; border-radius: 18px; background: white; box-shadow: 0 3px 0 rgba(61, 44, 34, 0.12); }
.level-row.reached { background: #eef9ea; }
.level-row.later { opacity: 0.6; }
.level-row.next { border: 3px solid #ffd43b; }
.level-row small { display: block; margin: 4px 0 0 40px; color: var(--soft-ink); }
.level-title { display: flex; align-items: center; gap: 10px; }
.level-badge { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: #efe3d1; font-weight: 700; }
.level-row.reached .level-badge { background: var(--leaf); color: white; }

/* The decorating tray at the bottom of the screen */
.decor-tray {
  position: fixed;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 20;
  width: min(760px, calc(100% - 24px));
  padding: 10px 12px 12px;
  border-radius: 24px;
  background: var(--cream);
  box-shadow: var(--shadow);
}
.decor-top { display: flex; align-items: center; gap: 10px; }
.decor-top > b { flex: 0 0 auto; }
.decor-top .soft-btn { margin-left: auto; padding: 8px 14px; }
.decor-done { flex: 0 0 auto; min-height: 44px; font-size: 1rem; }
.decor-hint { flex: 1 1 auto; padding: 6px 12px; border-radius: 12px; background: #f4ead9; color: var(--soft-ink); font-size: 0.95rem; font-weight: 600; min-height: 1.4em; }
.decor-hint.good { background: #e3f6dc; color: #2f6b22; }
.decor-hint.bad { background: #fde3dd; color: #a8432f; }
.decor-strip { display: flex; gap: 8px; margin: 6px 0 4px; padding: 4px 2px 6px; overflow-x: auto; scroll-snap-type: x proximity; }
.decor-item { position: relative; flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 1px; width: 100px; padding: 6px 6px; border: 3px solid transparent; border-radius: 16px; background: white; box-shadow: 0 2px 0 rgba(61, 44, 34, 0.12); font: inherit; color: inherit; scroll-snap-align: start; transition: transform 0.12s; }
.decor-item b { font-size: 0.8rem; line-height: 1.1; text-align: center; }
.decor-item small { font-size: 0.75rem; color: var(--soft-ink); }
.decor-item.picked { border-color: var(--leaf); background: #eef9ea; transform: translateY(-3px); box-shadow: 0 5px 0 var(--leaf-dark); }
.decor-badge { position: absolute; top: -4px; right: -4px; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--leaf); font-size: 0.9rem; }
.decor-item.poor { opacity: 0.7; }
.decor-item:disabled { opacity: 0.45; }
.decor-icon { font-size: 1.6rem; }
.decor-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; justify-content: center; min-height: 48px; }
.decor-actions .big-go, .decor-actions .soft-btn { min-height: 48px; padding: 10px 16px; font-size: 1rem; }
.decor-actions .decor-turn { min-width: 64px; font-size: 1.5rem; line-height: 1; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.decor-actions .decor-turn kbd { vertical-align: middle; }
.decor-tip { color: var(--soft-ink); font-size: 0.85rem; text-align: center; }
/* ➖ 100% ➕ : how big the thing in your hand is. */
.decor-size { display: inline-flex; align-items: center; gap: 4px; }
.decor-size .decor-turn { min-width: 52px; font-size: 1.15rem; }
.decor-size-text { min-width: 3.2em; text-align: center; font-variant-numeric: tabular-nums; color: var(--ink); }
.decor-tray kbd { padding: 0 6px; border-radius: 6px; background: #efe3d1; font: inherit; font-size: 0.75rem; color: var(--soft-ink); }
.decor-actions .big-go kbd { background: rgba(255, 255, 255, 0.3); color: white; }

/* While decorating, the game's own buttons make room for the tray. */
body.decorating .action-row, body.decorating .emotes, body.decorating .raid-pill { display: none; }
body.decorating.touch .joystick, body.decorating.touch .jump-btn, body.decorating .guide-card, body.decorating .help { display: none; }
body.in-battle .decor-tray { display: none; }
.treat-team { display: flex; gap: 6px; margin-bottom: 8px; }
.treat-team img { width: 52px; height: 52px; border-radius: 50%; background: white; box-shadow: 0 2px 0 rgba(61, 44, 34, 0.12); }
.decor-item.poor small { color: #c0432c; }

/* ---------- Power-ups (Milestone 9) ---------- */
.view-switch { display: flex; gap: 4px; margin-left: auto; margin-right: 8px; }
.view-switch button, .bag-filters button { padding: 7px 12px; border: 0; border-radius: 12px; background: #efe3d1; color: var(--ink); font-weight: 600; }
.view-switch button.on, .bag-filters button.on { background: var(--leaf); color: white; }
.card-stars { position: absolute; top: 4px; right: 8px; font-size: 0.7rem; color: #e0a32c; letter-spacing: -1px; }
.detail-stars { font-size: 1rem; letter-spacing: 1px; margin-bottom: 4px; }
.detail-tabs { display: flex; gap: 4px; justify-content: center; margin: 6px 0 10px; flex-wrap: wrap; }
.detail-tabs button { padding: 7px 12px; border: 0; border-radius: 12px 12px 4px 4px; background: #efe3d1; font-weight: 600; }
.detail-tabs button.on { background: #f6b93b; color: #4a3000; }
.tab-body { text-align: left; }
.tab-body .team-tip { text-align: left; }
.team-tip.small { font-size: 0.85rem; }
.tab-head { margin: 14px 0 6px; }
.stat em small.boost { margin-left: 4px; color: #2f9e44; font-size: 0.8rem; }
button:disabled { opacity: 0.45; cursor: default; }

.snack-list { display: grid; gap: 6px; }
.snack { display: grid; grid-template-columns: 34px 1fr auto auto; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 12px; background: #f7f0e5; }
.snack.none { opacity: 0.6; }
.snack-icon { font-size: 1.6rem; text-align: center; }
.snack b, .snack small { display: block; line-height: 1.2; }
.snack small { color: var(--soft-ink); }
.snack button, .move-up button, .gear-buttons button, .twin button { padding: 7px 10px; border: 0; border-radius: 10px; background: var(--leaf); color: white; font-weight: 600; }
.asc-pips { display: flex; gap: 6px; }
.asc-pips i { width: 22px; height: 22px; border-radius: 50%; background: #efe3d1; }
.asc-pips i.on { background: radial-gradient(circle at 40% 35%, #fff4b0, #f0a020); box-shadow: 0 0 6px #f6b93b; }
.cost-list { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.cost { padding: 2px 8px; border-radius: 999px; background: #efe3d1; font-weight: 600; font-size: 0.85rem; }
.cost.short { background: #ffd6d6; color: #b42318; }
.move-level { font-weight: 600; font-size: 0.8rem; color: #8a5a00; }
.move-up { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 4px; }
.maxed { color: #8a5a00 !important; font-weight: 700; }

.gear-slot { margin-bottom: 10px; padding: 8px; border-radius: 14px; background: #f7f0e5; }
.gear-slot-head { font-weight: 700; margin-bottom: 4px; }
.gear-card { padding: 6px 10px; border-left: 6px solid var(--rarity); border-radius: 10px; background: white; text-align: left; }
.gear-title { line-height: 1.25; }
.gear-stars { color: var(--rarity); font-size: 0.8rem; letter-spacing: -1px; }
.gear-level { padding: 0 6px; border-radius: 8px; background: var(--rarity); color: white; font-size: 0.8rem; font-weight: 700; }
.gear-main { font-weight: 700; color: #2f6f3e; font-size: 0.9rem; }
.gear-bonus { color: var(--soft-ink); font-size: 0.8rem; }
.gear-buttons { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.gear-buttons button small { font-weight: 500; }
.gear-buttons button small .cost { background: rgba(255,255,255,0.3); color: inherit; font-size: 0.75rem; }
.gear-buttons button[data-do="unequip"], .gear-buttons button[data-do="pick"] { background: #d9cbb6; color: var(--ink); }
.gear-buttons button[data-do="pick"].go { background: var(--leaf); color: white; }
.gear-pick { display: grid; gap: 4px; margin-top: 6px; max-height: 260px; overflow-y: auto; }
.gear-pick-row, .bag-gear-row { padding: 0; border: 2px solid transparent; border-radius: 12px; background: none; text-align: left; }
.gear-pick-row:hover, .bag-gear-row:hover { border-color: var(--leaf); }
.set-bonus { padding: 8px 10px; border-radius: 12px; background: #fff3d6; font-size: 0.9rem; }

.bond-hearts { font-size: 1.6rem; text-align: center; letter-spacing: 2px; }
.bond-perks { margin: 6px 0; padding-left: 4px; list-style: none; font-size: 0.9rem; }
.bond-perks li { margin: 3px 0; color: var(--soft-ink); }
.bond-perks li.on { color: var(--ink); font-weight: 600; }
.twin-list { display: grid; gap: 6px; }
.twin { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 12px; background: #f7f0e5; }
.twin small { color: var(--soft-ink); flex: 1; }
.twin button { background: #e0679a; }

.bag-body { flex: 1; padding: 4px 18px 18px; overflow-y: auto; }
.bag-body h3 small { font-weight: 500; color: var(--soft-ink); font-size: 0.85rem; }
.bag-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.bag-item { display: grid; justify-items: center; padding: 8px 4px; border-radius: 14px; background: white; box-shadow: 0 2px 0 #e6d8c4; }
.bag-item span { font-size: 1.8rem; }
.bag-item small { color: var(--soft-ink); font-size: 0.75rem; text-align: center; }
.bag-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.bag-filters .spacer { flex: 1; }
.bag-filters .break-go { background: #c2410c; color: white; }
.bag-gear { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.bag-gear-row.picked { border-color: #c2410c; background: #ffe3d3; }
.bag-gear-row.picked .gear-card { background: #fff1e8; }

#coin-count { font-weight: 700; }

@media (max-width: 760px) {
  .view-switch { margin-left: 0; }
  .bag-filters .spacer { display: none; }
}

/* ---------- Adventure (Milestone 10) ---------- */

/* The Adventure panel */
.adventure-btn.in-party { background: #ffd43b; color: #5a3d00; animation: pulse 1.6s ease-in-out infinite; }
.adv-panel { width: min(1060px, 100%); }
.adv-body { flex: 1; display: grid; grid-template-columns: 1fr 380px; min-height: 0; }
.adv-body.single { grid-template-columns: 1fr; }
.adv-main { padding: 10px 18px 18px; overflow-y: auto; }
.adv-detail { padding: 14px 20px; overflow-y: auto; background: white; border-left: 3px solid #efe3d1; }
.chapter-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.chapter-tabs button { padding: 8px 12px; border: 0; border-radius: 14px; background: #efe3d1; color: var(--ink); font-weight: 600; }
.chapter-tabs button small { display: block; font-weight: 500; font-size: 0.75rem; }
.chapter-tabs button.on { background: var(--wood); color: var(--cream); }
.chapter-tabs button:disabled { opacity: 0.5; }
.chest-row { position: relative; display: flex; align-items: center; justify-content: space-around; margin: 8px 0 14px; padding: 6px 0; }
.chest-bar { position: absolute; left: 4%; right: 4%; top: 50%; height: 10px; margin-top: -5px; border-radius: 999px; background: #efe3d1; overflow: hidden; }
.chest-bar i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #ffd43b, #f6a623); }
.chest { position: relative; display: grid; justify-items: center; width: 58px; padding: 4px; border: 3px solid #efe3d1; border-radius: 16px; background: white; font-size: 1.6rem; line-height: 1.1; }
.chest small { font-size: 0.7rem; font-weight: 700; }
.chest.ready { border-color: #ffc531; animation: pulse 1.2s ease-in-out infinite; }
.chest:disabled:not(.ready) { opacity: 0.7; }
.chest.done { background: #f2ece2; }
.stage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.stage-card { display: grid; gap: 2px; justify-items: center; padding: 10px 8px; border: 3px solid transparent; border-radius: 18px; background: white; box-shadow: 0 3px 0 #e6d8c4; color: var(--ink); text-align: center; }
.stage-card b { font-size: 1.15rem; }
.stage-card span { font-size: 0.85rem; line-height: 1.2; }
.stage-card.selected { border-color: var(--leaf); }
.stage-card.boss { background: #fff3d6; }
.stage-card.locked { opacity: 0.55; }
.star-row i { font-style: normal; color: #ddd2c2; font-size: 1rem; }
.star-row i.on { color: #ffc531; }
.stage-title { margin: 0 0 2px; font-size: 1.35rem; }
.stage-where { margin: 0 0 8px; color: var(--soft-ink); font-size: 0.9rem; }
.foe-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.foe { display: grid; justify-items: center; width: 74px; padding: 4px; border-radius: 12px; background: #f7f0e5; font-size: 1.6rem; }
.foe img { width: 46px; height: 46px; object-fit: contain; }
.foe small { font-size: 0.68rem; line-height: 1.1; text-align: center; }
.foe.gloomy { background: #efe2ff; }
.foe.gloomy img { filter: hue-rotate(230deg) saturate(0.8); }
.foe.boss { background: #ffe1d6; }
.level-hint { margin: 6px 0; font-size: 0.9rem; }
.level-hint.easy b { color: #2f9e44; }
.level-hint.fair b { color: #c27c0e; }
.level-hint.tough b { color: #c92a2a; }
.star-goals { margin: 8px 0; padding: 0; list-style: none; font-size: 0.9rem; color: var(--soft-ink); }
.star-goals li.on { color: var(--ink); font-weight: 600; }
.stage-prize { padding: 8px 10px; border-radius: 12px; background: #f7f0e5; font-size: 0.9rem; }
.first-clear { margin-top: 4px; font-weight: 700; color: #3b6fd8; }
.stage-actions { justify-content: flex-start; align-items: center; }
.stage-actions .soft-btn { padding: 10px 12px; font-size: 0.9rem; }
.sweep-tip { color: var(--soft-ink); }
.story-again { margin-top: 10px; padding: 8px 12px; font-size: 0.85rem; }
.trial-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(440px, 1fr)); align-content: start; gap: 14px; padding: 14px 18px 18px; overflow-y: auto; }
.trial-card { padding: 14px 16px; border-radius: 20px; background: white; box-shadow: 0 3px 0 #e6d8c4; }
.trial-card.locked { opacity: 0.7; }
.trial-head { display: flex; gap: 12px; align-items: center; }
.trial-head h3 { margin: 0; }
.trial-head p { margin: 2px 0 0; color: var(--soft-ink); font-size: 0.9rem; }
.trial-icon { font-size: 2.4rem; }
.pick-row, .tier-row { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin: 10px 0 4px; }
.pick-row small { color: var(--soft-ink); margin-right: 2px; }
.pick-row button { padding: 6px 10px; border: 2px solid transparent; border-radius: 12px; background: #f2ece2; color: var(--ink); font-weight: 600; font-size: 0.85rem; }
.pick-row button.on { border-color: var(--element-color, var(--leaf)); background: #e7f6dc; }
.pick-about { margin: 2px 0; font-size: 0.85rem; color: var(--soft-ink); }
.tier-row button { display: grid; justify-items: center; min-width: 58px; padding: 6px 8px; border: 3px solid transparent; border-radius: 14px; background: #f2ece2; color: var(--ink); font-weight: 700; }
.tier-row button.on { border-color: var(--leaf); background: #e7f6dc; }
.tier-row button small { font-size: 0.7rem; }
.party-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 18px; background: #fff3c4; border-bottom: 3px solid #f6d365; }
.party-bar .spacer { flex: 1; }
.party-bar .big-go, .party-bar .soft-btn { padding: 8px 14px; font-size: 0.95rem; }
.party-member { display: inline-flex; align-items: center; gap: 2px; margin-left: 6px; padding: 2px 8px; border-radius: 999px; background: white; font-weight: 600; }
.party-member img { width: 22px; height: 22px; object-fit: contain; }

/* The talking scenes */
.story { position: fixed; inset: 0; z-index: 42; display: flex; flex-direction: column; justify-content: flex-end; padding: 16px; background: linear-gradient(180deg, rgba(30, 20, 50, 0.25), rgba(30, 20, 50, 0.7)); cursor: pointer; }
.story-title { position: absolute; top: max(16px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); padding: 6px 16px; border-radius: 999px; background: rgba(255, 248, 236, 0.9); font-weight: 700; }
.story-skip { position: absolute; top: max(16px, env(safe-area-inset-top)); right: 16px; padding: 8px 14px; border: 0; border-radius: 14px; background: rgba(255, 248, 236, 0.9); font-weight: 700; }
.story-box { display: flex; gap: 16px; align-items: flex-end; width: min(820px, 100%); margin: 0 auto max(4vh, 70px); animation: pop-in 0.25s ease-out; }
.story-face { flex-shrink: 0; display: grid; place-items: center; width: 110px; height: 110px; border-radius: 50%; background: var(--cream); box-shadow: var(--shadow); font-size: 4rem; }
.story-words { position: relative; flex: 1; padding: 18px 22px 12px; border-radius: 24px; background: var(--cream); box-shadow: var(--shadow); }
.story-name { position: absolute; top: -16px; left: 18px; padding: 4px 14px; border-radius: 999px; color: white; font-weight: 700; }
.story-text { margin: 4px 0 6px; font-size: 1.25rem; line-height: 1.4; }
.story-box.narrator .story-words { background: rgba(255, 248, 236, 0.92); }
.story-box.narrator .story-text { font-style: italic; text-align: center; }
.story-next { text-align: right; color: var(--soft-ink); font-size: 0.85rem; animation: pulse 1.6s ease-in-out infinite; }

@media (max-width: 760px) {
  .adv-body { grid-template-columns: 1fr; overflow-y: auto; }
  .adv-main, .adv-detail { overflow: visible; }
  .adv-detail { border-left: 0; border-top: 3px solid #efe3d1; }
  .trial-list { grid-template-columns: 1fr; padding: 10px; }
  .story-face { width: 70px; height: 70px; font-size: 2.6rem; }
  .story-text { font-size: 1.05rem; }
}
@keyframes pulse { 50% { transform: scale(1.06); } }
@media (max-width: 760px) {
  .team-panel .pedia-header { flex-wrap: wrap; gap: 6px 10px; padding: 10px 14px; }
  .team-panel .pedia-header h2 { font-size: 1.25rem; }
  .team-panel .pedia-progress { order: 3; flex-basis: 100%; font-size: 0.85rem; }
  .team-panel .view-switch { margin-left: auto; }
  .chapter-tabs { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .chapter-tabs button { flex-shrink: 0; }
}

/* ---------- The Wish Shrine ---------- */
.wish-panel { width: min(1060px, 100%); }
.wish-body { flex: 1; display: grid; grid-template-columns: 190px 1fr 280px; gap: 14px; padding: 14px 18px 18px; min-height: 0; overflow-y: auto; }
.banner-tabs { display: flex; flex-direction: column; gap: 8px; }
.banner-tabs button { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 3px solid transparent; border-radius: 16px; background: linear-gradient(135deg, var(--top), var(--bottom)); color: white; font-weight: 700; text-align: left; text-shadow: 0 1px 2px #0006; opacity: 0.75; }
.banner-tabs button.on { opacity: 1; border-color: #fff4c2; box-shadow: 0 0 0 3px #ffd34d80; }
.banner-tabs img { width: 42px; height: 42px; flex: none; filter: drop-shadow(0 2px 2px #0005); }
.banner-tab-icon { width: 42px; text-align: center; font-size: 1.6rem; }
.banner { position: relative; overflow: hidden; display: flex; flex-direction: column; border-radius: 24px; background: linear-gradient(160deg, var(--top), var(--bottom) 75%, #1c1340); color: white; min-height: 420px; }
.banner-sky { position: absolute; inset: 0; pointer-events: none; }
.banner-sky i, .reveal-sky i { position: absolute; width: var(--size); height: var(--size); border-radius: 50%; background: white; animation: twinkle var(--twinkle) ease-in-out infinite alternate; }
@keyframes twinkle { from { opacity: 0.15; } to { opacity: 1; } }
.banner-art { position: relative; display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; padding: 18px 20px 0; }
.banner-art img { width: min(260px, 55%); filter: drop-shadow(0 0 22px #fff8) drop-shadow(0 6px 6px #0006); animation: banner-float 3.2s ease-in-out infinite; }
@keyframes banner-float { 50% { transform: translateY(-8px); } }
.banner-name { display: flex; flex-direction: column; align-items: flex-end; text-align: right; text-shadow: 0 2px 4px #0008; }
.banner-name b { font-size: 2rem; }
.wish-stars { letter-spacing: 1px; text-shadow: 0 0 6px currentColor; }
.wish-stars.five { color: #ffd34d; font-size: 1.3rem; }
.gear-art { justify-content: center; flex-direction: column; align-items: center; padding-top: 30px; }
.gear-big { display: flex; gap: 18px; font-size: 3.6rem; filter: drop-shadow(0 0 16px #fff8); animation: banner-float 3.2s ease-in-out infinite; }
.gear-art .banner-name { align-items: center; text-align: center; margin-top: 10px; }
.gear-art .banner-name b { font-size: 1.6rem; }
.banner-info { position: relative; margin-top: auto; padding: 14px 20px 18px; background: linear-gradient(transparent, #0007 30%); }
.banner-info h3 { margin: 0 0 4px; font-size: 1.3rem; }
.banner-info p { margin: 4px 0; }
.pity-line { font-size: 0.9rem; opacity: 0.92; }
.set-picks { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.set-picks button { padding: 6px 10px; border: 2px solid #fff6; border-radius: 12px; background: #fff2; color: white; font-weight: 600; }
.set-picks button.on { background: white; color: var(--ink); }
.wish-buttons { display: flex; gap: 10px; margin-top: 10px; }
.wish-btn { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 10px 14px; border: 0; border-radius: 18px; background: linear-gradient(#fff6d8, #ffd77a); color: #5a3a00; box-shadow: 0 4px 0 #b88a2a; font-size: 1.1rem; }
.wish-btn.ten { background: linear-gradient(#ffe7a8, #ffb53d); }
.wish-btn small { font-weight: 600; }
.wish-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #b88a2a; }
.wish-btn:disabled { opacity: 0.5; transform: none; }
.link-btn { margin-top: 8px; padding: 0; border: 0; background: none; color: inherit; text-decoration: underline; font-size: 0.9rem; opacity: 0.85; }
.wish-odds { padding: 12px 14px; border-radius: 18px; background: white; overflow-y: auto; }
.wish-odds h4 { margin: 0 0 8px; }
.wish-odds p { margin: 6px 0; font-size: 0.92rem; }
.odds-faces { display: flex; flex-wrap: wrap; gap: 2px; }
.odds-faces img { width: 34px; height: 34px; }
.wish-history ul { margin: 0; padding: 0; list-style: none; font-size: 0.92rem; }
.wish-history li { padding: 3px 0; border-bottom: 1px solid #f1e8da; }

/* The falling-star show */
.wish-reveal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; overflow: hidden; background: radial-gradient(circle at 50% 40%, #2b2470, #0d0b26 70%); color: white; cursor: pointer; user-select: none; }
.wish-reveal[hidden] { display: none; }
.reveal-sky { position: absolute; inset: 0; pointer-events: none; }
.reveal-falling { position: absolute; inset: 0; pointer-events: none; }
.falling-star { position: absolute; top: -10%; left: var(--left); width: 6px; height: 120px; border-radius: 6px; background: linear-gradient(transparent, var(--color)); box-shadow: 0 0 18px var(--color); transform: rotate(25deg); animation: star-fall 1.4s cubic-bezier(0.4, 0, 0.8, 0.6) var(--delay) both; }
.falling-star::after { content: "★"; position: absolute; bottom: -18px; left: 50%; transform: translateX(-50%) rotate(-25deg); color: var(--color); font-size: 30px; text-shadow: 0 0 14px var(--color); }
@keyframes star-fall { from { transform: translate(0, 0) rotate(25deg); opacity: 0; } 15% { opacity: 1; } to { transform: translate(-30vw, 110vh) rotate(25deg); opacity: 0.9; } }
.wish-reveal.best-5 { background: radial-gradient(circle at 50% 40%, #6a4a12, #1a0f26 70%); }
.wish-reveal.best-4 { background: radial-gradient(circle at 50% 40%, #4a2a7a, #120b26 70%); }
.reveal-hint { position: absolute; bottom: 28px; left: 0; right: 0; text-align: center; opacity: 0.8; animation: pulse 1.6s ease-in-out infinite; }
.reveal-skip { position: absolute; top: 18px; right: 18px; padding: 8px 14px; border: 2px solid #fff6; border-radius: 14px; background: #fff2; color: white; font-weight: 700; }
.reveal-card { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; width: min(340px, 86vw); padding: 22px 20px; border: 4px solid var(--color); border-radius: 28px; background: linear-gradient(#ffffff22, #ffffff08); box-shadow: 0 0 40px var(--color); text-align: center; animation: card-in 0.5s cubic-bezier(0.2, 1.4, 0.4, 1) both; }
.reveal-card b { font-size: 1.8rem; }
.reveal-card small { opacity: 0.9; }
.reveal-card .card-art img { width: 220px; height: 220px; filter: drop-shadow(0 0 18px var(--color)); }
@keyframes card-in { from { transform: scale(0.3) rotate(-8deg); opacity: 0; } }
.card-5 .reveal-card { animation-duration: 0.9s; }
.gold-burst { position: absolute; width: 140vmax; height: 140vmax; background: repeating-conic-gradient(#ffd34d33 0 8deg, transparent 8deg 20deg); animation: spin 14s linear infinite; pointer-events: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.card-note { padding: 2px 10px; border-radius: 10px; font-weight: 800; font-size: 0.85rem; }
.card-note.new { background: #ff5f8f; color: white; }
.card-note.bond { background: #ffd1e3; color: #9a2a5a; }
.card-note.prize { background: #fff2c2; color: #6a4a00; }
.gear-card-art { position: relative; font-size: 6rem; filter: drop-shadow(0 0 18px var(--color)); }
.gear-card-art small { position: absolute; right: -14px; bottom: 0; font-size: 2.4rem; }
.reveal-summary { position: relative; display: flex; flex-direction: column; align-items: center; gap: 14px; width: min(900px, 94vw); cursor: default; }
.reveal-summary h3 { margin: 0; font-size: 1.6rem; }
.summary-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; width: 100%; }
.summary-grid .mini-card { width: calc(20% - 8px); }
.mini-card { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border: 3px solid var(--color); border-radius: 18px; background: #ffffff14; box-shadow: 0 0 16px var(--color); text-align: center; font-size: 0.85rem; animation: card-in 0.4s both; }
.mini-card .card-art img { width: 80px; height: 80px; }
.mini-card .gear-card-art { font-size: 3rem; }
.mini-card .gear-card-art small { font-size: 1.3rem; right: -8px; }
.reveal-done { padding: 12px 40px; background: var(--leaf); color: white; }

@media (max-width: 760px) {
  .wish-body { grid-template-columns: 1fr; }
  .banner-tabs { flex-direction: row; overflow-x: auto; }
  .banner-tabs button { flex: none; }
  .banner-tabs button span:last-child { display: none; }
  .banner { min-height: 360px; }
  .banner-name b { font-size: 1.5rem; }
  .summary-grid .mini-card { width: calc(33% - 8px); }
}

/* ---------- Evolving ---------- */
.evo-pair { display: flex; align-items: center; justify-content: center; gap: 10px; }
.evo-pair img { width: 110px; height: 110px; }
.evo-arrow { font-size: 1.6rem; }
.evo-name { text-align: center; }
.evo-stats { display: grid; gap: 4px; margin: 6px 0 10px; }
.evo-stat { display: grid; grid-template-columns: 80px 50px 20px 50px; align-items: center; font-size: 0.95rem; }
.evo-stat i { font-style: normal; opacity: 0.5; }
.evo-stat .up { color: #2f9f4a; }
.evolve-go { background: linear-gradient(90deg, #ff7a7a, #ffc66a, #7ad87a, #6ab8ff, #b78aff) !important; color: white; text-shadow: 0 1px 2px #0006; }
.evolve-scene { background: radial-gradient(circle at 50% 45%, #3a3a7a, #0d0b26 70%); }
.evo-glow { position: absolute; width: min(520px, 100vw); height: min(520px, 100vw); border-radius: 50%; background: radial-gradient(#ffffffaa, transparent 65%); animation: pulse 0.9s ease-in-out infinite; pointer-events: none; }
.evo-shapes { position: relative; width: min(400px, 80vw); height: min(400px, 80vw); }
.evo-shapes img { position: absolute; inset: 0; width: 100%; height: 100%; }
.evolve-scene.glowing .evo-shapes img { filter: brightness(0) invert(1) drop-shadow(0 0 20px white); }
.evolve-scene.glowing .evo-old { animation: evo-flicker 2.6s ease-in both; }
.evolve-scene.glowing .evo-new { animation: evo-flicker 2.6s ease-in reverse both; }
@keyframes evo-flicker {
  0%, 30% { opacity: 1; } 35% { opacity: 0; } 42% { opacity: 1; } 50% { opacity: 0; } 55% { opacity: 1; } 62% { opacity: 0; }
  66% { opacity: 1; } 72% { opacity: 0; } 75% { opacity: 1; } 80% { opacity: 0; } 83% { opacity: 1; } 87%, 100% { opacity: 0; }
}
.evolve-scene.done .evo-old { display: none; }
.evolve-scene.done .evo-new { animation: card-in 0.8s cubic-bezier(0.2, 1.4, 0.4, 1) both; filter: drop-shadow(0 0 24px #fff8); }
.gold-burst.rainbow { background: repeating-conic-gradient(#ff7a7a33 0 6deg, transparent 6deg 12deg, #ffd34d33 12deg 18deg, transparent 18deg 24deg, #7ad87a33 24deg 30deg, transparent 30deg 36deg, #6ab8ff33 36deg 42deg, transparent 42deg 48deg); }
.evo-words { position: relative; margin-top: 24px; font-size: 1.4rem; text-align: center; }
.evo-words small { display: block; margin-top: 8px; font-size: 0.9rem; opacity: 0.75; }
.evolve-scene { flex-direction: column; display: flex; align-items: center; justify-content: center; }
.evolve-scene[hidden] { display: none; }

/* ---------- Quests ---------- */
.quest-badge { display: inline-grid; place-items: center; min-width: 22px; height: 22px; margin-left: 2px; padding: 0 6px; border-radius: 11px; background: #ff6b6b; color: white; font-size: 0.8rem; font-weight: 700; animation: pulse 1.2s ease-in-out infinite; }
.quest-badge[hidden] { display: none; }
.quest-panel { width: min(720px, 100%); }
.quest-tabs { display: flex; gap: 8px; padding: 0 18px 8px; }
.quest-tabs button { flex: 1; padding: 10px; border: 0; border-radius: 14px; background: #efe3d1; font-weight: 600; font-size: 1rem; }
.quest-tabs button.on { background: var(--leaf); color: white; }
.quest-tabs .dot { display: inline-grid; place-items: center; min-width: 20px; height: 20px; border-radius: 10px; background: #ff6b6b; color: white; font-size: 0.75rem; }
.quest-list { flex: 1; overflow-y: auto; padding: 0 18px 18px; display: grid; align-content: start; gap: 8px; }
.quest-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 16px; background: white; box-shadow: 0 3px 0 rgba(61, 44, 34, 0.1); }
.quest-row.ready { box-shadow: 0 0 0 3px #ffd43b, 0 3px 0 rgba(61, 44, 34, 0.1); }
.quest-row.claimed { opacity: 0.55; }
.quest-row.bonus { background: #fff6d9; }
.quest-text b { display: block; margin-bottom: 6px; }
.quest-bar { position: relative; height: 18px; border-radius: 9px; background: #ece2d3; overflow: hidden; }
.quest-bar span { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #7ad87a, #4fb35f); border-radius: 9px; }
.quest-bar small { position: relative; display: block; text-align: center; font-size: 0.75rem; font-weight: 700; line-height: 18px; }
.quest-prize { font-size: 0.9rem; color: var(--soft-ink); text-align: right; max-width: 160px; }
.quest-claim:disabled { background: #d8cfc2; }
.quest-claim { padding: 10px 16px !important; background: var(--leaf); color: white; font-size: 1rem; }
.quest-done { color: #2f9f4a; font-weight: 700; }

/* ---------- Trading ---------- */
.trade-row { display: flex; width: 100%; border: 0; background: none; font: inherit; color: inherit; cursor: pointer; text-align: left; border-radius: 10px; }
.trade-row:hover { background: #ffffff66; }
.trade-icon { margin-left: auto; font-size: 0.85rem; opacity: 0.7; }
.trade-panel { width: min(960px, 100%); }
.trade-body { flex: 1; display: grid; grid-template-columns: 1.3fr 1fr; gap: 14px; min-height: 0; padding: 0 18px; }
.trade-side { display: flex; flex-direction: column; min-height: 0; overflow-y: auto; padding: 10px 14px; border-radius: 20px; background: #f6ecdc; }
.trade-side.theirs { background: #e9f3ff; }
.trade-side h3 { display: flex; align-items: center; gap: 8px; margin: 4px 0 8px; }
.trade-side h4 { margin: 12px 0 6px; }
.trade-side h4 small { font-weight: 500; color: var(--soft-ink); }
.ready-tag { margin-left: auto; padding: 2px 10px; border-radius: 10px; background: #0000000f; font-size: 0.85rem; font-weight: 600; color: var(--soft-ink); }
.ready-tag.on { background: #d4f5d4; color: #2f9f4a; }
.trade-offer { display: flex; flex-wrap: wrap; gap: 8px; min-height: 120px; padding: 8px; border: 3px dashed #d8c7ad; border-radius: 16px; }
.trade-card { position: relative; display: flex; flex-direction: column; align-items: center; width: 108px; padding: 6px; border: 3px solid var(--element-color); border-radius: 16px; background: white; text-align: center; font-size: 0.85rem; animation: pop-in 0.25s ease-out; }
.trade-card img { width: 64px; height: 64px; object-fit: contain; }
.trade-card small { color: var(--soft-ink); }
.trade-card .card-stars { color: #e0a32c; font-size: 0.75rem; }
.trade-gear-icon { font-size: 2.6rem; line-height: 64px; }
.trade-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 6px; }
.trade-pick.gear { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.trade-chip { display: flex; flex-direction: column; align-items: center; padding: 4px; border: 3px solid transparent; border-radius: 14px; background: white; font: inherit; font-size: 0.8rem; cursor: pointer; }
.trade-chip img { width: 48px; height: 48px; object-fit: contain; }
.trade-chip small { color: var(--soft-ink); }
.trade-chip.on { border-color: var(--leaf); background: #e5f7e5; }
.trade-chip:disabled { opacity: 0.4; cursor: default; }
.gear-chip { align-items: flex-start; border-left: 6px solid var(--rarity); text-align: left; }
.trade-footer { display: flex; justify-content: space-between; gap: 12px; padding: 14px 18px; }
.trade-ready { padding: 14px 28px !important; background: var(--leaf); color: white; font-size: 1.1rem; }
.trade-ready.on { background: #2f9f4a; }
.trade-waiting { width: min(420px, 100%); height: auto; align-items: center; padding: 28px; text-align: center; }
.trade-wait-icon { font-size: 3.5rem; animation: spin 2.4s linear infinite; }

@media (max-width: 760px) {
  .trade-body { display: flex; flex-direction: column; overflow-y: auto; }
  .trade-side { flex-shrink: 0; overflow: visible; }
  .trade-side.theirs { order: -1; }
  .quest-row { grid-template-columns: 1fr auto; }
  .quest-text { grid-column: 1 / -1; }
  .quest-prize { grid-column: 1; text-align: left; max-width: none; }
}

/* ---------- Music and sounds ---------- */
.sound-panel { display: grid; gap: 10px; width: 260px; margin-top: 8px; padding: 14px 16px; border-radius: 18px; background: var(--cream); box-shadow: var(--shadow); pointer-events: auto; }
.sound-panel label { display: grid; grid-template-columns: 90px 1fr; align-items: center; font-weight: 600; }
.sound-panel input[type="range"] { width: 100%; accent-color: var(--leaf); }
.sound-panel .team-tip { margin: 0; }

/* ---------- The Wardrobe ---------- */
.join-look-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.wardrobe-btn { flex: 1; padding: 14px 16px; border: 0; border-radius: 16px; background: linear-gradient(90deg, #ff9fc8, #b79cff); color: white; font-size: 1.15rem; font-weight: 700; text-shadow: 0 1px 2px #0003; box-shadow: 0 4px 0 #9a6fd8; }
.wardrobe-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #9a6fd8; }
.join-tip { margin: 0; font-size: 0.9rem; color: var(--soft-ink); }
.wardrobe { z-index: 30; }
.wardrobe-panel { width: min(1060px, 100%); height: min(760px, 100%); }
.wardrobe-body { flex: 1; display: grid; grid-template-columns: minmax(260px, 0.8fr) minmax(0, 1.2fr); min-height: 0; }
.wardrobe-stage { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0 12px 14px 18px; min-height: 0; }
.wardrobe-preview { flex: 1; width: 100%; min-height: 240px; border-radius: 24px; background: radial-gradient(circle at 50% 80%, #fdf3e2, #e9dcf7 75%); cursor: grab; overflow: hidden; }
.wardrobe-preview canvas { display: block; }
.wardrobe-hint { margin: 0; font-size: 0.85rem; color: var(--soft-ink); }
.wardrobe-tools { display: flex; gap: 8px; }
.wardrobe-side { display: flex; flex-direction: column; min-height: 0; padding-right: 6px; }
.wardrobe-tabs { padding: 0 12px 8px 0; }
.wardrobe-tabs button { padding: 10px 6px; font-size: 0.95rem; }
.wardrobe-options { flex: 1; overflow-y: auto; padding: 0 12px 12px 0; }
.ward-row { margin-bottom: 14px; }
.ward-row h4 { margin: 4px 0 8px; font-size: 1rem; }
.ward-row h4 small { font-weight: 500; color: var(--soft-ink); }
.ward-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.ward-tile { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border: 3px solid transparent; border-radius: 16px; background: white; font: inherit; box-shadow: 0 2px 0 rgba(61, 44, 34, 0.12); cursor: pointer; }
.ward-tile span { font-size: 1.7rem; line-height: 1.2; }
.ward-tile small { font-size: 0.78rem; font-weight: 600; text-align: center; }
.ward-tile.on { border-color: var(--leaf); background: #e5f7e5; }
.ward-swatches { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 0 0 5px; }
.ward-swatch { width: 38px; height: 38px; border: 3px solid white; border-radius: 50%; box-shadow: 0 2px 0 rgba(0, 0, 0, 0.18); cursor: pointer; }
.ward-swatch.on { outline: 4px solid var(--leaf); outline-offset: 1px; }
.ward-switches { display: flex; flex-wrap: wrap; gap: 8px; }
.ward-switch { padding: 10px 14px; border: 0; border-radius: 14px; background: white; font: inherit; font-weight: 600; box-shadow: 0 2px 0 rgba(61, 44, 34, 0.12); }
.ward-switch.on { background: #e5f7e5; }
.wardrobe-footer { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px 14px 0; }
.wardrobe-save { padding: 14px 28px !important; background: linear-gradient(90deg, #ff8fc8, #a877ff); color: white; font-size: 1.1rem; box-shadow: 0 4px 0 #8a5ad8; }

@media (max-width: 760px) {
  .wardrobe-panel { height: 100%; }
  .wardrobe-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: 36% minmax(0, 1fr); }
  .wardrobe-stage, .wardrobe-side { min-width: 0; }
  .wardrobe-tools .soft-btn { padding: 8px 12px; font-size: 0.9rem; }
  .wardrobe-footer { padding-right: 12px; }
  .wardrobe-save { padding: 12px 18px !important; }
  .wardrobe-stage { flex-direction: row; flex-wrap: wrap; justify-content: center; padding: 0 12px 6px; }
  .wardrobe-preview { flex: 1 1 100%; min-height: 0; height: calc(100% - 50px); }
  .wardrobe-hint { display: none; }
  .wardrobe-side { padding: 0 0 0 12px; }
  .wardrobe-tabs button { font-size: 0.8rem; padding: 8px 4px; }
  .ward-tiles { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
}

/* ---------- Wren's Guide ---------- */
/* The step card sits under the storehouse bar. */
.guide-card {
  width: 300px;
  max-width: 100%;
  padding: 10px 14px 12px;
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
  pointer-events: auto;
}
.guide-card.ready { box-shadow: 0 0 0 3px #ffd43b, var(--shadow); animation: guide-ready 1.6s ease-in-out infinite; }
@keyframes guide-ready {
  50% { box-shadow: 0 0 0 5px #ffe066, var(--shadow); }
}
.guide-card.small { width: auto; padding: 8px 12px; }
.guide-head { display: flex; align-items: center; gap: 6px; width: 100%; padding: 0; border: 0; background: none; font: inherit; font-size: 0.9rem; color: var(--soft-ink); text-align: left; cursor: pointer; }
.guide-head b { color: var(--ink); }
.guide-head span { margin-left: auto; font-weight: 600; }
.guide-head i { font-style: normal; }
.guide-step { margin: 6px 0 2px; font-size: 1.05rem; font-weight: 700; line-height: 1.25; }
.guide-how { margin: 4px 0 8px; font-size: 0.88rem; color: var(--soft-ink); line-height: 1.3; }
.guide-card .quest-bar { margin: 4px 0 8px; }
.guide-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }
.guide-actions:empty { display: none; }
.guide-actions .soft-btn { padding: 7px 10px; font-size: 0.85rem; }
.guide-prize { margin-right: auto; font-size: 0.85rem; font-weight: 600; color: var(--soft-ink); }
.guide-claim { flex: 1; padding: 10px 14px; font-size: 1rem; animation: pulse 1.2s ease-in-out infinite; }
.guide-saved { display: block; width: 100%; margin-top: 8px; padding: 6px 10px; border: 0; border-radius: 12px; background: #fff3bf; font: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer; }

/* The arrow at the top of the screen that points the way */
.guide-compass {
  position: absolute;
  bottom: 168px; /* just above the action buttons */
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px 5px 6px;
  border-radius: 999px;
  background: rgba(61, 44, 34, 0.78);
  color: #fff3c4;
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
}
.guide-compass[hidden] { display: none; }
.compass-arrow { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: #ffd43b; color: #5a3d00; font-size: 1.1rem; transition: transform 0.15s linear; }
.guide-compass.here .compass-arrow { transform: none !important; }

/* A button at the top that Wren wants you to tap */
.guide-glow { animation: guide-glow 1.2s ease-in-out infinite; }
@keyframes guide-glow {
  0%, 100% { box-shadow: 0 0 0 3px #ffd43b, var(--shadow); }
  50% { box-shadow: 0 0 0 7px #ffe066aa, var(--shadow); }
}

/* The whole list of steps */
.guide-panel { width: min(760px, 100%); }
.guide-chapter { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; margin: 14px 0 2px; font-size: 1.1rem; }
.guide-chapter small { color: var(--soft-ink); }
.guide-chapter .quest-prize { margin-left: auto; max-width: none; }
.guide-chapter.done { color: #2f9f4a; }
.guide-row-how { display: block; margin: -2px 0 6px; color: var(--soft-ink); font-size: 0.85rem; }
.guide-row.now { box-shadow: 0 0 0 3px var(--leaf), 0 3px 0 rgba(61, 44, 34, 0.1); }
.guide-row.now.ready, .guide-row.later.ready { box-shadow: 0 0 0 3px #ffd43b, 0 3px 0 rgba(61, 44, 34, 0.1); }
.guide-row.later { background: #f6f0ff; }
.guide-row.future { opacity: 0.6; }
.guide-row .soft-btn { padding: 8px 12px; font-size: 0.9rem; }

@media (max-width: 760px) {
  .guide-card { width: 260px; }
  .guide-how { font-size: 0.82rem; }
}
@media (max-width: 560px) {
  .guide-card { width: 220px; padding: 8px 10px; }
  .guide-step { font-size: 0.95rem; }
  .guide-compass { bottom: 330px; font-size: 0.85rem; }
}

/* ---------- IV talent ranks (data/ivs.js) ---------- */
.iv-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5em;
  padding: 0 0.35em;
  border-radius: 6px;
  background: var(--rank);
  color: white;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.45;
  letter-spacing: 0;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
  vertical-align: middle;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.15);
}
.iv-rank.big { font-size: 0.95rem; padding: 1px 0.5em; border-radius: 8px; }
.iv-rank.rainbow, .iv-stat b.rainbow {
  background: linear-gradient(90deg, #ff5f6d, #ffc371, #7bd88f, #5ac8fa, #a66cff, #ff5fa2);
  background-size: 200% 100%;
  animation: iv-rainbow 3s linear infinite;
}
@keyframes iv-rainbow { to { background-position: 200% 0; } }
.card-rank { position: absolute; top: 4px; left: 8px; }
.card-note + .iv-rank { margin-left: 4px; }
.talent-box { margin: 10px 0; padding: 8px 10px; border-radius: 12px; background: #faf5ec; border: 2px solid color-mix(in srgb, var(--rank) 45%, transparent); text-align: left; }
.talent-head { display: flex; align-items: center; gap: 6px; font-weight: 700; margin-bottom: 6px; }
.talent-head small { color: var(--soft-ink); font-weight: 600; }
.iv-stat { display: grid; grid-template-columns: 64px 1fr 52px; align-items: center; gap: 8px; font-size: 0.85rem; margin: 3px 0; }
.iv-stat i { position: relative; height: 9px; border-radius: 999px; background: #e9dfcf; overflow: hidden; }
.iv-stat i b { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: var(--rank); }
.iv-stat em { font-style: normal; font-weight: 700; text-align: right; }
.iv-stat em small { color: var(--soft-ink); font-weight: 600; }

/* ============================================================
   PHONES AND SMALL SCREENS
   ============================================================
   Everything below only changes things on a small screen: a
   phone held either way up, or a small window. "Small" means
   760 wide or 520 tall (src/ui/guideTracker.js uses the same
   sizes to start the guide card small). Phones held upright
   (560 wide or less) get a few extra changes at the end.
   ============================================================ */

/* The 😊 button that folds the emotes away only shows on phones. */
.emote-toggle { display: none; }

@media (max-width: 760px), (max-height: 520px) {
  /* The top-left corner: one row of icon buttons, then small chips. */
  .top-left { top: max(8px, env(safe-area-inset-top)); left: max(8px, env(safe-area-inset-left)); gap: 6px; max-width: calc(100% - 16px); }
  .place-box { padding: 4px 10px; border-radius: 12px; font-size: 0.9rem; }
  .top-buttons { gap: 5px; }
  .btn-label { display: none; }
  .pedia-btn { min-width: 40px; height: 40px; padding: 0 9px; border-radius: 12px; font-size: 1.05rem; }
  #coin-count { font-size: 0.9rem; }
  .charm-count { padding: 4px 9px; border-radius: 12px; font-size: 0.85rem; }
  .clock { min-width: 0; }
  .quest-badge { min-width: 18px; height: 18px; padding: 0 4px; font-size: 0.7rem; }
  .storage { margin-top: 0; padding: 3px 10px; gap: 2px 8px; border-radius: 12px; font-size: 0.85rem; }
  .sound-panel { margin-top: 0; }
  .guide-card { width: 250px; padding: 8px 10px; border-radius: 14px; }
  .guide-card.small { max-width: 250px; padding: 6px 10px; }
  .guide-head { font-size: 0.82rem; }
  .guide-step { margin-top: 3px; font-size: 0.92rem; }
  .guide-claim { padding: 8px 10px; font-size: 0.92rem; }

  /* Who's playing (below the buttons, on the right). */
  .players { top: calc(max(8px, env(safe-area-inset-top)) + 48px); right: max(8px, env(safe-area-inset-right)); min-width: 0; padding: 4px 10px; border-radius: 12px; font-size: 0.8rem; }
  .player-row::before { width: 9px; height: 9px; }

  /* How to play: smaller, in the middle, and a tap makes it go away. */
  .help, body.touch .help { top: auto; bottom: 124px; max-width: min(460px, calc(100% - 300px)); padding: 6px 12px; font-size: 0.8rem; pointer-events: auto; }
  .help.faded { pointer-events: none; }

  /* The emotes fold up behind the 😊 button. */
  .emotes { right: max(10px, env(safe-area-inset-right)); bottom: max(10px, env(safe-area-inset-bottom)); grid-template-columns: repeat(3, 44px); gap: 6px; }
  .emote-btn { width: 44px; height: 44px; border-radius: 12px; font-size: 1.3rem; }
  .emotes:not(.open) .emote-btn:not(.emote-toggle) { display: none; }
  .emote-toggle { display: block; grid-column: 3; }
  .emotes.open .emote-toggle { background: #ffe8a3; }
  body.touch .emotes.open ~ .jump-btn { display: none; }

  /* A smaller joystick and jump button. */
  body.touch .joystick { left: max(14px, env(safe-area-inset-left)); bottom: max(14px, env(safe-area-inset-bottom)); width: 124px; height: 124px; }
  .stick { width: 54px; height: 54px; margin: -27px 0 0 -27px; }
  body.touch .jump-btn { right: max(10px, env(safe-area-inset-right)); bottom: 66px; width: 64px; height: 64px; font-size: 1.7rem; }
  .decor-tray { padding: 8px 8px 10px; border-radius: 18px; }
  .decor-top { flex-wrap: wrap; gap: 6px; }
  .decor-hint { order: 3; flex-basis: 100%; font-size: 0.85rem; padding: 5px 10px; }
  .decor-item { width: 88px; padding: 6px 4px; }
  .decor-icon { font-size: 1.4rem; }
  .decor-actions { gap: 6px; }
  .decor-actions .big-go, .decor-actions .soft-btn { padding: 8px 12px; font-size: 0.95rem; }
  .decor-actions .decor-turn { min-width: 56px; }
  .decor-size .decor-turn { min-width: 46px; }

  /* The action buttons sit between the joystick and the jump button. */
  .action-row { bottom: max(14px, env(safe-area-inset-bottom)); flex-wrap: wrap; justify-content: center; gap: 8px; width: max-content; max-width: calc(100% - 300px); }
  .action-btn { padding: 10px 16px; border-radius: 16px; font-size: 1rem; box-shadow: 0 4px 0 var(--leaf-dark); }
  .action-btn.battle-btn { box-shadow: 0 4px 0 #a8432f; }
  .action-btn.work-btn { box-shadow: 0 4px 0 #956127; }
  .action-btn.wish-btn { box-shadow: 0 4px 0 #8a5fc0; }
  .guide-compass { bottom: 76px; padding: 3px 12px 3px 4px; font-size: 0.85rem; }
  .compass-arrow { width: 26px; height: 26px; font-size: 0.95rem; }
  .raid-pill { top: auto; bottom: 116px; font-size: 0.85rem; }

  .toast { top: 26%; max-width: calc(100% - 32px); font-size: 1rem; text-align: center; }
  .status { top: auto; bottom: 50%; }
  .banner-title { font-size: clamp(1.6rem, 6vw, 2.4rem); }
  .banner-subtitle { font-size: 1rem; }
  .nametag { padding: 2px 8px; font-size: 0.8rem; border-width: 2px; }
  .creature-tag b { font-size: 0.82rem; }

  /* Menus fill the screen instead of floating with a big border. */
  .pedia, .starter, .invite { padding: max(6px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left)); }
  .pedia-panel, .team-panel { height: 100%; border-radius: 18px; }
  .team-lists { padding: 2px 10px 12px; }
  .team-row, .den-grid { gap: 8px; }
  .den-grid { grid-template-columns: repeat(auto-fill, minmax(98px, 1fr)); }
  .team-card img { width: 64px; height: 64px; }
  .team-detail { padding: 10px 12px; }
  .pedia-grid { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; padding: 10px; }
  .pedia-portrait { width: 60px; height: 60px; }
  .pedia-name { font-size: 0.9rem; }
  .pedia-detail { padding: 10px 14px; }
  .detail-portrait { width: 120px; height: 120px; }
  .detail h2 { font-size: 1.4rem; }
  .adv-main { padding: 8px 10px 12px; }
  .adv-detail { padding: 10px 12px; }
  .stage-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
  .stage-card { padding: 8px 6px; }
  .stage-card b { font-size: 1rem; }
  .stage-card span { font-size: 0.78rem; }
  .wish-body { grid-auto-rows: max-content; padding: 10px 12px 12px; }
  .pedia-header { gap: 10px; padding: 8px 12px; }
  .pedia-header h2 { font-size: 1.15rem; white-space: nowrap; }
  .pedia-progress { font-size: 0.85rem; }
  .pedia-close { flex-shrink: 0; width: 38px; height: 38px; font-size: 1.1rem; }
  .team-panel .pedia-header { padding: 8px 12px; }
  .team-panel .pedia-header h2 { margin-right: auto; font-size: 1.1rem; }
  .view-switch, .team-panel .view-switch { margin: 0; }
  .view-switch button { padding: 6px 9px; font-size: 0.85rem; }
}

/* Short screens (a phone on its side): the place name steps aside
   (the banner still shows it when you walk somewhere new). */
@media (max-height: 520px) {
  .place-box { display: none; }
  .players { top: max(8px, env(safe-area-inset-top)); }
  .top-left { max-width: calc(100% - 170px); }
  .help, body.touch .help { bottom: 112px; }
  /* The guide card moves to the right, under the players, away from the joystick. */
  .guide-card { position: fixed; top: calc(max(8px, env(safe-area-inset-top)) + 62px); right: max(8px, env(safe-area-inset-right)); max-height: calc(100% - 220px); overflow-y: auto; }
}

/* Phones held upright. */
@media (max-width: 560px) {
  /* The buttons on one row, the coins, charms, town and clock on the next. */
  .top-buttons::before { content: ""; order: 1; flex-basis: 100%; height: 0; margin-top: -5px; }
  #coin-btn, #charm-count, #town-level, #clock { order: 2; }
  #coin-btn { height: 30px; padding: 0 9px; }

  /* The list of players moves into the left-hand stack (see hud.js). */
  .top-left .players { position: static; display: flex; flex-wrap: wrap; gap: 2px 10px; }
  .top-left .player-row:not(.trade-row) { display: none; }
  .top-left .players:not(:has(.trade-row)) { display: none; }
  .top-left .trade-row { width: auto; padding: 0; gap: 5px; }
  .top-left .trade-icon { margin-left: 0; }

  /* The action buttons stack up above the joystick. */
  .action-row { flex-direction: column; align-items: stretch; bottom: 152px; max-width: calc(100% - 28px); }
  .guide-compass { bottom: 316px; }
  .raid-pill { bottom: 356px; }
  .help, body.touch .help { bottom: 360px; max-width: calc(100% - 28px); }
}

/* Battles on short screens (a phone on its side): the moves fit in one
   low row so you can still see the creatures. */
@media (max-height: 520px) {
  .battle-top { top: max(6px, env(safe-area-inset-top)); gap: 2px 8px; flex-wrap: wrap; }
  .battle-round { order: 0; padding: 5px 10px 4px; font-size: 0.85rem; }
  .battle-order { order: 0; flex-basis: auto; }
  .battle-toggles { order: 0; margin-left: 0; }
  .battle-toggle { padding: 5px 10px 4px; font-size: 0.85rem; }
  .order-track { padding: 2px 8px 8px; gap: 2px; }
  .order-face { width: 28px; height: 28px; padding: 1px; border-width: 2px; }
  .order-face.boss { width: 32px; height: 32px; }
  .order-face.now { width: 36px; height: 36px; border-width: 2px; }
  .order-now { bottom: -7px; font-size: 0.55rem; }
  .order-gap { width: 5px; height: 5px; margin: 0; }
  .battle-boss { max-width: 460px; margin-top: 0; padding: 4px 10px 4px 6px; gap: 7px; }
  .bboss-badge { width: 34px; height: 31px; }
  .bboss-badge small { display: none; }
  .bboss-badge b { font-size: 1rem; }
  .bboss-name { font-size: 1rem; }
  .bboss-tag { display: none; }
  .bboss-hp { height: 10px; margin-top: 3px; }
  .bboss-num { margin-top: 1px; font-size: 0.72rem; }
  .bboss-num b { font-size: 0.82rem; }
  .battle-hint { margin-top: 2px; padding: 4px 6px 4px 14px; font-size: 0.88rem; }
  .battle-banner { top: 26%; }
  .bb-band { padding: 8px 20px 10px; }
  .bb-title { font-size: clamp(1.8rem, 6vh, 2.6rem); }
  .battle-scrim.top { height: 90px; }
  .battle-scrim.bottom { height: 120px; }

  .battle-panel { left: max(8px, env(safe-area-inset-left)); right: max(8px, env(safe-area-inset-right)); bottom: max(6px, env(safe-area-inset-bottom)); flex-direction: row; min-height: 0; padding: 6px; gap: 6px; clip-path: polygon(10px 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 0 100%, 0 10px); }
  .panel-moves { grid-template-columns: repeat(3, 1fr) 1.2fr; gap: 6px; }
  .move-btn, .special-btn { flex-direction: row; justify-content: flex-start; gap: 7px; min-height: 0; padding: 5px 7px 6px 5px; text-align: left; }
  .special-btn { grid-column: auto; }
  .move-btn .move-icon, .special-btn .move-icon { width: 30px; height: 30px; }
  .move-btn .move-icon .el-icon, .special-btn .move-icon .el-icon { width: 17px; height: 17px; }
  .move-icon kbd { right: -5px; bottom: -4px; min-width: 14px; height: 14px; font-size: 0.62rem; line-height: 14px; }
  .move-btn .move-text { align-items: flex-start; width: auto; }
  .battle .move-btn .move-name, .battle .special-btn .move-name { overflow: hidden; font-size: 0.92rem; white-space: nowrap; text-overflow: ellipsis; }
  .battle .move-info { overflow: hidden; font-size: 0.7rem; white-space: nowrap; text-overflow: ellipsis; }
  .special-btn .move-info { display: none; }
  .special-label { font-size: 0.65rem; }
  .move-wait { flex-direction: row; gap: 5px; }
  .move-wait b { font-size: 1.4rem; }
  .move-wait small { display: none; }
  .panel-extra { flex-direction: column; min-width: 84px; min-height: 0; gap: 5px; }
  .extra-btn { padding: 4px 6px; font-size: 0.82rem; }
  .battle-message { bottom: 80px; padding: 5px 18px; font-size: 0.92rem; }
  .plate { width: 134px; padding: 4px 6px 4px; font-size: 0.68rem; }
  .plate-name { font-size: 0.84rem; }
  .plate-level { width: 22px; height: 20px; font-size: 0.72rem; }
  .plate-level small { display: none; }
  .plate-role, .wild-word { display: none; }
  .battle .bar.hp { height: 9px; margin-top: 3px; }
  .battle .bar.hp span { line-height: 9px; font-size: 0.58rem; }
  .battle .bar.energy { height: 4px; margin-top: 2px; }
  .floater { font-size: 1.6rem; }
  .floater.strong span { font-size: 2.1rem; }
  .floater.lucky span { font-size: 2.5rem; }
  .battle-result { padding: 8px; }
  .result-card { padding: 8px 16px 10px; }
  .result-kicker { font-size: 1.8rem; }
  .result-card h2 { margin: 2px 0 4px; font-size: 1.05rem; }
  .result-rays { top: -190px; }
  .result-row { margin: 3px 0; padding: 3px 10px 4px 6px; }
  .result-row img { width: 32px; height: 32px; }
  .result-row.friend img { width: 48px; height: 48px; }
  .result-continue { margin-top: 4px; padding: 7px; font-size: 1.05rem; }
  .result-charms, .result-loot { margin: 3px 0; }
  .bxp { margin-top: 3px; }
}

/* The Wish Shrine and its show on short screens. */
@media (max-height: 520px) {
  .wish-body { grid-template-columns: 150px 1fr; grid-auto-rows: max-content; gap: 10px; padding: 10px 12px 12px; }
  .wish-body > :nth-child(n + 3) { grid-column: 1 / -1; }
  .banner-tabs button { padding: 6px 8px; font-size: 0.85rem; }
  .banner-tabs img { width: 32px; height: 32px; }
  .banner { min-height: 0; }
  .banner-art { padding: 10px 14px 0; }
  .banner-art img { width: min(150px, 40%); }
  .banner-name b { font-size: 1.4rem; }
  .banner-info { padding: 10px 14px 12px; }
  .reveal-card { padding: 12px 16px; }
  .reveal-card .card-art img { width: 130px; height: 130px; }
  .reveal-card b { font-size: 1.4rem; }
  .reveal-summary { gap: 8px; }
  .reveal-summary h3 { font-size: 1.2rem; }
  .mini-card .card-art img { width: 48px; height: 48px; }
  .mini-card .gear-card-art { font-size: 2rem; }
  .reveal-done { padding: 8px 30px; }
}

/* ============================================================
   PINOCCHIO — his name tag, his 💤, and True or Fib?
   (The panel sits at the bottom so you can still see his nose.)
   ============================================================ */

.pino-tag { --tag-color: #b07a45; background: #fff3df; }
.pino-zzz { pointer-events: none; }
.pino-zzz span { display: inline-block; font-size: 1.6rem; animation: pino-drift 2.6s ease-in-out infinite; }
@keyframes pino-drift {
  0% { transform: translate(0, 6px) scale(0.8); opacity: 0.3; }
  50% { opacity: 1; }
  100% { transform: translate(14px, -18px) scale(1.15); opacity: 0; }
}

body.pino-talking .action-row,
body.pino-talking .joystick,
body.pino-talking .jump-btn,
body.pino-talking .emotes,
body.pino-talking .guide-compass { visibility: hidden; }

.pino-panel {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 30;
  width: min(560px, calc(100% - 32px));
  transform: translateX(-50%);
  max-height: 46vh;
  overflow-y: auto;
  animation: pino-up 0.22s ease-out;
}
@keyframes pino-up { from { transform: translate(-50%, 30px); opacity: 0; } }
.pino-card { position: relative; padding: 12px 18px 16px; border-radius: 24px; background: var(--cream); box-shadow: var(--shadow); border: 3px solid #d9b07a; }
.pino-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.pino-head b { font-size: 1.1rem; color: #8a5a32; }
.pino-close { margin-left: auto; width: 36px; height: 36px; border: 0; border-radius: 50%; background: #efe3d1; font-weight: 700; }
.pino-dots { display: inline-flex; gap: 5px; }
.pino-dots i { width: 13px; height: 13px; border-radius: 50%; background: #e5d6c0; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.1); }
.pino-dots i.done { background: #d9a054; }
.pino-dots i.now { background: #fff; box-shadow: 0 0 0 2px #d9a054; }
.pino-line { margin: 4px 0; color: var(--soft-ink); font-size: 1rem; line-height: 1.35; }
.pino-line.big { color: var(--ink); font-size: 1.15rem; }
.pino-statement { margin: 8px 0 4px; padding: 12px 16px; border-radius: 18px; background: #fff; box-shadow: inset 0 0 0 2px #f0dfc4; font-size: 1.35rem; font-weight: 600; line-height: 1.3; text-align: center; }
.pino-hint { margin: 4px 0 8px; color: var(--soft-ink); font-size: 0.85rem; text-align: center; }
.pino-buttons { display: flex; gap: 12px; justify-content: center; margin-top: 8px; }
.pino-buttons .big-go, .pino-buttons .soft-btn { flex: 1; max-width: 260px; }
.pino-answer { flex: 1; max-width: 220px; padding: 14px 10px; border: 0; border-radius: 18px; color: white; font-size: 1.3rem; font-weight: 700; touch-action: manipulation; }
.pino-answer:active { transform: translateY(3px); }
.pino-answer:disabled { opacity: 0.55; }
.pino-true { background: #4fa85a; box-shadow: 0 5px 0 #367c40; }
.pino-fib { background: #e07a4f; box-shadow: 0 5px 0 #a8532f; }
.pino-verdict { font-size: 1.35rem; font-weight: 700; text-align: center; }
.pino-verdict small { display: block; color: var(--soft-ink); font-size: 0.95rem; font-weight: 500; }
.pino-verdict.right { color: #3e8a42; }
.pino-verdict.wrong { color: #c0602f; }
.pino-reveal { margin: 6px 0 2px; font-size: 1.05rem; font-weight: 600; text-align: center; }
.pino-fact { margin: 2px 0 6px; padding: 8px 12px; border-radius: 14px; background: #f6ecdc; text-align: center; line-height: 1.35; }
.pino-prize { margin: 4px 0; font-size: 1.1rem; font-weight: 700; text-align: center; }
.pino-bonus { margin: 4px 0; padding: 6px 10px; border-radius: 12px; background: #fff3c4; font-weight: 600; text-align: center; }

@media (max-width: 760px), (max-height: 520px) {
  .pino-panel { width: calc(100% - 16px); bottom: max(8px, env(safe-area-inset-bottom)); max-height: 52vh; }
  .pino-card { padding: 10px 12px 12px; border-radius: 20px; }
  .pino-statement { font-size: 1.15rem; padding: 10px 12px; }
  .pino-answer { padding: 12px 8px; font-size: 1.15rem; }
}
@media (max-height: 520px) {
  .pino-panel { max-height: 70vh; width: min(520px, calc(100% - 16px)); }
  .pino-line, .pino-hint { margin: 2px 0; }
}
