:root {
  --bg-a: #050814;
  --bg-b: #11113f;
  --bg-c: #15235c;
  --text: #f8fbff;
  --muted: rgba(248, 251, 255, 0.66);
  --accent: #75e6ff;
  --accent-2: #7c3aed;
  --safe-bottom: env(safe-area-inset-bottom);
  --safe-top: env(safe-area-inset-top);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: #050814;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button, a { font: inherit; }

.stack-app {
  min-height: 100dvh;
  width: 100vw;
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, var(--bg-c), var(--bg-b) 48%, var(--bg-a));
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  overflow: hidden;
}

.screen.is-active { display: block; }

.screen-start {
  padding: calc(20px + var(--safe-top)) 18px calc(22px + var(--safe-bottom));
}

.start-shell {
  width: min(430px, 100%);
  height: min(760px, calc(100dvh - 44px - var(--safe-top) - var(--safe-bottom)));
  min-height: 610px;
  margin: 0 auto;
  position: relative;
  top: 50%;
  transform: translateY(-50%);
  border-radius: 34px;
  overflow: hidden;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.11);
  box-shadow: 0 36px 120px rgba(0,0,0,.42);
}

.start-art {
  position: absolute;
  inset: 0 0 282px 0;
  overflow: hidden;
}

.start-art canvas,
.game-canvas,
.result-bg {
  display: block;
  width: 100%;
  height: 100%;
}

.start-copy {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 28px 26px 26px;
  border-radius: 34px 34px 0 0;
  background: rgba(5, 8, 20, .84);
  backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255,255,255,.10);
}

.brand-pill {
  width: max-content;
  padding: 7px 10px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.68);
  font-size: 10px;
  letter-spacing: .16em;
  font-weight: 900;
  margin-bottom: 12px;
}

.start-copy h1 {
  margin: 0 0 11px;
  font-size: clamp(38px, 11vw, 56px);
  line-height: .9;
  letter-spacing: -.08em;
}

.start-copy p {
  margin: 0 0 21px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.42;
}

.primary-btn,
.ghost-btn {
  width: 100%;
  min-height: 57px;
  border-radius: 999px;
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-weight: 950;
  cursor: pointer;
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #06101f;
  box-shadow: 0 18px 52px rgba(117,230,255,.20);
}

.ghost-btn {
  margin-top: 11px;
  background: rgba(255,255,255,.09);
  color: var(--text);
}

.stack-home-link {
  position: absolute;
  top: calc(18px + var(--safe-top));
  right: 18px;
  z-index: 5;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(255,255,255,.15);
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.78);
  text-decoration: none;
  font-size: 12px;
  font-weight: 900;
  backdrop-filter: blur(16px);
}

.screen-game { background: #050814; }

.game-canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.tap-layer {
  position: absolute;
  inset: 0;
  z-index: 7;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.game-hud {
  position: absolute;
  top: calc(15px + var(--safe-top));
  left: 0;
  right: 0;
  height: 94px;
  display: grid;
  grid-template-columns: 76px 1fr 76px;
  align-items: start;
  padding: 0 17px;
  z-index: 10;
  pointer-events: none;
}

.hud-close {
  pointer-events: auto;
  width: 52px;
  height: 52px;
  border: 0;
  background: transparent;
  color: rgba(255,255,255,.82);
  font-size: 48px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.hud-center { text-align: center; }

.score {
  font-size: clamp(60px, 20vw, 102px);
  line-height: .82;
  font-weight: 1000;
  letter-spacing: -.08em;
  text-shadow: 0 18px 48px rgba(0,0,0,.25);
}

.score-label {
  margin-top: 9px;
  font-size: 11px;
  letter-spacing: .20em;
  color: rgba(255,255,255,.58);
  font-weight: 950;
}

.streak {
  justify-self: end;
  margin-top: 9px;
  min-width: 50px;
  height: 34px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,.12);
  color: rgba(255,255,255,.78);
  font-weight: 1000;
  backdrop-filter: blur(12px);
}

.drop-zone-text {
  position: absolute;
  left: 50%;
  bottom: calc(74px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 9;
  width: max-content;
  max-width: calc(100vw - 40px);
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(0,0,0,.34);
  color: rgba(255,255,255,.78);
  font-size: 14px;
  font-weight: 900;
  backdrop-filter: blur(14px);
  transition: opacity .22s ease, transform .22s ease;
  pointer-events: none;
}

.drop-zone-text.is-hidden {
  opacity: 0;
  transform: translate(-50%, 10px);
}

.screen-result {
  padding: calc(22px + var(--safe-top)) 20px calc(22px + var(--safe-bottom));
}

.result-bg {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.result-card {
  position: relative;
  z-index: 2;
  width: min(430px, 100%);
  margin: 13dvh auto 0;
  padding: 30px 26px 26px;
  border-radius: 34px;
  background: rgba(7, 10, 24, .78);
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: 0 32px 100px rgba(0,0,0,.40);
  backdrop-filter: blur(24px);
}

.result-kicker {
  width: max-content;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.10);
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .16em;
  font-weight: 1000;
}

.result-card h2 {
  margin: 18px 0 8px;
  font-size: clamp(38px, 11vw, 58px);
  line-height: .96;
  letter-spacing: -.07em;
}

.result-status {
  margin: 0 0 16px;
  color: var(--accent);
  font-weight: 1000;
  letter-spacing: .05em;
}

.result-copy {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.45;
}

.about-dialog {
  width: min(430px, calc(100vw - 32px));
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 28px;
  padding: 28px;
  color: var(--text);
  background: rgba(8,10,24,.94);
  backdrop-filter: blur(24px);
  box-shadow: 0 30px 100px rgba(0,0,0,.44);
}

.about-dialog::backdrop { background: rgba(0,0,0,.56); }

.about-dialog h2 {
  margin: 0 0 10px;
  font-size: 28px;
  letter-spacing: -.05em;
}

.about-dialog p {
  color: var(--muted);
  line-height: 1.45;
}

.dialog-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 42px;
  height: 42px;
  border: 0;
  background: transparent;
  color: rgba(255,255,255,.75);
  font-size: 32px;
  cursor: pointer;
}

@media (min-width: 768px) {
  body {
    display: grid;
    place-items: center;
    background: #03050d;
  }

  .stack-app {
    max-width: 480px;
    max-height: 920px;
    min-height: 860px;
    border-radius: 34px;
    box-shadow: 0 40px 140px rgba(0,0,0,.46);
  }
}
