:root {
  color-scheme: dark;
  --ink: #eaf7f6;
  --muted: #8ca5a9;
  --accent: #ffb84d;
  --cyan: #6ee7db;
  --panel: rgba(9, 31, 43, 0.86);
  font-family: "Avenir Next", Avenir, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 0%, rgba(28, 96, 103, 0.35), transparent 32rem),
    linear-gradient(145deg, #071521 0%, #0a202b 55%, #061219 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  opacity: 0.035;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 120 120' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.8'/%3E%3C/svg%3E");
}

button { font: inherit; }

.game-shell {
  width: min(100%, 1040px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) 24px max(18px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: auto auto minmax(390px, 1fr) auto;
  gap: 16px;
}

.topbar, .instrument-panel, footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(110, 231, 219, 0.35);
  border-radius: 50%;
  color: var(--cyan);
  font-size: 18px;
}
.brand p, .brand h1 { margin: 0; }
.brand p { color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: 0.22em; }
.brand h1 { font-size: 18px; font-weight: 650; letter-spacing: 0.12em; }
.top-actions { display: flex; gap: 8px; }

.icon-button {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(151, 187, 188, 0.18);
  border-radius: 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.035);
  cursor: pointer;
  transition: border-color 160ms, background 160ms, transform 160ms;
}
.icon-button:hover { border-color: var(--cyan); background: rgba(110, 231, 219, 0.08); }
.icon-button:active { transform: scale(0.94); }
.icon-button.off { color: #64787c; text-decoration: line-through; }

.instrument-panel {
  padding: 13px 18px;
  border: 1px solid rgba(151, 187, 188, 0.13);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.16);
}
.metric { min-width: 120px; }
.metric.center { text-align: center; }
.metric.right { text-align: right; }
.metric span { display: block; margin-bottom: 2px; color: var(--muted); font-size: 9px; letter-spacing: 0.18em; }
.metric strong { font-size: 13px; font-weight: 500; }
.metric b { color: var(--accent); font-family: "SFMono-Regular", Consolas, monospace; font-size: 17px; letter-spacing: 0.05em; }
#shieldStatus.active { color: var(--cyan); }

.game-frame {
  position: relative;
  min-height: 390px;
  overflow: hidden;
  border: 1px solid rgba(165, 211, 211, 0.22);
  border-radius: 42px;
  background: #92d7df;
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.34), inset 0 0 0 8px rgba(4, 18, 26, 0.32);
  isolation: isolate;
  touch-action: none;
}
.game-frame::before {
  content: "";
  position: absolute;
  inset: 8px;
  z-index: 3;
  border: 1px solid rgba(235, 255, 252, 0.16);
  border-radius: 34px;
  pointer-events: none;
}
.game-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  border-radius: inherit;
  box-shadow: inset 0 0 90px rgba(3, 22, 31, 0.38);
}

canvas { width: 100%; height: 100%; display: block; }

.screen-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(38px, 8vw, 88px);
  opacity: 0;
  visibility: hidden;
  background: linear-gradient(90deg, rgba(5, 24, 33, 0.91) 0%, rgba(5, 24, 33, 0.68) 48%, rgba(5, 24, 33, 0.08) 100%);
  transition: opacity 240ms, visibility 240ms;
}
.screen-overlay.visible { opacity: 1; visibility: visible; }
.screen-overlay.compact { align-items: center; text-align: center; background: rgba(4, 20, 29, 0.78); backdrop-filter: blur(8px); }
.eyebrow { margin-bottom: 14px; color: var(--cyan); font-size: 10px; font-weight: 700; letter-spacing: 0.24em; }
.screen-overlay h2 { margin: 0; font-size: clamp(38px, 6vw, 66px); line-height: 0.98; letter-spacing: -0.05em; }
.screen-overlay h2 em { color: var(--accent); font-family: Georgia, serif; font-weight: 400; }
.screen-overlay p { width: min(400px, 100%); margin: 20px 0 26px; color: #bdd1d2; font-size: 14px; line-height: 1.75; }

.primary-button {
  min-width: 190px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 30px;
  padding: 14px 17px 14px 20px;
  border: 0;
  border-radius: 12px;
  color: #10232a;
  background: var(--accent);
  font-size: 14px;
  font-weight: 750;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(255, 184, 77, 0.2);
  transition: transform 160ms, filter 160ms;
}
.primary-button i { font-size: 20px; font-style: normal; }
.primary-button:hover { filter: brightness(1.08); transform: translateY(-2px); }
.primary-button:active { transform: translateY(1px); }

.controls-hint { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: 22px; color: #91aeb0; font-size: 11px; }
kbd { padding: 3px 6px; border: 1px solid rgba(255,255,255,.2); border-radius: 5px; color: #d9e8e7; background: rgba(255,255,255,.07); font: inherit; }
.touch-hint { position: absolute; z-index: 4; bottom: 22px; left: 50%; translate: -50% 0; color: rgba(240,255,252,.65); font-size: 10px; letter-spacing: .12em; opacity: 0; pointer-events: none; }

footer { color: #718d91; font-size: 10px; letter-spacing: .08em; }
.status { display: flex; align-items: center; gap: 7px; color: #8dafaa; }
.status i { width: 6px; height: 6px; border-radius: 50%; background: #5ed6a7; box-shadow: 0 0 10px #5ed6a7; }

@media (max-width: 600px) {
  .game-shell { padding-inline: 12px; grid-template-rows: auto auto minmax(440px, 1fr) auto; gap: 10px; }
  .brand-mark { width: 34px; height: 34px; }
  .brand h1 { font-size: 15px; }
  .icon-button { width: 36px; height: 36px; }
  .instrument-panel { padding: 10px 12px; border-radius: 13px; }
  .metric { min-width: 0; }
  .metric span { font-size: 8px; }
  .metric strong { font-size: 10px; }
  .metric b { font-size: 14px; }
  .game-frame { min-height: 440px; border-radius: 31px; }
  .game-frame::before { border-radius: 24px; }
  .screen-overlay { padding: 36px 30px; justify-content: flex-end; background: linear-gradient(0deg, rgba(5,24,33,.94) 0%, rgba(5,24,33,.55) 60%, rgba(5,24,33,.12) 100%); }
  .screen-overlay.compact { justify-content: center; }
  .screen-overlay h2 { font-size: 42px; }
  .screen-overlay p { margin-block: 15px 20px; font-size: 13px; }
  .controls-hint { display: none; }
  .touch-hint { opacity: 1; }
}

@media (max-height: 650px) and (orientation: landscape) {
  .game-shell { min-height: 650px; }
}

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