/* ============================================================
   TANK BATTLE — retro arcade styling
   ============================================================ */

:root {
  --bg: #070a0e;
  --panel: #0f1720;
  --panel-2: #131d27;
  --line: rgba(126, 168, 196, 0.16);
  --line-strong: rgba(126, 168, 196, 0.32);
  --text: #dfe9f1;
  --dim: #7d90a0;
  --amber: #ffcb45;
  --amber-soft: rgba(255, 203, 69, 0.12);
  --green: #54e0a0;
  --red: #ff5f5f;
  --font: ui-monospace, "Cascadia Mono", "SF Mono", "Segoe UI Mono", Consolas, "Liberation Mono", "Microsoft YaHei", "PingFang SC", "Noto Sans SC", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
}

body {
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1100px 560px at 50% -10%, rgba(255, 203, 69, 0.06), transparent 60%),
    radial-gradient(900px 520px at 50% 112%, rgba(84, 224, 160, 0.05), transparent 60%),
    var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 18px 32px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.017) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.017) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: radial-gradient(circle at 50% 38%, #000, transparent 72%);
  mask-image: radial-gradient(circle at 50% 38%, #000, transparent 72%);
}

.app {
  width: 100%;
  max-width: 590px;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-block: auto;
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 2px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-icon {
  width: 38px;
  height: 38px;
  flex: none;
  filter: drop-shadow(0 0 12px rgba(255, 203, 69, 0.28));
}

.brand-text h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.3em;
  color: var(--amber);
  text-shadow: 0 0 22px rgba(255, 203, 69, 0.32);
  white-space: nowrap;
}

.brand-text p {
  margin: 3px 0 0;
  font-size: 8px;
  letter-spacing: 0.26em;
  color: var(--dim);
  text-transform: uppercase;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  flex: none;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--dim);
  font-family: var(--font);
  font-size: 14px;
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease, transform 0.12s ease;
}

.icon-btn:hover {
  color: var(--amber);
  border-color: var(--line-strong);
  background: var(--panel-2);
}

.icon-btn:active { transform: scale(0.94); }

.icon-btn.is-off { opacity: 0.38; }

/* ---------- HUD ---------- */

.hud {
  display: grid;
  grid-template-columns: 1.35fr 1.35fr 0.75fr 0.75fr 0.9fr;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 12px 36px -18px rgba(0, 0, 0, 0.9);
}

.stat {
  background: linear-gradient(180deg, rgba(19, 29, 39, 0.96), rgba(11, 17, 24, 0.96));
  padding: 9px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.stat-label {
  font-size: 8px;
  letter-spacing: 0.2em;
  color: var(--dim);
}

.stat-value {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.stat:nth-child(1) .stat-value { color: var(--amber); }
.stat:nth-child(2) .stat-value { color: var(--green); }
.stat:nth-child(4) .stat-value { color: var(--red); }
.stat:nth-child(5) .stat-value { color: #ff9e63; }

/* ---------- cabinet / screen ---------- */

.stage {
  display: flex;
  justify-content: center;
}

.cabinet {
  width: 100%;
  background: linear-gradient(180deg, #141c25 0%, #0a0f15 100%);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 12px 12px 9px;
  box-shadow:
    0 34px 80px -28px rgba(0, 0, 0, 0.95),
    inset 0 1px 0 rgba(255, 255, 255, 0.045);
}

.screen {
  position: relative;
  border-radius: 9px;
  overflow: hidden;
  background: #080b0f;
  border: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow:
    inset 0 0 70px rgba(0, 0, 0, 0.72),
    0 0 0 4px #0a0e13,
    0 0 0 5px var(--line);
  isolation: isolate;
}

#game {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  image-rendering: pixelated;
  background: #0a0f14;
  touch-action: none;
}

.scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.22) 0px,
    rgba(0, 0, 0, 0.22) 1px,
    transparent 1px,
    transparent 3px
  );
  opacity: 0.32;
  mix-blend-mode: multiply;
}

.glare {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background:
    radial-gradient(360px 220px at 50% -8%, rgba(255, 255, 255, 0.05), transparent 70%),
    radial-gradient(140% 100% at 50% 50%, transparent 55%, rgba(0, 0, 0, 0.34) 100%);
}

