:root {
  --bg: #111827;
  --bg-2: #0f172a;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-strong: #ffffff;
  --ink: #111827;
  --muted: #64748b;
  --line: rgba(15, 23, 42, 0.12);
  --accent: #34d399;
  --accent-2: #60a5fa;
  --danger: #ef4444;
  --warning: #f59e0b;
  --cell: rgba(255, 255, 255, 0.18);
  --cell-border: rgba(255, 255, 255, 0.24);
  --radius-xl: 34px;
  --radius-lg: 24px;
  --radius-md: 16px;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(circle at 20% 10%, #1e3a8a 0 0, transparent 35%),
              radial-gradient(circle at 80% 80%, #065f46 0 0, transparent 38%),
              linear-gradient(135deg, var(--bg), var(--bg-2));
  color: var(--ink);
  overflow: hidden;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.brand-splash {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background: #ffffff;
  opacity: 1;
  pointer-events: auto;
  transition: background-color 520ms ease, opacity 520ms ease;
}
.brand-splash__inner {
  width: min(72vw, 340px);
  display: grid;
  place-items: center;
}
.brand-splash__logo {
  display: block;
  width: 100%;
  height: auto;
  opacity: 1;
  transform: scale(1);
  transition: none;
  filter: drop-shadow(0 10px 26px rgba(133, 138, 196, 0.12));
}
.brand-splash.to-black {
  background: #000000;
}
.brand-splash.to-black .brand-splash__logo {
  opacity: 0;
  transform: scale(1);
  filter: none;
}
.brand-splash.hide {
  opacity: 0;
  pointer-events: none;
}


button {
  font: inherit;
  border: 0;
  cursor: pointer;
  user-select: none;
}

button:focus-visible {
  outline: 3px solid rgba(96, 165, 250, 0.8);
  outline-offset: 3px;
}

.app-shell {
  position: relative;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(14px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}

.ambient {
  position: fixed;
  width: 42vmin;
  height: 42vmin;
  border-radius: 999px;
  filter: blur(30px);
  opacity: 0.2;
  pointer-events: none;
}
.ambient-a { top: 7%; left: 2%; background: #22c55e; }
.ambient-b { bottom: 4%; right: 0%; background: #38bdf8; }

.phone-frame {
  position: relative;
  width: min(100%, 440px);
  height: min(100dvh - 28px, 760px);
  min-height: 620px;
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255,255,255,0.18), rgba(255,255,255,0.07));
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.screen, .modal-screen {
  position: absolute;
  inset: 0;
  display: none;
}
.screen.active, .modal-screen.active { display: flex; }

.panelish {
  flex-direction: column;
  justify-content: space-between;
  gap: 20px;
  padding: clamp(20px, 5vw, 32px);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.96), rgba(243,244,246,0.94)),
    var(--panel);
}

.top-toggles {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  min-height: 38px;
}
.icon-btn, .hud-btn {
  min-width: 48px;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 999px;
  background: #e5e7eb;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.icon-btn.off, .secondary-btn.off { opacity: 0.42; text-decoration: line-through; }

.brand-block { text-align: center; margin: auto 0; }
.eyebrow {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}
h1, h2, h3, p { margin-top: 0; }
h1 {
  margin-bottom: 10px;
  font-size: clamp(46px, 14vw, 72px);
  line-height: 0.9;
  letter-spacing: -0.08em;
}
h2 {
  margin-bottom: 8px;
  font-size: clamp(32px, 9vw, 48px);
  letter-spacing: -0.06em;
}
h3 {
  margin: 18px 0 4px;
  font-size: 13px;
  letter-spacing: 0.12em;
  color: var(--muted);
}
.subtitle, .hint, .build-note, .game-footer p {
  color: var(--muted);
  line-height: 1.45;
}
.build-note { text-align: center; font-size: 12px; margin: 0; }

.lang-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 42px;
  margin-top: -8px;
}
.lang-row label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.lang-select {
  appearance: none;
  border: 1px solid var(--line);
  background: #ffffff;
  color: #0f172a;
  border-radius: 999px;
  min-height: 40px;
  padding: 0 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  max-width: 56%;
}
.lang-select:focus-visible {
  outline: 3px solid rgba(96, 165, 250, 0.8);
  outline-offset: 2px;
}


.menu-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}
.menu-stack.compact { gap: 10px; }
.primary-btn, .secondary-btn, .ghost-btn, .mode-btn, .back-btn {
  width: 100%;
  min-height: 54px;
  border-radius: var(--radius-md);
  padding: 12px 18px;
  font-weight: 900;
  transition: transform 120ms ease, opacity 120ms ease, background 120ms ease;
}
.primary-btn:active, .secondary-btn:active, .ghost-btn:active, .mode-btn:active, .back-btn:active,
.cell:active, .hud-btn:active, .icon-btn:active { transform: scale(0.97); }
.primary-btn {
  background: linear-gradient(135deg, var(--accent), #22c55e);
  color: #052e1b;
}
.secondary-btn {
  background: #e2e8f0;
  color: #0f172a;
}
.ghost-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}
.ghost-btn.danger { color: var(--danger); border-color: rgba(239,68,68,0.3); }
.back-btn {
  width: auto;
  align-self: flex-start;
  min-height: 40px;
  background: #e5e7eb;
  color: #334155;
  border-radius: 999px;
}
.mode-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  background: #ffffff;
  color: #111827;
  border: 1px solid var(--line);
}
.mode-btn span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}
.mode-btn.clean { background: #ecfeff; }

.stats-screen { overflow-y: auto; }
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.stats-grid article {
  min-height: 76px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: #fff;
  border: 1px solid var(--line);
}
.stats-grid span {
  display: block;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.08em;
  font-weight: 900;
}
.stats-grid strong {
  display: block;
  margin-top: 9px;
  font-size: 20px;
}
.difficulty-stats {
  padding: 12px 0;
}
.difficulty-stats p { color: var(--muted); margin-bottom: 8px; }

.game-screen {
  flex-direction: column;
  padding: 14px;
  background: linear-gradient(180deg, rgba(15,23,42,0.72), rgba(15,23,42,0.9));
  color: white;
}
.hud {
  display: grid;
  grid-template-columns: 86px 1fr 116px;
  gap: 8px;
  align-items: center;
  min-height: 60px;
}
.hud-btn {
  background: rgba(255,255,255,0.16);
  color: white;
}
.score-box, .speed-box {
  min-height: 52px;
  border-radius: var(--radius-md);
  padding: 8px 10px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.12);
  overflow: hidden;
}
.score-box span, .speed-box span {
  display: block;
  color: rgba(255,255,255,0.62);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
}
.score-box strong, .speed-box strong {
  display: block;
  margin-top: 3px;
  font-size: clamp(18px, 5.5vw, 26px);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.speed-box strong { font-size: clamp(16px, 4.5vw, 22px); }
.level-strip {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 2px 10px;
  color: rgba(255,255,255,0.72);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
}
.grid-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  border-radius: var(--radius-lg);
  padding: 4px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  overflow: hidden;
}
.grid {
  position: absolute;
  inset: 4px;
  display: grid;
  gap: 2px;
  align-content: center;
  justify-content: center;
}
.cell {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: clamp(5px, 1.9vw, 10px);
  background: var(--cell);
  border: 1px solid var(--cell-border);
  color: white;
  padding: 0;
  overflow: hidden;
}
.cell.occupied { background: rgba(255,255,255,0.1); }
.cell.miss::after,
.cell.null-hit::after,
.cell.correct-hit::after,
.cell.forgiven-hit::after {
  content: "";
  position: absolute;
  inset: -10%;
  border-radius: inherit;
  animation: cellPulse 190ms ease-out forwards;
  pointer-events: none;
}
.cell.miss::after { background: rgba(239, 68, 68, 0.56); }
.cell.null-hit::after { background: rgba(245, 158, 11, 0.54); animation-duration: 210ms; }
.cell.correct-hit::after { background: rgba(52, 211, 153, 0.50); animation-duration: 260ms; }
.block {
  position: absolute;
  inset: 9%;
  display: grid;
  place-items: center;
  border-radius: 18%;
  font-size: clamp(13px, 5.4vw, 28px);
  line-height: 1;
  font-weight: 900;
  opacity: 0;
  transform: scale(0.72);
  transition: transform 150ms ease, opacity 150ms ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
}
.cell.occupied .block { opacity: 1; transform: scale(1); }
.cell.destroying .block {
  animation: destroyBlock 380ms ease-in forwards;
}
.cell.spawning .block {
  animation: spawnBlock 150ms ease-out both;
}

