/* ---------- Landing ---------- */

.landing-body { display: flex; flex-direction: column; align-items: center; text-align: center; margin-top: 8vh; }

.title {
  font-size: clamp(2.3rem, 11vw, 3.4rem);
  font-weight: 800;
  line-height: 1.05;
  margin-bottom: 14px;
  background: linear-gradient(180deg, var(--white) 30%, rgba(255, 255, 255, 0.75));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lead { font-size: 1.1rem; color: var(--text-dim); max-width: 22em; }
.lead b { color: var(--gold); }

.prize-card {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  margin-top: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--gold-soft);
  border: 1px solid rgba(253, 202, 12, 0.4);
}
.prize-icon { font-size: 1.8rem; }
.prize-card strong { display: block; font-family: var(--font-head); }
.prize-card small { color: var(--text-dim); }

.returning {
  margin-top: 18px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--surface);
  font-size: 0.9rem;
  color: var(--text-dim);
}
.returning strong { color: var(--white); }

/* ---------- How to play ---------- */

.samples { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 8px 0 16px; }
.sample { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.sample .tile { position: relative; aspect-ratio: 1; }
.sample-tag {
  text-align: center;
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
}
.sample-tag--tap { color: var(--ok); }
.sample-tag--leave { color: var(--text-dim); }
.sample-tag--bonus { color: var(--gold); }

.rules { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rules-col { padding: 12px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.rules-col h3 { font-size: 0.9rem; margin-bottom: 6px; }
.rules-col--tap h3 { color: var(--gold); }
.rules-col ul { margin: 0; padding-left: 18px; font-size: 0.85rem; color: var(--text-dim); }
.rules-col li { margin: 3px 0; }

.howto-points { margin: 14px 0 0; padding-left: 20px; color: var(--text-dim); font-size: 0.92rem; }
.howto-points li { margin: 4px 0; }
.howto-points b { color: var(--white); }

/* ---------- Countdown ---------- */

.countdown {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 9rem;
  line-height: 1;
  color: var(--gold);
  animation: count-pop var(--step, 800ms) ease-out;
}
@keyframes count-pop {
  0% { transform: scale(1.8); opacity: 0; }
  30% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.9; }
}

/* ---------- Game HUD ---------- */

.screen--game {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  gap: 10px;
  padding-top: calc(10px + var(--safe-top));
}

.hud { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 8px; align-items: center; }
.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 4px;
  border-radius: 10px;
  background: var(--surface);
}
.hud-label { font-size: 0.65rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-faint); font-weight: 700; }
.hud-value { font-family: var(--font-mono); font-weight: 700; font-size: 1.5rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
#hud-time.danger { color: var(--bad); animation: pulse 500ms ease-in-out infinite alternate; }
#hud-combo.hot { color: var(--gold); }
.bump { animation: bump 220ms ease-out; }
@keyframes bump { 50% { transform: scale(1.25); } }
@keyframes pulse { to { transform: scale(1.12); } }

.uptime-row { display: flex; justify-content: space-between; font-size: 0.8rem; font-weight: 700; color: var(--text-dim); margin-bottom: 4px; }
.uptime-row b { color: var(--white); font-family: var(--font-mono); }
.uptime-track { height: 10px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
#uptime-fill {
  height: 100%;
  width: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--blue), #4fb3ef);
  transition: width 250ms ease, background 250ms;
}
#uptime-fill.low { background: var(--bad); }
.uptime.hit #uptime-fill { animation: flash-bad 400ms; }
@keyframes flash-bad { 50% { background: var(--bad); } }

.phase-label {
  text-align: center;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* ---------- Grid & tiles ---------- */

.stage { position: relative; margin: auto 0; }
.stage.fx-slow::after, .stage.fx-auto::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 20px;
  pointer-events: none;
}
.stage.fx-slow::after { box-shadow: 0 0 0 3px var(--blue), 0 0 30px var(--blue); }
.stage.fx-auto::after { box-shadow: 0 0 0 3px var(--gold), 0 0 30px var(--gold); }

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 8px;
  width: min(100%, 62dvh);
  aspect-ratio: 1;
  margin: 0 auto;
}

