/* ============================================================
   Number Wilds — style.css
   Chunky sticker-book cartoon UI: thick ink outlines, hard
   offset shadows, rounded everything.
   ============================================================ */

:root {
  --ink: #2B2440;
  --ink-soft: rgba(43, 36, 64, 0.55);
  --cream: #FFF6E5;
  --paper: #FFFDF7;
  --amber: #FFB938;
  --amber-deep: #E89B18;
  --green: #57B86A;
  --green-deep: #3E9552;
  --blue: #3E9BD6;
  --blue-deep: #2C7EB3;
  --berry: #E4526E;
  --berry-deep: #C23652;
  --sky: #A8DDF0;
  --shadow: 0 6px 0 rgba(43, 36, 64, 0.22);
  --font-display: "Fredoka", "Arial Rounded MT Bold", system-ui, sans-serif;
  --font-body: "Nunito", "Trebuchet MS", system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  font-weight: 700;
  color: var(--ink);
  background: var(--sky);
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}

.hidden { display: none !important; }

/* ---------- screens ---------- */

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.screen.active { display: flex; animation: screenIn 0.35s ease; }

@keyframes screenIn {
  from { opacity: 0; transform: scale(1.02); }
  to   { opacity: 1; transform: scale(1); }
}

/* ---------- shared bits ---------- */

