:root {
  --bg: #04060c;
  --panel: rgba(8, 14, 26, 0.94);
  --border: rgba(100, 180, 255, 0.18);
  --cyan: #5ee0ff;
  --orange: #ff9a4a;
  --green: #34d399;
  --text: #eef3fb;
  --muted: #7a8ba8;
  --glass: blur(18px);
  --radius: 16px;
  --font: "Inter", system-ui, -apple-system, sans-serif;
  --display: "Orbitron", "Inter", sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --touch-min: 48px;
  --ctrl-h: auto;
  --chrome: linear-gradient(180deg, rgba(28,40,64,0.95), rgba(10,16,28,0.98));
}

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

html, body {
  height: 100%;
  height: 100dvh;
  min-height: -webkit-fill-available;
  min-height: 100dvh;
  width: 100%;
  background-color: #04060c;
  background: radial-gradient(1000px 560px at 50% -15%, #0e1a30 0%, #060a12 45%, var(--bg) 70%) no-repeat, #04060c;
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

/* Form fields must opt back into text entry (iOS blocks typing under user-select:none) */
input, textarea, select, [contenteditable="true"] {
  user-select: text !important;
  -webkit-user-select: text !important;
  -webkit-touch-callout: default;
  pointer-events: auto !important;
  touch-action: manipulation;
  caret-color: var(--cyan, #5ee0ff);
}

#app {
  height: 100%;
  height: 100dvh;
  width: 100%;
  position: relative;
  overflow: hidden;
  padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l);
}

.screen {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: manipulation;
}
.screen.active { display: flex; }
.screen:not(.active) {
  display: none !important;
  pointer-events: none !important;
  visibility: hidden;
}

.glass {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
  box-shadow:
    0 20px 56px rgba(0,0,0,0.55),
    inset 0 1px 0 rgba(255,255,255,0.07),
    inset 0 -1px 0 rgba(0,0,0,0.35);
}

/* ===== BUTTONS ===== */
.btn, .touch-btn, .touch-fire {
  appearance: none;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #1a2740, #0c1422);
  color: var(--text);
  font: 600 0.95rem var(--font);
  border-radius: 12px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}
.btn {
  padding: 0.75rem 1rem;
  min-height: var(--touch-min);
  transition: transform 0.1s, border-color 0.12s, box-shadow 0.12s;
}
.btn-lg { min-height: 52px; font-size: 1.05rem; width: 100%; }
.btn:active, .touch-btn:active, .touch-fire:active { transform: scale(0.97); }
.btn.primary, .btn.primary:active {
  background: linear-gradient(180deg, #1e90c8, #0e5f8a);
  border-color: rgba(79,209,255,0.55);
  box-shadow: 0 0 20px rgba(79,209,255,0.22);
}
.btn.ghost, .ghost-btn {
  background: rgba(10, 16, 28, 0.6);
  border-color: rgba(139,155,180,0.35);
  color: var(--muted);
}
.btn:disabled, .touch-btn:disabled { opacity: 0.4; }

.touch-btn {
  min-width: var(--touch-min);
  min-height: var(--touch-min);
  padding: 0 0.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  font-weight: 700;
}
.touch-fire {
  width: 100%;
  min-height: 64px;
  min-width: 72px;
  font-family: var(--display);
  letter-spacing: 0.14em;
  font-size: 1.15rem;
  font-weight: 700;
  background: linear-gradient(180deg, #ff9a4a, #d45512);
  border-color: rgba(255,170,80,0.7);
  box-shadow: 0 0 24px rgba(255,138,61,0.35);
  color: #fff;
  position: relative;
  z-index: 6;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  /* Expand hit target without shifting layout */
  padding: 0.55rem 0.4rem;
}
.touch-fire::before {
  content: '';
  position: absolute;
  inset: -10px -6px;
  z-index: -1;
}

/* ===== MENU ===== */
#screen-menu { flex-direction: column; padding: 0.75rem; }
.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-bottom: 0.9rem;
}
.hint {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.4;
  margin-bottom: 0.65rem;
}

/* ===== SHOP ===== */
#screen-shop { padding: 0.5rem; align-items: stretch; }
.shop-wrap {
  width: min(920px, 100%);
  max-height: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 0.9rem;
  margin: auto;
}
.shop-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.45rem 0.9rem;
  margin-bottom: 0.7rem;
  position: sticky;
  top: 0;
  background: rgba(14,22,38,0.95);
  z-index: 2;
  padding-bottom: 0.4rem;
}
.shop-header h2 {
  font-family: var(--display);
  letter-spacing: 0.08em;
  font-size: 1rem;
}
.shop-scores { margin-left: auto; display: flex; gap: 0.75rem; color: var(--muted); font-size: 0.8rem; }
.shop-pool {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}
.shop-card {
  background: #0b1422;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem;
  cursor: pointer;
  text-align: left;
  min-height: 72px;
  touch-action: manipulation;
  color: inherit;
  font: inherit;
}
.shop-card:active { border-color: var(--cyan); }
.shop-card .cat {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--cyan);
  margin-bottom: 0.15rem;
}
.shop-card .nm { font-weight: 600; font-size: 0.88rem; }
.shop-card .ds { font-size: 0.7rem; color: var(--muted); margin-top: 0.2rem; line-height: 1.3; }
.shop-inventories {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}
.shop-inventories h3 { font-size: 0.78rem; color: var(--muted); margin-bottom: 0.3rem; }
.shop-inventories ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  min-height: 2rem;
}
.shop-inventories li {
  background: #121c2e;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.5rem;
  font-size: 0.7rem;
}
.shop-actions { display: flex; gap: 0.5rem; position: sticky; bottom: 0; padding-top: 0.4rem; background: rgba(14,22,38,0.95); }

/* ===== BATTLE ===== */
#screen-battle {
  flex-direction: column;
  align-items: stretch;
  justify-content: stretch;
  background: #03060c;
  /* Use full app area already padded for safe insets */
}

.battle-hud {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.35rem 0.5rem;
  padding: 0.45rem 0.7rem;
  background: linear-gradient(180deg, rgba(3, 6, 12, 0.22), rgba(3, 6, 12, 0.05) 58%, rgba(3, 6, 12, 0));
  border-bottom: 0;
  box-shadow: none;
  z-index: 3;
  pointer-events: none;
}
.hud-side .name {
  font-family: var(--display);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
}
.hud-side { min-width: 0; }
.hud-side .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hud-side.p1 .name { color: var(--cyan); }
.hud-side.p2 .name { color: var(--orange); text-align: right; }
.hud-side.p3 .name { color: #c084fc; }
.hud-side.p4 .name { color: #4ade80; text-align: right; }
.hud-side .score {
  font-family: var(--display);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.1;
}
.hud-side.p2 .score, .hud-side.p4 .score { text-align: right; }
.hud-side .meta { font-size: 0.62rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hud-side.p2 .meta, .hud-side.p4 .meta { text-align: right; }
#screen-battle:not(.roster-3):not(.roster-4) .hud-side.p3,
#screen-battle:not(.roster-3):not(.roster-4) .hud-side.p4 { display: none; }
.hud-side[hidden], #screen-shop .draft-loadout[hidden], .result-scores > [hidden] { display: none !important; }
#screen-battle.roster-3 .battle-hud { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto minmax(0, 1fr); }
#screen-battle.roster-4 .battle-hud { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto minmax(0, 1fr) minmax(0, 1fr); }
.hud-center { text-align: center; min-width: 0; }
.turn-banner {
  font-family: var(--display);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  color: #fff;
  text-shadow: 0 0 14px rgba(79,209,255,0.45);
}
.wind, .volley { font-size: 0.62rem; color: var(--muted); margin-top: 0.1rem; }

.canvas-wrap {
  flex: 1 1 auto;
  position: relative;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #05080f;
  overflow: hidden;
  /* Prevent browser gestures on the playfield */
  touch-action: none;
  z-index: 1;
}
#game-canvas {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  background: #05080f;
  /* Actual pixel size set by fitCanvas() in main.js */
}
/* 3D surface. Transparent until acquire3d() draws. Must not take a 2D context. */
#game-gl {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  background: none;
}
#fx-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--display);
  font-size: clamp(0.95rem, 4vw, 1.35rem);
  letter-spacing: 0.1em;
  color: #fff;
  text-shadow: 0 0 18px rgba(79,209,255,0.7);
  opacity: 0;
  transition: opacity 0.2s;
  padding: 0.5rem;
  text-align: center;
}
#fx-overlay.show { opacity: 1; }
#your-move {
  position: absolute;
  left: 50%;
  top: calc(7rem + var(--safe-t));
  z-index: 6;
  transform: translateX(-50%);
  display: none;
  pointer-events: none;
  padding: 0.35rem 1rem 0.4rem;
  border-radius: 999px;
  border: 2px solid rgba(94, 224, 255, 0.95);
  background: rgba(4, 10, 22, 0.78);
  box-shadow: 0 0 28px rgba(79, 209, 255, 0.65), 0 8px 24px rgba(0, 0, 0, 0.45);
  font-family: var(--display);
  font-size: clamp(1.35rem, 6.4vw, 2.5rem);
  font-weight: 700;
  letter-spacing: 0.16em;
  color: #fff;
  text-shadow: 0 0 16px rgba(79, 209, 255, 0.95);
  white-space: nowrap;
}
#your-move.on {
  display: block;
  animation: your-move-flash 0.9s ease-in-out infinite;
}
@keyframes your-move-flash {
  0%, 100% { opacity: 1; filter: brightness(1.15); }
  50% { opacity: 0.22; filter: brightness(0.85); }
}
@media (prefers-reduced-motion: reduce) {
  #your-move.on { animation: none; opacity: 1; }
}
@media (orientation: landscape) and (max-height: 500px) {
  #your-move { top: calc(6.4rem + var(--safe-t)); font-size: clamp(1.15rem, 5.2vw, 1.8rem); }
}
#flash-toast {
  position: fixed;
  left: 50%;
  top: 12%;
  transform: translateX(-50%);
  z-index: 80;
  max-width: min(36rem, 92vw);
  padding: 0.7rem 1.1rem;
  border-radius: 12px;
  pointer-events: none;
  opacity: 0;
  text-align: center;
  font-family: var(--display);
  font-size: clamp(0.95rem, 2.4vw, 1.25rem);
  letter-spacing: 0.06em;
  color: #fff;
  background: rgba(8, 14, 28, 0.92);
  border: 1px solid rgba(94, 224, 255, 0.55);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  transition: opacity 0.2s;
}
#flash-toast.show { opacity: 1; }

/* ===== TOUCH CONTROL DOCK ===== */
.battle-controls {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.45rem 0.55rem calc(0.55rem + var(--safe-b));
  margin: 0;
  border-radius: 16px 16px 0 0;
  border-left: none;
  border-right: none;
  border-bottom: none;
  z-index: 50;
  max-height: min(48dvh, 420px);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  pointer-events: auto;
  position: relative;
  /* Keep dock above canvas hit layer on iOS — no translateZ (breaks pickers) */
  isolation: isolate;
  touch-action: manipulation;
}
.battle-controls .touch-dock,
.battle-controls .fire-col,
.battle-controls .touch-fire,
.battle-controls .touch-btn,
.battle-controls .touch-slider,
.battle-controls select,
.battle-controls input {
  pointer-events: auto;
  position: relative;
  z-index: 2;
}

.ctrl-top { display: flex; flex-direction: column; gap: 0.3rem; }
.weapon-panel {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.weapon-info { flex: 1; min-width: 0; text-align: left; }
.w-name {
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.w-desc {
  font-size: 0.65rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inv-strip {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.3rem;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  max-height: 44px;
  min-height: 36px;
  padding: 2px 1.25rem 4px 2px; /* end pad so last chip scrolls fully into view */
  scroll-padding-inline: 0.75rem;
  scrollbar-width: thin;
}
.inv-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.22rem;
  font-size: 0.65rem;
  padding: 0.28rem 0.55rem;
  min-height: 32px;
  max-height: 36px;
  line-height: 1.15;
  border-radius: 999px;
  background: #121c2e;
  border: 1px solid transparent;
  color: var(--muted);
  cursor: pointer;
  touch-action: manipulation;
  white-space: nowrap;
  overflow: visible; /* full name — strip scrolls instead of ellipsis */
  text-overflow: clip;
  max-width: none;
}
.inv-chip .w-ico { width: 18px; height: 18px; flex-basis: 18px; }
.inv-chip.active {
  border-color: var(--cyan);
  color: var(--text);
  background: #163048;
}

.touch-dock {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.4rem;
  align-items: end;
}
.pad-col {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
}
.pad-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}
.pad-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.25rem;
}
.pad-row .touch-btn { width: 100%; min-height: 44px; }
.pad-col .pad-label #ctrl-power,
.pad-col .pad-label #ctrl-angle { color: var(--cyan); font-variant-numeric: tabular-nums; }
.pad-row .touch-btn[data-power],
.pad-row .touch-btn[data-angle] {
  font-weight: 700;
  letter-spacing: 0.02em;
}
.fire-col {
  width: clamp(88px, 22vw, 120px);
  align-items: stretch;
}
.move-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem;
}
.move-row .touch-btn { width: 100%; }

.touch-slider {
  width: 100%;
  height: 28px;
  accent-color: var(--cyan);
  touch-action: pan-x;
}

/* ===== RESULT / PROGRESS ===== */
.result-panel, .progress-panel {
  width: min(420px, 94vw);
  max-height: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 1.35rem 1.15rem;
  text-align: center;
}
.result-panel h2, .progress-panel h2 {
  font-family: var(--display);
  letter-spacing: 0.1em;
  margin-bottom: 0.85rem;
  font-size: 1.35rem;
}
.result-scores {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  margin-bottom: 0.85rem;
}
.result-scores strong {
  display: block;
  font-family: var(--display);
  font-size: 1.7rem;
  margin-top: 0.2rem;
}
.muted { color: var(--muted); font-size: 0.85rem; margin-bottom: 0.85rem; }
.progress-stats {
  text-align: left;
  background: #0b1422;
  border-radius: 10px;
  padding: 0.85rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  line-height: 1.55;
}
.progress-packs {
  display: grid;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
  text-align: left;
}
.pack-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  background: #0b1422;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
  font-size: 0.78rem;
}
.pack-row .lock { color: var(--orange); font-size: 0.68rem; white-space: nowrap; }
.pack-row .open { color: var(--green); font-size: 0.68rem; }


/* ===== All portrait — dock never under canvas ===== */
@media (orientation: portrait) {
  #screen-battle {
    flex-direction: column;
  }
  .canvas-wrap {
    flex: 1 1 auto;
    min-height: 0;
    max-height: 55dvh;
  }
  .battle-controls {
    flex: 0 0 auto;
    z-index: 50;
    pointer-events: auto;
    position: relative;
  }
  .touch-fire {
    position: relative;
    bottom: auto;
    z-index: 9;
    pointer-events: auto;
  }
}

/* ===== Portrait phones (SE / ~390) — build 46 dock ===== */
@media (max-width: 480px) and (orientation: portrait) {
  #screen-battle {
    flex-direction: column;
  }
  .canvas-wrap {
    flex: 1 1 auto;
    min-height: 0;
    max-height: 46dvh;
    overflow: hidden;
    /* Never steal taps meant for the dock */
    pointer-events: auto;
  }
  .battle-controls {
    flex: 0 0 auto;
    /* Prefer fitting controls over scroll-burying buttons */
    max-height: none;
    overflow-x: hidden;
    overflow-y: visible;
    padding: 0.4rem 0.5rem calc(0.75rem + var(--safe-b));
    z-index: 80;
    pointer-events: auto;
    position: relative;
    isolation: isolate;
  }
  .ctrl-top {
    gap: 0.25rem;
    position: relative;
    z-index: 10;
    pointer-events: auto;
  }
  .weapon-panel {
    flex-wrap: wrap;
    gap: 0.3rem;
    position: relative;
    z-index: 12;
  }
  .weapon-panel .touch-btn {
    min-width: 44px;
    min-height: 44px;
    flex: 0 0 auto;
  }
  button.weapon-info {
    flex: 1 1 140px;
    min-height: 44px;
    z-index: 12;
  }
  #btn-open-weapon-picker {
    min-width: 56px;
    min-height: 44px;
    z-index: 12;
  }
  .inv-strip {
    max-height: 42px;
    min-height: 36px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-right: 1.5rem;
    z-index: 11;
    position: relative;
    pointer-events: auto;
  }
  .inv-chip {
    min-height: 34px;
    max-height: 38px;
    font-size: 0.62rem;
    padding: 0.28rem 0.55rem;
    max-width: none;
    pointer-events: auto;
    z-index: 11;
  }
  .touch-dock {
    align-items: stretch;
    position: relative;
    z-index: 9;
  }
  .fire-col {
    width: clamp(96px, 28vw, 118px);
    order: 0;
  }
  .touch-fire {
    min-height: 64px;
    font-size: 1.05rem;
    /* No sticky — sticky covered weapon/chips when dock scrolled */
    position: relative;
    bottom: auto;
    z-index: 9;
    pointer-events: auto;
  }
  .pad-row .touch-btn {
    min-width: 40px;
    min-height: 42px;
    font-size: 0.9rem;
  }
  .hud-side .meta { display: none; }
  .shop-pool { grid-template-columns: 1fr 1fr; }
  .w-desc { display: none; }
  .practice-weapon-wrap {
    font-size: 0.72rem;
    width: 100%;
    z-index: 14;
    position: relative;
    pointer-events: auto;
  }
  .practice-weapon-btn {
    min-height: 48px;
    font-size: 0.9rem;
    width: 100%;
    z-index: 14;
  }
  /* Practice: drop redundant ‹ › — Weapon ▾ + Wpns + chips cover selection */
  .mode-practice #btn-prev-weapon,
  .mode-practice #btn-next-weapon {
    display: none;
  }
}