.theme-rainbow .block {
  color: transparent;
  text-shadow: none;
  border: 1px solid rgba(15,23,42,0.28);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08), 0 4px 12px rgba(0,0,0,0.18);
}
.theme-symbols .block {
  color: rgba(255,255,255,0.94);
  text-shadow: 0 2px 8px rgba(0,0,0,0.28);
  border: 1px solid rgba(15,23,42,0.28);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08), 0 4px 12px rgba(0,0,0,0.18);
  font-size: clamp(15px, 5.6vw, 30px);
}
.theme-emoji .block {
  border: 1px solid rgba(15,23,42,0.28);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08), 0 4px 12px rgba(0,0,0,0.18);
}
.block.emoji {
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", system-ui, sans-serif;
  font-size: clamp(17px, 6.2vw, 34px);
  text-shadow: 0 2px 8px rgba(0,0,0,0.24);
}

.effect-layer {
  position: absolute;
  inset: 4px;
  pointer-events: none;
  z-index: 4;
}
.laser {
  position: absolute;
  height: 2px;
  background: rgba(255,255,255,0.6);
  transform-origin: left center;
  border-radius: 99px;
  animation: laserFade 160ms linear forwards;
}
.particle {
  position: absolute;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  margin-top: -6px;
  border-radius: 999px;
  background: white;
  opacity: 0.7;
  animation: laserFade 160ms linear forwards;
}
.accelerate-text {
  position: absolute;
  left: 50%;
  top: 44%;
  transform: translate(-50%, -50%) scale(0.9);
  z-index: 6;
  display: none;
  color: white;
  font-size: clamp(34px, 13vw, 62px);
  font-weight: 950;
  letter-spacing: -0.05em;
  text-shadow: 0 8px 24px rgba(0,0,0,0.35);
  pointer-events: none;
}
.accelerate-text.active { display: block; animation: accelerate 660ms ease-out forwards; }
.game-footer {
  min-height: 42px;
  display: flex;
  align-items: center;
}
.game-footer p {
  margin: 8px 4px 0;
  color: rgba(255,255,255,0.62);
  font-size: 12px;
}

