:root {
  color-scheme: dark;
  --bg: #050b10;
  --panel: rgba(10, 20, 27, 0.9);
  --panel-2: #0b151d;
  --line: rgba(181, 218, 213, 0.14);
  --line-strong: rgba(181, 218, 213, 0.28);
  --text: #edf7f4;
  --muted: #81959c;
  --accent: #71f6c7;
  --blue: #78bfff;
  --gold: #e8b269;
  --pink: #ff88b7;
  --danger: #ff7c84;
  --mono: "SFMono-Regular", "Cascadia Code", Consolas, monospace;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; overscroll-behavior: none; }
body {
  margin: 0;
  min-width: 320px;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 10%, rgba(113, 246, 199, 0.08), transparent 30rem),
    radial-gradient(circle at 90% 80%, rgba(120, 191, 255, 0.08), transparent 35rem),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, a { font: inherit; color: inherit; }
a { text-underline-offset: 4px; }

.game-ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(113, 246, 199, 0.026) 1px, transparent 1px),
    linear-gradient(90deg, rgba(113, 246, 199, 0.026) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(circle at center, #000, transparent 92%);
}

.game-header {
  position: relative;
  z-index: 10;
  height: 70px;
  display: grid;
  grid-template-columns: minmax(205px, 1fr) auto minmax(42px, 1fr);
  align-items: center;
  gap: 20px;
  padding: 9px clamp(12px, 2.6vw, 32px);
  border-bottom: 1px solid var(--line);
  background: rgba(5, 11, 16, 0.84);
  backdrop-filter: blur(18px);
}

.game-brand {
  width: max-content;
  display: inline-flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
}

.game-brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(113, 246, 199, 0.5);
  color: var(--accent);
  font: 700 0.7rem/1 var(--mono);
}

