:root {
  --ink: #22192b;
  --ink-soft: #5d5269;
  --paper: #fffdf6;
  --line: #22192b;
  --red: #ff4d4d;
  --red-d: #c92f2f;
  --blue: #3d8bff;
  --blue-d: #2563c9;
  --green: #47c94a;
  --green-d: #2f9a32;
  --yellow: #ffc21a;
  --yellow-d: #d39a00;
  --hard: 6px 6px 0 var(--ink);
  --radius: 14px;
  --display: 'Bangers', Impact, 'Arial Black', sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; overscroll-behavior: none; }

body {
  font-family: 'Fredoka', 'Segoe UI', system-ui, sans-serif;
  font-weight: 500;
  color: var(--ink);
  background-color: #ffb627;
  background-image:
    radial-gradient(circle, rgba(34, 25, 43, 0.14) 2px, transparent 2.5px),
    radial-gradient(circle at 50% 0%, #ffe066 0%, #ffb627 55%, #ff8a1f 100%);
  background-size: 18px 18px, 100% 100%;
  background-attachment: fixed;
  overflow-x: hidden;
  user-select: none;
}

button { font-family: inherit; }
input { font-family: inherit; color: var(--ink); }

.screen { display: none; min-height: 100vh; min-height: 100dvh; padding: 28px 16px 40px; }
.screen.active { display: flex; flex-direction: column; align-items: center; }

/* ---------- buttons ---------- */
.btn {
  --bg: var(--blue);
  border: 3px solid var(--ink); cursor: pointer;
  background: var(--bg); color: #fff;
  font-family: var(--display); font-size: 22px; letter-spacing: 0.04em;
  padding: 8px 20px; border-radius: 12px;
  box-shadow: 0 5px 0 var(--ink);
  transition: transform 0.08s, box-shadow 0.08s, filter 0.15s;
  -webkit-text-stroke: 1.2px var(--ink); paint-order: stroke fill;
  white-space: nowrap;
}
@media (hover: hover) { .btn:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-2px) rotate(-1deg); box-shadow: 0 7px 0 var(--ink); } }
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { cursor: not-allowed; filter: grayscale(0.85) opacity(0.6); }
.btn-big { font-size: 30px; padding: 10px 32px; border-radius: 16px; box-shadow: 0 7px 0 var(--ink); }
.btn-small { font-size: 17px; padding: 4px 12px; border-radius: 10px; box-shadow: 0 4px 0 var(--ink); }
.btn-pink { --bg: var(--red); }
.btn-blue { --bg: var(--blue); }
.btn-green { --bg: var(--green); }
.btn-yellow { --bg: var(--yellow); }
.btn-ghost { --bg: #fff; color: var(--ink); -webkit-text-stroke: 0; }

.corner-btns { position: fixed; top: 12px; right: 12px; display: flex; gap: 8px; z-index: 50; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 12px; border: 3px solid var(--ink); cursor: pointer;
  background: #fff; font-size: 19px; box-shadow: 0 4px 0 var(--ink);
}
.icon-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.icon-btn.off { opacity: 0.5; filter: grayscale(1); }

/* ---------- cards ---------- */
.card {
  background: var(--paper);
  border: 4px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--hard);
  padding: 20px;
}
h3 {
  margin: 4px 0 10px; font-family: var(--display); font-weight: 400;
  font-size: 22px; letter-spacing: 0.05em; color: var(--ink);
}
h3 small { font-family: 'Fredoka', sans-serif; font-size: 13px; font-weight: 600; color: var(--ink-soft); letter-spacing: 0; }