.modal-screen {
  z-index: 20;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(2, 6, 23, 0.58);
  backdrop-filter: blur(8px);
}
.modal-box {
  width: min(100%, 340px);
  padding: 24px;
  border-radius: var(--radius-lg);
  background: var(--panel-strong);
  color: var(--ink);
  box-shadow: var(--shadow);
  transform-origin: center;
  animation: modalIn 90ms ease-out both;
}
.modal-box.success { background: #f0fdf4; }
.modal-box.danger-box { background: #fef2f2; }
.modal-box h2 { margin-bottom: 8px; }
.modal-box p { color: var(--muted); }

.score-pop {
  position: absolute;
  z-index: 10;
  left: 50%;
  top: 72px;
  min-width: 160px;
  transform: translateX(-50%);
  color: #86efac;
  font-size: 34px;
  font-weight: 950;
  text-align: center;
  pointer-events: none;
  animation: scorePop 750ms ease-out forwards;
}
.shake { animation: shake 160ms linear; }


.cell.forgiven-hit::after { background: rgba(56, 189, 248, 0.46); animation-duration: 240ms; }
.stats-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.credits-box .credits-list {
  display: grid;
  gap: 10px;
  margin: 16px 0 18px;
}
.credits-box .credits-list p {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 0;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.credits-box .credits-list span {
  color: var(--ink);
  font-weight: 800;
  text-align: right;
}
@keyframes spawnBlock {
  from { opacity: 0; transform: scale(0.6); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes destroyBlock {
  0% { opacity: 1; transform: translate(0,0) scale(1) rotate(0deg); }
  45% { opacity: 0.88; transform: translate(var(--dx, 12px), calc(var(--jump, -20px))) scale(0.86) rotate(8deg); }
  100% { opacity: 0; transform: translate(var(--dx, 12px), var(--fall, 46px)) scale(0.72) rotate(20deg); }
}
@keyframes cellPulse {
  from { opacity: 0.62; transform: scale(0.85); }
  to { opacity: 0; transform: scale(1.35); }
}
@keyframes laserFade {
  from { opacity: 0.6; }
  to { opacity: 0; }
}
@keyframes accelerate {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.85); }
  20% { opacity: 0.8; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.35); }
}
@keyframes scorePop {
  from { opacity: 0; transform: translate(-50%, 30px) scale(0.92); }
  16% { opacity: 1; }
  to { opacity: 0; transform: translate(-50%, -60px) scale(1); }
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(34px) scale(0.3); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(4px, -3px); }
  40% { transform: translate(-5px, 3px); }
  60% { transform: translate(3px, 4px); }
  80% { transform: translate(-3px, -4px); }
}

@media (max-height: 670px) {
  .phone-frame { min-height: 0; height: calc(100dvh - 16px); }
  .panelish { padding: 18px; }
  .brand-block { margin: 18px 0; }
  .subtitle { margin-bottom: 0; }
  .game-footer { display: none; }
  .hud { min-height: 52px; }
  .score-box, .speed-box { min-height: 48px; }
}