.game-brand > span:last-child {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.game-brand strong {
  font-size: 0.92rem;
  letter-spacing: 0.025em;
}

.game-brand small {
  color: var(--muted);
  font: 0.55rem/1.2 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.game-stats {
  display: flex;
  align-items: center;
  gap: clamp(20px, 4vw, 50px);
}

.game-stats span {
  min-width: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.game-stats small,
.label {
  color: var(--muted);
  font: 600 0.58rem/1.2 var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.game-stats b {
  color: #fff;
  font: 600 0.95rem/1 var(--mono);
}

.pause-button {
  justify-self: end;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
  font: 600 0.9rem/1 var(--mono);
  cursor: pointer;
}

.pause-button:hover,
.pause-button:focus-visible {
  border-color: rgba(113, 246, 199, 0.48);
  color: var(--accent);
  outline: none;
}

.game-layout {
  position: relative;
  z-index: 1;
  width: min(1400px, 100%);
  height: calc(100dvh - 70px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 224px;
  gap: 18px;
  margin: auto;
  padding: 17px clamp(11px, 2vw, 25px) 20px;
}

.play-column {
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
}

.canvas-shell {
  position: relative;
  width: min(100%, calc((100dvh - 112px) * 4 / 3));
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: #050b10;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.34), inset 0 1px rgba(255, 255, 255, 0.025);
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: none;
}

.seed-label {
  position: absolute;
  left: 12px;
  top: 12px;
  padding: 7px 9px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(3, 8, 12, 0.66);
  color: #71858e;
  font: 600 0.52rem/1 var(--mono);
  letter-spacing: 0.08em;
  pointer-events: none;
}

.effect-strip {
  position: absolute;
  left: 50%;
  bottom: 12px;
  display: flex;
  gap: 6px;
  transform: translateX(-50%);
  pointer-events: none;
  white-space: nowrap;
}

.effect-chip {
  padding: 6px 8px;
  border: 1px solid rgba(113, 246, 199, 0.26);
  background: rgba(3, 9, 13, 0.76);
  color: #cceee3;
  font: 600 0.54rem/1 var(--mono);
  letter-spacing: 0.04em;
}

.game-help {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 22px;
  padding: 22px 19px;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(16px);
}

.game-help .label { margin: 0 0 15px; }
.game-help dl { display: grid; gap: 12px; margin: 0; }
.game-help dl div { display: flex; justify-content: space-between; gap: 12px; }
.game-help dt { color: #c2d0d1; font-size: 0.7rem; }
.game-help dd { margin: 0; color: var(--muted); font: 0.61rem/1.4 var(--mono); }

.power-list { display: grid; gap: 8px; }
.power-list .label { margin-bottom: 4px; }
.power-list span {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #a9b9bc;
  font-size: 0.68rem;
}

.power-list i,
.power-ribbon i {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(113, 246, 199, 0.38);
  background: rgba(113, 246, 199, 0.08);
  color: var(--accent);
  font: 700 0.58rem/1 var(--mono);
  font-style: normal;
}

.power-list i { width: 23px; height: 23px; }
.help-note { margin: 0; color: #71858c; font-size: 0.64rem; line-height: 1.65; }
.back-to-games { color: var(--muted); font: 600 0.61rem/1 var(--mono); text-decoration: none; }
.back-to-games:hover, .back-to-games:focus-visible { color: var(--accent); outline: none; }

.touch-pad {
  display: none;
}

.overlay {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(2, 7, 10, 0.75);
  backdrop-filter: blur(13px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.overlay.is-visible { opacity: 1; pointer-events: auto; }
.overlay[hidden] { display: none; }

.dialog {
  width: min(560px, 100%);
  padding: clamp(33px, 6vw, 58px);
  border: 1px solid rgba(113, 246, 199, 0.24);
  background:
    linear-gradient(rgba(113, 246, 199, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(113, 246, 199, 0.02) 1px, transparent 1px),
    #09131a;
  background-size: 30px 30px;
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.5);
  text-align: center;
}

.dialog.compact { width: min(480px, 100%); }
.dialog h1, .dialog h2 { margin: 15px 0 18px; letter-spacing: -0.06em; }
.dialog h1 { font-size: clamp(4rem, 14vw, 7rem); line-height: 0.82; }
.dialog h2 { font-size: clamp(3rem, 10vw, 5rem); line-height: 0.9; }
.dialog > p:not(.label) { max-width: 450px; margin: 0 auto 24px; color: #9dafb5; line-height: 1.7; }
.dialog > a { display: block; width: max-content; margin: 17px auto 0; color: var(--muted); font: 600 0.64rem/1 var(--mono); }

.power-ribbon { display: flex; justify-content: center; gap: 8px; margin: 27px 0; }
.power-ribbon i { width: 35px; height: 35px; }

.primary, .secondary {
  min-height: 47px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 19px;
  border: 1px solid transparent;
  font: 700 0.67rem/1 var(--mono);
  letter-spacing: 0.045em;
  text-transform: uppercase;
  cursor: pointer;
  text-decoration: none;
}

.primary { background: var(--accent); color: #03100c; }
.primary:hover, .primary:focus-visible { background: #a4ffdf; outline: none; }
.secondary { border-color: var(--line-strong); background: rgba(255,255,255,0.025); }
.secondary:hover, .secondary:focus-visible { border-color: rgba(113,246,199,.45); color: var(--accent); outline: none; }

.dialog-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 9px; margin-top: 28px; }
.link-button { margin: 0 !important; }
.results { display: grid; grid-template-columns: repeat(3, 1fr); margin: 27px 0 0; border: 1px solid var(--line); }
.results > div { padding: 16px 8px; }
.results > div + div { border-left: 1px solid var(--line); }
.results span { display: block; color: var(--muted); font: 600 0.55rem/1 var(--mono); text-transform: uppercase; }
.results strong { display: block; margin-top: 6px; font: 600 1.05rem/1 var(--mono); }

@media (max-width: 900px) {
  body { overflow: auto; }
  .game-layout { grid-template-columns: 1fr; height: calc(100dvh - 70px); }
  .game-help { display: none; }
  .play-column { align-content: center; }
  #game { cursor: default; }
}

@media (max-width: 650px) {
  .game-header { height: 62px; grid-template-columns: 1fr auto auto; gap: 9px; padding-inline: 9px; }
  .game-brand-mark { width: 34px; height: 34px; }
  .game-brand small { display: none; }
  .game-stats { gap: 9px; }
  .game-stats span { min-width: 37px; }
  .game-stats small { font-size: 0.48rem; }
  .game-stats b { font-size: 0.76rem; }
  .best-stat { display: none !important; }
  .pause-button { width: 36px; height: 36px; }
  .game-layout { height: calc(100dvh - 62px); padding: 8px; }
  .canvas-shell { width: 100%; }
  .dialog { padding: 35px 21px; }
  .seed-label { top: 7px; left: 7px; }
  .effect-strip { bottom: 7px; max-width: 92%; overflow: hidden; }
}

@media (max-width: 900px) and (pointer: coarse) {
  .game-layout { overflow: hidden; }
  .play-column { display: flex; flex-direction: column; gap: 8px; justify-content: center; }
  .canvas-shell { flex: 0 1 auto; max-height: calc(100dvh - 62px - 130px); }
  .touch-pad {
    width: min(100%, 520px);
    min-height: 106px;
    display: block;
    padding: 11px 14px 14px;
    border: 1px solid rgba(113, 246, 199, 0.22);
    background: rgba(7, 16, 22, 0.92);
    touch-action: none;
    user-select: none;
  }
  .touch-pad > span { display: block; margin-bottom: 9px; color: var(--muted); font: 600 0.55rem/1 var(--mono); letter-spacing: .08em; text-align: center; text-transform: uppercase; }
  .touch-track { position: relative; height: 58px; overflow: hidden; border: 1px solid var(--line); background: linear-gradient(90deg,rgba(113,246,199,.03),rgba(113,246,199,.08),rgba(113,246,199,.03)); }
  .touch-track::after { content:""; position:absolute; left:50%; top:10px; bottom:10px; width:1px; background:var(--line); }
  .touch-track i { position:absolute; z-index:1; left:50%; top:50%; width:72px; height:25px; transform:translate(-50%,-50%); background:var(--accent); box-shadow:0 0 20px rgba(113,246,199,.2); }
}

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