.cell {
  position: relative;
  padding: 0;
  border: 1px dashed rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.02);
  touch-action: none;
  cursor: pointer;
  overflow: visible;
}

.tile {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 6px 12px;
  border-radius: var(--radius);
  background: #1a2540; /* navy lifted with white overlay, pre-mixed for performance */
  border: 1px solid var(--line);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  text-align: center;
  color: var(--white);
}
.tile--in { animation: tile-in 140ms ease-out; }
@keyframes tile-in { from { transform: scale(0.6); opacity: 0; } }

.tile-icon {
  width: 30%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--blue);
  display: grid;
  place-items: center;
}
.icon { width: 62%; height: 62%; fill: none; stroke: var(--white); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.tile-svc {
  font-size: clamp(0.6rem, 2.6vw, 0.75rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
  line-height: 1.1;
}
.tile-status {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: clamp(0.72rem, 3.5vw, 1.05rem);
  line-height: 1.15;
  word-break: break-word;
}

.tile-bar { position: absolute; left: 8px; right: 8px; bottom: 5px; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, 0.1); }
.tile-bar i { display: block; height: 100%; border-radius: 2px; background: var(--white); opacity: 0.5; transform-origin: left; }

/* Warm-up training wheels only (phase 1) */
.tile--hint { border-color: rgba(239, 68, 68, 0.6); }

/* DDoS after first tap */
.tile.engaging { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue), 0 0 18px var(--blue); animation: pulse-tile 300ms ease-in-out infinite alternate; }
@keyframes pulse-tile { to { transform: scale(0.95); } }

/* Power-ups: the only visually distinct tiles */
.tile--power {
  background: linear-gradient(160deg, rgba(253, 202, 12, 0.3), rgba(253, 202, 12, 0.08)), #1a2540;
  border: 2px solid var(--gold);
  box-shadow: 0 0 22px rgba(253, 202, 12, 0.55);
  animation: tile-in 140ms ease-out, glow 600ms ease-in-out infinite alternate;
}
.tile--power .tile-svc { color: var(--gold); }
.tile-emoji { font-size: clamp(1.4rem, 7vw, 2rem); line-height: 1; }
@keyframes glow { to { box-shadow: 0 0 34px rgba(253, 202, 12, 0.85); } }

/* Removal effects (after a tap / expiry) */
.tile.fx-ok { background: var(--ok); border-color: var(--ok); animation: pop-out 380ms ease-out forwards; }
.tile.fx-bad { background: var(--bad); border-color: var(--bad); animation: shake-out 400ms ease-out forwards; }
.tile.fx-miss { animation: miss-out 420ms ease-out forwards; }
.tile.fx-miss::after { content: '💥'; position: absolute; inset: 0; display: grid; place-items: center; font-size: 2.2rem; }
.tile.fx-power { background: var(--gold); color: var(--navy); animation: pop-out 380ms ease-out forwards; }
.tile.fx-out { animation: fade-out 250ms ease-out forwards; }
.tile.fx-ok *, .tile.fx-bad * { color: var(--white); }

@keyframes pop-out { to { transform: scale(1.18); opacity: 0; } }
@keyframes fade-out { to { transform: scale(0.8); opacity: 0; } }
@keyframes miss-out { 0% { filter: grayscale(1); opacity: 0.8; } 100% { filter: grayscale(1); opacity: 0; transform: scale(0.9); } }
@keyframes shake-out {
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); opacity: 1; }
  100% { transform: translateX(0); opacity: 0; }
}

.screen--game.shake { animation: screen-shake 300ms ease-out; }
@keyframes screen-shake {
  20% { transform: translate(-5px, 2px); }
  40% { transform: translate(5px, -2px); }
  60% { transform: translate(-3px, 1px); }
  80% { transform: translate(3px, 0); }
}