/* ---------- menu ---------- */
.logo {
  margin: 14px 0 0;
  font-family: var(--display); font-weight: 400;
  font-size: clamp(44px, 13vw, 112px);
  line-height: 1; letter-spacing: 0.03em;
  display: flex; align-items: center; gap: 0.15em;
  transform: rotate(-4deg);
}
.logo .l1, .logo .l2 {
  -webkit-text-stroke: 7px var(--ink); paint-order: stroke fill;
  text-shadow: 6px 7px 0 var(--ink);
}
.logo .l1 { color: var(--red); animation: bob 2.4s ease-in-out infinite; }
.logo .l2 { color: var(--blue); animation: bob 2.4s ease-in-out infinite 0.3s; }
.logo .amp {
  color: var(--ink); background: var(--yellow);
  width: 1.1em; height: 1.1em; display: grid; place-items: center;
  font-size: 0.55em;
  clip-path: polygon(50% 0%, 61% 25%, 88% 12%, 78% 39%, 100% 50%, 78% 61%, 88% 88%, 61% 75%, 50% 100%, 39% 75%, 12% 88%, 22% 61%, 0% 50%, 22% 39%, 12% 12%, 39% 25%);
  animation: spin 6s linear infinite;
}
.tagline {
  margin: 22px 0 26px; font-size: 18px; font-weight: 600;
  background: var(--ink); color: #fff; padding: 6px 16px; border-radius: 8px;
  transform: rotate(-1.5deg);
}
.tagline b { font-family: var(--display); font-weight: 400; color: var(--yellow); letter-spacing: 0.06em; font-size: 22px; }

@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes wiggle { 0%, 100% { transform: rotate(-10deg); } 50% { transform: rotate(10deg); } }

.menu-grid { display: grid; grid-template-columns: 320px 420px; gap: 26px; max-width: 100%; }
.profile { display: flex; flex-direction: column; align-items: center; gap: 12px; transform: rotate(-1deg); }
.play { transform: rotate(0.8deg); }
#menuTank {
  width: 240px; height: 170px;
  background: repeating-conic-gradient(#f6d894 0 25%, #efcc80 0 50%) 0 0 / 40px 40px;
  border-radius: 10px; border: 4px solid var(--ink);
}
.field { display: flex; flex-direction: column; gap: 6px; width: 100%; min-width: 0; }
.field input { width: 100%; min-width: 0; }
.field > span { font-family: var(--display); font-size: 18px; letter-spacing: 0.05em; }
input {
  border: 3px solid var(--ink); background: #fff; border-radius: 10px;
  font-size: 18px; font-weight: 600; padding: 9px 14px; outline: none;
  box-shadow: inset 0 3px 0 rgba(34, 25, 43, 0.12);
}
input:focus { box-shadow: inset 0 3px 0 rgba(34, 25, 43, 0.12), 0 0 0 3px var(--yellow); }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--ink); background: var(--c); cursor: pointer;
  box-shadow: 0 3px 0 var(--ink);
  transition: transform 0.12s;
  position: relative;
}
@media (hover: hover) { .swatch:hover:not(:disabled) { transform: scale(1.12) rotate(-8deg); } }
.swatch.on { transform: scale(1.18); box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--ink); }
.swatch.on::after {
  content: '✓'; position: absolute; inset: 0; display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 16px; -webkit-text-stroke: 1px var(--ink); paint-order: stroke fill;
}
.swatch.taken { opacity: 0.3; cursor: not-allowed; }
.swatches.small .swatch { width: 28px; height: 28px; }