.cabinet-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 4px 2px;
  font-size: 8px;
  letter-spacing: 0.24em;
  color: var(--dim);
}

.led {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: led-pulse 2.4s ease-in-out infinite;
}

.cabinet-hint {
  margin-left: auto;
  color: rgba(125, 144, 160, 0.68);
  font-size: 9px;
  letter-spacing: 0.06em;
}

@keyframes led-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ---------- overlays ---------- */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(4, 7, 10, 0.78);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s ease, visibility 0.22s ease;
}

.overlay.is-visible {
  opacity: 1;
  visibility: visible;
}

.panel {
  position: relative;
  width: 100%;
  max-width: 336px;
  text-align: center;
  padding: 22px 20px 18px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(21, 31, 42, 0.97), rgba(9, 14, 20, 0.97));
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.66);
  transform: translateY(6px) scale(0.99);
  transition: transform 0.24s ease;
}

.overlay.is-visible .panel {
  transform: translateY(0) scale(1);
}

.panel::before,
.panel::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border: 1px solid rgba(255, 203, 69, 0.5);
  pointer-events: none;
}

.panel::before {
  top: 7px;
  left: 7px;
  border-right: none;
  border-bottom: none;
}

.panel::after {
  right: 7px;
  bottom: 7px;
  border-left: none;
  border-top: none;
}

.panel-kicker {
  margin: 0 0 10px;
  font-size: 8px;
  letter-spacing: 0.34em;
  color: var(--amber);
  animation: blink 1.8s steps(2, end) infinite;
}

@keyframes blink {
  50% { opacity: 0.25; }
}

.panel-title {
  margin: 0;
  font-size: 29px;
  line-height: 1.18;
  font-weight: 800;
  letter-spacing: 0.09em;
  color: var(--text);
  text-shadow: 0 0 30px rgba(255, 203, 69, 0.18);
}

.panel-sub {
  margin: 7px 0 17px;
  font-size: 9px;
  letter-spacing: 0.38em;
  color: var(--dim);
  text-transform: uppercase;
}

.legend {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-bottom: 19px;
  font-size: 9px;
  color: var(--dim);
}

.legend b {
  color: var(--text);
  font-weight: 700;
}

.btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-family: var(--font);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  padding: 12px 18px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.12s ease, box-shadow 0.18s ease;
}

.btn:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.06);
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  width: 100%;
  background: var(--amber);
  border-color: var(--amber);
  color: #171204;
  font-size: 11px;
  letter-spacing: 0.22em;
  box-shadow: 0 8px 26px -10px rgba(255, 203, 69, 0.5);
}

.btn-primary:hover {
  background: #ffd669;
  border-color: #ffd669;
  box-shadow: 0 10px 30px -8px rgba(255, 203, 69, 0.5);
}

.btn-row {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.btn-row .btn { flex: 1; }
.btn-row .btn-primary { width: auto; }

.panel-foot {
  margin: 14px 0 0;
  font-size: 9px;
  line-height: 1.8;
  color: var(--dim);
  letter-spacing: 0.03em;
}

.panel-foot b { color: var(--text); font-weight: 700; }

.hi-line {
  margin-top: 15px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  font-size: 8px;
  letter-spacing: 0.22em;
  color: var(--dim);
}

.hi-line b {
  color: var(--green);
  font-weight: 700;
  letter-spacing: 0.1em;
}

.panel-danger .panel-title {
  color: var(--red);
  text-shadow: 0 0 34px rgba(255, 95, 95, 0.28);
}

.panel-danger .panel-kicker { color: var(--red); }

.panel-win .panel-title {
  color: var(--amber);
  text-shadow: 0 0 34px rgba(255, 203, 69, 0.35);
}

.panel-win .panel-kicker { color: var(--green); }

.results {
  margin: 18px 0 2px;
  border-top: 1px dashed var(--line);
}

.result-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 2px;
  border-bottom: 1px dashed var(--line);
  font-size: 9px;
  letter-spacing: 0.16em;
  color: var(--dim);
}