.card {
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.btn {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  color: var(--ink);
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 0.55em 1.2em;
  cursor: pointer;
  box-shadow: 0 5px 0 var(--ink);
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.15s;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn:focus-visible { outline: 4px solid var(--blue); outline-offset: 2px; }
.btn-big { font-size: 1.35rem; padding: 0.6em 1.5em; border-radius: 20px; }
.btn-amber { background: var(--amber); }
.btn-green { background: var(--green); color: #fff; }
.btn-blue  { background: var(--blue);  color: #fff; }
.btn-berry { background: var(--berry); color: #fff; }
.btn-ghost { background: rgba(255,255,255,0.7); box-shadow: 0 4px 0 rgba(43,36,64,0.35); }
.btn:disabled { opacity: 0.45; cursor: default; filter: none; }

h1, h2, h3 { font-family: var(--font-display); }

/* ============ TITLE ============ */

#screen-title {
  background: linear-gradient(#8ED8F5, #D9F2FB 70%);
  align-items: center;
  justify-content: center;
}

.title-sky { position: absolute; inset: 0; pointer-events: none; }
.title-sun {
  position: absolute; top: 7%; right: 10%;
  width: 110px; height: 110px; border-radius: 50%;
  background: #FFE9A8;
  box-shadow: 0 0 60px 30px rgba(255, 233, 168, 0.7);
  animation: sunPulse 5s ease-in-out infinite;
}
@keyframes sunPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}
.title-cloud {
  position: absolute;
  background: #fff; opacity: 0.85;
  border-radius: 60px;
  animation: drift 40s linear infinite;
}
.title-cloud::before, .title-cloud::after {
  content: ""; position: absolute; background: #fff; border-radius: 50%;
}
.c1 { top: 12%; left: -180px; width: 160px; height: 44px; }
.c1::before { width: 70px; height: 70px; top: -32px; left: 28px; }
.c1::after  { width: 50px; height: 50px; top: -20px; left: 84px; }
.c2 { top: 28%; left: -320px; width: 120px; height: 36px; animation-duration: 55s; animation-delay: -18s; }
.c2::before { width: 54px; height: 54px; top: -24px; left: 20px; }
.c2::after  { width: 40px; height: 40px; top: -16px; left: 62px; }
.c3 { top: 6%; left: -240px; width: 200px; height: 50px; animation-duration: 65s; animation-delay: -40s; }
.c3::before { width: 84px; height: 84px; top: -38px; left: 36px; }
.c3::after  { width: 60px; height: 60px; top: -26px; left: 108px; }
@keyframes drift { to { transform: translateX(calc(100vw + 400px)); } }

.title-hills {
  position: absolute; bottom: 0; left: 0; right: 0; height: 26vh;
  background:
    radial-gradient(120% 100% at 20% 100%, #5BAF62 30%, transparent 31%),
    radial-gradient(130% 115% at 80% 100%, #7ECB6F 34%, transparent 35%),
    linear-gradient(transparent 40%, #7ECB6F 41%);
  pointer-events: none;
}

.title-content {
  position: relative; z-index: 2;
  display: flex; flex-direction: column; align-items: center;
  gap: 1.1rem; text-align: center; padding: 1rem;
}

.title-creatures { display: flex; gap: 0.4rem; align-items: flex-end; }
.title-creatures .tc {
  width: 92px; height: 92px;
  animation: bob 2.6s ease-in-out infinite;
}
.title-creatures .tc:nth-child(2) { animation-delay: 0.3s; width: 108px; height: 108px; }
.title-creatures .tc:nth-child(3) { animation-delay: 0.6s; }
.title-creatures .tc:nth-child(4) { animation-delay: 0.9s; width: 120px; height: 120px; }
.title-creatures .tc svg { width: 100%; height: 100%; }

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.game-logo {
  font-size: clamp(3rem, 9vw, 5.5rem);
  line-height: 0.95;
  letter-spacing: 0.01em;
  color: #fff;
  text-shadow:
    -3px -3px 0 var(--ink), 3px -3px 0 var(--ink),
    -3px 3px 0 var(--ink), 3px 3px 0 var(--ink),
    0 9px 0 rgba(43, 36, 64, 0.35);
}
.game-logo .logo-wild { color: var(--amber); }

.title-tag {
  font-size: 1.15rem;
  background: rgba(255, 255, 255, 0.85);
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 0.4em 1.2em;
  box-shadow: var(--shadow);
}

.title-buttons { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: center; }

/* ============ CHARACTER CREATE ============ */

#screen-create {
  background: linear-gradient(#B3E5F5, #E8F8E8);
  align-items: center; justify-content: center;
}

.create-layout {
  display: flex; gap: 1.5rem; padding: 1.5rem;
  max-width: 900px; width: 100%;
  max-height: 100%; overflow: auto;
}

.create-preview {
  flex: 0 0 300px;
  display: flex; flex-direction: column; align-items: center; gap: 1rem;
  padding: 1.5rem;
  align-self: flex-start;
}
.preview-stage {
  width: 230px; height: 300px;
  background: linear-gradient(#CDEFFA, #E9F8DF);
  border: 3px solid var(--ink);
  border-radius: 16px;
  display: flex; align-items: flex-end; justify-content: center;
  overflow: hidden;
}
.preview-stage svg { width: 85%; height: 95%; animation: bob 3s ease-in-out infinite; }

#input-name {
  font-family: var(--font-display); font-weight: 600;
  font-size: 1.2rem; text-align: center;
  width: 100%;
  padding: 0.5em;
  border: 3px solid var(--ink); border-radius: 14px;
  background: var(--cream);
  color: var(--ink);
}
#input-name:focus { outline: 4px solid var(--amber); }

.create-options { flex: 1; padding: 1.5rem; min-width: 0; }
.create-options h2 { font-size: 1.7rem; margin-bottom: 0.8rem; }
.opt-group { margin-bottom: 0.9rem; }
.opt-group h3 { font-size: 0.95rem; opacity: 0.75; margin-bottom: 0.35rem; text-transform: uppercase; letter-spacing: 0.06em; }
.swatches { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.swatch {
  width: 46px; height: 46px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 0.7rem; font-weight: 600;
  background: #fff;
  box-shadow: 0 4px 0 rgba(43, 36, 64, 0.25);
  transition: transform 0.1s;
  color: var(--ink);
}
.swatch:hover { transform: translateY(-2px); }
.swatch.selected {
  outline: 4px solid var(--amber);
  outline-offset: 2px;
  transform: scale(1.08);
}
.swatch.wide { width: auto; padding: 0 0.7em; }

/* ============ STARTER ============ */

#screen-starter {
  background: linear-gradient(#8ED8F5, #D8F2C8);
  align-items: center; justify-content: center; text-align: center;
}
.starter-wrap { padding: 1.5rem; max-width: 860px; width: 100%; }
.starter-wrap h2 { font-size: clamp(1.8rem, 5vw, 2.6rem); color: #fff;
  text-shadow: -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink), 2px 2px 0 var(--ink), 0 6px 0 rgba(43,36,64,.3); }
.starter-sub { margin: 0.5rem 0 1.5rem; font-size: 1.1rem; }
.starter-row { display: flex; gap: 1.2rem; justify-content: center; flex-wrap: wrap; }

.starter-card {
  width: 200px; padding: 1.2rem 1rem;
  cursor: pointer; text-align: center;
  transition: transform 0.15s;
}
.starter-card:hover { transform: translateY(-6px) rotate(-1deg); }
.starter-card .art { width: 130px; height: 130px; margin: 0 auto; }
.starter-card .art svg { width: 100%; height: 100%; }
.starter-card h3 { font-size: 1.3rem; margin-top: 0.4rem; }
.starter-card p { font-size: 0.85rem; opacity: 0.7; }

/* ============ HUD / MAP ============ */

#screen-map { background: linear-gradient(#9BDCF2, #D8F2C8); }

.hud {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1.2rem;
  background: rgba(255, 253, 247, 0.92);
  border-bottom: 3px solid var(--ink);
  z-index: 5;
}
.hud-right { display: flex; gap: 0.6rem; }

.hud-player { display: flex; align-items: center; gap: 0.8rem; min-width: 0; }
.hud-avatar {
  width: 54px; height: 62px; flex: 0 0 auto;
  background: var(--cream);
  border: 3px solid var(--ink); border-radius: 14px;
  overflow: hidden;
  display: flex; align-items: flex-end; justify-content: center;
}
.hud-avatar svg { width: 88%; height: 110%; }
.hud-info { min-width: 0; }
.hud-name { font-family: var(--font-display); font-weight: 600; font-size: 1.1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-sub { font-size: 0.8rem; opacity: 0.75; white-space: nowrap; }
.xp-bar {
  width: 170px; max-width: 34vw; height: 14px;
  border: 2.5px solid var(--ink); border-radius: 999px;
  background: #fff; overflow: hidden; margin-top: 3px;
}
.xp-fill { height: 100%; background: linear-gradient(90deg, var(--amber), #FFD97A); transition: width 0.5s ease; }

.map-scroll { flex: 1; overflow-y: auto; padding: 1.4rem; }
.zones {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.3rem;
  max-width: 1100px; margin: 0 auto;
}

.zone-card { overflow: hidden; display: flex; flex-direction: column; }
.zone-head {
  padding: 0.9rem 1.1rem;
  color: #fff;
  border-bottom: 3px solid var(--ink);
  display: flex; align-items: baseline; gap: 0.5rem;
  text-shadow: 0 2px 0 rgba(43, 36, 64, 0.4);
}
.zone-head h3 { font-size: 1.35rem; }
.zone-emoji { font-size: 1.5rem; }
.zone-tag { padding: 0.7rem 1.1rem 0.2rem; font-size: 0.85rem; opacity: 0.7; }
.zone-body { padding: 0.6rem 1.1rem 1.1rem; display: flex; flex-direction: column; gap: 0.55rem; }

.rival-row {
  display: flex; align-items: center; gap: 0.7rem;
  border: 2.5px solid var(--ink); border-radius: 14px;
  background: var(--cream);
  padding: 0.45rem 0.7rem;
}
.rival-face {
  width: 40px; height: 46px; flex: 0 0 auto;
  background: #fff; border: 2.5px solid var(--ink); border-radius: 10px;
  overflow: hidden; display: flex; align-items: flex-end; justify-content: center;
}
.rival-face svg { width: 90%; height: 115%; }
.rival-name { flex: 1; font-size: 0.95rem; min-width: 0; }
.rival-name small { display: block; font-size: 0.72rem; opacity: 0.65; }
.rival-row .btn { font-size: 0.85rem; padding: 0.4em 0.9em; }
.rival-row.beaten { opacity: 0.85; }
.badge-done {
  font-family: var(--font-display);
  background: var(--green); color: #fff;
  border: 2.5px solid var(--ink); border-radius: 999px;
  font-size: 0.75rem; padding: 0.25em 0.7em;
}

.zone-wild-btn { margin-top: 0.2rem; }

.zone-locked { position: relative; }
.zone-locked .zone-body, .zone-locked .zone-tag { filter: grayscale(0.9) opacity(0.45); pointer-events: none; }
.lock-note {
  position: absolute; inset: auto 0 0 0; top: 62px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 1.05rem;
  color: var(--ink);
  z-index: 2;
}
.lock-note span {
  background: rgba(255, 253, 247, 0.95);
  border: 3px solid var(--ink); border-radius: 14px;
  padding: 0.5em 1em; box-shadow: var(--shadow);
}

/* ============ TEAM ============ */

#screen-team { background: linear-gradient(#B3E5F5, #E8F8E8); }
.team-title { font-size: 1.5rem; }
.team-count { font-size: 1rem; opacity: 0.6; }
.team-wrap { flex: 1; overflow-y: auto; padding: 1.3rem; max-width: 950px; margin: 0 auto; width: 100%; }
.team-hint { margin-bottom: 1rem; background: rgba(255,255,255,0.75); border: 2.5px solid var(--ink); border-radius: 12px; padding: 0.5em 0.9em; font-size: 0.95rem; }

.team-slots {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.9rem; margin-bottom: 1.6rem;
}
.creature-card {
  padding: 0.8rem 0.6rem;
  text-align: center; cursor: pointer;
  position: relative;
  transition: transform 0.12s;
}
.creature-card:hover { transform: translateY(-4px); }
.creature-card .art { width: 92px; height: 92px; margin: 0 auto; }
.creature-card .art svg { width: 100%; height: 100%; }
.creature-card h4 { font-family: var(--font-display); font-size: 1.02rem; }
.creature-card .lvl { font-size: 0.78rem; opacity: 0.7; }
.creature-card .tierlab {
  position: absolute; top: 8px; left: 8px;
  font-size: 0.65rem; font-weight: 800;
  background: var(--cream); border: 2px solid var(--ink); border-radius: 999px;
  padding: 0.15em 0.55em;
}
.creature-card.empty-slot {
  border-style: dashed; background: rgba(255,255,255,0.5);
  display: flex; align-items: center; justify-content: center;
  min-height: 170px; cursor: default;
  font-size: 0.9rem; color: var(--ink-soft);
  box-shadow: none;
}
.bench-title { margin-bottom: 0.7rem; font-size: 1.2rem; }
.bench { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.9rem; }
.bench-empty { opacity: 0.6; font-size: 0.95rem; }

/* ============ BATTLE ============ */

#screen-battle { background: #9BDCF2; }

.battle-backdrop { position: absolute; inset: 0; }
.battle-backdrop svg { width: 100%; height: 100%; display: block; }

.battle-stage { position: relative; flex: 1; min-height: 0; }

.battle-banner {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(0.95rem, 2.6vw, 1.25rem);
  background: rgba(255, 253, 247, 0.94);
  border: 3px solid var(--ink); border-radius: 999px;
  padding: 0.35em 1.2em;
  box-shadow: var(--shadow);
  white-space: nowrap; max-width: 92%;
  overflow: hidden; text-overflow: ellipsis;
  z-index: 4;
}

.combatant { position: absolute; bottom: 4%; width: 44%; }
.player-side { left: 3%; }
.enemy-side { right: 3%; }

.fighter {
  width: clamp(130px, 22vw, 230px);
  margin: 0 auto;
  position: relative;
  z-index: 2;
}
.fighter svg { width: 100%; height: auto; }
.player-side .fighter { animation: bob 3s ease-in-out infinite; }
.enemy-side .fighter { animation: bob 3.4s ease-in-out infinite; }
.enemy-side .fighter svg { transform: scaleX(-1); }

.trainer {
  position: absolute; bottom: 0;
  width: clamp(60px, 9vw, 100px);
  z-index: 1; opacity: 0.95;
}
.player-side .trainer { left: 0; }
.enemy-side .trainer { right: 0; }
.enemy-side .trainer svg { transform: scaleX(-1); }
.trainer svg { width: 100%; height: auto; }

.hp-card {
  position: relative; z-index: 3;
  background: rgba(255, 253, 247, 0.95);
  border: 3px solid var(--ink); border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 0.5rem 0.8rem;
  max-width: 290px; margin: 0 auto 0.6rem;
}
.hp-name { font-family: var(--font-display); font-weight: 600; font-size: 1rem; display: flex; justify-content: space-between; gap: 0.5rem; }
.hp-name small { font-weight: 700; opacity: 0.65; font-family: var(--font-body); }
.hp-track {
  height: 16px; margin-top: 4px;
  border: 2.5px solid var(--ink); border-radius: 999px;
  background: #fff; overflow: hidden;
}
.hp-fill { height: 100%; border-radius: 999px; background: var(--green); transition: width 0.45s ease, background 0.3s; }
.hp-fill.mid { background: var(--amber); }
.hp-fill.low { background: var(--berry); }
.team-dots { margin-top: 5px; display: flex; gap: 4px; }
.team-dot { width: 12px; height: 12px; border: 2px solid var(--ink); border-radius: 50%; background: var(--green); }
.team-dot.out { background: #ccc; }

/* attack + hit animations */
@keyframes lungeRight { 0% { transform: translateX(0); } 35% { transform: translateX(9vw) rotate(4deg); } 100% { transform: translateX(0); } }
@keyframes lungeLeft  { 0% { transform: translateX(0); } 35% { transform: translateX(-9vw) rotate(-4deg); } 100% { transform: translateX(0); } }
.fighter.attack-right { animation: lungeRight 0.5s ease; }
.fighter.attack-left  { animation: lungeLeft 0.5s ease; }
@keyframes hitShake {
  0%, 100% { transform: translateX(0); filter: none; }
  20% { transform: translateX(-8px); filter: brightness(1.8) saturate(0.3); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); filter: brightness(1.8) saturate(0.3); }
  80% { transform: translateX(5px); }
}
.fighter.hit { animation: hitShake 0.5s ease; }
@keyframes faintDown { to { transform: translateY(40px) rotate(10deg); opacity: 0; } }
.fighter.faint { animation: faintDown 0.7s ease forwards; }
@keyframes popIn { 0% { transform: scale(0); } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }
.fighter.enter { animation: popIn 0.45s ease; }

.dmg-pop {
  position: absolute;
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(1.4rem, 4vw, 2.2rem);
  color: #fff;
  text-shadow: -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink), 2px 2px 0 var(--ink);
  animation: dmgFloat 0.9s ease forwards;
  z-index: 6; pointer-events: none;
}
@keyframes dmgFloat {
  0% { opacity: 0; transform: translateY(10px) scale(0.6); }
  25% { opacity: 1; transform: translateY(-6px) scale(1.15); }
  100% { opacity: 0; transform: translateY(-46px) scale(1); }
}

.fx-layer { position: absolute; inset: 0; pointer-events: none; z-index: 5; }

.projectile {
  position: absolute;
  width: 30px; height: 30px;
  margin: -15px 0 0 -15px;
  border: 3px solid var(--ink);
  border-radius: 50% 50% 50% 12px;
  background: radial-gradient(circle at 35% 35%, #fff 8%, var(--pc, var(--amber)) 55%);
  box-shadow: 0 0 18px 4px var(--pc, var(--amber));
  will-change: transform;
}
.projectile.super {
  width: 42px; height: 42px;
  margin: -21px 0 0 -21px;
  box-shadow: 0 0 26px 8px var(--pc, var(--amber)), 0 0 50px 16px rgba(255, 185, 56, 0.5);
}
.trail-dot {
  position: absolute;
  width: 10px; height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  background: var(--pc, var(--amber));
  opacity: 0.8;
  animation: trailFade 0.38s ease-out forwards;
}
@keyframes trailFade {
  to { opacity: 0; transform: scale(0.2) translateY(6px); }
}
.spark {
  position: absolute; width: 14px; height: 14px;
  background: var(--amber); border: 2px solid var(--ink);
  border-radius: 4px;
  animation: sparkFly 0.6s ease-out forwards;
}
@keyframes sparkFly {
  from { opacity: 1; transform: translate(0, 0) rotate(0deg) scale(1); }
  to   { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(200deg) scale(0.3); }
}

/* battle bottom panel */

.battle-panel {
  position: relative; z-index: 6;
  background: rgba(255, 253, 247, 0.96);
  border-top: 3px solid var(--ink);
  padding: 0.7rem 1rem 1rem;
  display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
}

.streak { display: flex; gap: 5px; height: 22px; align-items: center; font-size: 1.1rem; }
.streak .star { opacity: 0.25; transition: transform 0.2s, opacity 0.2s; }
.streak .star.lit { opacity: 1; transform: scale(1.2); }
.streak .super-note {
  font-family: var(--font-display); font-size: 0.85rem;
  color: var(--berry); margin-left: 6px;
  animation: popIn 0.3s ease;
}

/* move chooser */
.move-chooser { width: min(640px, 100%); padding: 0.8rem 1rem; text-align: center; }
.move-title { font-family: var(--font-display); font-weight: 600; font-size: 1.2rem; margin-bottom: 0.6rem; }
.move-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.7rem; }
.move-btn {
  font-family: var(--font-display); font-weight: 600;
  display: flex; flex-direction: column; align-items: center; gap: 0.1rem;
  border: 3px solid var(--ink); border-radius: 16px;
  padding: 0.55em 0.4em;
  cursor: pointer;
  box-shadow: 0 5px 0 rgba(43, 36, 64, 0.8);
  transition: transform 0.08s, box-shadow 0.08s, filter 0.15s;
  color: var(--ink);
}
.move-btn:hover { filter: brightness(1.06); transform: translateY(-2px); }
.move-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(43, 36, 64, 0.8); }
.move-easy   { background: #CDEFD6; }
.move-medium { background: #FFE6A8; }
.move-hard   { background: #FFC9D4; }
.move-emoji { font-size: 1.5rem; }
.move-name { font-size: 1.1rem; }
.move-hint { font-family: var(--font-body); font-weight: 700; font-size: 0.72rem; opacity: 0.7; }

/* timer */
.timer-track {
  height: 12px;
  border: 2.5px solid var(--ink); border-radius: 999px;
  background: #fff; overflow: hidden;
  margin-bottom: 0.6rem;
}
.timer-fill {
  height: 100%; width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--green), #9ADF8F);
  transition: width 0.1s linear, background 0.3s;
}
.timer-fill.urgent { background: linear-gradient(90deg, var(--berry), #F08080); }

.question { width: min(640px, 100%); padding: 0.9rem 1.2rem; text-align: center; }
.question.defending { border-color: var(--blue); box-shadow: 0 6px 0 rgba(44, 126, 179, 0.5); }
.question.defending .question-text::before { content: "🛡️ "; }

.shield-pop {
  position: absolute; top: 22%; left: 50%;
  transform: translateX(-50%);
  font-size: clamp(2.2rem, 6vw, 3.5rem);
  animation: shieldPop 0.9s ease forwards;
  z-index: 6; pointer-events: none;
  filter: drop-shadow(0 3px 0 rgba(43, 36, 64, 0.4));
}
@keyframes shieldPop {
  0% { opacity: 0; transform: translateX(-50%) scale(0.3); }
  30% { opacity: 1; transform: translateX(-50%) scale(1.25); }
  70% { opacity: 1; transform: translateX(-50%) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) scale(1.1) translateY(-14px); }
}
.question-text {
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(1.5rem, 4.5vw, 2.3rem);
  margin-bottom: 0.7rem;
  letter-spacing: 0.02em;
}
.answers { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 0.7rem; }
.answer-btn {
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(1.1rem, 3vw, 1.5rem);
  background: var(--cream);
  border: 3px solid var(--ink); border-radius: 14px;
  padding: 0.45em 0.4em;
  cursor: pointer;
  box-shadow: 0 5px 0 rgba(43, 36, 64, 0.8);
  transition: transform 0.08s, box-shadow 0.08s, background 0.15s;
  color: var(--ink);
}
.answer-btn:hover { background: #fff; }
.answer-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(43,36,64,0.8); }
.answer-btn:disabled { cursor: default; }
.answer-btn.correct { background: var(--green); color: #fff; }
.answer-btn.wrong { background: var(--berry); color: #fff; animation: hitShake 0.4s; }
.answer-btn.reveal { outline: 4px solid var(--green); }

.battle-msg {
  min-height: 1.4em;
  font-size: 1.05rem;
  font-weight: 800;
}
.battle-msg.pow { color: var(--berry); animation: popIn 0.3s ease; }

/* ============ MODAL ============ */

.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(43, 36, 64, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  animation: screenIn 0.25s ease;
}
.modal-card {
  max-width: 480px; width: 100%;
  padding: 1.6rem;
  text-align: center;
  max-height: 90vh; overflow-y: auto;
}
.modal-card h2 { font-size: 1.8rem; margin-bottom: 0.5rem; }
.modal-card p { margin: 0.4rem 0 0.9rem; font-size: 1.05rem; }
.modal-art { width: 150px; height: 150px; margin: 0 auto; }
.modal-art svg { width: 100%; height: 100%; }
.modal-art.celebrate svg { animation: bob 1.2s ease-in-out infinite; }
.modal-buttons { display: flex; gap: 0.8rem; justify-content: center; flex-wrap: wrap; margin-top: 0.6rem; }

.modal-q {
  font-family: var(--font-display); font-size: 1.7rem; font-weight: 600;
  background: var(--cream); border: 3px solid var(--ink); border-radius: 14px;
  padding: 0.4em; margin: 0.6rem 0;
}
.modal-answers { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }

.prize-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.7rem;
  margin: 0.8rem 0 0.3rem;
}
.prize-card {
  font-family: var(--font-body);
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 16px;
  box-shadow: 0 5px 0 rgba(43, 36, 64, 0.25);
  padding: 0.7rem 0.4rem;
  cursor: pointer;
  text-align: center;
  color: var(--ink);
  transition: transform 0.12s;
}
.prize-card:hover { transform: translateY(-4px) rotate(-1deg); background: #fff; }
.prize-card .art { width: 80px; height: 80px; margin: 0 auto; }
.prize-card .art svg { width: 100%; height: 100%; }
.prize-card h4 { font-family: var(--font-display); font-size: 0.98rem; margin-top: 0.2rem; }
.prize-card .lvl { font-size: 0.75rem; opacity: 0.7; font-weight: 700; }

.confetti-bit {
  position: fixed; top: -20px;
  width: 12px; height: 12px;
  border: 2px solid var(--ink);
  border-radius: 3px;
  z-index: 60; pointer-events: none;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  to { transform: translateY(110vh) rotate(720deg); }
}

/* ============ responsive ============ */

.mode-note {
  font-size: 0.82rem; opacity: 0.75; margin-top: 0.4rem;
}

/* ---------- player picker (title screen) ---------- */

.player-list-title {
  font-family: var(--font-display); font-weight: 600;
  font-size: 1.15rem; color: var(--ink);
  margin-bottom: 0.6rem;
}
.player-list {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 0.7rem; margin-bottom: 1rem; max-width: 620px;
}
.player-card {
  position: relative; display: flex;
}
.player-pick {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.45rem 1.4rem 0.45rem 0.55rem;
  background: var(--cream); color: var(--ink);
  border: 3px solid var(--ink); border-radius: 16px;
  box-shadow: 3px 4px 0 rgba(43, 36, 64, 0.3);
  font-family: var(--font-display); cursor: pointer;
  transition: transform 0.1s;
}
.player-pick:hover { transform: translateY(-2px); }
.player-pick:active { transform: translateY(1px); box-shadow: 1px 2px 0 rgba(43, 36, 64, 0.3); }
.player-avatar {
  width: 46px; height: 46px; border-radius: 50%; overflow: hidden;
  background: #DFF3FA; border: 2px solid var(--ink); flex: none;
}
.player-avatar svg { width: 100%; height: 118%; }
.player-info { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; }
.player-name { font-weight: 700; font-size: 1.02rem; }
.player-sub { font-size: 0.78rem; opacity: 0.7; }
.player-del {
  position: absolute; top: -8px; right: -8px;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--berry); color: #fff;
  border: 2px solid var(--ink); cursor: pointer;
  font-size: 0.72rem; line-height: 1; padding: 0;
  box-shadow: 1px 2px 0 rgba(43, 36, 64, 0.3);
}
.player-del:hover { transform: scale(1.12); }

/* ---------- audio buttons ---------- */

#audio-global {
  position: fixed; bottom: 12px; left: 12px; z-index: 500;
  display: flex; gap: 0.5rem;
}
.btn-audio {
  position: relative; padding: 0.4em 0.55em; font-size: 1.05rem; line-height: 1;
}
.btn-audio.off { opacity: 0.8; }
.btn-audio.off::after {
  content: ""; position: absolute; left: 14%; right: 14%; top: 50%;
  height: 4px; margin-top: -2px;
  background: var(--berry); border-radius: 3px;
  box-shadow: 0 0 0 2px var(--cream);
  transform: rotate(-42deg);
  pointer-events: none;
}

@media (max-width: 720px) {
  .create-layout { flex-direction: column; align-items: center; }
  .move-row { grid-template-columns: repeat(3, 1fr); gap: 0.4rem; }
  .move-hint { display: none; }
  .create-preview { flex: none; width: 100%; max-width: 340px; }
  .preview-stage { width: 180px; height: 230px; }
  .hud .btn { font-size: 0.85rem; }
  .answers { grid-template-columns: 1fr 1fr; }

  /* battle: shrink everything so trainer + pet + panel all fit */
  .combatant { width: 48%; bottom: 3%; }
  .fighter { width: clamp(80px, 24vw, 130px); }
  .trainer { width: clamp(42px, 12vw, 60px); }
  .hp-card { padding: 0.35rem 0.55rem; max-width: 230px; border-radius: 12px; margin-bottom: 0.4rem; }
  .hp-name { font-size: 0.85rem; }
  .hp-track { height: 12px; }
  .team-dot { width: 9px; height: 9px; }
  .battle-panel { padding: 0.45rem 0.7rem 0.7rem; gap: 0.35rem; }
  .streak { height: 18px; font-size: 0.95rem; }
  .move-chooser { padding: 0.55rem 0.7rem; }
  .move-title { font-size: 1rem; margin-bottom: 0.4rem; }
  .move-btn { padding: 0.4em 0.3em; border-radius: 12px; box-shadow: 0 4px 0 rgba(43, 36, 64, 0.8); }
  .move-emoji { font-size: 1.2rem; }
  .move-name { font-size: 0.95rem; }
  .battle-msg { font-size: 0.92rem; padding: 0 2.9rem; }

  /* smaller corner audio buttons so they stay out of the way */
  #audio-global { bottom: 8px; left: 8px; gap: 0.35rem; }
  .btn-audio { font-size: 0.85rem; padding: 0.3em 0.42em; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ---------- friend battles (versus.js) ---------- */

.vs-stack { flex-direction: column; align-items: stretch; }
.vs-stack .btn { width: 100%; }

.vs-code {
  font-family: var(--font-display);
  font-size: 2.6rem;
  font-weight: 700;
  letter-spacing: 0.35em;
  text-indent: 0.35em; /* balances the letter-spacing */
  background: var(--cream);
  border: 3px dashed var(--ink);
  border-radius: 16px;
  padding: 0.25em 0.4em;
  margin: 0.6rem auto;
  max-width: 12em;
}

.vs-code-input {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-align: center;
  text-transform: uppercase;
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 0.3em 0.5em;
  width: 8em;
  max-width: 90%;
  margin: 0.6rem auto;
  display: block;
  background: var(--paper);
  color: var(--ink);
}

.vs-link-row { display: flex; gap: 0.5rem; justify-content: center; align-items: stretch; margin: 0.5rem 0; }
.vs-link {
  flex: 1;
  min-width: 0;
  font-family: var(--font-body);
  font-size: 0.9rem;
  border: 3px solid var(--ink);
  border-radius: 12px;
  padding: 0.4em 0.7em;
  background: var(--paper);
  color: var(--ink);
}

.vs-hint { font-size: 0.9rem; color: var(--ink-soft); }
.vs-error { color: var(--berry-deep); font-weight: 700; }

.vs-wait { font-weight: 700; color: var(--ink-soft); }
.vs-spinner {
  display: inline-block;
  width: 0.85em; height: 0.85em;
  border: 3px solid var(--ink-soft);
  border-top-color: transparent;
  border-radius: 50%;
  vertical-align: -0.1em;
  animation: vsSpin 0.8s linear infinite;
}
@keyframes vsSpin { to { transform: rotate(360deg); } }

.invite-note {
  font-family: var(--font-display);
  font-weight: 600;
  background: var(--amber);
  border: 3px solid var(--ink);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 0.5em 1em;
  margin: 0.8rem auto 0.2rem;
  max-width: 30em;
  animation: invitePulse 1.6s ease-in-out infinite;
}
@keyframes invitePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

.vs-leave {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  z-index: 30;
  font-size: 0.85rem;
}