/* ===== iPad / tablets portrait — FIRE must work ===== */
@media (min-width: 600px) and (max-width: 1180px) and (orientation: portrait) {
  #screen-battle {
    flex-direction: column;
  }
  .canvas-wrap {
    flex: 1 1 auto;
    min-height: 0;
    max-height: 58dvh;
  }
  .battle-controls {
    flex: 0 0 auto;
    max-height: min(45dvh, 480px);
    width: 100%;
    padding: 0.55rem 0.75rem calc(0.7rem + var(--safe-b));
    z-index: 50;
    pointer-events: auto;
    position: relative;
    overflow-y: auto;
  }
  .touch-dock {
    grid-template-columns: 1fr minmax(140px, 200px) 1fr;
    gap: 0.6rem;
    align-items: end;
  }
  .fire-col { width: 100%; }
  .touch-fire {
    min-height: 76px;
    font-size: 1.25rem;
    letter-spacing: 0.16em;
  }
  .touch-btn { min-height: 52px; min-width: 52px; }
  .touch-slider { height: 32px; }
}

/* Very short screens (SE landscape or small height) */
@media (max-height: 500px) {
  .battle-controls {
    max-height: 54dvh;
    padding: 0.3rem 0.4rem calc(0.4rem + var(--safe-b));
    gap: 0.25rem;
    z-index: 30;
  }
  .touch-btn { min-height: 44px; min-width: 44px; }
  .touch-fire { min-height: 56px; }
  .touch-slider { height: 24px; }
  .inv-strip { display: none; }
  .w-desc { display: none; }
  .battle-hud { padding: 0.25rem 0.45rem; }
  .hud-side .score { font-size: 1.05rem; }
}

/* Landscape phones: side-by-side playfield + controls if wide enough */
@media (orientation: landscape) and (max-height: 500px) {
  #screen-battle {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .battle-hud {
    flex: 0 0 100%;
    order: 1;
  }
  .canvas-wrap {
    flex: 1 1 55%;
    order: 2;
    min-width: 0;
  }
  .battle-controls {
    flex: 0 0 min(42vw, 360px);
    order: 3;
    max-height: none;
    height: calc(100% - 0px);
    border-radius: 0;
    justify-content: center;
    overflow: auto;
  }
  .touch-dock {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }
  .fire-col {
    width: 100%;
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 0.35rem;
    align-items: stretch;
  }
  .fire-col .touch-fire { min-height: 56px; }
  .fire-col .move-row { align-content: center; }
}

/* Desktop / large tablets: slightly roomier dock, keep stacked bottom */
@media (min-width: 900px) and (min-height: 700px) {
  .battle-controls {
    margin: 0.4rem 0.6rem calc(0.6rem + var(--safe-b));
    border-radius: 14px;
    border: 1px solid var(--border);
    max-height: none;
    overflow: visible;
    z-index: 20;
  }
  .touch-dock { gap: 0.75rem; }
  .fire-col { width: 140px; }
  .touch-fire { min-height: 72px; }
  .hud-side .score { font-size: 1.5rem; }
  .hud-side .meta { display: block; font-size: 0.72rem; }
}

/* iPad landscape (often 1024–1366 wide, short height) — keep FIRE hittable */
@media (orientation: landscape) and (min-width: 768px) and (max-height: 900px) {
  .battle-controls {
    z-index: 30;
    pointer-events: auto;
    padding-bottom: calc(0.5rem + var(--safe-b));
  }
  .touch-fire { min-height: 64px; }
}

/* HP bars (owner deathmatch) */
.hp-bar {
  height: 7px;
  background: rgba(4, 8, 16, 0.35);
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 4px;
  overflow: hidden;
  margin: 3px 0 4px;
  max-width: 148px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.5);
}
.hud-side.p2 .hp-bar, .hud-side.p4 .hp-bar { margin-left: auto; }
.hp-fill {
  height: 100%;
  width: 100%;
  transition: width 0.2s ease-out;
}
.hp-fill.p1 { background: linear-gradient(90deg, #0ea5e9, #4ade80); }
.hp-fill.p2 { background: linear-gradient(90deg, #fb923c, #fbbf24); }
.hp-fill.p3 { background: linear-gradient(90deg, #a855f7, #e9d5ff); }
.hp-fill.p4 { background: linear-gradient(90deg, #22c55e, #86efac); }


/* Practice mode weapon picker trigger */
.practice-weapon-wrap {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.15rem 0.1rem 0.25rem;
  position: relative;
  z-index: 6;
  pointer-events: auto;
}
.practice-weapon-wrap[hidden] { display: none !important; }
.practice-weapon-wrap label {
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  font-weight: 600;
}
.practice-weapon-btn {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 44px;
  background: #0c1422;
  color: var(--text);
  border: 1px solid rgba(56,189,248,0.45);
  border-radius: 10px;
  padding: 0.45rem 0.65rem;
  font-size: 0.82rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  pointer-events: auto;
  position: relative;
  z-index: 6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.practice-weapon-btn .w-ico { width: 22px; height: 22px; flex-basis: 22px; }
.practice-weapon-btn .w-name-txt {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.practice-weapon-select-sync {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0,0,0,0) !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Weapon name is a tap target → opens picker */
button.weapon-info {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  font: inherit;
  flex: 1;
  min-width: 0;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  pointer-events: auto;
  padding: 0.15rem 0.35rem;
  border-radius: 8px;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
button.weapon-info:active {
  background: rgba(56,189,248,0.12);
  border-color: rgba(56,189,248,0.25);
}
#btn-open-weapon-picker {
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  min-width: 52px;
  font-weight: 800;
}

/* ===== Portrait-safe weapon picker sheet ===== */
.weapon-picker-sheet {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  pointer-events: auto;
  touch-action: manipulation;
  /* Body-level sheet — never trapped under #app / canvas */
}
.weapon-picker-sheet[hidden] { display: none !important; }
.weapon-picker-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(0, 4, 12, 0.72);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.weapon-picker-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-height: min(72dvh, 640px);
  border-radius: 18px 18px 0 0;
  border-bottom: none;
  display: flex;
  flex-direction: column;
  padding: 0.55rem 0.55rem calc(0.7rem + var(--safe-b));
  box-shadow: 0 -16px 48px rgba(0,0,0,0.55);
}
.weapon-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.15rem 0.25rem 0.45rem;
  flex: 0 0 auto;
}
.weapon-picker-head h2 {
  font-family: var(--display);
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  margin: 0;
}
.weapon-picker-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  padding: 0.15rem 0.1rem 0.4rem;
  touch-action: pan-y;
}
.weapon-picker-group {
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  padding: 0.45rem 0.35rem 0.15rem;
}
.weapon-picker-item {
  appearance: none;
  width: 100%;
  text-align: left;
  min-height: 48px;
  padding: 0.55rem 0.7rem;
  border-radius: 12px;
  border: 1px solid rgba(100,180,255,0.16);
  background: #0c1422;
  color: var(--text);
  font: 600 0.9rem var(--font);
  cursor: pointer;
  touch-action: manipulation;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.weapon-picker-item .wp-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
  flex: 1 1 auto;
}
.weapon-picker-item .wp-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.weapon-picker-item .meta {
  font-size: 0.68rem;
  color: var(--muted);
  font-weight: 600;
  flex: 0 0 auto;
}
.w-ico {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  object-fit: contain;
  pointer-events: none;
  display: block;
}
.weapon-picker-item.active {
  border-color: var(--cyan);
  background: #163048;
  box-shadow: 0 0 0 1px rgba(94,224,255,0.25);
}
.weapon-picker-item.elite {
  border-color: rgba(250,204,21,0.45);
  color: #fde68a;
  background: #2a1c08;
}
.weapon-picker-item:active { transform: scale(0.985); }

.inv-chip {
  pointer-events: auto;
  position: relative;
  z-index: 3;
}

/* Elite / Apex Edge marks */
.shop-card.elite {
  border-color: rgba(250,204,21,0.55);
  box-shadow: 0 0 0 1px rgba(250,204,21,0.2), 0 8px 28px rgba(250,204,21,0.12);
  background: linear-gradient(165deg, rgba(66,32,6,0.55), rgba(12,18,32,0.92));
}
.shop-card .elite-badge {
  position: absolute;
  top: 0.35rem;
  right: 0.4rem;
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #fde68a;
  background: rgba(120,53,15,0.85);
  border: 1px solid rgba(250,204,21,0.45);
  border-radius: 999px;
  padding: 0.12rem 0.4rem;
}
.shop-card { position: relative; }
.inv-chip.elite {
  border-color: rgba(250,204,21,0.55);
  color: #fde68a;
  background: #2a1c08;
}


/* Portrait: weapon picker + dock always reachable (build 46) */
@media (orientation: portrait) {
  .practice-weapon-btn { min-height: 48px; font-size: 0.9rem; }
  .battle-controls {
    z-index: 80 !important;
    pointer-events: auto !important;
  }
  .battle-controls .ctrl-top,
  .battle-controls .weapon-panel,
  .battle-controls .practice-weapon-wrap,
  .battle-controls #btn-open-weapon-picker,
  .battle-controls #btn-battle-settings,
  .battle-controls #btn-forfeit,
  .battle-controls button.weapon-info,
  .battle-controls .inv-chip,
  .battle-controls .touch-btn,
  .battle-controls .touch-fire,
  .battle-controls .touch-slider {
    pointer-events: auto !important;
    position: relative;
    z-index: 12;
  }
  .inv-strip {
    z-index: 11;
    position: relative;
    pointer-events: auto !important;
  }
  .weapon-picker-panel {
    max-height: min(78dvh, 720px);
    padding-bottom: calc(0.9rem + var(--safe-b));
  }
  .weapon-picker-item { min-height: 52px; }
  /* Canvas must not paint above dock hit targets */
  .canvas-wrap { z-index: 1; }
  #fx-overlay { pointer-events: none !important; }
}

/* ===== SETTINGS ===== */
.settings-panel {
  width: min(420px, 94vw);
  padding: 1.35rem 1.25rem 1.15rem;
  text-align: left;
}
.settings-panel h2 {
  margin: 0 0 0.2rem;
  font-family: var(--display, Orbitron, sans-serif);
  letter-spacing: 0.12em;
  font-size: 1.25rem;
  text-align: center;
}
.settings-sub {
  text-align: center;
  margin: 0 0 1.1rem;
  font-size: 0.78rem;
}
.settings-row {
  margin-bottom: 1rem;
}
.settings-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.4rem;
}
.settings-val {
  color: var(--cyan, #4fd1ff);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.settings-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, #0a1220, #1a2740);
  border: 1px solid var(--border);
  outline: none;
}
.settings-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(180deg, #7dd3fc, #0ea5e9);
  border: 2px solid rgba(255,255,255,0.35);
  box-shadow: 0 0 12px rgba(79,209,255,0.45);
  cursor: pointer;
}
.settings-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(180deg, #7dd3fc, #0ea5e9);
  border: 2px solid rgba(255,255,255,0.35);
  cursor: pointer;
}
.settings-mute-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.15rem 0.75rem;
  font-size: 0.85rem;
  color: var(--text);
}
a.settings-link {
  margin-bottom: 0.15rem;
  min-height: 44px;
  padding: 0.45rem 0.7rem;
  border-radius: 10px;
  text-decoration: none;
  color: #efe6d8;
  background: rgba(232, 214, 186, 0.06);
  border: 1px solid rgba(176, 148, 112, 0.35);
}
a.settings-link:hover,
a.settings-link:focus-visible {
  background: rgba(232, 214, 186, 0.14);
  color: #f7f1e7;
}
.settings-link-go {
  color: #c4b5a0;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.settings-toggle {
  min-width: 72px;
  min-height: 40px;
  padding: 0.35rem 0.85rem;
  font-size: 0.85rem;
  letter-spacing: 0.06em;
}
.settings-toggle[aria-pressed="true"] {
  background: linear-gradient(180deg, #7f1d1d, #450a0a);
  border-color: rgba(248,113,113,0.55);
  color: #fecaca;
  box-shadow: 0 0 14px rgba(239,68,68,0.25);
}
.settings-toggle-good[aria-pressed="true"] {
  background: linear-gradient(180deg, #0e7490, #155e75);
  border-color: rgba(94, 224, 255, 0.55);
  color: #ecfeff;
  box-shadow: 0 0 14px rgba(34, 211, 238, 0.28);
}
.settings-haptics-note {
  margin: -0.45rem 0 0.85rem;
  text-align: left;
}
#set-haptics-note[hidden] { display: none !important; }
.settings-hint {
  margin: 0.2rem 0 1rem;
  font-size: 0.72rem;
  text-align: center;
}
.settings-hint kbd {
  display: inline-block;
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: #0a1220;
  font-size: 0.7rem;
  font-family: inherit;
  color: var(--cyan, #4fd1ff);
}
.result-panel, .progress-panel, .settings-panel {
  margin: auto;
}

.build-stamp {
  margin-top: 0.45rem;
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #fde68a;
  font-family: var(--display);
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  background: rgba(251, 191, 36, 0.14);
  border: 1px solid rgba(251, 191, 36, 0.55);
  box-shadow: 0 0 18px rgba(251, 191, 36, 0.22);
}
.online-build-stamp {
  margin: 0 0 0.65rem;
  text-align: center;
  width: 100%;
}

/* Elite locked in draft (already holding 1★) */
.shop-card.elite-locked {
  opacity: 0.42;
  filter: grayscale(0.55);
  cursor: not-allowed;
  pointer-events: none;
  box-shadow: none;
}
.shop-card.elite-locked .elite-badge {
  background: rgba(40,40,48,0.9);
  color: #94a3b8;
  border-color: rgba(148,163,184,0.35);
}
.shop-inventories li.elite-inv {
  color: #fde68a;
  font-weight: 700;
}

/* Online 1v1 lobby (live) */
.btn.online-soon {
  position: relative;
  border-color: rgba(167,139,250,0.45);
  background: linear-gradient(165deg, rgba(76,29,149,0.35), rgba(12,18,32,0.92));
}
.soon-pill {
  display: inline-block;
  margin-left: 0.35rem;
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
  background: rgba(167,139,250,0.25);
  border: 1px solid rgba(167,139,250,0.45);
  color: #e9d5ff;
  vertical-align: middle;
}
.online-panel {
  width: min(440px, 94vw);
  padding: 1.35rem 1.25rem 1.15rem;
  text-align: left;
}
.online-col,
.online-room-codeblock { display: contents; }
.online-panel h2 {
  margin: 0 0 0.25rem;
  font-family: var(--display, Orbitron, sans-serif);
  letter-spacing: 0.12em;
  font-size: 1.25rem;
  text-align: center;
}
.online-sub {
  text-align: center;
  margin: 0 0 1rem;
  font-size: 0.78rem;
  line-height: 1.45;
}
.online-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--muted);
  background: rgba(15,23,42,0.65);
  border: 1px solid rgba(148,163,184,0.2);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  margin-bottom: 1rem;
}
.online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fbbf24;
  box-shadow: 0 0 8px rgba(251,191,36,0.7);
  flex-shrink: 0;
}
.online-room {
  text-align: center;
  margin-bottom: 1rem;
}
.online-room-label {
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.online-code {
  font-family: var(--display, Orbitron, sans-serif);
  font-size: 1.65rem;
  letter-spacing: 0.28em;
  color: #e9d5ff;
  margin-bottom: 0.65rem;
}
#btn-online-share {
  width: 100%;
  margin-top: 0.4rem;
}
#btn-online-share[hidden] { display: none !important; }
.app-handoff {
  position: fixed;
  z-index: 2147483600;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  background: rgba(4, 6, 12, 0.94);
}
.app-handoff-card {
  width: min(92vw, 420px);
  max-height: calc(100vh - 1.5rem);
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 1rem 0.95rem 0.9rem;
  border-radius: 16px;
  background: rgba(6, 12, 22, 0.96);
  border: 1px solid rgba(94, 224, 255, 0.35);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.45);
  text-align: center;
}
.app-handoff-title { margin: 0; font-size: 1rem; }
.app-handoff-code {
  margin: 0;
  font-family: var(--display, Orbitron, sans-serif);
  font-size: 1.7rem;
  letter-spacing: 0.28em;
  color: #e9d5ff;
}
.app-handoff-steps,
.app-handoff-note {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.35;
  color: var(--muted, #9fb0c3);
}
.app-handoff-card .btn { width: 100%; text-decoration: none; }
body:has(#app-handoff) .rotate-overlay { display: none !important; }
.online-join label {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.online-join-row {
  display: flex;
  gap: 0.45rem;
  margin-bottom: 1rem;
}
.online-join-row input {
  flex: 1;
  min-width: 0;
  background: #0c1422;
  color: var(--text);
  border: 1px solid rgba(167,139,250,0.4);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-align: center;
}
.online-notes {
  margin: 0 0 1rem;
  padding-left: 1.1rem;
  font-size: 0.76rem;
  color: var(--muted);
  line-height: 1.55;
}
.online-panel #btn-online-back {
  width: 100%;
}

.online-dot.kind-idle { background: #94a3b8; box-shadow: 0 0 8px rgba(148,163,184,0.5); }
.online-dot.kind-connecting { background: #fbbf24; box-shadow: 0 0 8px rgba(251,191,36,0.7); animation: onlinePulse 1s ease-in-out infinite; }
.online-dot.kind-waiting { background: #38bdf8; box-shadow: 0 0 8px rgba(56,189,248,0.75); animation: onlinePulse 1.4s ease-in-out infinite; }
.online-dot.kind-ready { background: #4ade80; box-shadow: 0 0 10px rgba(74,222,128,0.8); }
.online-dot.kind-error { background: #f87171; box-shadow: 0 0 8px rgba(248,113,113,0.7); }
@keyframes onlinePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.85); }
}
.online-phase {
  text-align: center;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #c4b5fd;
  margin: -0.35rem 0 0.65rem;
  min-height: 1em;
}
.online-players {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
}
.online-player {
  font-size: 0.8rem;
  padding: 0.4rem 0.55rem;
  border-radius: 8px;
  background: rgba(15,23,42,0.55);
  border: 1px solid rgba(148,163,184,0.18);
}
.online-player.empty { color: var(--muted); }
.online-player.in { border-color: rgba(74,222,128,0.35); color: #e2e8f0; }
.online-player.out { opacity: 0.65; }
#btn-online-leave {
  width: 100%;
  margin-bottom: 0.75rem;
}
.btn.danger {
  background: linear-gradient(165deg, rgba(127,29,29,0.55), rgba(12,18,32,0.92));
  border-color: rgba(248,113,113,0.45);
  color: #fecaca;
}
.soon-pill {
  background: rgba(74,222,128,0.2);
  border-color: rgba(74,222,128,0.45);
  color: #bbf7d0;
}


.shop-rule {
  margin: 0.15rem 0 0.45rem;
  font-size: 0.74rem;
  color: var(--muted);
  text-align: left;
}
.shop-rule strong { color: var(--cyan); font-weight: 600; }


/* ===== Build 46 — portrait / picker safety net ===== */
#weapon-picker-sheet {
  z-index: 10000 !important;
}
.mode-practice .practice-weapon-wrap {
  display: flex !important;
}
@media (orientation: portrait) and (max-width: 430px) {
  #screen-battle .battle-hud {
    flex: 0 0 auto;
    padding: 0.25rem 0.4rem;
  }
  #screen-battle .battle-controls {
    flex: 0 0 auto;
    max-height: none;
    overflow: visible;
  }
  #screen-battle .canvas-wrap {
    flex: 1 1 auto;
    max-height: 44dvh;
  }
}

/* ===== Build 51 — bulletproof online join code ===== */
#screen-online {
  overflow-y: auto !important;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 0.75rem max(0.75rem, var(--safe-r)) max(0.75rem, var(--safe-b)) max(0.75rem, var(--safe-l));
  touch-action: pan-y;
  pointer-events: auto !important;
  z-index: 20;
}
#screen-online.screen.active {
  display: flex !important;
  visibility: visible !important;
  pointer-events: auto !important;
}
#screen-online .online-panel {
  margin: auto;
  width: min(440px, 100%);
  max-width: 100%;
  pointer-events: auto !important;
  position: relative;
  z-index: 2;
  -webkit-user-select: text;
  user-select: text;
}
#online-join-block,
.online-join,
.online-join-row {
  pointer-events: auto !important;
  position: relative;
  z-index: 6;
  -webkit-user-select: text !important;
  user-select: text !important;
}
.online-join-hint {
  font-size: 0.72rem;
  color: #86efac;
  letter-spacing: 0.04em;
  margin: -0.15rem 0 0.4rem;
  min-height: 1.1em;
}
.online-join-hint.is-on { display: block !important; }
#online-join-code,
.online-code-input,
.online-join-row input {
  flex: 1;
  min-width: 0;
  min-height: 56px;
  width: 100%;
  background: #0c1422 !important;
  color: #f8fafc !important;
  border: 2px solid rgba(167,139,250,0.7) !important;
  border-radius: 12px;
  padding: 0.7rem 0.75rem;
  font-size: 18px; /* iOS: avoid focus zoom (>=16) */
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  text-align: center;
  user-select: text !important;
  -webkit-user-select: text !important;
  -webkit-touch-callout: default !important;
  pointer-events: auto !important;
  touch-action: manipulation !important;
  -webkit-appearance: none;
  appearance: none;
  caret-color: #c4b5fd;
  position: relative;
  z-index: 8;
  opacity: 1 !important;
}
#online-join-code:focus,
.online-code-input:focus,
#online-join-code.is-focused {
  outline: 3px solid rgba(134,239,172,0.9);
  outline-offset: 2px;
  border-color: #86efac !important;
  box-shadow: 0 0 0 4px rgba(134,239,172,0.2);
}
.online-code-ce {
  margin: 0.45rem 0 0.55rem;
  min-height: 48px;
  padding: 0.65rem 0.7rem;
  border-radius: 12px;
  border: 1px dashed rgba(167,139,250,0.45);
  background: rgba(12,20,34,0.85);
  color: #e9d5ff;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-align: center;
  text-transform: uppercase;
  -webkit-user-select: text !important;
  user-select: text !important;
  -webkit-touch-callout: default !important;
  pointer-events: auto !important;
  touch-action: manipulation !important;
  caret-color: #c4b5fd;
  outline: none;
}
.online-code-ce:empty:before {
  content: attr(data-placeholder);
  color: #64748b;
  letter-spacing: 0.08em;
  font-weight: 600;
  font-size: 0.85rem;
}
.online-code-ce:focus {
  border-style: solid;
  border-color: #86efac;
  outline: 2px solid rgba(134,239,172,0.7);
}
#btn-online-ready {
  width: 100%;
  margin-top: 10px;
}
.online-lock {
  position: static;
  inset: auto;
  z-index: auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  width: 100%;
  margin: 0.35rem 0 0;
  padding: 0;
  background: none;
  pointer-events: auto;
}
.online-lock[hidden] { display: none !important; }
.online-lock-copy { margin: 0; color: #9fb0c8; font-size: 0.72rem; line-height: 1.3; }
#btn-online-lock { width: 100%; min-height: 44px; font-size: 0.95rem; }
.online-dot.kind-ready { background: #4ade80; }


/* Online draft — waiting for opponent turn */
.shop-card.wait-turn {
  opacity: 0.55;
  filter: grayscale(0.25);
  cursor: not-allowed;
}


/* BUILD 59 — online draft Random Pick */
.shop-actions { flex-wrap: nowrap; align-items: stretch; z-index: 5; }
.shop-actions #btn-shop-random { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shop-actions .shop-random-one,
.shop-actions .shop-back { flex: 0 0 auto; width: auto; min-width: 64px; padding-left: 0.8rem; padding-right: 0.8rem; }
.shop-actions [hidden] { display: none !important; }
#btn-shop-random.online-random {
  font-weight: 700;
  letter-spacing: 0.02em;
  min-height: 56px;
  background: linear-gradient(135deg, #22d3ee, #6366f1);
  color: #fff;
  box-shadow: 0 0 18px rgba(34, 211, 238, 0.35);
}
#btn-shop-random.online-random.active {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.45);
  animation: iaRandPulse 0.9s ease-in-out infinite alternate;
}
@keyframes iaRandPulse { from { filter: brightness(1); } to { filter: brightness(1.18); } }
@media (max-width: 420px) {
  .shop-actions #btn-shop-random { font-size: 0.95rem; }
  .shop-actions .shop-random-one, .shop-actions .shop-back { min-width: 56px; padding-left: 0.55rem; padding-right: 0.55rem; font-size: 0.92rem; }
}

/* BUILD 59 — update banner + iOS install hint (safe-area aware) */
.ia-update-banner {
  position: fixed; left: 50%; transform: translateX(-50%);
  top: calc(var(--safe-t) + 8px); z-index: 9999;
  padding: 0.7rem 1.1rem; min-height: 44px; border-radius: 999px; border: 1px solid rgba(125,211,252,0.6);
  background: linear-gradient(135deg, #0ea5e9, #6366f1); color: #fff; font-weight: 700; font-size: 0.92rem;
  box-shadow: 0 6px 24px rgba(14,165,233,0.45); cursor: pointer;
}
.ia-install-hint {
  position: fixed; left: calc(var(--safe-l) + 10px); right: calc(var(--safe-r) + 10px);
  bottom: calc(var(--safe-b) + 10px); z-index: 9998;
  display: flex; align-items: center; gap: 0.6rem; padding: 0.7rem 0.8rem;
  border-radius: 14px; background: rgba(14,22,38,0.96); border: 1px solid rgba(125,211,252,0.4);
  color: #e2e8f0; font-size: 0.85rem; box-shadow: 0 8px 28px rgba(0,0,0,0.5);
}
.ia-install-hint span { flex: 1; }
.ia-install-hint button { min-width: 40px; min-height: 40px; border-radius: 10px; border: 0; background: rgba(255,255,255,0.08); color: #fff; font-size: 1rem; }

/* BUILD 59 — iOS home-screen (standalone, black-translucent): no white band under the app.
   Root canvas is dark, body is pinned to the full screen, and #app pads the safe areas. */
html { background-color: #04060c; }
@media (display-mode: standalone) {
  html, body { height: 100dvh; min-height: 100dvh; }
  body { position: fixed; inset: 0; }
  #app { height: 100%; min-height: 100dvh; }
}

/* =====================================================================
   BUILD 59 — battle layout: controls ALWAYS in a bottom dock (every orientation /
   size), HUD below the status bar, battlefield fills the space between. This block
   is last on purpose and overrides the older side-column breakpoints.
   ===================================================================== */
html body #screen-battle {
  flex-direction: column !important;
  align-items: stretch !important;
  justify-content: stretch !important;
  padding: var(--safe-t) var(--safe-r) 0 var(--safe-l) !important;
  display: none;
  grid-template-columns: none !important;
  grid-template-areas: none !important;
}
html body #screen-battle.active { display: flex !important; }
html body #screen-battle .battle-hud {
  flex: 0 0 auto !important;
  position: relative !important;
  inset: auto !important;
  width: auto !important;
  padding: 0.3rem 0.7rem !important;
}
html body #screen-battle .canvas-wrap {
  flex: 1 1 0 !important;
  min-height: 0 !important;
  width: auto !important;
  height: auto !important;
  position: relative !important;
  inset: auto !important;
  grid-area: auto !important;
  align-items: center !important;
  justify-content: center !important;
  background: linear-gradient(180deg, #060b16 0%, #070d1a 60%, #05080f 100%) !important;
}
html body #screen-battle .battle-controls {
  flex: 0 0 auto !important;
  position: relative !important;
  inset: auto !important;
  width: auto !important;
  max-width: none !important;
  height: auto !important;
  max-height: none !important;
  grid-area: auto !important;
  margin: 0 calc(-1 * var(--safe-r)) 0 calc(-1 * var(--safe-l)) !important;
  padding: 0.4rem calc(0.5rem + var(--safe-r)) calc(0.4rem + var(--safe-b)) calc(0.5rem + var(--safe-l)) !important;
  border-radius: 14px 14px 0 0 !important;
  border-left: 0 !important; border-right: 0 !important; border-bottom: 0 !important;
  overflow: visible !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 0.35rem !important;
  order: 3;
}
/* Condense duplicate weapon selectors: one weapon button (opens the picker) + ‹ › */
html body #screen-battle #btn-open-weapon-picker,
html body #screen-battle #practice-weapon-wrap,
html body #screen-battle #inv-strip { display: none !important; }
html body #screen-battle .ctrl-top { display: block !important; gap: 0 !important; }
html body #screen-battle .weapon-panel {
  display: flex !important;
  flex-wrap: nowrap !important;
  gap: 0.3rem !important;
  align-items: stretch !important;
}
html body #screen-battle .weapon-panel .touch-btn { flex: 0 0 44px !important; min-height: 42px !important; min-width: 0 !important; width: 44px !important; padding: 0 !important; }
html body #screen-battle .weapon-info {
  flex: 1 1 auto !important;
  min-height: 42px !important; min-width: 0 !important; width: auto !important;
  display: flex !important; flex-direction: column !important; justify-content: center !important;
  padding: 0.15rem 0.55rem !important; overflow: hidden !important;
}
html body #screen-battle .weapon-info .w-name { white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important; }
html body #screen-battle .weapon-info .w-desc { white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important; font-size: 0.66rem !important; }
html body #screen-battle .weapon-info .w-name::after { content: ' ▾'; opacity: 0.7; }