.play { display: flex; flex-direction: column; gap: 12px; }
.play #createBtn { width: 100%; }
.divider { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; margin: 4px 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 3px; border-radius: 3px; background: var(--ink); }
.join-row { display: flex; gap: 10px; }
.join-row input { flex: 1; min-width: 0; text-align: center; font-family: var(--display); font-weight: 400; font-size: 26px; padding: 4px 10px; letter-spacing: 0.3em; text-transform: uppercase; }
.lobby-list { display: flex; flex-direction: column; gap: 8px; max-height: 230px; overflow-y: auto; }
.lobby-item {
  display: flex; align-items: center; gap: 12px;
  background: #fff; border-radius: 10px; padding: 8px 10px;
  border: 3px solid var(--ink); box-shadow: 0 3px 0 var(--ink);
}
.li-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.li-main b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-meta { font-size: 13px; color: var(--ink-soft); }
.li-meta code { font-family: var(--display); font-size: 15px; letter-spacing: 0.12em; color: var(--ink); }
.li-count { color: var(--red); letter-spacing: 1px; font-size: 13px; }
.li-count span { color: #d8cfc0; }
.empty { color: var(--ink-soft); text-align: center; padding: 18px 0; font-weight: 600; }

.controls-hint {
  margin-top: 28px; display: flex; gap: 18px; flex-wrap: wrap; justify-content: center;
  font-size: 15px; font-weight: 600;
  background: var(--paper); border: 3px solid var(--ink); border-radius: 12px; padding: 8px 16px; box-shadow: 0 4px 0 var(--ink);
}
kbd {
  display: inline-block; min-width: 24px; padding: 1px 7px; margin: 0 2px;
  font-family: inherit; font-size: 13px; font-weight: 700; text-align: center;
  background: #fff; border: 2px solid var(--ink); border-radius: 6px; box-shadow: 0 2px 0 var(--ink); color: var(--ink);
}

/* ---------- lobby ---------- */
#lobby { gap: 22px; }
.lobby-top { width: min(1000px, 100%); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; }
.lobby-top .btn-ghost { justify-self: start; }
.code-box {
  display: flex; align-items: center; gap: 12px;
  background: var(--paper); padding: 6px 10px 6px 18px; border-radius: 14px;
  border: 4px solid var(--ink); box-shadow: var(--hard);
  font-family: var(--display); font-size: 20px; letter-spacing: 0.05em;
  transform: rotate(-1deg);
}
.code-box b {
  font-weight: 400; font-size: 40px; letter-spacing: 0.15em; color: var(--red);
  -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill;
}

.slots { width: min(1000px, 100%); display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.slot {
  position: relative; min-height: 215px; border-radius: var(--radius);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: 18px 10px 14px;
}
.slot.filled {
  background: var(--paper); border: 4px solid var(--ink); box-shadow: var(--hard);
  animation: slam 0.35s cubic-bezier(0.3, 1.6, 0.6, 1);
  overflow: hidden;
}
.slot.filled:nth-child(odd) { transform: rotate(-1deg); }
.slot.filled:nth-child(even) { transform: rotate(1deg); }
.slot.filled::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 14px;
  background: repeating-linear-gradient(-45deg, var(--c) 0 10px, rgba(255, 255, 255, 0.35) 10px 20px), var(--c);
  border-bottom: 3px solid var(--ink);
}
.slot.me { box-shadow: 0 0 0 4px var(--c), 10px 10px 0 var(--ink); }
.slot.empty { border: 4px dashed rgba(34, 25, 43, 0.45); background: rgba(255, 253, 246, 0.4); color: var(--ink); }
.slot-empty-icon { font-size: 34px; opacity: 0.5; font-weight: 700; }
.slot-wait { font-size: 14px; font-weight: 600; }
.dots i { font-style: normal; animation: blink 1.4s infinite; }
.dots i:nth-child(2) { animation-delay: 0.2s; }
.dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 100% { opacity: 0.2; } 50% { opacity: 1; } }
.slot-tank { width: 150px; height: 110px; }
.slot-name { font-family: var(--display); font-size: 24px; letter-spacing: 0.04em; text-align: center; word-break: break-word; line-height: 1.1; }
.crown { margin-right: 4px; }
.tag {
  font-family: 'Fredoka', sans-serif; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 5px;
  background: #fff; border: 2px solid var(--ink); color: var(--ink); vertical-align: middle; letter-spacing: 0;
}
.tag.you { background: var(--c); color: #fff; }
.slot-status { font-size: 13px; font-weight: 700; padding: 2px 12px; border-radius: 99px; background: #eee6d8; border: 2px solid var(--ink); }
.slot-status.ready { background: var(--green); color: #fff; }
.slot-status.host { background: var(--yellow); }
.kick {
  position: absolute; top: 22px; right: 10px; width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid var(--ink); background: #fff; color: var(--ink); cursor: pointer; font-size: 13px; font-weight: 700;
}
.kick:hover { background: var(--red); color: #fff; }
@keyframes slam { from { transform: scale(1.4) rotate(6deg); opacity: 0; } to { opacity: 1; } }

.lobby-grid { width: min(1000px, 100%); display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; }
.map-picker { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 14px; }
.map-card {
  border: 3px solid var(--ink); background: #fff; border-radius: 10px; padding: 5px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-family: var(--display); font-size: 16px; letter-spacing: 0.04em; color: var(--ink);
  box-shadow: 0 4px 0 var(--ink); transition: transform 0.12s;
}
.map-card canvas { width: 100%; height: auto; border-radius: 5px; display: block; border: 2px solid var(--ink); }
@media (hover: hover) { .map-card:hover:not(:disabled) { transform: translateY(-3px) rotate(-2deg); } }
.map-card:disabled { cursor: default; }
.map-card.on { background: var(--yellow); transform: rotate(-2deg) scale(1.04); }
.map-card:disabled:not(.on) { opacity: 0.55; }
.settings-row { display: flex; gap: 28px; flex-wrap: wrap; }
.seg { display: flex; gap: 6px; }
.seg-btn {
  border: 3px solid var(--ink); background: #fff; border-radius: 10px; padding: 4px 14px;
  font-family: var(--display); font-size: 20px; letter-spacing: 0.04em;
  color: var(--ink); cursor: pointer; box-shadow: 0 3px 0 var(--ink);
}
.seg-btn.on { background: var(--yellow); }
.seg-btn:disabled { cursor: default; }
.seg-btn:disabled:not(.on) { opacity: 0.55; }

.chat { display: flex; flex-direction: column; min-height: 0; }
.chat-log {
  flex: 1; min-height: 150px; max-height: 210px; overflow-y: auto;
  background: #fff; border-radius: 10px; padding: 10px 12px; margin-bottom: 10px;
  font-size: 15px; display: flex; flex-direction: column; gap: 4px;
  border: 3px solid var(--ink); user-select: text;
}
.chat-msg { word-break: break-word; }
.chat-msg b { -webkit-text-stroke: 0.6px var(--ink); }
.chat-sys { color: var(--ink-soft); font-style: italic; font-size: 13px; }
#chatForm input { width: 100%; font-size: 16px; padding: 8px 12px; }

.lobby-actions { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.lobby-actions .btn { min-width: min(300px, 100%); }
#readyBtn.is-ready { --bg: #fff; color: var(--green-d); -webkit-text-stroke: 0; }
.hint { font-size: 15px; font-weight: 600; background: var(--paper); border: 3px solid var(--ink); border-radius: 10px; padding: 4px 12px; }

/* ---------- game ---------- */
#game { padding: 12px 12px 0; gap: 10px; }
body[data-screen='game'] .corner-btns { top: auto; bottom: 12px; }
#quitBtn { display: none; }
body[data-screen='game'] #quitBtn { display: block; }
.hud { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; align-items: center; min-height: 44px; }
.chip {
  display: flex; align-items: center; gap: 8px; background: var(--paper); border-radius: 10px;
  padding: 4px 12px 4px 6px; box-shadow: 0 4px 0 var(--ink); font-weight: 700;
  border: 3px solid var(--ink); transition: opacity 0.2s, filter 0.2s;
}
.chip.dead { opacity: 0.6; filter: grayscale(0.9); }
.chip.gone { opacity: 0.3; text-decoration: line-through; }
.chip-dot { width: 20px; height: 20px; border-radius: 6px; background: var(--c); border: 2px solid var(--ink); }
.chip-name em { font-style: normal; color: var(--ink-soft); font-weight: 600; font-size: 13px; }
.pips { display: flex; gap: 3px; }
.pips i { width: 14px; height: 14px; border-radius: 50%; background: #e6dccb; border: 2px solid var(--ink); transition: background 0.3s, transform 0.3s; }
.pips i.on { background: var(--yellow); transform: scale(1.15) rotate(15deg); }
.round-pill {
  background: var(--ink); color: #fff; border-radius: 10px; padding: 4px 14px;
  font-family: var(--display); font-size: 20px; letter-spacing: 0.05em; box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3);
}

.stage { position: relative; border-radius: 12px; overflow: hidden; border: 5px solid var(--ink); box-shadow: 8px 8px 0 var(--ink); box-sizing: content-box; }
#gameCanvas { display: block; cursor: none; }

.banner { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.banner-inner { text-align: center; animation: bannerPop 1.7s cubic-bezier(0.3, 1.5, 0.5, 1) forwards; }
.b-title {
  font-family: var(--display); font-size: clamp(34px, 12vh, 84px); letter-spacing: 0.04em; line-height: 1;
  color: var(--c, var(--yellow));
  -webkit-text-stroke: 10px var(--ink); paint-order: stroke fill;
  text-shadow: 7px 8px 0 var(--ink);
  transform: rotate(-4deg);
}
.b-sub {
  display: inline-block; margin-top: 12px; font-size: 18px; font-weight: 700; color: #fff;
  background: var(--ink); padding: 4px 14px; border-radius: 8px; transform: rotate(-2deg);
}
.banner-inner.count .b-title { font-size: clamp(64px, 24vh, 150px); color: var(--yellow); }
.banner-inner.go .b-title { font-size: clamp(64px, 24vh, 150px); color: var(--green); }
.banner-inner.small .b-title { font-size: clamp(30px, 9vh, 60px); color: var(--red); }
.banner-inner.count, .banner-inner.go { animation-duration: 0.95s; }
@keyframes bannerPop {
  0% { transform: scale(2.4); opacity: 0; }
  14% { transform: scale(0.92); opacity: 1; }
  24% { transform: scale(1); }
  75% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.85); }
}

.feed { position: absolute; top: 12px; right: 12px; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; pointer-events: none; }
.feed-item {
  background: var(--paper); border: 3px solid var(--ink); border-radius: 10px; padding: 3px 12px; font-size: 14px; font-weight: 600;
  box-shadow: 0 3px 0 var(--ink); animation: slideIn 0.3s cubic-bezier(0.3, 1.5, 0.5, 1);
  transition: opacity 0.4s, transform 0.4s;
}
.feed-item b { -webkit-text-stroke: 0.5px var(--ink); }
.feed-item.out { opacity: 0; transform: translateX(20px); }
.feed-boom { display: inline-block; animation: wiggle 0.5s ease-in-out infinite; }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

.ammo { position: absolute; left: 12px; bottom: 12px; display: flex; gap: 10px; align-items: center; pointer-events: none; }
.ammo-group { display: flex; gap: 4px; background: var(--paper); padding: 5px 8px; border-radius: 10px; border: 3px solid var(--ink); box-shadow: 0 3px 0 var(--ink); }
.ammo-bullet { width: 9px; height: 18px; border-radius: 5px 5px 2px 2px; background: linear-gradient(var(--red) 0 40%, #fff 40%); border: 2px solid var(--ink); transition: opacity 0.15s; }
.ammo-mine { width: 18px; height: 18px; border-radius: 50%; background: #3a3146; border: 3px solid var(--yellow); outline: 2px solid var(--ink); transition: opacity 0.15s; }
.ammo-bullet.used, .ammo-mine.used { opacity: 0.2; }
.ammo-buff { background: var(--c); border: 3px solid var(--ink); border-radius: 10px; padding: 2px 9px; font-weight: 700; font-size: 14px; color: #fff; -webkit-text-stroke: 0.6px var(--ink); box-shadow: 0 3px 0 var(--ink); }

.overlay {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(34, 25, 43, 0.55);
  animation: fadeIn 0.4s;
}
.overlay.hidden { display: none; }
@keyframes fadeIn { from { opacity: 0; } }
.go-card {
  background: var(--paper); border: 5px solid var(--ink); border-radius: 18px; box-shadow: 10px 10px 0 var(--ink);
  padding: 10px 28px 22px; text-align: center; min-width: 400px;
  animation: slam 0.45s cubic-bezier(0.3, 1.6, 0.6, 1);
  transform: rotate(-1.5deg);
}
.go-tank { width: 200px; height: 140px; margin-top: -4px; }
.go-card h2 {
  margin: 0 0 12px; font-family: var(--display); font-weight: 400; font-size: 58px; letter-spacing: 0.04em; line-height: 1;
  color: var(--yellow); -webkit-text-stroke: 7px var(--ink); paint-order: stroke fill; text-shadow: 5px 6px 0 var(--ink);
}
.go-table { width: 100%; border-collapse: separate; border-spacing: 0 5px; font-size: 16px; font-weight: 600; }
.go-table th { font-family: var(--display); font-weight: 400; font-size: 17px; letter-spacing: 0.05em; padding: 0 8px; }
.go-table td { background: #fff; padding: 6px 10px; border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink); }
.go-table td:first-child { border-radius: 8px 0 0 8px; border-left: 2px solid var(--ink); }
.go-table td:last-child { border-radius: 0 8px 8px 0; border-right: 2px solid var(--ink); }
.go-table td:nth-child(2) { text-align: left; }
.go-table tr.me td { background: #ffe58a; }
.dot { display: inline-block; width: 13px; height: 13px; border-radius: 4px; margin-right: 8px; vertical-align: -1px; border: 2px solid var(--ink); }
.go-foot { margin-top: 14px; font-size: 14px; font-weight: 600; color: var(--ink-soft); }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 160%);
  background: var(--ink); color: #fff; padding: 10px 22px; border-radius: 12px; font-weight: 600;
  border: 3px solid #fff; box-shadow: 5px 5px 0 rgba(34, 25, 43, 0.5);
  transition: transform 0.3s cubic-bezier(0.3, 1.5, 0.5, 1);
  z-index: 100; max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { transform: translate(-50%, 0); }

/* ---------- small screens ---------- */
@media (max-width: 820px) {
  .menu-grid, .lobby-grid { grid-template-columns: minmax(0, 1fr); width: 100%; }
  .slots { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .map-picker { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .lobby-top { grid-template-columns: 1fr; justify-items: center; }
  .lobby-top .spacer { display: none; }
  .go-card { min-width: 0; width: calc(100% - 32px); }
}

/* ---------- touch / phones ---------- */
.only-touch { display: none !important; }
@media (pointer: coarse) {
  .only-touch { display: flex !important; }
  .only-mouse { display: none !important; }
}
@media (max-width: 600px) {
  .screen { padding-top: 64px; }
  .slot { min-height: 180px; }
  .b-sub { font-size: 13px; }
}
button, input { touch-action: manipulation; }
body[data-screen='game'] { overflow: hidden; }
#game {
  touch-action: none; -webkit-touch-callout: none; -webkit-user-select: none;
  padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right));
}

.touch-ui { display: none; }
body.touch-mode .touch-ui { display: block; }
/* faint "where do my thumbs go" rings */
body.touch-mode .touch-ui::before,
body.touch-mode .touch-ui::after {
  content: 'MOVE'; position: fixed; bottom: max(24px, env(safe-area-inset-bottom)); left: max(24px, env(safe-area-inset-left));
  width: 92px; height: 92px; border-radius: 50%; border: 3px dashed rgba(34, 25, 43, 0.35);
  display: grid; place-items: center; font-family: var(--display); font-size: 18px; letter-spacing: 0.06em;
  color: rgba(34, 25, 43, 0.45); pointer-events: none; z-index: 29;
}
body.touch-mode .touch-ui::after { content: 'AIM'; left: auto; right: max(24px, env(safe-area-inset-right)); }
.stick { position: fixed; left: 0; top: 0; width: 0; height: 0; pointer-events: none; z-index: 30; opacity: 0; transition: opacity 0.12s; }
.stick.on { opacity: 1; }
.stick::before {
  content: ''; position: absolute; left: -56px; top: -56px; width: 112px; height: 112px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.2); border: 4px solid rgba(34, 25, 43, 0.6); box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.35);
}
.stick .knob {
  position: absolute; left: -26px; top: -26px; width: 52px; height: 52px; border-radius: 50%;
  background: var(--blue); border: 4px solid var(--ink); box-shadow: 0 4px 0 var(--ink);
}
.stick.aim .knob { background: var(--red); }
.mine-btn {
  position: fixed; right: max(36px, calc(env(safe-area-inset-right) + 12px)); bottom: 136px;
  width: 64px; height: 64px; border-radius: 50%; padding: 0;
  background: var(--yellow); border: 4px solid var(--ink); box-shadow: 0 5px 0 var(--ink);
  font-size: 28px; z-index: 31; touch-action: none; cursor: pointer;
}
.mine-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }

/* compact in-game layout for phones */
body.touch-mode #game { padding-top: max(4px, env(safe-area-inset-top)); padding-bottom: 0; gap: 4px; }
body.touch-mode .hud { min-height: 0; gap: 5px; }
body.touch-mode .chip { padding: 1px 8px 1px 4px; font-size: 12px; border-width: 2px; box-shadow: 0 2px 0 var(--ink); gap: 5px; }
body.touch-mode .chip-dot { width: 13px; height: 13px; border-radius: 4px; }
body.touch-mode .chip-name em { display: none; }
body.touch-mode .pips i { width: 9px; height: 9px; border-width: 1.5px; }
body.touch-mode .round-pill { font-size: 14px; padding: 1px 8px; box-shadow: none; }
body.touch-mode .stage { border-width: 3px; box-shadow: 4px 4px 0 var(--ink); }
body.touch-mode .ammo { left: 50%; bottom: 4px; transform: translateX(-50%) scale(0.7); transform-origin: bottom center; opacity: 0.9; }
body.touch-mode .feed { top: 6px; right: 6px; transform: scale(0.8); transform-origin: top right; }
body[data-screen='game'].touch-mode .corner-btns {
  top: max(6px, env(safe-area-inset-top)); bottom: auto; right: max(6px, env(safe-area-inset-right));
  flex-direction: column; gap: 6px;
}
body.touch-mode .icon-btn { width: 34px; height: 34px; font-size: 15px; border-width: 2px; box-shadow: 0 3px 0 var(--ink); }

@media (max-height: 520px) {
  .go-card { padding: 4px 14px 10px; min-width: 0; }
  .go-tank { width: 110px; height: 76px; }
  .go-card h2 { font-size: 34px; margin-bottom: 4px; }
  .go-table { font-size: 13px; }
  .go-table td { padding: 3px 8px; }
  .go-foot { margin-top: 6px; }
  .b-sub { font-size: 13px; margin-top: 6px; }
}

.rotate-hint {
  display: none; position: fixed; inset: 0; z-index: 60;
  background: rgba(34, 25, 43, 0.94); color: #fff;
  flex-direction: column; align-items: center; justify-content: center; gap: 18px; text-align: center;
  font-family: var(--display); font-size: 30px; letter-spacing: 0.04em; padding: 24px;
}
.rotate-hint p { margin: 0; }
.rotate-note { font-family: "Fredoka", sans-serif; font-size: 14px; font-weight: 600; letter-spacing: 0; opacity: 0.75; max-width: 280px; }
.rotate-icon { font-size: 70px; animation: rotatePhone 1.8s ease-in-out infinite; }
@keyframes rotatePhone { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
@media (orientation: portrait) and (pointer: coarse) {
  body[data-screen='game']:not(.rotate-ok) .rotate-hint { display: flex; }
}
