:root {
  --bg: #0b0f19;
  --surface: rgba(17, 24, 39, .95);
  --surface-2: rgba(12, 19, 32, .98);
  --surface-hover: rgba(23, 32, 53, .98);
  --text: #e8f0ff;
  --muted: #8aa0b7;
  --accent: #6ee7ff;
  --accent-soft: rgba(110, 231, 255, .12);
  --accent-border: rgba(110, 231, 255, .34);
  --border: rgba(255, 255, 255, .09);
  --border-strong: rgba(255, 255, 255, .15);
  --danger: #ff9aa7;
  --warning: #ffd166;
  --radius: 20px;
  --radius-small: 13px;
  --shadow: 0 18px 48px rgba(0, 0, 0, .34);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body.arcade-game-page {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(900px 520px at 13% -12%, rgba(91, 139, 255, .105), transparent 62%),
    radial-gradient(760px 460px at 104% 4%, rgba(110, 231, 255, .055), transparent 65%),
    var(--bg);
  font-family: Poppins, system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.game-backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: .54;
  background-image:
    linear-gradient(rgba(110, 231, 255, .025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(110, 231, 255, .025) 1px, transparent 1px);
  background-size: 54px 54px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.8), transparent 88%);
}

.game-topbar {
  width: min(1180px, calc(100% - 36px));
  min-height: 64px;
  margin: 0 auto;
  padding: 18px 0 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.game-brand {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .02em;
  white-space: nowrap;
}

.game-brand-mark {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--accent-border);
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: 0 10px 24px rgba(0, 0, 0, .22);
}

.game-brand-path { color: var(--muted); font-weight: 600; }
.top-actions, .game-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.game-button,
.game-icon-button {
  appearance: none;
  min-height: 38px;
  padding: 9px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-small);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--text);
  background: rgba(255,255,255,.045);
  text-decoration: none;
  font-weight: 700;
  font-size: 12.5px;
  line-height: 1;
  cursor: pointer;
  transition: transform .17s ease, background-color .17s ease, border-color .17s ease, box-shadow .17s ease, opacity .17s ease;
}
.game-button:hover,
.game-icon-button:hover {
  transform: translateY(-2px);
  background: var(--accent-soft);
  border-color: var(--accent-border);
  box-shadow: 0 12px 26px rgba(0,0,0,.26);
}
.game-button:active,
.game-icon-button:active { transform: translateY(0); }
.game-button.primary {
  color: #eaffff;
  background: rgba(110,231,255,.16);
  border-color: rgba(110,231,255,.42);
}
.game-button.danger {
  color: #ffdbe0;
  background: rgba(255,154,167,.07);
  border-color: rgba(255,154,167,.25);
}
.game-button:disabled { opacity: .48; cursor: not-allowed; transform: none; box-shadow: none; }
.game-icon-button { width: 38px; padding: 0; }

.game-main {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
}
.game-hero {
  width: min(820px, 100%);
  margin: 0 auto;
  padding: 48px 0 28px;
  text-align: center;
}
.game-eyebrow {
  margin: 0 0 9px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .22em;
  text-transform: uppercase;
}
.game-hero h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(34px, 5.4vw, 54px);
  line-height: 1.08;
  letter-spacing: -.025em;
}
.game-hero > p:not(.game-eyebrow) {
  max-width: 680px;
  margin: 13px auto 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}
.game-summary {
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.game-summary span {
  min-height: 31px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255,255,255,.03);
  color: #b9c9dc;
  font-size: 10.5px;
  font-weight: 600;
}
.game-summary strong { color: var(--accent); }

.game-card {
  width: min(1000px, 100%);
  margin: 0 auto;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background:
    radial-gradient(580px 220px at 0% 0%, rgba(110,231,255,.045), transparent 68%),
    linear-gradient(180deg, var(--surface), var(--surface-2));
  box-shadow: var(--shadow);
}
.game-card.wide { width: 100%; }
.game-card + .game-card { margin-top: 18px; }

.game-card-head,
.game-toolbar,
.game-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.game-card-head { margin-bottom: 14px; }
.game-card-title { min-width: 0; }
.game-card-title h2 { margin: 0; font-size: 18px; line-height: 1.25; }
.game-card-title p { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }

.game-toolbar {
  margin-bottom: 14px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: rgba(255,255,255,.025);
}
.game-toolbar-group { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.game-label { display: flex; align-items: center; gap: 8px; color: #c9d9ec; font-size: 12px; font-weight: 700; }
.game-select,
.game-input {
  min-height: 38px;
  min-width: 0;
  padding: 8px 11px;
  border: 1px solid rgba(69,88,124,.76);
  border-radius: 11px;
  outline: none;
  color: var(--text);
  background: #0f1626;
  font-size: 12.5px;
  transition: border-color .16s ease, box-shadow .16s ease;
}
.game-select:focus,
.game-input:focus { border-color: rgba(110,231,255,.56); box-shadow: 0 0 0 3px rgba(110,231,255,.08); }
input[type="color"].game-color {
  width: 38px;
  height: 38px;
  padding: 3px;
  border: 1px solid rgba(69,88,124,.76);
  border-radius: 11px;
  background: #0f1626;
  cursor: pointer;
}

.game-stage {
  position: relative;
  min-width: 0;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 17px;
  overflow: hidden;
  background: #080d16;
  box-shadow: inset 0 0 34px rgba(0,0,0,.28);
}
.game-canvas-wrap {
  position: relative;
  width: min(100%, 720px);
  margin: 0 auto;
  touch-action: none;
  overscroll-behavior: contain;
  user-select: none;
  -webkit-user-select: none;
}
.game-canvas-wrap canvas,
canvas.game-canvas {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.game-hud { margin-top: 12px; }
.game-stat {
  min-height: 34px;
  padding: 8px 11px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255,255,255,.035);
  color: #cfe0f7;
  font-size: 11.5px;
  font-weight: 700;
}
.game-stat strong { color: var(--accent); }

.game-help-grid {
  width: min(1000px, 100%);
  margin: 18px auto 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 12px;
}
.game-help-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(17,24,39,.62);
}
.game-help-card strong { display: block; margin-bottom: 4px; color: #dffaff; font-size: 12px; }
.game-help-card p { margin: 0; color: var(--muted); font-size: 11.5px; line-height: 1.55; }

.game-modal {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(4,8,14,.72);
  backdrop-filter: blur(6px);
}
.game-modal[hidden], .game-modal.hidden { display: none; }
.game-modal-card {
  width: min(390px,100%);
  padding: 20px;
  border: 1px solid var(--accent-border);
  border-radius: 18px;
  background: linear-gradient(180deg,#131d30,#0d1423);
  box-shadow: 0 22px 54px rgba(0,0,0,.48);
  text-align: center;
}
.game-modal-card h2, .game-modal-card h3 { margin: 0 0 7px; font-size: 22px; }
.game-modal-card p { margin: 5px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.game-modal-actions { margin-top: 16px; display: flex; justify-content: center; gap: 9px; flex-wrap: wrap; }

.mobile-controls {
  display: none;
  margin-top: 13px;
  justify-content: center;
  gap: 9px;
  touch-action: none;
  user-select: none;
}
.mobile-control {
  width: 54px;
  height: 48px;
  padding: 0;
  border: 1px solid var(--accent-border);
  border-radius: 14px;
  color: var(--text);
  background: rgba(110,231,255,.08);
  font-size: 19px;
  font-weight: 800;
  cursor: pointer;
}
.mobile-control:active,
.mobile-control.is-active { background: rgba(110,231,255,.2); transform: translateY(1px); }
.mobile-dpad {
  width: 174px;
  margin: 13px auto 0;
  display: none;
  grid-template-columns: repeat(3,54px);
  grid-template-rows: repeat(2,48px);
  gap: 6px;
  justify-content: center;
  touch-action: none;
}
.mobile-dpad .up { grid-column: 2; grid-row: 1; }
.mobile-dpad .left { grid-column: 1; grid-row: 2; }
.mobile-dpad .down { grid-column: 2; grid-row: 2; }
.mobile-dpad .right { grid-column: 3; grid-row: 2; }

.game-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 80;
  max-width: min(420px, calc(100vw - 28px));
  padding: 10px 14px;
  border: 1px solid var(--accent-border);
  border-radius: 13px;
  color: #dffaff;
  background: rgba(10,17,29,.96);
  box-shadow: 0 18px 42px rgba(0,0,0,.38);
  font-size: 12px;
  font-weight: 700;
  transform: translate(-50%, 18px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.game-toast.show { opacity: 1; transform: translate(-50%,0); }

@media (max-width: 780px) {
  .game-topbar { width: min(100% - 26px,1180px); padding-top: 14px; align-items: flex-start; }
  .game-brand-path { display: none; }
  .game-main { width: min(100% - 26px,1180px); }
  .game-hero { padding: 38px 0 23px; }
  .game-hero h1 { font-size: clamp(31px,10vw,44px); }
  .game-card { padding: 13px; border-radius: 17px; }
  .game-help-grid { grid-template-columns: 1fr; }
  .mobile-controls { display: flex; }
  .mobile-dpad { display: grid; }
  .desktop-control-note { display: none; }
  .game-toolbar { align-items: stretch; }
  .game-toolbar-group { width: 100%; }
  .game-toolbar .game-button { flex: 1 1 auto; }
}

@media (max-width: 520px) {
  .game-topbar { gap: 10px; }
  .game-brand { font-size: 11.5px; }
  .game-brand-mark { width: 32px; height: 32px; flex-basis: 32px; }
  .top-actions { gap: 6px; }
  .game-button { min-height: 35px; padding: 8px 10px; font-size: 11.5px; }
  .game-hero > p:not(.game-eyebrow) { font-size: 12.5px; }
  .game-summary { gap: 6px; }
  .game-summary span { padding: 6px 8px; font-size: 9.5px; }
  .game-card-title h2 { font-size: 16px; }
  .game-hud { justify-content: center; }
  .game-stat { font-size: 10.5px; }
}

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