/* Dock grid — portrait default: [ANGLE | POWER] then [◀ FIRE ▶] */
html body #screen-battle .touch-dock {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
  grid-template-areas: "angle power" "fire fire" !important;
  gap: 0.35rem 0.5rem !important;
  width: 100% !important;
  flex-direction: unset !important;
}
html body #screen-battle .touch-dock > .pad-col { min-width: 0 !important; width: auto !important; display: flex !important; flex-direction: column !important; gap: 0.2rem !important; }
html body #screen-battle .touch-dock > .pad-col:first-child { grid-area: angle !important; }
html body #screen-battle .touch-dock > .pad-col:last-child { grid-area: power !important; }
html body #screen-battle .touch-dock > .fire-col {
  grid-area: fire !important;
  display: grid !important;
  grid-template-columns: 64px minmax(0, 1fr) 64px !important;
  gap: 0.4rem !important;
  align-items: stretch !important;
}
html body #screen-battle .fire-col .move-row { display: contents !important; }
html body #screen-battle #btn-move-left { grid-column: 1 !important; grid-row: 1 !important; width: 100% !important; min-height: 50px !important; }
html body #screen-battle #btn-fire { grid-column: 2 !important; grid-row: 1 !important; width: 100% !important; min-width: 0 !important; min-height: 50px !important; height: auto !important; margin: 0 !important; position: relative !important; inset: auto !important; transform: none !important; animation-name: none; }
html body #screen-battle #btn-move-right { grid-column: 3 !important; grid-row: 1 !important; width: 100% !important; min-height: 50px !important; }
html body #screen-battle .pad-row {
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  gap: 0.25rem !important;
}
html body #screen-battle .pad-row .touch-btn { min-height: 44px !important; min-width: 0 !important; width: 100% !important; padding: 0 !important; font-size: 0.95rem !important; }
html body #screen-battle .pad-label { font-size: 0.66rem !important; line-height: 1.1 !important; display: flex !important; justify-content: space-between !important; }
html body #screen-battle .touch-slider { width: 100% !important; margin: 0.15rem 0 0 !important; }

/* Portrait: battlefield sits right above the dock (sky fills above, no band below) */
@media (orientation: portrait) {
  html body #screen-battle .canvas-wrap { align-items: flex-end !important; }
}

/* Landscape / wide: ONE compact bottom row — [weapon] [ANGLE] [◀ FIRE ▶] [POWER] */
@media (orientation: landscape) {
  html body #screen-battle .battle-hud { padding: 0.2rem 0.7rem !important; }
  html body #screen-battle .battle-controls {
    display: grid !important;
    grid-template-columns: minmax(250px, 1.2fr) minmax(0, 3fr) !important;
    align-items: end !important;
    gap: 0.5rem !important;
    padding-top: 0.3rem !important;
  }
  html body #screen-battle .ctrl-top { align-self: end !important; }
  html body #screen-battle .weapon-panel { gap: 0.25rem !important; }
  html body #screen-battle .weapon-panel .touch-btn { flex: 0 0 38px !important; width: 38px !important; }
  html body #screen-battle .weapon-panel .touch-btn,
  html body #screen-battle .weapon-info { min-height: 44px !important; }
  html body #screen-battle .weapon-info .w-desc { display: none !important; }
  html body #screen-battle .touch-dock {
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.95fr) minmax(0, 1fr) !important;
    grid-template-areas: "angle fire power" !important;
    align-items: end !important;
  }
  html body #screen-battle .touch-dock > .fire-col { grid-template-columns: 38px minmax(0, 1fr) 38px !important; gap: 0.3rem !important; }
  html body #screen-battle .pad-row { gap: 0.2rem !important; }
  html body #screen-battle #btn-move-left,
  html body #screen-battle #btn-move-right,
  html body #screen-battle #btn-fire { min-height: 44px !important; }
  html body #screen-battle .touch-slider { display: none !important; }
  html body #screen-battle .pad-row .touch-btn { min-height: 44px !important; }
}
@media (orientation: landscape) and (max-height: 500px) {
  html body #screen-battle .hud-side .meta { display: none !important; }
  html body #screen-battle .hud-center .volley { display: none !important; }
}
/* Big screens (iPad / desktop): same bottom dock, comfortably sized + centered */
@media (orientation: landscape) and (min-width: 1000px) and (min-height: 600px) {
  html body #screen-battle .battle-controls { padding-left: max(1rem, calc((100% - 1180px) / 2)) !important; padding-right: max(1rem, calc((100% - 1180px) / 2)) !important; }
  html body #screen-battle .touch-slider { display: block !important; }
  html body #screen-battle .pad-row .touch-btn, html body #screen-battle #btn-fire { min-height: 50px !important; }
}
html body #screen-battle #btn-move-left, html body #screen-battle #btn-move-right { min-width: 0 !important; max-width: none !important; padding: 0 !important; }
/* BUILD 59 — ONE in-match weapon selector: the WEAPON dropdown (opens the bottom-sheet picker).
   No chip row, no Wpns button, no ‹ › arrows, no duplicate name label. */
html body #screen-battle #btn-prev-weapon,
html body #screen-battle #btn-next-weapon,
html body #screen-battle #btn-open-weapon-picker,
html body #screen-battle #inv-strip,
html body #screen-battle #practice-weapon-wrap,
html body #screen-battle .weapon-info .w-desc { display: none !important; }
html body #screen-battle .weapon-info {
  display: flex !important; flex-direction: row !important; align-items: center !important; gap: 0.45rem !important;
  border: 1px solid rgba(94, 224, 255, 0.45) !important; border-radius: 12px !important;
  background: rgba(8, 18, 34, 0.92) !important;
}
html body #screen-battle .weapon-info::before {
  content: 'WEAPON'; flex: 0 0 auto; font-size: 0.6rem; letter-spacing: 0.1em; color: var(--muted);
}
html body #screen-battle .weapon-info .w-name { flex: 1 1 auto; min-width: 0; font-weight: 700 !important; font-size: 0.95rem !important; }
html body #screen-battle .weapon-info > .w-ico { width: 22px; height: 22px; flex: 0 0 22px; }
html body #screen-battle #game-canvas { max-width: none !important; max-height: none !important; flex: 0 0 auto !important; }
html body #screen-battle .canvas-wrap { align-items: flex-end !important; }
html body #screen-battle .canvas-wrap { max-height: none !important; }