/* Floating score text */
.float {
  position: absolute;
  left: 50%;
  top: 4%;
  transform: translate(-50%, 0);
  white-space: nowrap;
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 1.1rem;
  pointer-events: none;
  z-index: 5;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
  animation: float-up 850ms ease-out forwards;
}
.float.ok { color: var(--white); }
.float.bad { color: var(--bad); }
.float.gold { color: var(--gold); }
@keyframes float-up { to { transform: translate(-50%, -48px); opacity: 0; } }

/* Center banners (phase changes, combos, power-ups) */
.banners { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; z-index: 10; }
.banner {
  grid-area: 1 / 1;
  padding: 10px 18px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.88);
  border: 2px solid var(--gold);
  color: var(--gold);
  font-family: var(--font-head);
  font-weight: 800;
  font-size: clamp(1.1rem, 6vw, 1.6rem);
  letter-spacing: 0.04em;
  text-align: center;
  animation: banner 1250ms ease-out forwards;
}
.banner.danger { border-color: var(--bad); color: var(--bad); }
.banner.blue { border-color: var(--blue); color: var(--white); }
@keyframes banner {
  0% { transform: scale(0.6); opacity: 0; }
  15% { transform: scale(1.05); opacity: 1; }
  25% { transform: scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-12px); }
}

/* ---------- Results ---------- */

.results-head { text-align: center; padding-top: 8px; }
.badge {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--gold);
  color: var(--navy);
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 0.9rem;
}
.big-score {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: clamp(4rem, 22vw, 6rem);
  line-height: 1;
  margin: 10px 0 4px;
  font-variant-numeric: tabular-nums;
}
.breakdown { color: var(--text-dim); font-family: var(--font-mono); font-size: 0.9rem; margin-bottom: 4px; }
.uptime-tag { color: var(--gold); font-weight: 700; }

.rank-card {
  margin: 8px 0 14px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--blue-soft);
  border: 1px solid rgba(25, 129, 193, 0.5);
  text-align: center;
  font-weight: 700;
}
.rank-card.prize { background: var(--gold-soft); border-color: var(--gold); }
.rank-card small { display: block; font-weight: 400; color: var(--text-dim); margin-top: 4px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat { display: flex; flex-direction: column; align-items: center; padding: 10px 4px; border-radius: 12px; background: var(--surface); text-align: center; }
.stat b { font-family: var(--font-mono); font-size: 1.3rem; }
.stat span { font-size: 0.68rem; color: var(--text-faint); line-height: 1.2; margin-top: 2px; }

.learn { margin-top: 16px; padding: 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.learn ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.learn li { font-size: 0.9rem; color: var(--text-dim); }
.learn code {
  display: inline-block;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--white);
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 6px;
  margin-bottom: 2px;
}
.learn .kind { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; margin-left: 6px; }
.learn .kind--missed { color: var(--gold); }
.learn .kind--wrong { color: var(--bad); }

/* ---------- Message screen ---------- */

.message-body { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: auto 0; }
.message-icon { font-size: 3.5rem; }
#screen-message .actions { width: 100%; }

/* Short phones: tighten spacing so the grid stays large */
@media (max-height: 680px) {
  .hud-value { font-size: 1.25rem; }
  .phase-label { display: none; }
  .landing-body { margin-top: 3vh; }
}

/* ---------- Branding ---------- */

.brandbar--compact { justify-content: center; padding: 0 0 12px; }
.brandbar--game { padding: 0; }
.logo--xs { height: 22px; }
.countdown-logo { position: absolute; top: calc(var(--gutter) + var(--safe-top)); left: 50%; transform: translateX(-50%); }
#screen-countdown { position: relative; }

.brand-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 22px;
  padding: 20px 16px 8px;
  border-top: 1px solid var(--line);
  text-align: center;
}
.brand-footer .logo { height: 36px; }
.tagline {
  font-family: var(--font-head);
  font-weight: 700;
  color: var(--gold);
  margin: 4px 0 0;
  letter-spacing: 0.02em;
}
.brand-contact { color: var(--text-dim); font-size: 0.85rem; margin: 0; max-width: 26em; }

.actions .order-first { order: -1; }