.result-row b {
  color: var(--text);
  font-size: 11px;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
}

/* ---------- touch controls ---------- */

.touch {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 2px 8px 0;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 48px);
  grid-template-rows: repeat(3, 48px);
  gap: 4px;
}

.dpad-btn {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(19, 29, 39, 0.9);
  color: var(--dim);
  font-size: 14px;
  font-family: var(--font);
  cursor: pointer;
  touch-action: none;
  transition: background 0.1s ease, color 0.1s ease, border-color 0.1s ease;
}

.dpad-btn.up { grid-area: 1 / 2; }
.dpad-btn.left { grid-area: 2 / 1; }
.dpad-btn.right { grid-area: 2 / 3; }
.dpad-btn.down { grid-area: 3 / 2; }

.dpad-btn:active,
.dpad-btn.active {
  background: var(--amber-soft);
  border-color: rgba(255, 203, 69, 0.4);
  color: var(--amber);
}

.fire-btn {
  appearance: none;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: 2px solid #ffb199;
  background: radial-gradient(circle at 35% 28%, #ff8a70, #c22b2b 72%);
  color: #fff;
  font-family: var(--font);
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.08em;
  cursor: pointer;
  touch-action: none;
  box-shadow:
    0 12px 30px -10px rgba(255, 70, 70, 0.45),
    inset 0 -6px 0 rgba(0, 0, 0, 0.28);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.fire-btn:active,
.fire-btn.active {
  transform: scale(0.95);
  box-shadow:
    0 4px 16px -6px rgba(255, 70, 70, 0.5),
    inset 0 -3px 0 rgba(0, 0, 0, 0.3);
}

/* ---------- footer ---------- */

.footer {
  margin-top: 1px;
  text-align: center;
  color: var(--dim);
  font-size: 9px;
  line-height: 1.9;
  letter-spacing: 0.03em;
}

.footer p { margin: 0; }

.footer kbd {
  display: inline-block;
  min-width: 17px;
  padding: 1px 4px;
  margin: 0 1px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.03);
  font-family: var(--font);
  font-size: 8px;
  color: var(--text);
}

.pickups {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 8px !important;
  font-size: 8px;
  letter-spacing: 0.06em;
  opacity: 0.82;
}

.pickups i {
  font-style: normal;
  margin-right: 2px;
}

/* ---------- focus & reduced motion ---------- */

button:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

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

/* ---------- responsive ---------- */

@media (hover: none), (max-width: 760px) {
  .touch { display: flex; }
}

@media (max-width: 540px) {
  body { padding: 16px 12px 24px; }
  .app { gap: 12px; }
  .brand-text h1 { font-size: 14px; letter-spacing: 0.24em; }
  .brand-text p { font-size: 7px; letter-spacing: 0.2em; }
  .brand-icon { width: 32px; height: 32px; }
  .icon-btn { width: 34px; height: 34px; }
  .stat { padding: 8px 9px; }
  .stat-label { font-size: 7px; }
  .stat-value { font-size: 12px; }
  .hud { grid-template-columns: 1.3fr 0.7fr 0.7fr 0.9fr; }
  .stat.hi { display: none; }
  .cabinet { padding: 9px 9px 7px; border-radius: 16px; }
  .cabinet-hint { display: none; }
  .panel { padding: 19px 14px 15px; }
  .panel-title { font-size: 24px; }
  .overlay { padding: 16px; }
  .legend { flex-direction: column; gap: 5px; }
  .dpad { grid-template-columns: repeat(3, 44px); grid-template-rows: repeat(3, 44px); }
  .fire-btn { width: 78px; height: 78px; }
  .footer { font-size: 8px; }
  .footer .keys { display: none; }
}

@media (max-width: 380px) {
  .dpad { grid-template-columns: repeat(3, 40px); grid-template-rows: repeat(3, 40px); }
  .fire-btn { width: 70px; height: 70px; font-size: 11px; }
  .stat-value { font-size: 11px; }
}

@media (min-width: 900px) and (min-height: 900px) {
  .app { max-width: 640px; }
  .brand-text h1 { font-size: 19px; }
}