/* =====================================================================
   BUILD 60 — LANDSCAPE ONLY + full-bleed battlefield.
   Canvas spans the whole viewport width (under the notch / side safe areas);
   only HUD text and dock buttons are kept inside env(safe-area-inset-*).
   ===================================================================== */
html body #screen-battle {
  padding: 0 !important;
  background: #03060c !important;
}
html body #screen-battle .battle-hud {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: auto !important;
  z-index: 8 !important;
  margin: 0 !important;
  border-radius: 0 !important;
  border: 0 !important;
  padding: calc(0.18rem + var(--safe-t)) calc(0.7rem + var(--safe-r)) 0.28rem calc(0.7rem + var(--safe-l)) !important;
  gap: 0.1rem 0.6rem !important;
  max-width: none !important;
  background: linear-gradient(180deg, rgba(3, 6, 12, 0.2), rgba(3, 6, 12, 0.04) 62%, rgba(3, 6, 12, 0)) !important;
  box-shadow: none !important;
  pointer-events: none !important;
}
html body #screen-battle .hud-side .name,
html body #screen-battle .hud-side .score,
html body #screen-battle .hud-side .meta,
html body #screen-battle .turn-banner,
html body #screen-battle .wind,
html body #screen-battle .volley {
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.92), 0 0 8px rgba(0, 0, 0, 0.72);
}
html body #screen-battle .hud-side .meta,
html body #screen-battle .hud-center .volley { display: none !important; }
html body #screen-battle .hud-side .name { font-size: 0.58rem !important; line-height: 1.05 !important; }
html body #screen-battle .hud-side .score { font-size: 0.9rem !important; line-height: 1.05 !important; }
html body #screen-battle .hud-side .hp-bar { height: 5px !important; margin: 2px 0 !important; }
html body #screen-battle .hud-center .turn-banner { font-size: 0.78rem !important; line-height: 1.1 !important; }
html body #screen-battle .hud-center .wind { font-size: 0.6rem !important; line-height: 1.1 !important; }
html body #screen-battle #hud-wind.wind-flip {
  animation: wind-shift-right 0.95s ease-out;
  color: #bae6fd;
}
html body #screen-battle #hud-wind.wind-flip[data-wind="left"] {
  animation-name: wind-shift-left;
}
@keyframes wind-shift-right {
  0% { transform: translateX(-12px); opacity: 0.4; }
  38% { transform: translateX(5px); opacity: 1; }
  100% { transform: none; opacity: 1; }
}
@keyframes wind-shift-left {
  0% { transform: translateX(12px); opacity: 0.4; }
  38% { transform: translateX(-5px); opacity: 1; }
  100% { transform: none; opacity: 1; }
}
html body #screen-battle .canvas-wrap {
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  width: 100% !important;
  align-items: stretch !important;
  justify-content: stretch !important;
  background: #05080f !important;
}
html body #screen-battle #game-canvas {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}
html body #screen-battle .battle-controls {
  margin: 0 !important;
  border-radius: 0 !important;
  border: 0 !important;
  border-top: 1px solid rgba(100,180,255,0.16) !important;
  box-shadow: 0 -6px 18px rgba(0,0,0,0.35) !important;
  padding: 0.3rem calc(0.6rem + var(--safe-r)) calc(0.3rem + var(--safe-b)) calc(0.6rem + var(--safe-l)) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  background: linear-gradient(180deg, rgba(10,16,28,0.97), rgba(6,10,18,0.99)) !important;
}
@media (orientation: landscape) and (max-height: 500px) {
  html body #screen-battle .pad-label { font-size: 0.6rem !important; }
  html body #screen-battle .pad-row .touch-btn,
  html body #screen-battle #btn-fire,
  html body #screen-battle #btn-move-left,
  html body #screen-battle #btn-move-right,
  html body #screen-battle .weapon-info,
  html body #screen-battle .weapon-panel .touch-btn { min-height: 42px !important; }
}

/* Rotate gate — CSS, not JS, so a portrait phone still sees it if the script fails to load.
   Landscape always wins, so a stuck class cannot leave the menu buttons dead. */
.rotate-overlay {
  position: fixed; inset: 0; z-index: 2147483000;
  display: none; align-items: center; justify-content: center;
  background: radial-gradient(700px 500px at 50% 30%, #0e1a30 0%, #04060c 70%);
  color: var(--text, #eef3fb);
  padding: calc(1.5rem + var(--safe-t)) 1.5rem calc(1.5rem + var(--safe-b));
  touch-action: none;
  pointer-events: none;
}
.rotate-card { text-align: center; max-width: 320px; }
.rotate-stage { width: 200px; height: 200px; margin: 0 auto 1rem; display: grid; place-items: center; }
.rotate-icon { width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 0 10px rgba(94,224,255,0.35)); }
.rotate-arrow {
  fill: none; stroke: #5ee0ff; stroke-width: 5; stroke-linecap: round;
  transform-box: view-box; transform-origin: 60px 60px;
  animation: ia-rotate-arrow 2.6s ease-in-out infinite;
}
.rotate-phone { transform-box: view-box; transform-origin: 60px 60px; animation: ia-rotate-phone 2.6s ease-in-out infinite; }
.rotate-phone-body { fill: #141c28; stroke: #cfe6ff; stroke-width: 3.5; }
@keyframes ia-rotate-phone { 0%, 18% { transform: rotate(0deg); } 52%, 78% { transform: rotate(-90deg); } 96%, 100% { transform: rotate(0deg); } }
@keyframes ia-rotate-arrow {
  0%, 12% { transform: rotate(12deg); opacity: 0.55; }
  50%, 80% { transform: rotate(-14deg); opacity: 1; }
  100% { transform: rotate(12deg); opacity: 0.55; }
}
@media (prefers-reduced-motion: reduce) {
  .rotate-phone, .rotate-arrow { animation: none; }
  .rotate-phone { transform: rotate(-45deg); }
}
.rotate-title { font-family: var(--display, sans-serif); font-size: 1.15rem; letter-spacing: 0.06em; margin-bottom: 0.5rem; }
.rotate-sub { color: var(--muted, #7a8ba8); font-size: 0.85rem; }
.rotate-install { margin-top: 1rem; width: 100%; min-height: 48px; }
.rotate-install-note { margin: 0.7rem 0 0; color: #dbeafe; font-size: 0.82rem; line-height: 1.35; }
@media (orientation: portrait) {
  .rotate-overlay { display: flex !important; pointer-events: auto; }
  html #app { pointer-events: none !important; }
  .ia-install-hint, .ia-update-banner { display: none !important; }
}
@media (orientation: landscape) {
  .rotate-overlay { display: none !important; pointer-events: none !important; }
  html #app { pointer-events: auto !important; }
}

/* BUILD 60 — landscape phone layouts for menu / online lobby / panels (no clipping). */
@media (orientation: landscape) and (max-height: 560px) {
  .screen:not(#screen-battle) { padding: max(0.4rem, var(--safe-t)) calc(0.6rem + var(--safe-r)) calc(0.4rem + var(--safe-b)) calc(0.6rem + var(--safe-l)) !important; }
  .menu-panel, .online-panel, .settings-panel, .progress-panel, .result-panel, .screen > .glass {
    max-height: 100% !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  /* Online lobby: status/room on the left, join field on the right. The phone keyboard types the code. */
  html body #screen-online .online-panel {
    display: grid !important;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr) !important;
    column-gap: 1rem !important;
    row-gap: 0.3rem !important;
    align-content: start !important;
    width: min(100%, 860px) !important;
    max-width: 860px !important;
    padding: 0.6rem 0.9rem !important;
  }
  html body #screen-online .online-panel > *,
  html body #screen-online .online-col > * { grid-column: 1; margin-top: 0 !important; margin-bottom: 0 !important; min-width: 0 !important; }
  html body #screen-online .online-map-chip { min-width: 0 !important; overflow: hidden !important; white-space: normal !important; }
  html body #screen-online .online-panel > h2 { font-size: 1.1rem !important; }
  html body #screen-online .online-sub { font-size: 0.7rem !important; }
  html body #screen-online .online-notes { display: none !important; }
  html body #screen-online .online-panel .btn { min-height: 44px !important; padding-top: 0.4rem !important; padding-bottom: 0.4rem !important; }
  html body #screen-online .online-code { font-size: 1.3rem !important; margin: 0.1rem 0 0.3rem !important; }
  html body #screen-online .online-join { grid-column: 2 !important; grid-row: 1 / span 4 !important; align-self: start; margin: 0 !important; }
  html body #screen-online .online-map,
  html body #screen-online .online-room,
  html body #screen-online #btn-online-back,
  html body #screen-online #btn-online-leave,
  html body #screen-online #btn-online-ready { grid-column: 1 / -1 !important; }
  html body #screen-online .online-join-row .btn, html body #screen-online .online-code-input { min-height: 42px !important; }
  html body #screen-online .online-code-ce { min-height: 34px !important; margin: 0.3rem 0 !important; padding: 0.35rem !important; }
}
@media (orientation: landscape) and (max-height: 560px) {
  html body #screen-online .online-join-row { display: grid !important; grid-template-columns: minmax(0, 1fr) auto auto !important; gap: 0.4rem !important; }
  html body #screen-online .online-code-input { width: 100% !important; min-width: 0 !important; }
  html body #screen-online .online-phase:empty { display: none !important; }
}
html body #screen-battle .hud-side.p2,
html body #screen-battle .hud-side.p4 { text-align: right !important; }
html body #screen-battle .hud-side.p2 .hp-bar,
html body #screen-battle .hud-side.p4 .hp-bar { margin-left: auto !important; }
html body #screen-battle.roster-3 .battle-hud { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto minmax(0, 1fr) !important; }
html body #screen-battle.roster-4 .battle-hud { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto minmax(0, 1fr) minmax(0, 1fr) !important; }
html body #screen-battle:not(.roster-3):not(.roster-4) .hud-side.p3,
html body #screen-battle:not(.roster-3):not(.roster-4) .hud-side.p4 { display: none !important; }
html body #screen-battle.roster-3 .hud-side .score,
html body #screen-battle.roster-4 .hud-side .score { font-size: 0.95rem !important; }
@media (orientation: landscape) and (max-height: 560px) {
  /* Draft: header / scrolling pool / compact picks / action bar — nothing overlaps */
  html body #screen-shop .shop-wrap {
    display: flex !important; flex-direction: column !important;
    width: min(100%, 980px) !important; max-width: 980px !important;
    height: 100% !important; max-height: 100% !important;
    overflow: hidden !important; padding: 0.45rem 0.7rem !important; gap: 0.3rem !important;
  }
  html body #screen-shop .shop-header { flex: 0 0 auto !important; flex-wrap: wrap !important; gap: 0.2rem 0.8rem !important; margin: 0 !important; }
  html body #screen-shop .shop-header h2 { font-size: 1rem !important; }
  html body #screen-shop .shop-scores { font-size: 0.68rem !important; flex-wrap: wrap !important; gap: 0.15rem 0.6rem !important; margin-left: auto !important; }
  html body #screen-shop .shop-rule { flex: 0 0 auto !important; margin: 0 !important; font-size: 0.66rem !important; }
  html body #screen-shop .shop-pool { flex: 1 1 auto !important; min-height: 0 !important; overflow-y: auto !important; max-height: none !important; padding-bottom: 0.2rem !important; }
  html body #screen-shop .shop-inventories { flex: 0 0 auto !important; max-height: 52px !important; overflow-y: auto !important; margin: 0 !important; font-size: 0.68rem !important; }
  html body #screen-shop .shop-inventories h3 { font-size: 0.66rem !important; margin: 0 !important; }
  html body #screen-shop .shop-actions { flex: 0 0 auto !important; position: static !important; inset: auto !important; margin: 0 !important; padding: 0 !important; box-shadow: none !important; background: none !important; }
  html body #screen-shop .shop-actions .btn { min-height: 44px !important; padding-top: 0.35rem !important; padding-bottom: 0.35rem !important; }
}
/* Narrow landscape phones (iPhone SE / mini): tighter battle dock so FIRE never overlaps */
@media (orientation: landscape) and (max-width: 760px) {
  html body #screen-battle .battle-controls { grid-template-columns: minmax(150px, 0.9fr) minmax(0, 3fr) !important; gap: 0.35rem !important; padding-left: calc(0.4rem + var(--safe-l)) !important; padding-right: calc(0.4rem + var(--safe-r)) !important; }
  html body #screen-battle .weapon-info::before { display: none !important; }
  html body #screen-battle .weapon-panel .touch-btn { flex: 0 0 36px !important; width: 36px !important; }
  html body #screen-battle .touch-dock { gap: 0.3rem !important; grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr) minmax(0, 1fr) !important; }
  html body #screen-battle .touch-dock > .fire-col { grid-template-columns: 32px minmax(0, 1fr) 32px !important; gap: 0.2rem !important; }
  html body #screen-battle .pad-row { gap: 0.15rem !important; }
  html body #screen-battle .pad-row .touch-btn { font-size: 0.85rem !important; }
  html body #screen-battle #btn-fire { font-size: 0.95rem !important; letter-spacing: 0.04em !important; padding: 0 !important; }
}

/* BUILD 61 — sound status / toast / debug */
.settings-sound-row { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; }
.settings-sound-state { font-size: 0.85rem; }
.ia-sound-toast {
  position: fixed; z-index: 2147482000;
  left: 50%; transform: translateX(-50%);
  top: calc(3.2rem + var(--safe-t));
  padding: 0.65rem 1.1rem; min-height: 44px;
  border-radius: 999px; border: 1px solid rgba(94,224,255,0.55);
  background: rgba(8,18,34,0.95); color: #eef3fb; font: 600 0.95rem var(--font, sans-serif);
  box-shadow: 0 8px 28px rgba(0,0,0,0.5);
}
.ia-sound-toast[hidden] { display: none !important; }
.ia-audio-debug {
  position: fixed; z-index: 2147482500; left: calc(4px + var(--safe-l)); top: calc(4px + var(--safe-t));
  max-width: 60vw; padding: 4px 6px; border-radius: 6px;
  background: rgba(0,0,0,0.75); color: #9ef; font: 10px/1.3 ui-monospace, Menlo, monospace;
  pointer-events: none; white-space: normal;
}
.ia-audio-debug[hidden] { display: none !important; }

/* =====================================================================
   BUILD 61 — landscape dock relayout (844x390 / 667x375, notch insets included):
   value sits next to its label (centered over its pad group, never drifting over FIRE),
   weapon name wraps to 2 lines instead of truncating, compact icon buttons.
   ===================================================================== */
@media (orientation: landscape) and (max-height: 560px) {
  html body #screen-battle .pad-label { justify-content: center !important; gap: 0.4em !important; font-size: 0.62rem !important; line-height: 1.1 !important; }
  html body #screen-battle .pad-label #ctrl-angle,
  html body #screen-battle .pad-label #ctrl-power { font-size: 0.72rem !important; font-weight: 800 !important; }
  html body #screen-battle .weapon-info::before { display: none !important; }
  html body #screen-battle .weapon-info { padding: 0.2rem 0.5rem !important; min-width: 0 !important; justify-content: flex-start !important; }
  html body #screen-battle .weapon-info .w-name {
    font-size: 0.8rem !important; line-height: 1.08 !important; text-align: left !important;
    white-space: normal !important; overflow: hidden !important; text-overflow: clip !important;
    display: -webkit-box !important; -webkit-box-orient: vertical !important; -webkit-line-clamp: 2 !important;
    overflow-wrap: anywhere;
  }
  html body #screen-battle .weapon-panel { gap: 0.25rem !important; }
  html body #screen-battle .weapon-panel .touch-btn { flex: 0 0 34px !important; width: 34px !important; min-width: 34px !important; padding: 0 !important; }
  html body #screen-battle .touch-dock { gap: 0.35rem !important; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) !important; }
  html body #screen-battle .touch-dock > .fire-col { width: auto !important; display: grid !important; grid-template-columns: 30px minmax(64px, 84px) 30px !important; gap: 0.2rem !important; align-items: stretch !important; }
  html body #screen-battle .touch-dock > .fire-col .move-row { display: contents !important; }
  html body #screen-battle .touch-dock > .fire-col #btn-move-left { grid-column: 1; grid-row: 1; }
  html body #screen-battle .touch-dock > .fire-col #btn-fire { grid-column: 2; grid-row: 1; font-size: 0.95rem !important; letter-spacing: 0.05em !important; padding: 0 !important; }
  html body #screen-battle .touch-dock > .fire-col #btn-move-right { grid-column: 3; grid-row: 1; }
  html body #screen-battle .pad-row { gap: 0.18rem !important; }
  html body #screen-battle .pad-row .touch-btn { min-width: 0 !important; padding: 0 !important; font-size: 0.85rem !important; }
}

/* BUILD 61 — online lobby, landscape phones: two columns, no scrolling at 844x390. */
@media (orientation: landscape) and (max-height: 560px) {
  html body #screen-online .online-panel { overflow: hidden !important; row-gap: 0.28rem !important; padding: 0.5rem 0.9rem !important; align-content: center !important; }
  html body #screen-online .online-panel > h2 { grid-row: 1; justify-self: start; text-align: left !important; font-size: 1.02rem !important; line-height: 1.2 !important; }
  html body #screen-online .online-build-stamp { grid-row: 1; justify-self: end; align-self: center; width: auto !important; max-width: 45% !important; display: inline-block !important; padding: 0.12rem 0.6rem !important; margin: 0 !important; transform: scale(0.85); transform-origin: right center; }
  html body #screen-online .online-sub { display: none !important; }
  html body #screen-online .online-status { min-height: 0 !important; padding: 0.3rem 0.55rem !important; font-size: 0.74rem !important; }
  html body #screen-online .online-players { display: grid !important; grid-template-columns: 1fr 1fr !important; gap: 0.3rem !important; }
  html body #screen-online .online-player { min-height: 0 !important; padding: 0.3rem 0.5rem !important; font-size: 0.74rem !important; margin: 0 !important; }
  html body #screen-online .online-room-label { font-size: 0.6rem !important; margin: 0 !important; }
  html body #screen-online .online-code { font-size: 1.15rem !important; margin: 0 0 0.25rem !important; line-height: 1.2 !important; }
  html body #screen-online .online-phase { font-size: 0.66rem !important; }
  html body #screen-online .online-panel .btn { min-height: 42px !important; }
  html body #screen-online .online-panel:has(#btn-online-leave:not([hidden])) #btn-online-create { display: none !important; }
  html body #screen-online #btn-online-share { margin-top: 0.2rem !important; min-height: 40px !important; }
  html body #screen-online .online-join label { font-size: 0.62rem !important; }
  html body #screen-online .online-join-hint { font-size: 0.62rem !important; margin: 0 0 0.35rem !important; line-height: 1.2 !important; }
}

/* BUILD 61 — big landscape screens (1280x800 / iPad): menu + lobby use the width. */
@media (orientation: landscape) and (min-width: 900px) and (min-height: 561px) {
  html body #screen-online .online-panel {
    display: grid !important;
    grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr) !important;
    column-gap: 2rem !important; row-gap: 0.55rem !important;
    align-content: center !important;
    width: min(94vw, 1100px) !important; max-width: 1100px !important;
    max-height: 100% !important; overflow-y: auto !important;
    padding: 1.4rem 1.8rem !important;
  }
  html body #screen-online .online-panel > *,
  html body #screen-online .online-col > * { grid-column: 1; margin-top: 0 !important; margin-bottom: 0 !important; min-width: 0 !important; }
  html body #screen-online .online-map-chip { min-width: 0 !important; overflow: hidden !important; white-space: normal !important; }
  html body #screen-online .online-notes { display: none !important; }
  html body #screen-online .online-join { grid-column: 2 !important; grid-row: 1 / span 6 !important; align-self: start; margin: 0 !important; }
  html body #screen-online .online-map,
  html body #screen-online .online-room,
  html body #screen-online #btn-online-back,
  html body #screen-online #btn-online-leave,
  html body #screen-online #btn-online-ready { grid-column: 1 / -1 !important; }
  html body #screen-online .online-join-row { display: grid !important; grid-template-columns: minmax(0, 1fr) auto auto !important; gap: 0.6rem !important; }
  html body #screen-online .online-code-input { width: 100% !important; min-width: 0 !important; min-height: 56px !important; }
  html body #screen-online .online-join-row .btn { min-height: 56px !important; }
  html body #screen-online .online-panel:has(#btn-online-leave:not([hidden])) #btn-online-create { display: none !important; }
}

/* BUILD 68 — host-only online map picker (lobby + online draft). */
.online-map { margin: 0 0 0.8rem; }
.online-map-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.35rem; }
.online-map-note { font-size: 0.68rem; color: var(--muted); }
.online-map-chips { display: grid; grid-template-columns: repeat(auto-fit, minmax(5.6rem, 1fr)); gap: 0.3rem; }
.online-map-chip {
  min-height: 40px; padding: 0.3rem 0.2rem; border-radius: 10px;
  border: 1px solid var(--border); background: rgba(12, 22, 40, 0.8); color: var(--text);
  font: 600 0.74rem/1.1 var(--font); letter-spacing: 0.02em; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  touch-action: manipulation;
}
.online-map-chip:hover:not(:disabled) { border-color: rgba(94, 224, 255, 0.5); }
.online-map-chip.active {
  border-color: var(--cyan); background: linear-gradient(180deg, rgba(94, 224, 255, 0.28), rgba(94, 224, 255, 0.1));
  box-shadow: 0 0 12px rgba(94, 224, 255, 0.35); color: #fff;
}
.online-map-chip:disabled { cursor: default; opacity: 0.45; }
.online-map-chip.active:disabled { opacity: 1; }
.shop-map { margin: 0.2rem 0 0.5rem; }
@media (orientation: landscape) and (max-height: 560px) {
  html body #screen-online .online-map { margin: 0 !important; }
  html body #screen-online .online-map-head { margin-bottom: 0.15rem; }
  html body #screen-online .online-map-chip { min-height: 32px !important; font-size: 0.66rem !important; padding: 0.15rem !important; }
  html body #screen-shop .shop-map { margin: 0.1rem 0 0.25rem !important; }
  html body #screen-shop .online-map-chip { min-height: 30px !important; font-size: 0.64rem !important; }
}

