:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #050608;
  color: #f8fbff;
  font-synthesis: none;
  --dutton-red: #e2232e;
  --dutton-silver: #d9dee4;
  --signal-cyan: #62eff3;
  --graphite: #111419;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  position: relative;
  margin: 0;
  min-height: 100vh;
  isolation: isolate;
  background:
    radial-gradient(circle at 12% 10%, rgba(37, 225, 235, .13), transparent 28rem),
    radial-gradient(circle at 90% 14%, rgba(226, 35, 46, .12), transparent 29rem),
    linear-gradient(150deg, #080b0f 0%, #11151b 56%, #050608 100%);
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

body::before {
  opacity: .36;
  background:
    linear-gradient(118deg, transparent 0 18%, rgba(111, 236, 241, .045) 18.1% 18.25%, transparent 18.35% 68%, rgba(226, 35, 46, .045) 68.1% 68.25%, transparent 68.35%),
    repeating-linear-gradient(0deg, transparent 0 39px, rgba(255, 255, 255, .018) 40px),
    repeating-linear-gradient(90deg, transparent 0 39px, rgba(255, 255, 255, .014) 40px);
  mask-image: linear-gradient(to bottom, #000, transparent 82%);
}

body::after {
  background: radial-gradient(ellipse at center, transparent 22%, rgba(1, 3, 6, .58) 100%);
}

button { font: inherit; }
.hidden { display: none !important; }
.game-shell { width: min(1380px, 100%); margin: 0 auto; padding: clamp(15px, 3vw, 32px); }
.game-header, .score-strip, footer { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.brand-lockup { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-lockup img { width: 54px; height: 54px; object-fit: contain; }
.brand-lockup h1 { margin: -2px 0 0; font-size: clamp(1.3rem, 4vw, 2.05rem); letter-spacing: .1em; font-style: italic; }
.eyebrow, .panel-tag { color: var(--signal-cyan); font-size: .68rem; font-weight: 900; letter-spacing: .2em; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.activity-mode { padding: 8px 10px; border: 1px solid rgba(101, 232, 238, .2); border-radius: 999px; color: #9ceff2; font-size: .59rem; font-weight: 900; letter-spacing: .11em; }
.sponsor-lockup { position: relative; display: flex; align-items: center; gap: 9px; overflow: hidden; padding: 6px 10px; border: 1px solid rgba(216, 222, 228, .16); border-radius: 10px; background: linear-gradient(135deg, rgba(255,255,255,.055), rgba(226,35,46,.045)); box-shadow: inset 3px 0 0 rgba(226, 35, 46, .72); }
.sponsor-lockup::after { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 30%, rgba(255,255,255,.06), transparent 64%); pointer-events: none; }
.sponsor-lockup span { color: #87909b; font-size: .48rem; font-weight: 900; letter-spacing: .13em; }
.sponsor-lockup img { width: 92px; height: 34px; object-fit: contain; }

.small-button, .primary-button, .tower-button, .upgrade-button, .account-button {
  border: 1px solid rgba(112, 224, 255, .35);
  border-radius: 10px;
  color: #f8fbff;
  background: rgba(13, 19, 39, .85);
  font-weight: 900;
  cursor: pointer;
}
.small-button { padding: 10px 14px; font-size: .76rem; letter-spacing: .08em; }
.small-button[aria-pressed="false"] { color: #8992a7; border-color: rgba(137, 146, 167, .25); }

.arcade-account {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 18px;
  padding: 11px 14px;
  border: 1px solid rgba(214, 221, 228, .13);
  border-radius: 13px;
  background: linear-gradient(90deg, rgba(13, 17, 23, .9), rgba(21, 24, 30, .84));
}
.arcade-player { display: flex; align-items: center; gap: 10px; min-width: 0; }
.arcade-player > div { display: grid; gap: 2px; min-width: 0; }
.arcade-player strong, .arcade-player span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.arcade-player span { color: #858f9d; font-size: .71rem; }
.player-avatar { display: grid; flex: 0 0 36px; width: 36px; height: 36px; place-items: center; overflow: hidden; border: 1px solid rgba(105, 239, 241, .4); border-radius: 50%; color: #061013; background: linear-gradient(135deg, #83f0e1, #a7b3bd); font-weight: 950; }
.player-avatar img { width: 100%; height: 100%; object-fit: cover; }
.account-button { flex: 0 0 auto; padding: 9px 12px; color: #b4f5f6; text-decoration: none; font-size: .61rem; letter-spacing: .1em; }

.score-strip {
  position: relative;
  overflow: hidden;
  margin: 22px 0 13px;
  padding: 13px clamp(12px, 3vw, 28px);
  border: 1px solid rgba(130, 235, 255, .17);
  border-radius: 14px;
  background: linear-gradient(110deg, rgba(12, 16, 21, .94), rgba(18, 21, 28, .9));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}
.score-strip::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: linear-gradient(#e2232e, #62eff3); box-shadow: 0 0 18px rgba(98, 239, 243, .35); }
.score-strip div { display: grid; min-width: 82px; text-align: center; }
.score-strip span { color: #8791a8; font-size: .63rem; font-weight: 800; letter-spacing: .15em; }
.score-strip strong { margin-top: 2px; font-size: clamp(1.25rem, 4vw, 1.9rem); font-variant-numeric: tabular-nums; }

.battle-shell { display: grid; grid-template-columns: minmax(0, 1fr) 350px; gap: 14px; align-items: start; min-width: 0; }
.canvas-wrap {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(122, 213, 219, .27);
  border-radius: 22px;
  background: #080b10;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .52), 0 0 44px rgba(0, 205, 255, .045), inset 0 1px 0 rgba(255,255,255,.05);
}
.canvas-wrap::after { content: ""; position: absolute; inset: 0; z-index: 2; border-radius: inherit; box-shadow: inset 0 0 54px rgba(0, 0, 0, .32); pointer-events: none; }
canvas { display: block; width: 100%; max-width: 100%; height: auto; outline: none; touch-action: none; user-select: none; }
canvas:focus-visible { box-shadow: inset 0 0 0 3px #7beef1; }

.overlay-panel {
  position: absolute;
  z-index: 4;
  inset: 50% auto auto 50%;
  width: min(610px, calc(100% - 34px));
  transform: translate(-50%, -50%);
  padding: clamp(25px, 5vw, 48px);
  border: 1px solid rgba(115, 227, 255, .26);
  border-radius: 19px;
  background: linear-gradient(145deg, rgba(15, 18, 23, .97), rgba(5, 8, 12, .97));
  box-shadow: 0 22px 70px rgba(0,0,0,.66), inset 0 1px 0 rgba(255,255,255,.05);
  text-align: center;
  backdrop-filter: blur(12px);
}
.overlay-panel h2 { margin: 11px 0; font-size: clamp(1.65rem, 4vw, 2.75rem); line-height: 1.08; }
.overlay-panel > p { max-width: 510px; margin: 0 auto 24px; color: #b7c1d7; line-height: 1.55; }
.keyboard-hint { display: block; margin-top: 14px; color: #6f7b94; font-size: .7rem; }
.primary-button { padding: 14px 22px; border: 0; color: #fff; background: linear-gradient(110deg, #bb1721, #e52a35 54%, #ff5660); box-shadow: 0 10px 30px rgba(226, 35, 46, .23); font-size: .76rem; letter-spacing: .08em; }
.primary-button:hover, .primary-button:focus-visible { filter: brightness(1.08); transform: translateY(-1px); }

.result-icon { display: grid; width: 62px; height: 62px; margin: 12px auto 0; place-items: center; border: 1px solid rgba(116, 240, 232, .4); border-radius: 50%; color: #82f4d8; background: rgba(62, 224, 206, .1); box-shadow: 0 0 30px rgba(69, 226, 218, .15); font-size: 1.8rem; font-weight: 950; }
.result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 auto 24px; }
.result-grid div { display: grid; gap: 3px; padding: 12px 7px; border-radius: 10px; background: rgba(255,255,255,.035); }
.result-grid strong { color: #8bf2dd; font-size: 1.25rem; }
.result-grid span { color: #78849c; font-size: .54rem; font-weight: 900; letter-spacing: .1em; }

.wave-banner { position: absolute; z-index: 3; left: 50%; top: 18%; transform: translate(-50%, -8px); opacity: 0; padding: 9px 15px; border: 1px solid rgba(119, 241, 232, .3); border-radius: 999px; color: #9ffbed; background: rgba(5, 13, 28, .9); font-size: .7rem; font-weight: 950; letter-spacing: .15em; pointer-events: none; transition: opacity .18s ease, transform .18s ease; }
.wave-banner.show { opacity: 1; transform: translate(-50%, 0); }

.control-card { position: relative; min-height: 100%; overflow: hidden; padding: 19px 16px; border: 1px solid rgba(135, 210, 214, .19); border-radius: 22px; background: linear-gradient(155deg, rgba(17, 20, 25, .96), rgba(7, 9, 13, .94)); box-shadow: 0 24px 70px rgba(0,0,0,.42), inset 0 1px 0 rgba(255,255,255,.04); }
.control-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: linear-gradient(90deg, var(--dutton-red), transparent 42%, var(--signal-cyan)); opacity: .7; }
.control-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.control-heading h2 { margin: 7px 0 18px; font-size: 1.05rem; }
.pad-status { flex: 0 0 auto; padding: 6px 8px; border-radius: 7px; color: #8b96ac; background: rgba(255,255,255,.04); font-size: .54rem; font-weight: 900; letter-spacing: .1em; }
.tower-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.tower-button { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; align-items: center; gap: 10px; width: 100%; padding: 12px; text-align: left; }
.tower-button > span:nth-child(2) { display: grid; gap: 2px; }
.tower-button strong { font-size: .82rem; }
.tower-button small { color: #8490a7; font-size: .61rem; font-weight: 500; }
.tower-button b { color: #84f3d6; font-size: .77rem; }
.tower-button:not(:disabled):hover, .tower-button:not(:disabled):focus-visible { border-color: #7ce9eb; background: rgba(27, 52, 58, .87); }
.tower-button:disabled, .upgrade-button:disabled { cursor: not-allowed; opacity: .42; }
.tower-icon { position: relative; width: 36px; height: 36px; border: 2px solid currentColor; border-radius: 50%; color: #79eadf; background: radial-gradient(circle, currentColor 0 3px, transparent 4px); }
.tower-icon::before, .tower-icon::after { content: ""; position: absolute; inset: 6px; border: 1px solid currentColor; border-radius: 50%; opacity: .6; }
.tower-icon::after { inset: -5px; border-style: dashed; }
.pulse-icon { color: #ef4c55; transform: rotate(45deg); border-radius: 9px; }
.rail-icon { color: #f4d064; border-radius: 8px; transform: rotate(45deg); }
.rail-icon::before { inset: 13px -8px; border: 0; border-radius: 2px; background: currentColor; box-shadow: 0 0 12px currentColor; }
.rail-icon::after { inset: 5px; border-style: solid; border-radius: 4px; }
.jammer-icon { color: #aa7cff; border-radius: 50% 50% 8px 8px; border-width: 1px; background: radial-gradient(circle at 50% 68%, currentColor 0 3px, transparent 4px); }
.jammer-icon::before { inset: 5px 8px 12px; border-width: 2px 2px 0; border-radius: 50% 50% 0 0; }
.jammer-icon::after { inset: 0; border-style: dashed; }
.upgrade-button { width: 100%; margin-top: 10px; padding: 11px; color: #aab4ca; font-size: .66rem; letter-spacing: .1em; }
.control-message { min-height: 2.7em; margin: 15px 2px; color: #8a96ad; font-size: .7rem; line-height: 1.45; }
.legend { display: grid; gap: 7px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.06); color: #77839b; font-size: .64rem; }
.legend span { display: flex; align-items: center; gap: 8px; }
.legend i { width: 9px; height: 9px; border-radius: 50%; }
.legend-threat { background: #ef3442; box-shadow: 0 0 9px #ef3442; }
.legend-armour { background: #f4d064; box-shadow: 0 0 9px rgba(244, 208, 100, .8); }
.legend-core { background: #6cf3d1; box-shadow: 0 0 9px #6cf3d1; }

footer { padding: 14px 3px 0; color: #7f8aa2; font-size: .76rem; }
footer p { margin: 0; }
footer strong { color: #cbd5e8; }

@media (max-width: 1000px) {
  .battle-shell { grid-template-columns: minmax(0, 1fr); }
  .control-card { min-height: 0; }
}

@media (max-width: 620px) {
  .game-shell { padding: 12px; }
  .brand-lockup img { width: 43px; height: 43px; }
  .brand-lockup h1 { font-size: 1.05rem; letter-spacing: .07em; }
  .eyebrow { font-size: .57rem; }
  .small-button { padding: 8px 9px; font-size: .58rem; }
  .sponsor-lockup span, .activity-mode { display: none; }
  .sponsor-lockup { padding: 4px 7px; }
  .sponsor-lockup img { width: 66px; height: 27px; }
  .header-actions { gap: 5px; }
  .arcade-account { align-items: stretch; flex-direction: column; gap: 8px; }
  .account-button { text-align: center; }
  .score-strip { gap: 4px; margin-top: 15px; }
  .score-strip div { min-width: 0; }
  .score-strip span { font-size: .49rem; letter-spacing: .07em; }
  .score-strip strong { font-size: 1.14rem; }
  .canvas-wrap { border-radius: 17px; }
  .overlay-panel { width: calc(100% - 18px); padding: 17px 13px; border-radius: 14px; }
  .overlay-panel h2 { margin: 7px 0; font-size: 1.35rem; }
  .overlay-panel > p { margin-bottom: 13px; font-size: .73rem; line-height: 1.35; }
  .primary-button { padding: 10px 13px; font-size: .64rem; }
  .keyboard-hint { margin-top: 8px; font-size: .53rem; }
  .result-icon { width: 43px; height: 43px; margin-top: 6px; font-size: 1.2rem; }
  .result-grid { margin-bottom: 12px; }
  .result-grid div { padding: 7px 4px; }
  .result-grid strong { font-size: 1rem; }
  .control-card { padding: 15px 12px; border-radius: 17px; }
  .tower-options { grid-template-columns: 1fr; }
  .tower-button { min-height: 60px; }
  footer { align-items: flex-start; flex-direction: column; gap: 5px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