/* BUILD 70 — progression: unlock bar, pack contents, locked map chips, result unlock notice. */
.progress-line { display: flex; gap: 1rem; flex-wrap: wrap; }
.progress-next { margin-top: 0.55rem; }
.progress-next-label { font-size: 0.8rem; color: #c8d4e6; }
.progress-bar { height: 8px; border-radius: 999px; background: #16233a; overflow: hidden; margin: 0.35rem 0 0.3rem; }
.progress-bar > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #22d3ee, #a855f7); box-shadow: 0 0 10px rgba(34, 211, 238, 0.55); }
.progress-rule { font-size: 0.7rem; color: #8b9bb4; }
.progress-rule strong { color: var(--cyan); }
.pack-head { color: #8b9bb4; font-size: 0.72rem; margin: 0.4rem 0 0.2rem; letter-spacing: 0.06em; text-transform: uppercase; }
.pack-main { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.pack-sub { color: #8b9bb4; font-size: 0.68rem; line-height: 1.35; }
.pack-row.locked .pack-name { color: #9aa7bb; }
.online-map-chip.locked,
.online-map-chip.unavailable { opacity: 0.4; border-style: dashed; }
.online-map-chip.locked::after { content: ' · locked'; font-size: 0.8em; }
#opt-map option:disabled { color: #6b778a; }
.result-unlock {
  margin: 0.2rem auto 0.7rem; padding: 0.45rem 0.7rem; border-radius: 8px; max-width: 30rem;
  font-family: var(--display); font-size: 0.78rem; letter-spacing: 0.08em; color: #0b1422;
  background: linear-gradient(90deg, #22d3ee, #a855f7); box-shadow: 0 0 18px rgba(168, 85, 247, 0.45);
}
@media (max-height: 560px) and (orientation: landscape) {
  .progress-next { margin-top: 0.35rem; }
  .pack-sub { font-size: 0.62rem; }
  .online-map-chip.locked::after { content: ''; }
}

/* =====================================================================
   BUILD 71 — main menu: animated battlefield backdrop, title-slam intro,
   four mode cards, one compact setup bar, corner utilities.
   ===================================================================== */
#screen-menu { padding: 0 !important; background: #040712; }
.menu-fx { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.menu-flash {
  position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(60% 50% at 50% 26%, rgba(255,240,215,0.85), rgba(255,140,70,0.25) 45%, transparent 75%);
}
.menu-v2 {
  position: relative; z-index: 1;
  width: min(100%, 980px); height: 100%;
  display: grid; grid-template-rows: 1fr auto auto; gap: clamp(0.5rem, 2.6vh, 1.2rem);
  padding: 0.7rem 1rem 0.8rem;
  align-content: center;
}
.mv-hero { align-self: end; text-align: center; }
.mv-title {
  font-family: var(--display); font-weight: 700; line-height: 0.95;
  font-size: clamp(2.2rem, 13vh, 4.6rem); letter-spacing: 0.14em;
  display: inline-flex; gap: 0.32em; padding-left: 0.14em;
}
.mv-word {
  display: inline-block;
  background: linear-gradient(100deg, #ffffff 0%, #c7f3ff 30%, #5ee0ff 48%, #ffffff 52%, #c7f3ff 70%, #ffffff 100%);
  background-size: 260% 100%; background-position: 100% 0;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 18px rgba(94,224,255,0.35)) drop-shadow(0 4px 0 rgba(0,0,0,0.5));
  animation: mv-sheen 7s ease-in-out 3s infinite;
}
.mv-word-b {
  background-image: linear-gradient(100deg, #fff2e0 0%, #ffc58a 30%, #ff9a4a 48%, #fff7ec 52%, #ffc58a 70%, #fff2e0 100%);
  filter: drop-shadow(0 0 18px rgba(255,154,74,0.35)) drop-shadow(0 4px 0 rgba(0,0,0,0.5));
}
.mv-tag {
  margin-top: 0.45rem; display: flex; align-items: center; justify-content: center; gap: 0.6rem;
  color: #a9b7cf; font-size: 0.7rem; letter-spacing: 0.32em; text-transform: uppercase;
}
.mv-tag .build-stamp { margin: 0; font-size: 0.6rem; padding: 0.18rem 0.55rem; letter-spacing: 0.16em; }

.mv-util { position: absolute; z-index: 2; top: 0.6rem; right: 0.8rem; display: flex; gap: 0.45rem; }
.mv-util-btn {
  position: relative; display: inline-flex; align-items: center; gap: 0.4rem;
  min-height: 40px; padding: 0 0.85rem; border-radius: 999px; cursor: pointer;
  border: 1px solid rgba(148,180,220,0.25); background: rgba(8,14,28,0.55);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  color: #c8d4e6; font: 600 0.78rem var(--font); letter-spacing: 0.04em;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.mv-util-btn svg { width: 16px; height: 16px; fill: currentColor; }
.mv-util-btn:hover { border-color: rgba(94,224,255,0.55); color: #fff; }
.mv-util-btn:active { transform: scale(0.96); }
.mv-util-btn.has-claim { color: #fde68a; border-color: rgba(251,191,36,0.7); box-shadow: 0 0 18px rgba(251,191,36,0.35); animation: mv-claim-glow 1.6s ease-in-out infinite; }
.claim-badge {
  position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px;
  display: grid; place-items: center; border-radius: 999px;
  background: #f59e0b; color: #1a1000; font: 800 0.7rem var(--font);
  box-shadow: 0 0 0 2px #040712, 0 0 12px rgba(245,158,11,0.8);
}
.claim-badge[hidden] { display: none; }

.mv-modes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(0.45rem, 1.4vw, 0.8rem); }
.mv-mode {
  position: relative; overflow: hidden; cursor: pointer; text-align: left;
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 0.6rem; align-items: center;
  min-height: clamp(62px, 19vh, 92px); padding: 0.7rem 0.85rem; border-radius: 14px;
  border: 1px solid rgba(148,180,220,0.2);
  background: linear-gradient(160deg, rgba(22,34,58,0.82), rgba(8,12,24,0.88));
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  color: var(--text); font-family: var(--font);
  box-shadow: 0 10px 28px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.06);
  transition: transform 0.12s, border-color 0.15s, box-shadow 0.15s;
  touch-action: manipulation;
}
.mv-mode::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,0.09) 50%, transparent 70%);
  transform: translateX(-120%); transition: transform 0.5s;
}
.mv-mode:hover::after { transform: translateX(120%); }
.mv-mode:hover { border-color: rgba(94,224,255,0.5); }
.mv-mode:active { transform: scale(0.97); }
.mv-mode svg { width: 26px; height: 26px; flex: 0 0 auto; fill: none; stroke: #8fdcff; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.mv-mode svg .fill { fill: #8fdcff; stroke: none; }
.mv-mode-name { font-weight: 700; font-size: clamp(0.84rem, 2vw, 1.05rem); line-height: 1.15; min-width: 0; overflow-wrap: anywhere; }
.mv-mode-sub { grid-column: 1 / -1; margin-top: 0.3rem; font-size: 0.68rem; line-height: 1.25; color: #8b9bb4; }
.mv-primary {
  border-color: rgba(94,224,255,0.6);
  background: linear-gradient(160deg, rgba(30,144,200,0.9), rgba(10,70,110,0.92));
  box-shadow: 0 10px 30px rgba(0,0,0,0.45), 0 0 26px rgba(94,224,255,0.28), inset 0 1px 0 rgba(255,255,255,0.18);
}
.mv-primary svg { stroke: #fff; }
.mv-primary svg .fill { fill: #fff; }
.mv-primary .mv-mode-sub { color: #cdeeff; }
.mv-online { border-color: rgba(167,139,250,0.4); background: linear-gradient(160deg, rgba(76,29,149,0.55), rgba(12,12,30,0.9)); }
.mv-online svg { stroke: #c4b5fd; }
.mv-online .soon-pill { margin: 0 0.2rem 0 0; font-size: 0.5rem; padding: 0.04rem 0.32rem; vertical-align: 1px; }

.mv-setup {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.45rem 0.5rem;
  justify-content: stretch; justify-self: stretch; align-self: center; width: 100%; margin-inline: 0;
  padding: 0.45rem 0.55rem; border-radius: 14px;
  background: rgba(6,10,20,0.62); border: 1px solid rgba(148,180,220,0.14);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.mv-tank-field {
  min-width: 0; position: relative;
  display: flex; flex-direction: column; gap: 0.15rem;
}
.mv-field-label { font-size: 0.58rem; letter-spacing: 0.12em; text-transform: uppercase; color: #7f8fa8; }
.tank-select-row { position: relative; display: block; width: 100%; min-width: 0; }
.tank-select-btn {
  width: 100%; min-height: 36px; display: flex; align-items: center; gap: 0.35rem;
  padding: 0 1.55rem 0 0.3rem; border-radius: 9px; cursor: pointer; text-align: left;
  border: 1px solid rgba(148,180,220,0.2); color: var(--text);
  font: 600 0.82rem var(--font); text-transform: none; letter-spacing: 0;
  background: #0a1220 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%237f8fa8' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 0.55rem center;
}
.tank-select-btn:focus { outline: none; border-color: rgba(94,224,255,0.6); }
.tank-select-btn > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tank-select-preview {
  width: 46px; height: 22px; object-fit: contain; flex: none;
  background: #070d18; border-radius: 4px;
}
.tank-select-list {
  position: absolute; right: 0; bottom: calc(100% + 6px); z-index: 40;
  width: min(300px, 78vw); margin: 0; padding: 0.28rem; list-style: none;
  display: flex; flex-direction: column; gap: 0.18rem;
  border-radius: 12px; border: 1px solid rgba(148,180,220,0.28);
  background: #0b1424; box-shadow: 0 14px 36px rgba(0,0,0,0.6);
}
.tank-select-list[hidden] { display: none; }
/* tank-scroll fix: with 10 tanks the list was taller than a landscape phone and had no scroll */
.tank-select-list {
  max-height: min(70vh, 320px); overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-y;
}
.tank-select-list.opens-down { bottom: auto; top: calc(100% + 6px); }
.tank-select-opt { flex: none; touch-action: pan-y; }
.tank-select-opt {
  display: flex; align-items: center; gap: 0.45rem; width: 100%; min-height: 48px;
  padding: 0.15rem 0.4rem; border: 0; border-radius: 8px; cursor: pointer; text-align: left;
  background: transparent; color: var(--text); font: 600 0.8rem var(--font);
  text-transform: none; letter-spacing: 0;
}
.tank-select-opt img {
  width: 84px; height: 40px; object-fit: contain; flex: none;
  background: #070d18; border-radius: 6px;
}
.tank-select-opt:hover:not(:disabled), .tank-select-opt.is-current { background: rgba(56,189,248,0.16); }
.tank-select-opt:disabled { color: #8b7355; cursor: default; }
.tank-select-opt:disabled img { filter: grayscale(0.85) brightness(0.65); }
.tank-select-opt .tank-xp { margin-left: auto; flex: none; font-size: 0.62rem; letter-spacing: 0.04em; color: #8b7355; }
.pack-row.tank-row .pack-main { flex-direction: row; align-items: center; gap: 0.55rem; }
.pack-row.tank-row .tank-copy { display: flex; flex-direction: column; gap: 0.08rem; min-width: 0; }
.pack-main .tank-unlock-art {
  width: 78px; height: 52px; object-fit: contain; flex: none;
  filter: drop-shadow(0 5px 6px rgba(0,0,0,0.45));
}
.mv-setup label { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; font-size: 0.58rem; letter-spacing: 0.12em; text-transform: uppercase; color: #7f8fa8; }
.mv-ai-row { display: flex; gap: 0.3rem; min-width: 0; align-items: stretch; }
.mv-ai-row #opt-ai { flex: 1 1 auto; min-width: 0; }
.mv-ai-row #opt-roster { flex: 0 0 5.4rem; padding-left: 0.35rem; padding-right: 1.15rem; }
.mv-tank-name input {
  width: 100%; min-height: 36px; padding: 0 0.45rem; border-radius: 9px;
  border: 1px solid rgba(148,180,220,0.2); background: #0a1220; color: var(--text);
  font: 600 16px var(--font); letter-spacing: 0; text-transform: none; text-align: left;
}
.mv-tank-name input:focus { outline: none; border-color: rgba(94,224,255,0.6); }
.mv-tank-name input.is-rejected { border-color: rgba(176, 132, 84, 0.85); }
.mv-setup { position: relative; }
.tank-name-note {
  position: absolute;
  left: 0.45rem;
  right: 0.45rem;
  bottom: calc(100% + 6px);
  z-index: 4;
  margin: 0;
  padding: 0.32rem 0.55rem;
  border-radius: 8px;
  border: 1px solid rgba(176, 148, 112, 0.45);
  background: rgba(62, 44, 30, 0.94);
  color: #e7d7c3;
  font-size: 0.78rem;
  letter-spacing: 0.01em;
  text-transform: none;
  line-height: 1.35;
  text-align: center;
}
.tank-name-note[hidden] { display: none !important; }
.mv-setup select {
  width: 100%; min-width: 0; min-height: 36px; padding: 0 1.6rem 0 0.6rem; border-radius: 9px;
  border: 1px solid rgba(148,180,220,0.2); color: var(--text); font: 600 0.82rem var(--font);
  background: #0a1220 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%237f8fa8' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 0.6rem center;
  -webkit-appearance: none; appearance: none; text-overflow: ellipsis;
}
.mv-setup select:focus { outline: none; border-color: rgba(94,224,255,0.6); }

/* Intro: hidden until JS starts it; auto-reveal fallback if the script never runs. */
#screen-menu.intro-pending .menu-v2 > * { opacity: 0; animation: mv-fallback 0.4s ease 3s forwards; }
#screen-menu.intro .mv-word { animation: mv-slam 0.62s cubic-bezier(0.2, 1.5, 0.4, 1) 1s both, mv-sheen 1.4s ease-out 1.5s both; }
#screen-menu.intro .mv-word-b { animation-delay: 1.07s, 1.6s; }
#screen-menu.intro .mv-tag { animation: mv-rise 0.5s ease-out 1.35s both; }
#screen-menu.intro .menu-flash { animation: mv-flash 0.7s ease-out 0.98s both; }
#screen-menu.intro .menu-v2 { animation: mv-shake 0.42s linear 1s both; }
#screen-menu.intro .mv-mode { animation: mv-rise 0.5s cubic-bezier(0.2, 1.2, 0.4, 1) both; }
#screen-menu.intro .mv-mode:nth-child(1) { animation-delay: 1.4s; }
#screen-menu.intro .mv-mode:nth-child(2) { animation-delay: 1.48s; }
#screen-menu.intro .mv-mode:nth-child(3) { animation-delay: 1.56s; }
#screen-menu.intro .mv-mode:nth-child(4) { animation-delay: 1.64s; }
#screen-menu.intro .mv-setup { animation: mv-rise 0.5s ease-out 1.78s both; }
#screen-menu.intro .mv-util { animation: mv-drop 0.45s ease-out 1.9s both; }

@keyframes mv-slam {
  0% { opacity: 0; transform: scale(2.6) translateY(-10px); filter: blur(14px) brightness(3); }
  55% { opacity: 1; filter: blur(0) brightness(1.8); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes mv-sheen { from { background-position: 100% 0; } to { background-position: -60% 0; } }
@keyframes mv-flash { 0% { opacity: 0; } 12% { opacity: 1; } 100% { opacity: 0; } }
@keyframes mv-shake {
  0%, 100% { transform: none; } 15% { transform: translate(-6px, 4px); } 30% { transform: translate(5px, -3px); }
  45% { transform: translate(-4px, 2px); } 60% { transform: translate(3px, -1px); } 80% { transform: translate(-1px, 1px); }
}
@keyframes mv-rise { from { opacity: 0; transform: translateY(18px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes mv-drop { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }
@keyframes mv-fallback { to { opacity: 1; } }
@keyframes mv-claim-glow { 50% { box-shadow: 0 0 28px rgba(251,191,36,0.6); } }

@media (prefers-reduced-motion: reduce) {
  #screen-menu.intro *, #screen-menu.intro-pending .menu-v2 > * { animation: none !important; opacity: 1 !important; }
  .mv-word { animation: none; }
}
@media (orientation: landscape) and (max-height: 400px) {
  .mv-title { font-size: clamp(2rem, 14vh, 3.4rem); }
  .mv-tag { margin-top: 0.3rem; font-size: 0.6rem; }
  .mv-mode { padding: 0.5rem 0.6rem; column-gap: 0.4rem; }
  .mv-mode svg { width: 22px; height: 22px; }
  .mv-mode-sub { font-size: 0.62rem; margin-top: 0.2rem; }
  .mv-util-btn { min-height: 36px; padding: 0 0.7rem; }
  .mv-setup { padding: 0.28rem 0.4rem; gap: 0.28rem; }
}
.mv-xp { gap: 0.35rem; color: #fde68a; border-color: rgba(251, 191, 36, 0.45); }
.mv-xp-amt { font-weight: 700; }
.mv-xp-price { color: #f8fafc; font-weight: 700; }
.settings-build {
  margin-left: 0.35rem;
  color: rgba(148, 163, 184, 0.4);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
}
.xp-pack-row {
  display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
  width: 100%; margin: 0.55rem 0 0.15rem; padding: 0.55rem 0.7rem;
  border-radius: 12px; cursor: pointer; text-align: left;
  border: 1px solid rgba(251, 191, 36, 0.4);
  background: rgba(251, 191, 36, 0.08); color: #f8fafc;
}
.xp-pack-copy { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.xp-pack-copy span { color: #94a3b8; font-size: 0.72rem; }
.xp-pack-price { font-weight: 800; color: #fde68a; white-space: nowrap; }
.xp-offer {
  position: fixed; inset: 0; z-index: 80;
  display: grid; place-items: center; padding: 1rem;
}
.xp-offer[hidden] { display: none !important; }
.xp-offer-backdrop { position: absolute; inset: 0; border: 0; background: rgba(2, 6, 14, 0.62); }
.xp-offer-card {
  position: relative; width: min(92vw, 360px); padding: 1rem 1rem 0.85rem; text-align: center;
}
.xp-offer-card h2 { margin: 0 0 0.35rem; font-size: 1.25rem; }
.xp-offer-lead { margin: 0 0 0.75rem; color: #cbd5e1; }
.xp-offer-note { margin: 0 0 0.6rem; min-height: 1.1em; color: #fde68a; font-size: 0.8rem; }
.xp-offer-note:empty { display: none; }
#btn-xp-buy, #btn-xp-later { width: 100%; }
#btn-xp-later { margin-top: 0.4rem; }
@media (max-width: 720px) {
  .mv-util-btn > span:not(.mv-shine):not(.claim-badge):not(.mv-xp-amt):not(.mv-xp-price) { display: none; }
  .mv-util-btn:not(.mv-xp) { width: 40px; padding: 0; justify-content: center; }
  .mv-xp { width: auto; padding: 0 0.55rem; }
}

/* BUILD 71 — progress screen: claimable rewards + reveal. */
#screen-progress .progress-panel { width: min(94vw, 760px); }
@media (orientation: landscape) and (max-height: 560px) {
  #screen-progress .progress-panel {
    display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); grid-template-rows: auto auto 1fr auto;
    column-gap: 1rem; text-align: left; padding: 0.7rem 0.9rem !important; overflow: hidden !important; height: 100%;
  }
  #screen-progress .progress-panel > h2 { grid-column: 1; margin-bottom: 0.2rem; font-size: 1.1rem; }
  #screen-progress .progress-panel > .muted { grid-column: 1; font-size: 0.7rem; margin-bottom: 0.4rem; }
  #screen-progress .progress-stats { grid-column: 1; grid-row: 3; margin: 0; align-self: stretch; min-height: 0; overflow: auto; }
  #screen-progress .xp-pack-row { grid-column: 2; grid-row: 1; margin: 0 0 0.35rem; align-self: start; }
  #screen-progress .progress-packs { grid-column: 2; grid-row: 2 / span 4; min-height: 0; overflow-y: auto; margin: 0; align-content: start; padding-right: 0.2rem; }
  #screen-progress #btn-progress-close { grid-column: 1; grid-row: 5; align-self: end; }
}
.progress-ready {
  margin: 0.5rem 0 0.1rem; padding: 0.35rem 0.6rem; border-radius: 8px; font-weight: 700; font-size: 0.78rem;
  color: #fde68a; background: rgba(245,158,11,0.14); border: 1px solid rgba(245,158,11,0.5);
  animation: mv-claim-glow 1.6s ease-in-out infinite;
}
.pack-row.ready {
  border-color: rgba(245,158,11,0.7);
  background: linear-gradient(120deg, rgba(120,70,10,0.35), #0b1422 60%);
  box-shadow: 0 0 18px rgba(245,158,11,0.25);
}
.pack-row.ready .pack-name { color: #fde68a; }
.pack-claim {
  flex: 0 0 auto; min-height: 38px !important; padding: 0 1rem !important; font-family: var(--display); letter-spacing: 0.1em; font-size: 0.78rem !important;
  background: linear-gradient(180deg, #fbbf24, #d97706) !important; border-color: rgba(253,230,138,0.8) !important; color: #1a1000 !important;
  box-shadow: 0 0 18px rgba(245,158,11,0.55) !important; animation: claim-pulse 1.2s ease-in-out infinite;
}
@keyframes claim-pulse { 50% { transform: scale(1.06); box-shadow: 0 0 28px rgba(245,158,11,0.85); } }

.claim-reveal {
  position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; overflow: hidden;
  background: radial-gradient(circle at 50% 50%, rgba(40,24,6,0.92), rgba(2,4,10,0.97) 70%);
}
.claim-reveal[hidden] { display: none; }
.claim-rays {
  position: absolute; left: 50%; top: 50%; width: 180vmax; height: 180vmax; margin: -90vmax 0 0 -90vmax; opacity: 0;
  background: repeating-conic-gradient(from 0deg, rgba(251,191,36,0.16) 0deg 7deg, transparent 7deg 22deg);
  -webkit-mask: radial-gradient(circle, #000 0%, transparent 55%); mask: radial-gradient(circle, #000 0%, transparent 55%);
}
.claim-crate { position: absolute; width: 96px; height: 96px; left: 50%; top: 50%; margin: -48px 0 0 -48px; }
.claim-crate span {
  position: absolute; left: 0; width: 100%; height: 50%; border: 2px solid #fbbf24; background: linear-gradient(180deg, #3a2a10, #1d1406);
  box-shadow: 0 0 24px rgba(251,191,36,0.6), inset 0 0 18px rgba(251,191,36,0.35);
}
.claim-crate span:first-child { top: 0; border-radius: 10px 10px 2px 2px; }
.claim-crate span:last-child { bottom: 0; border-radius: 2px 2px 10px 10px; }
.claim-card { position: relative; width: min(92vw, 460px); max-height: 92%; overflow: auto; text-align: center; opacity: 0; padding: 0.5rem; }
.claim-kicker { font-family: var(--display); font-size: 0.68rem; letter-spacing: 0.35em; text-transform: uppercase; color: #fbbf24; }
.claim-name {
  margin: 0.25rem 0 0.3rem; font-family: var(--display); font-weight: 700; font-size: clamp(1.3rem, 6vh, 2rem); letter-spacing: 0.06em;
  background: linear-gradient(90deg, #fff7e0, #fbbf24, #fff7e0); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 16px rgba(251,191,36,0.45));
}
.claim-blurb { color: #c8d4e6; font-size: 0.8rem; margin-bottom: 0.6rem; }
.claim-items { display: grid; gap: 0.35rem; margin-bottom: 0.5rem; }
.claim-item {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 0.55rem; text-align: left;
  padding: 0.45rem 0.7rem; border-radius: 10px; background: rgba(12,18,32,0.9); border: 1px solid color-mix(in srgb, var(--c) 55%, transparent);
  box-shadow: 0 0 14px color-mix(in srgb, var(--c) 25%, transparent); opacity: 0;
}
.claim-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); box-shadow: 0 0 10px var(--c); }
.claim-item-name { font-weight: 700; font-size: 0.85rem; }
.claim-item-note { font-size: 0.68rem; color: #8b9bb4; }
.claim-where { font-size: 0.7rem; color: #8b9bb4; margin-bottom: 0.6rem; }
.claim-reveal.play .claim-crate { animation: crate-shake 0.75s ease-in both; }
.claim-reveal.play .claim-crate span:first-child { animation: crate-lid 0.5s ease-out 0.75s forwards; }
.claim-reveal.play .claim-crate span:last-child { animation: crate-base 0.5s ease-out 0.75s forwards; }
.claim-reveal.play .claim-rays { animation: rays-in 0.6s ease-out 0.75s forwards, rays-spin 18s linear 0.75s infinite; }
.claim-reveal.play .claim-card { animation: card-pop 0.55s cubic-bezier(0.2, 1.4, 0.4, 1) 0.85s forwards; }
.claim-reveal.play .claim-item { animation: mv-rise 0.4s ease-out forwards; animation-delay: calc(1.2s + var(--i) * 0.12s); }
@keyframes crate-shake {
  0% { transform: scale(0.4); opacity: 0; } 25% { transform: scale(1); opacity: 1; }
  40% { transform: rotate(-6deg); } 55% { transform: rotate(7deg) scale(1.04); } 70% { transform: rotate(-8deg) scale(1.08); }
  85% { transform: rotate(9deg) scale(1.12); } 100% { transform: scale(1.18); }
}
@keyframes crate-lid { to { transform: translateY(-140px) rotate(-28deg); opacity: 0; } }
@keyframes crate-base { to { transform: translateY(140px) rotate(18deg); opacity: 0; } }
@keyframes rays-in { from { opacity: 0; transform: scale(0.3); } to { opacity: 1; transform: scale(1); } }
@keyframes rays-spin { from { rotate: 0deg; } to { rotate: 360deg; } }
@keyframes card-pop { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .claim-reveal.play * { animation: none !important; }
  .claim-reveal.play .claim-card, .claim-reveal.play .claim-item { opacity: 1; }
  .claim-reveal.play .claim-crate { display: none; }
}

/* Progress button: always gold and shiny so it's easy to spot. */
.mv-util-btn.mv-progress {
  color: #fff3c4;
  border-color: rgba(251,191,36,0.75);
  background: linear-gradient(180deg, rgba(120,72,8,0.75), rgba(40,24,4,0.8));
  box-shadow: 0 0 16px rgba(251,191,36,0.35), inset 0 1px 0 rgba(255,240,200,0.35);
  text-shadow: 0 0 8px rgba(251,191,36,0.6);
}
.mv-shine { position: absolute; inset: 0; border-radius: inherit; overflow: hidden; pointer-events: none; }
.mv-shine::after {
  content: ''; position: absolute; top: 0; bottom: 0; left: -60%; width: 45%;
  background: linear-gradient(105deg, transparent, rgba(255,250,225,0.75), transparent);
  transform: skewX(-20deg); animation: mv-progress-sheen 3.2s ease-in-out 2.4s infinite;
}
.mv-util-btn.mv-progress .mv-star { width: 19px; height: 19px; fill: url(#mv-star-g); filter: drop-shadow(0 0 4px rgba(251,191,36,0.9)); animation: mv-star-twinkle 3.2s ease-in-out 2.4s infinite; }
.mv-util-btn.mv-progress:hover { border-color: #fde68a; color: #fff; }
@keyframes mv-progress-sheen { 0% { left: -60%; } 45%, 100% { left: 130%; } }
@keyframes mv-star-twinkle { 0%, 100% { transform: scale(1) rotate(0); } 20% { transform: scale(1.25) rotate(18deg); } 40% { transform: scale(1) rotate(0); } }
@media (prefers-reduced-motion: reduce) { .mv-shine::after, .mv-util-btn.mv-progress .mv-star { animation: none; } }

/* BUILD 73 — cloud save: backup row on the progress screen + save-code dialog. */
.cloud-row {
  display: flex; align-items: center; gap: 0.6rem; width: 100%; margin: 0.6rem 0 0.75rem; padding: 0.55rem 0.75rem;
  border-radius: 10px; border: 1px solid rgba(56,189,248,0.4); background: rgba(14,52,80,0.45);
  color: #e0f2fe; font: inherit; text-align: left; cursor: pointer; transition: border-color .15s, background .15s;
}
.cloud-row:hover, .cloud-row:focus-visible { border-color: #7dd3fc; background: rgba(14,70,110,0.55); outline: none; }
.cloud-row svg { flex: none; width: 24px; height: 24px; fill: #38bdf8; filter: drop-shadow(0 0 4px rgba(56,189,248,0.7)); }
.cloud-row-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.2; }
.cloud-row-text strong { font-size: 0.85rem; }
.cloud-row-text span { font-size: 0.72rem; color: #a5c8e0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cloud-row-go { flex: none; font-size: 0.75rem; font-weight: 700; color: #7dd3fc; }
.cloud-row.unseen { border-color: rgba(251,191,36,0.8); box-shadow: 0 0 14px rgba(251,191,36,0.3); }
.cloud-row.unseen .cloud-row-go { color: #fde68a; }

.cloud-panel {
  position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; padding: 0.75rem;
  background: rgba(2,6,14,0.82); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.cloud-panel[hidden] { display: none; }
.cloud-card { width: min(94vw, 520px); max-height: 100%; overflow-y: auto; padding: 1rem 1.1rem; text-align: left; }
.cloud-card h3 { margin: 0 0 0.35rem; font-size: 1.1rem; }
.cloud-lead { margin: 0 0 0.7rem; font-size: 0.8rem; color: #b8c6d8; line-height: 1.4; }
.cloud-code-row { display: flex; gap: 0.5rem; align-items: stretch; }
.cloud-code {
  flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; padding: 0.55rem 0.6rem;
  border-radius: 10px; border: 1px dashed rgba(251,191,36,0.7); background: rgba(40,26,4,0.55);
  color: #fde68a; font: 700 clamp(0.95rem, 4.2vw, 1.25rem)/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.08em; user-select: all; -webkit-user-select: all; white-space: nowrap;
}
.cloud-status { margin: 0.45rem 0 0.7rem; font-size: 0.75rem; color: #a5c8e0; min-height: 1em; }
.cloud-restore { border-top: 1px solid rgba(148,163,184,0.2); padding-top: 0.65rem; margin-bottom: 0.75rem; }
.cloud-restore label { display: block; font-size: 0.78rem; font-weight: 700; margin-bottom: 0.35rem; }
.cloud-restore-row { display: flex; gap: 0.5rem; }
.cloud-restore-row input {
  flex: 1; min-width: 0; padding: 0.5rem 0.65rem; border-radius: 9px; border: 1px solid rgba(148,163,184,0.4);
  background: rgba(2,6,14,0.6); color: #f1f5f9; font: 600 0.9rem ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.05em; text-transform: uppercase;
}
.cloud-restore-row input:focus { outline: none; border-color: #7dd3fc; }
.cloud-restore-note { margin: 0.4rem 0 0; font-size: 0.72rem; color: #94a3b8; }
.cloud-restore-note.bad { color: #fca5a5; }
.cloud-restore-note.good { color: #86efac; }
#btn-cloud-close { width: 100%; }

@media (orientation: landscape) and (max-height: 560px) {
  #screen-progress .progress-panel { grid-template-rows: auto auto minmax(0, 1fr) auto auto; }
  #screen-progress .progress-packs { grid-row: 2 / span 4; }
  #screen-progress .xp-pack-row { grid-column: 2; grid-row: 1; margin: 0 0 0.35rem; }
  #screen-progress .cloud-row { grid-column: 1; grid-row: 4; margin: 0.4rem 0; padding: 0.4rem 0.6rem; }
  #screen-progress #btn-progress-close { grid-row: 5; }
  .cloud-card {
    width: min(96vw, 720px); display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 1rem;
    padding: 0.75rem 0.9rem;
  }
  .cloud-card h3, .cloud-lead, .cloud-code-row, .cloud-status { grid-column: 1; }
  .cloud-lead { font-size: 0.72rem; margin-bottom: 0.5rem; }
  .cloud-restore { grid-column: 2; grid-row: 1 / span 3; border-top: 0; border-left: 1px solid rgba(148,163,184,0.2); padding: 0 0 0 1rem; margin: 0; align-self: center; }
  #btn-cloud-close { grid-column: 2; grid-row: 4; align-self: end; }
}

/* ===== Weapon picker: left sidebar, about a third of the screen ===== */
html body .weapon-picker-sheet { flex-direction: row; justify-content: flex-start; align-items: stretch; }
html body .weapon-picker-backdrop { background: rgba(0, 4, 12, 0.35); }
html body .weapon-picker-panel {
  width: calc(33.333vw + var(--safe-l));
  min-width: calc(250px + var(--safe-l));
  max-width: calc(400px + var(--safe-l));
  height: 100%;
  max-height: none;
  border-radius: 0 18px 18px 0;
  border-left: none;
  border-bottom: 1px solid rgba(148, 180, 220, 0.14);
  padding: calc(0.5rem + var(--safe-t)) 0.5rem calc(0.6rem + var(--safe-b)) calc(0.5rem + var(--safe-l));
  box-shadow: 18px 0 48px rgba(0, 0, 0, 0.55);
  animation: wp-slide-in 0.18s ease-out;
}
html body .weapon-picker-item { min-height: 42px; padding: 0.42rem 0.6rem; font-size: 0.8rem; }
html body .weapon-picker-item .meta { font-size: 0.62rem; }
@keyframes wp-slide-in { from { transform: translateX(-100%); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { html body .weapon-picker-panel { animation: none; } }

/* ===== Armory draft: full board + loadout slots ===== */
html body #screen-shop { align-items: stretch; justify-content: center; }
html body #screen-shop .draft-wrap {
  display: flex; flex-direction: column; gap: 0.45rem;
  width: min(1120px, 100%); height: 100%; max-height: 100%;
  overflow: hidden !important; padding: 0.55rem 0.75rem; margin: 0 auto;
}
.draft-head { display: flex; align-items: center; gap: 0.6rem; flex: 0 0 auto; min-width: 0; }
.draft-head h2 { font-family: var(--display); font-size: 0.95rem; letter-spacing: 0.1em; white-space: nowrap; }
.draft-turn {
  padding: 0.2rem 0.7rem; border-radius: 999px; font-size: 0.74rem; font-weight: 700;
  background: rgba(148, 180, 220, 0.1); border: 1px solid rgba(148, 180, 220, 0.25); white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.draft-turn.p1 { color: var(--cyan); background: rgba(94, 224, 255, 0.12); border-color: rgba(94, 224, 255, 0.5); }
.draft-turn.p2 { color: var(--orange); background: rgba(255, 154, 74, 0.12); border-color: rgba(255, 154, 74, 0.5); }
.draft-turn.p3 { color: #e9d5ff; background: rgba(192, 132, 252, 0.14); border-color: rgba(192, 132, 252, 0.5); }
.draft-turn.p4 { color: #bbf7d0; background: rgba(74, 222, 128, 0.12); border-color: rgba(74, 222, 128, 0.5); }
.draft-turn.shop-warn { color: #fecaca; background: rgba(239, 68, 68, 0.18); border-color: rgba(239, 68, 68, 0.6); }
.draft-rule { flex: 1 1 auto; min-width: 0; text-align: right; color: var(--muted); font-size: 0.68rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.draft-rule b { color: #facc15; font-weight: 700; }

.draft-body { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) clamp(200px, 26vw, 270px); gap: 0.65rem; }
.draft-main { min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding-right: 0.15rem; }
.draft-main .shop-map { margin: 0 0 0.35rem; }

.draft-sec-head { display: flex; align-items: baseline; gap: 0.45rem; margin: 0.15rem 0 0.3rem; font-size: 0.66rem; }
.draft-sec-head:not(:first-child) { margin-top: 0.6rem; }
.draft-sec-head .t { font-family: var(--display); letter-spacing: 0.12em; text-transform: uppercase; font-size: 0.7rem; color: var(--text); }
.draft-sec-head.apex .t { color: #facc15; }
.draft-sec-head .n { color: var(--muted); }
.draft-sec-head.done .n { color: var(--green); }
.draft-sec-head .l { margin-left: auto; color: var(--muted); opacity: 0.8; }

.draft-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 0.35rem; }
.draft-tile {
  appearance: none; font: inherit; color: inherit; text-align: left; cursor: pointer; touch-action: manipulation;
  display: flex; flex-direction: column; gap: 0.08rem; min-width: 0; min-height: 56px;
  padding: 0.38rem 0.5rem 0.4rem 0.55rem; border-radius: 9px;
  background: #0b1422; border: 1px solid rgba(148, 180, 220, 0.14); border-left: 3px solid var(--wc);
  transition: transform 0.1s, border-color 0.12s, background 0.12s, opacity 0.15s;
}
.draft-tile .top { display: flex; align-items: center; gap: 0.3rem; min-width: 0; }
.draft-tile .cat { font-size: 0.55rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--wc); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.draft-tile .nm-row { display: flex; align-items: center; gap: 0.28rem; min-width: 0; }
.draft-tile .nm-row .w-ico { width: 22px; height: 22px; flex: 0 0 22px; }
.draft-tile .nm { font-size: 0.78rem; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.draft-tile .ds { font-size: 0.6rem; color: var(--muted); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.draft-tile.apex { background: linear-gradient(160deg, rgba(250, 204, 21, 0.1), #0b1422 60%); border-color: rgba(250, 204, 21, 0.3); border-left-color: var(--wc); }
.draft-tile.apex .nm::before { content: '★ '; color: #facc15; }
.draft-tile:not(:disabled):hover { border-color: var(--wc); background: #10203a; }
.draft-tile:not(:disabled):active { transform: scale(0.97); }
.draft-tile:disabled { cursor: default; }
.draft-tile.waiting { opacity: 0.8; }
.draft-tile.blocked { opacity: 0.38; }
.draft-tile.taken { background: #070b13; border-style: dashed; border-left-style: solid; border-left-color: rgba(148, 180, 220, 0.2); }
.draft-tile.taken .cat, .draft-tile.taken .nm, .draft-tile.taken .ds, .draft-tile.taken .w-ico { opacity: 0.38; }
.draft-tile .own {
  margin-left: auto; flex: 0 1 auto; min-width: 0; max-width: 60%;
  font-size: 0.52rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 0.05rem 0.35rem; border-radius: 999px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.draft-tile.by-p1 .own { color: #04121a; background: var(--cyan); }
.draft-tile.by-p2 .own { color: #1a0d02; background: var(--orange); }
.draft-tile.by-p3 .own { color: #1a0a24; background: #c084fc; }
.draft-tile.by-p4 .own { color: #052e16; background: #4ade80; }

.draft-side { min-height: 0; display: flex; flex-direction: column; gap: 0.4rem; overflow-y: auto; overscroll-behavior: contain; }
.draft-loadout {
  padding: 0.4rem 0.45rem 0.45rem; border-radius: 10px;
  background: rgba(10, 16, 28, 0.6); border: 1px solid rgba(148, 180, 220, 0.14);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.draft-loadout.p1.active { border-color: rgba(94, 224, 255, 0.6); box-shadow: 0 0 14px rgba(94, 224, 255, 0.15); }
.draft-loadout.p2.active { border-color: rgba(255, 154, 74, 0.6); box-shadow: 0 0 14px rgba(255, 154, 74, 0.15); }
.draft-loadout.p3.active { border-color: rgba(192, 132, 252, 0.65); box-shadow: 0 0 14px rgba(192, 132, 252, 0.16); }
.draft-loadout.p4.active { border-color: rgba(74, 222, 128, 0.6); box-shadow: 0 0 14px rgba(74, 222, 128, 0.14); }
#screen-shop:not(.roster-3):not(.roster-4) #shop-load-p3,
#screen-shop:not(.roster-3):not(.roster-4) #shop-load-p4 { display: none; }
#screen-shop.roster-3 .draft-side,
#screen-shop.roster-4 .draft-side { display: grid; grid-template-columns: 1fr 1fr; align-content: start; }
.draft-load-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.4rem; margin-bottom: 0.3rem; }
.draft-load-head h3 { font-family: var(--display); font-size: 0.7rem; letter-spacing: 0.08em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.draft-loadout.p1 h3 { color: var(--cyan); }
.draft-loadout.p2 h3 { color: var(--orange); }
.draft-loadout.p3 h3 { color: #c084fc; }
.draft-loadout.p4 h3 { color: #4ade80; }
.draft-load-head span { font-size: 0.6rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.draft-slots { list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 0.2rem; }
.draft-slot {
  height: 19px; line-height: 17px; padding: 0 0.35rem; border-radius: 5px; min-width: 0;
  font-size: 0.58rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border: 1px dashed rgba(148, 180, 220, 0.18); color: var(--muted);
}
.draft-slot.apex { grid-column: 1 / -1; border-color: rgba(250, 204, 21, 0.4); color: rgba(250, 204, 21, 0.7); }
.draft-slot.filled { border-style: solid; border-color: rgba(148, 180, 220, 0.16); border-left: 3px solid var(--wc); background: rgba(255, 255, 255, 0.04); color: var(--text); }
.draft-slot.apex.filled { border-color: rgba(250, 204, 21, 0.45); border-left-color: var(--wc); background: rgba(250, 204, 21, 0.08); }
.draft-slot.apex.filled::before { content: '★ '; color: #facc15; }
.draft-slot.filled {
  display: flex; align-items: center; gap: 0.12rem;
  height: 22px; line-height: 1; padding: 0 0.22rem 0 0.08rem;
}
.draft-slot .w-ico { width: 16px; height: 16px; flex: 0 0 16px; }
.draft-slot .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.draft-actions { display: flex; align-items: center; gap: 0.35rem; flex: 0 0 auto; margin-left: auto; }
.draft-actions [hidden] { display: none !important; }
.draft-actions .btn { min-height: 34px; padding: 0.3rem 0.75rem; font-size: 0.76rem; border-radius: 10px; white-space: nowrap; }
.draft-actions #btn-shop-random { max-width: 190px; overflow: hidden; text-overflow: ellipsis; }
.draft-actions #btn-online-start { min-height: 34px; padding: 0.3rem 0.9rem; font-size: 0.78rem; letter-spacing: 0.04em; }
.draft-actions #btn-online-start:disabled { opacity: 0.72; }
.draft-actions #btn-shop-random.online-random { min-height: 34px; box-shadow: 0 0 10px rgba(34, 211, 238, 0.25); }

@media (orientation: portrait) and (max-width: 640px) {
  .draft-body { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .draft-side { overflow: visible; }
  .draft-rule { display: none; }
}
/* BUILD 174 — phone landscape lobby is two cards: room on the left, join and maps on the right. */
@media (orientation: landscape) and (max-height: 560px) {
  html body #screen-online {
    overflow: hidden !important;
    align-items: stretch !important;
    justify-content: stretch !important;
    padding: max(0.2rem, var(--safe-t)) max(0.35rem, var(--safe-r)) max(0.2rem, var(--safe-b)) max(0.35rem, var(--safe-l)) !important;
  }
  html body #screen-online .online-panel {
    display: grid !important;
    grid-template-columns: minmax(210px, 0.78fr) minmax(0, 1.22fr) !important;
    grid-template-rows: minmax(0, 1fr) !important;
    column-gap: 0.4rem !important;
    row-gap: 0 !important;
    align-content: stretch !important;
    align-items: stretch !important;
    width: 100% !important;
    max-width: none !important;
    height: 100% !important;
    max-height: 100% !important;
    margin: 0 !important;
    overflow: hidden !important;
    padding: 0.28rem !important;
  }
  html body #screen-online .online-panel > h2,
  html body #screen-online .online-sub,
  html body #screen-online .online-build-stamp,
  html body #screen-online .online-notes { display: none !important; }
  html body #screen-online .online-col {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.28rem !important;
    min-width: 0 !important;
    min-height: 0 !important;
    height: 100% !important;
    padding: 0.4rem !important;
    border-radius: 14px !important;
    background: rgba(3, 8, 18, 0.42) !important;
    border: 1px solid rgba(130, 176, 240, 0.14) !important;
    grid-row: 1 !important;
  }
  html body #screen-online .online-col-room { grid-column: 1 !important; }
  html body #screen-online .online-col-play { grid-column: 2 !important; }
  html body #screen-online .online-col [hidden] { display: none !important; }
  html body #screen-online .online-status {
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0.28rem 0.5rem !important;
    font-size: 0.72rem !important;
  }
  html body #screen-online .online-phase { margin: 0 !important; min-height: 0 !important; font-size: 0.62rem !important; }
  html body #screen-online .online-phase:empty { display: none !important; }
  html body #screen-online .online-players {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 0.28rem !important;
    margin: 0 !important;
  }
  html body #screen-online .online-player {
    min-height: 0 !important;
    padding: 0.28rem 0.4rem !important;
    font-size: 0.72rem !important;
    margin: 0 !important;
  }
  html body #screen-online .online-col-room .online-room { display: contents !important; }
  html body #screen-online .online-room-codeblock {
    display: flex !important;
    flex: 1 1 auto !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.15rem !important;
    min-height: 0 !important;
    text-align: center !important;
    border-radius: 12px !important;
    border: 1px solid rgba(126, 176, 240, 0.18) !important;
    background: rgba(8, 18, 36, 0.62) !important;
    padding: 0.3rem 0.4rem !important;
  }
  html body #screen-online .online-room-label { font-size: 0.58rem !important; margin: 0 !important; }
  html body #screen-online .online-code {
    margin: 0 !important;
    font-size: 1.15rem !important;
    letter-spacing: 0.2em !important;
    line-height: 1.1 !important;
  }
  html body #screen-online .online-col-room .btn {
    flex: 0 0 auto !important;
    width: 100% !important;
    min-height: 36px !important;
    margin: 0 !important;
    padding-top: 0.2rem !important;
    padding-bottom: 0.2rem !important;
    font-size: 0.9rem !important;
  }
  html body #screen-online .online-join {
    display: grid !important;
    grid-template-columns: auto minmax(0, 1fr) !important;
    grid-template-areas: "label hint" "row row" !important;
    gap: 0.12rem 0.4rem !important;
    margin: 0 !important;
    min-width: 0 !important;
    align-self: stretch !important;
  }
  html body #screen-online .online-join label {
    grid-area: label !important;
    margin: 0 !important;
    font-size: 0.58rem !important;
    white-space: nowrap !important;
  }
  html body #screen-online .online-join-hint {
    grid-area: hint !important;
    display: block !important;
    margin: 0 !important;
    text-align: right !important;
    font-size: 0.58rem !important;
    line-height: 1.15 !important;
    min-height: 0 !important;
  }
  html body #screen-online .online-join-row {
    grid-area: row !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto auto !important;
    gap: 0.3rem !important;
    margin: 0 !important;
  }
  html body #screen-online .online-col-play .online-code-input {
    min-height: 36px !important;
    height: 36px !important;
    letter-spacing: 0.08em !important;
    font-size: 16px !important;
    padding: 0 0.35rem !important;
  }
  html body #screen-online .online-join-row .btn {
    min-height: 36px !important;
    height: 36px !important;
    padding: 0 0.7rem !important;
    font-size: 0.85rem !important;
  }
  html body #screen-online .online-col-play .online-map {
    flex: 1 1 auto !important;
    display: flex !important;
    flex-direction: column !important;
    min-height: 0 !important;
    min-width: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
  }
  html body #screen-online .online-map-head {
    flex: 0 0 auto !important;
    min-width: 0 !important;
    width: 100% !important;
    margin: 0 0 0.15rem !important;
  }
  html body #screen-online .online-map-note {
    min-width: 0 !important;
    margin-left: auto !important;
    text-align: right !important;
    white-space: nowrap !important;
    font-size: 0.62rem !important;
  }
  html body #screen-online .online-col-play .online-map-chips {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    grid-auto-rows: minmax(0, 1fr) !important;
    gap: 0.28rem !important;
    align-content: stretch !important;
  }
  html body #screen-online .online-col-play .online-map-chip {
    min-height: 0 !important;
    height: auto !important;
    white-space: nowrap !important;
    font-size: 0.68rem !important;
    padding: 0.1rem 0.35rem !important;
  }
  html body #screen-online .online-col-play .online-map-chip[data-map="random"] {
    grid-column: 1 / -1 !important;
  }
  html body #screen-online .online-lock {
    position: static !important;
    inset: auto !important;
    z-index: auto !important;
    display: flex !important;
    flex: 0 0 auto !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: none !important;
    grid-column: auto !important;
    grid-row: auto !important;
    pointer-events: auto !important;
  }
  html body #screen-online .online-lock[hidden] { display: none !important; }
  html body #screen-online .online-lock-copy { display: none !important; }
  html body #screen-online #btn-online-lock { min-height: 36px !important; }
}
@media (max-height: 420px) {
  .draft-loadout { padding: 0.3rem 0.4rem 0.35rem; }
  .draft-load-head { margin-bottom: 0.2rem; }
  .draft-slots { gap: 0.15rem; }
  .draft-slot { height: 17px; line-height: 15px; font-size: 0.56rem; }
  .draft-slot.filled { height: 18px; }
  .draft-slot .w-ico { width: 14px; height: 14px; flex-basis: 14px; }
}

/* Skip sits in the FIRE slot once your tank is out of a versus-AI match. */
html body #screen-battle #btn-fire[hidden],
html body #screen-battle #btn-skip-ai[hidden] { display: none !important; }
html body #screen-battle #btn-skip-ai {
  grid-column: 2 !important;
  grid-row: 1 !important;
  width: 100% !important;
  min-width: 0 !important;
  min-height: 50px !important;
  height: auto !important;
  margin: 0 !important;
  position: relative !important;
  letter-spacing: 0.14em !important;
  background: linear-gradient(180deg, #c2410c, #7c2d12) !important;
  border-color: rgba(251, 146, 60, 0.75) !important;
  color: #fff7ed !important;
}

/* BUILD 193 — tap a progress row for a large map, weapon, or tank preview. */
.pack-hint {
  margin: 0 0 0.15rem;
  color: #7f8fa8;
  font-size: 0.68rem;
}
.pack-look {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 0.65rem;
  border-radius: 8px;
  border: 1px solid rgba(94, 224, 255, 0.5);
  background: rgba(8, 32, 52, 0.9);
  color: #e0f2fe;
  font: 700 0.66rem var(--font);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.pack-main { flex: 1; }
.preview-map-pending {
  background:
    linear-gradient(180deg, rgba(12, 20, 36, 0.2), rgba(12, 20, 36, 0.55)),
    #0b1422;
}
.pack-row.can-preview { cursor: pointer; }
.pack-row.can-preview:hover,
.pack-row.can-preview:focus-within {
  border-color: rgba(94, 224, 255, 0.55);
}
.progress-preview {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: grid;
  place-items: center;
  padding: 0.55rem;
}
.progress-preview[hidden] { display: none !important; }
.progress-preview-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(2, 6, 14, 0.78);
}
.progress-preview-card {
  position: relative;
  width: min(96vw, 980px);
  height: min(92dvh, 640px);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  padding: 0.7rem 0.85rem 0.75rem;
  text-align: left;
  overflow: hidden;
}
.progress-preview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.7rem;
}
.progress-preview-kicker {
  margin: 0;
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #8b9bb4;
}
.progress-preview-card h3 {
  margin: 0.12rem 0 0;
  font-family: var(--display);
  font-size: clamp(1rem, 3.4vh, 1.35rem);
  letter-spacing: 0.04em;
}
#progress-preview-close { flex: none; min-height: 40px; }
.progress-preview-blurb {
  margin: 0.35rem 0 0.5rem;
  color: #b8c6d8;
  font-size: 0.74rem;
  line-height: 1.35;
}
.progress-preview-blurb:empty { display: none; }
.progress-preview-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.preview-split {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(168px, 0.8fr);
  gap: 0.5rem;
  height: 100%;
  min-height: 0;
}
.preview-side {
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
}
.preview-side .preview-weapons {
  grid-template-columns: 1fr;
  align-content: start;
}
.preview-side .preview-weapon {
  flex-direction: row;
  text-align: left;
  align-items: center;
  gap: 0.45rem;
}
.preview-side .preview-weapon-art,
.preview-side .preview-weapon .preview-ico,
.preview-side .preview-weapon .w-ico {
  width: 58px;
  height: 58px;
}
.preview-side .preview-weapon strong,
.preview-side .preview-weapon em { text-align: left; }
.preview-maps {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.preview-maps.solo { grid-template-columns: minmax(0, 1fr); }
.preview-map { margin: 0; display: flex; flex-direction: column; gap: 0.25rem; }
.preview-map canvas {
  width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid rgba(148, 180, 220, 0.28);
  background: #05070e;
  display: block;
}
.preview-map figcaption {
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #c8d4e6;
}
.preview-section {
  margin: 0.65rem 0 0.35rem;
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #8b9bb4;
}
.preview-weapons {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 0.4rem;
}
.preview-weapon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.4rem 0.35rem 0.5rem;
  border-radius: 10px;
  background: #0b1422;
  border: 1px solid color-mix(in srgb, var(--c, #5ee0ff) 45%, transparent);
  text-align: center;
}
.preview-weapon-art {
  width: 84px;
  height: 84px;
  display: grid;
  place-items: center;
}
.preview-weapon .preview-ico,
.preview-weapon .w-ico {
  width: 84px;
  height: 84px;
  flex: none;
}
.preview-weapon strong { font-size: 0.72rem; line-height: 1.2; }
.preview-weapon em { font-style: normal; font-size: 0.62rem; color: #8b9bb4; }
.preview-tank {
  height: 100%;
  min-height: 160px;
  display: grid;
  place-items: center;
}
.preview-tank img {
  width: min(78%, 460px);
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 14px 18px rgba(0, 0, 0, 0.55));
}
@media (max-width: 720px), (orientation: portrait) {
  .preview-maps { grid-template-columns: minmax(0, 1fr); }
  .preview-split { grid-template-columns: minmax(0, 1fr); height: auto; }
  .preview-weapon-art,
  .preview-weapon .preview-ico,
  .preview-weapon .w-ico { width: 72px; height: 72px; }
}
@media (orientation: landscape) and (max-height: 560px) {
  .progress-preview { padding: 0.3rem; }
  .progress-preview-card {
    width: min(98vw, 1100px);
    height: calc(100dvh - 0.6rem);
    padding: 0.4rem 0.65rem 0.45rem;
  }
  .progress-preview-card h3 { font-size: 1rem; }
  .progress-preview-blurb {
    margin: 0.12rem 0 0.28rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .preview-maps:not(.solo) canvas {
    max-height: 28vh;
    object-fit: cover;
    object-position: center bottom;
  }
  .preview-side .preview-weapon-art,
  .preview-side .preview-weapon .preview-ico,
  .preview-side .preview-weapon .w-ico { width: 48px; height: 48px; }
}

/* BUILD 201 — opponent-ready arrow. Sits on the Start Match button, does not block taps. */
.ready-anchor { position: relative; width: 100%; }
.ready-nudge {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 1px);
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  pointer-events: none;
  line-height: 1;
}
.ready-nudge[hidden] { display: none !important; }
.ready-nudge-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #bff6ff;
  background: rgba(6, 16, 32, 0.92);
  border: 1px solid rgba(94, 224, 255, 0.55);
  border-radius: 999px;
  padding: 0.12rem 0.4rem;
  white-space: nowrap;
}
.ready-nudge-arrow {
  width: 0;
  height: 0;
  margin-top: 1px;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 7px solid #5ee0ff;
  animation: ready-nudge-bob 0.85s ease-in-out infinite;
}
@keyframes ready-nudge-bob {
  0%, 100% { transform: translateY(0); opacity: 0.7; }
  50% { transform: translateY(4px); opacity: 1; }
}

/* BUILD 201 — first-launch sheet. Stays above the landscape bottom dock and does not cover it. */
.tutorial-sheet {
  position: fixed;
  z-index: 40;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: calc(0.35rem + var(--safe-t)) calc(0.55rem + var(--safe-r)) calc(8.2rem + var(--safe-b)) calc(0.55rem + var(--safe-l));
  pointer-events: none;
}
.tutorial-sheet[hidden] { display: none !important; }
.tutorial-card {
  pointer-events: auto;
  width: min(680px, 100%);
  max-height: 100%;
  overflow: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "kicker actions"
    "title actions"
    "body actions"
    "mini mini";
  gap: 0.12rem 0.75rem;
  align-items: center;
  padding: 0.5rem 0.7rem 0.45rem;
  border-radius: 14px;
  background: rgba(6, 12, 24, 0.94);
  border: 1px solid rgba(94, 224, 255, 0.4);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
  color: var(--text);
}
.tutorial-kicker { grid-area: kicker; margin: 0; color: var(--cyan); font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; }
.tutorial-card h2 { grid-area: title; margin: 0; font-family: var(--display); font-size: 1rem; letter-spacing: 0.04em; }
#tutorial-body { grid-area: body; margin: 0; color: #c5d2e4; font-size: 0.82rem; line-height: 1.3; }
.tutorial-actions { grid-area: actions; display: flex; gap: 0.35rem; align-items: center; }
.tutorial-actions .btn { min-height: 36px; padding: 0.3rem 0.7rem; }
.tutorial-mini {
  grid-area: mini;
  display: flex;
  gap: 0.3rem;
  align-items: stretch;
  min-width: 0;
}
.tutorial-mini span {
  flex: 1 1 0;
  min-width: 0;
  text-align: center;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 0.28rem 0.15rem;
  border-radius: 8px;
  color: #9fb0c6;
  background: rgba(16, 28, 48, 0.9);
  border: 1px solid rgba(126, 176, 240, 0.18);
}
.tutorial-mini span.on {
  color: #041018;
  background: #5ee0ff;
  border-color: #5ee0ff;
}
@media (orientation: landscape) and (max-height: 430px) {
  .tutorial-sheet { padding-bottom: calc(7.2rem + var(--safe-b)); }
  .tutorial-card { padding: 0.35rem 0.55rem; gap: 0.08rem 0.6rem; }
  .tutorial-card h2 { font-size: 0.9rem; }
  #tutorial-body { font-size: 0.74rem; }
  .tutorial-actions .btn { min-height: 32px; }
}

/* BUILD 201 — iPhone app uses iCloud. The save code stays available, tucked away. */
#cloud-manual[hidden],
#btn-cloud-manual[hidden] { display: none !important; }
html.ia-ios-app #btn-cloud-manual {
  width: 100%;
  margin: 0.2rem 0 0.6rem;
}

/* Collapsed Unlocked tab on the progress screen */
.unlocked-group { margin-top: 10px; border-top: 1px solid rgba(255,255,255,0.12); }
.unlocked-toggle { display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 6px; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.12); border-radius: 8px; color: inherit; font: inherit; font-weight: 700; text-align: left; cursor: pointer; margin-top: 8px; }
.unlocked-arrow { width: 1em; display: inline-block; }
.unlocked-count { margin-left: auto; font-weight: 400; opacity: 0.75; font-size: 0.9em; }
.unlocked-list { margin-top: 6px; }
.unlocked-list[hidden] { display: none; }

/* Apple-readiness fixes (testing): first-run tutorial card sits below the top menu bar
   (Progress / XP offer / Settings stay tappable), and every battle button is at least 44px. */
.tutorial-sheet { padding-top: calc(4rem + var(--safe-t)); }
.tutorial-actions .btn { min-height: 44px; min-width: 44px; }
@media (orientation: landscape) and (max-height: 430px) {
  .tutorial-actions .btn { min-height: 44px; padding-top: 0.2rem; padding-bottom: 0.2rem; }
  .tutorial-mini span { padding: 0.18rem 0.15rem; }
}
html body #screen-battle #btn-battle-settings,
html body #screen-battle #btn-forfeit,
html body #screen-battle .weapon-panel .touch-btn { flex: 0 0 44px !important; width: 44px !important; min-width: 44px !important; min-height: 44px !important; }
html body #screen-battle #btn-move-left,
html body #screen-battle #btn-move-right { min-width: 44px !important; min-height: 44px !important; }
html body #screen-battle .weapon-info,
html body #screen-battle #btn-fire,
html body #screen-battle .pad-row .touch-btn { min-height: 44px !important; }
@media (orientation: landscape) and (max-height: 560px) {
  html body #screen-battle .touch-dock > .fire-col { grid-template-columns: 44px minmax(60px, 76px) 44px !important; }
}
html body #screen-battle #slider-angle,
html body #screen-battle #slider-power { min-height: 44px !important; }

/* Full-screen "How to play" (testing): covers the whole screen, notch and home bar included. */
.tutorial-sheet.tutorial-full {
  position: fixed; inset: 0; z-index: 10050;
  width: 100vw; height: 100vh; height: 100dvh;
  margin: 0; padding: calc(0.4rem + var(--safe-t, 0px)) calc(0.7rem + var(--safe-r, 0px)) calc(0.4rem + var(--safe-b, 0px)) calc(0.7rem + var(--safe-l, 0px));
  box-sizing: border-box; display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 0.35rem;
  background: #0b1220; color: #e8eef8; pointer-events: auto; overscroll-behavior: contain; touch-action: manipulation;
}
.tutorial-full .tutorial-top { display: flex; align-items: center; gap: 0.6rem; flex: 0 0 auto; }
.tutorial-full .tutorial-kicker { margin: 0; color: #9fb3cf; font-size: 0.8rem; letter-spacing: 0.06em; text-transform: uppercase; min-width: 4.5rem; }
.tutorial-full .tutorial-head { flex: 1; text-align: center; font-family: var(--display); font-size: 0.95rem; letter-spacing: 0.08em; color: #c9d6ea; }
.tutorial-full .tutorial-skip { min-height: 44px; min-width: 88px; font-size: 0.95rem; }
.tutorial-full .tutorial-main { flex: 1 1 auto; min-height: 0; display: flex; gap: 0.9rem; align-items: stretch; }
.tutorial-full .tutorial-pic { flex: 1 1 64%; min-width: 0; min-height: 0; display: flex; align-items: center; justify-content: center; }
.tutorial-full .tutorial-pic img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; border-radius: 12px; border: 1px solid #2a3a55; user-select: none; -webkit-user-drag: none; }
.tutorial-full .tutorial-text { flex: 0 0 34%; max-width: 22rem; display: flex; flex-direction: column; justify-content: center; gap: 0.55rem; min-height: 0; }
.tutorial-full h2 { margin: 0; font-family: var(--display); font-size: 1.35rem; letter-spacing: 0.03em; }
.tutorial-full #tutorial-body { margin: 0; color: #c5d2e4; font-size: 1rem; line-height: 1.4; }
.tutorial-full .tutorial-dots { display: flex; gap: 10px; padding: 6px 0; }
.tutorial-full .tutorial-dot { display: block; width: 10px; height: 10px; border-radius: 50%; background: #3a4b66; }
.tutorial-full .tutorial-dot.on { background: #ffb547; }
.tutorial-full .tutorial-actions { display: flex; gap: 0.5rem; }
.tutorial-full .tutorial-actions .btn { flex: 1; min-height: 48px; min-width: 44px; font-size: 1rem; padding: 0.4rem 0.8rem; }
.tutorial-full .tutorial-actions .btn:disabled { opacity: 0.35; }
html.tutorial-open, html.tutorial-open body { overflow: hidden; }
@media (max-height: 440px) {
  .tutorial-full h2 { font-size: 1.1rem; }
  .tutorial-full #tutorial-body { font-size: 0.88rem; line-height: 1.3; }
  .tutorial-full .tutorial-text { gap: 0.25rem; }
  .tutorial-full .tutorial-actions .btn { min-height: 44px; }
  .tutorial-full .tutorial-sheet, .tutorial-sheet.tutorial-full { padding-top: calc(0.25rem + var(--safe-t, 0px)); padding-bottom: calc(0.25rem + var(--safe-b, 0px)); }
}

/* b250: Restore Purchases (iOS app only; [hidden] when the App Store bridge is missing) */
.ia-restore-btn[hidden], .mv-restore[hidden], .ia-restore-msg[hidden] { display: none !important; }
.ia-restore-btn { display: block; width: 100%; min-height: 46px; margin: 0.5rem 0 0.35rem; font-weight: 700; color: #eef3fb; background: linear-gradient(180deg, #1a2740, #0c1422); border: 1px solid rgba(94,224,255,0.85); border-radius: 12px; }
.mv-util-btn.mv-restore { display: inline-flex !important; width: auto !important; padding: 0 0.8rem !important; white-space: nowrap; font-weight: 700; color: #eef3fb; border-color: rgba(94,224,255,0.7); }
.ia-restore-msg { margin: 0.25rem 0 0.5rem; font-size: 0.82rem; color: #cbd5e1; text-align: center; }
.ia-restore-msg[data-tone="good"] { color: #86efac; }
.ia-restore-msg[data-tone="bad"] { color: #fca5a5; }
.mv-restore-msg { position: absolute; z-index: 3; top: calc(0.6rem + 44px); right: 0.8rem; max-width: min(80vw, 360px); padding: 0.45rem 0.7rem; border-radius: 10px; background: rgba(8,14,28,0.85); border: 1px solid rgba(94,224,255,0.5); text-align: right; }
