/* Cosmic Drop & Merge — self-contained styles, no remote fonts or assets */
:root {
  --bg0: #070816;
  --bg1: #12142b;
  --panel: rgba(16, 18, 42, 0.72);
  --stroke: rgba(190, 210, 255, 0.22);
  --text: #eef3ff;
  --muted: #9aa6c8;
  --gold: #f0c35a;
  --cyan: #6ae0ff;
  --magenta: #d46bff;
  --danger: #ff5a6a;
  --ok: #6dffb0;
  --shadow: 0 10px 32px rgba(0, 0, 0, 0.45);
  --radius: 16px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(90, 40, 140, 0.35), transparent 60%),
    radial-gradient(800px 500px at 100% 100%, rgba(20, 40, 120, 0.35), transparent 55%),
    var(--bg0);
  color: var(--text);
  font-family: system-ui, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  user-select: none;
  touch-action: none;
}

#app {
  height: 100%;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: calc(8px + var(--safe-t)) 10px calc(8px + var(--safe-b));
  gap: 8px;
}

.hud {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand {
  flex: 1;
  min-width: 0;
}

.brand h1 {
  margin: 0;
  font-size: clamp(15px, 4.2vw, 20px);
  font-weight: 750;
  letter-spacing: 0.02em;
  line-height: 1.15;
  background: linear-gradient(90deg, #fff, var(--cyan) 55%, var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tag {
  margin: 2px 0 0;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.scores {
  display: flex;
  gap: 8px;
}

.score-box,
.next-box,
.legend-wrap,
.powers button,
.icon-btn,
.overlay-card {
  background: var(--panel);
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.score-box {
  min-width: 68px;
  padding: 6px 10px;
  border-radius: 12px;
  text-align: right;
}

.score-box .lbl,
.next-box .lbl,
.legend-wrap .lbl {
  display: block;
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.score-box span:last-child {
  display: block;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 18px;
  color: var(--gold);
  line-height: 1.2;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
}

.icon-btn.muted {
  color: var(--danger);
}

.icon-btn:focus-visible,
.powers button:focus-visible,
.overlay-card button:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.strip-row {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  align-items: stretch;
}

.next-box {
  width: 76px;
  border-radius: 14px;
  padding: 6px 6px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#next-canvas,
#legend-canvas {
  display: block;
  width: 100%;
}

.legend-wrap {
  flex: 1;
  min-width: 0;
  border-radius: 14px;
  padding: 6px 8px 4px;
}

#stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#game {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  border-radius: 22px;
  box-shadow:
    0 0 0 1px rgba(160, 200, 255, 0.16),
    0 16px 50px rgba(0, 0, 0, 0.55),
    0 0 60px rgba(80, 40, 160, 0.25);
  cursor: crosshair;
  touch-action: none;
}

#combo-badge {
  position: absolute;
  top: 14%;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, #6a20a8, #2040c8);
  border: 1px solid rgba(255, 255, 255, 0.28);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 13px;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(80, 0, 160, 0.45);
}

#combo-badge.hidden,
.hidden {
  display: none !important;
}

#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 6, 16, 0.62);
  border-radius: 22px;
  padding: 18px;
}

#overlay.hidden {
  display: none !important;
}

.overlay-card {
  width: min(320px, 100%);
  border-radius: var(--radius);
  padding: 22px 20px 18px;
  text-align: center;
}

.overlay-card h2 {
  margin: 0 0 8px;
  font-size: 26px;
  letter-spacing: 0.04em;
}

.overlay-card p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.overlay-card .big-score {
  font-size: 32px;
  font-weight: 800;
  color: var(--gold);
  margin: 0 0 4px;
}

.overlay-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.overlay-card button,
.powers button {
  appearance: none;
  border: 1px solid var(--stroke);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  border-radius: 12px;
}

.overlay-card button {
  padding: 11px 14px;
  background: linear-gradient(180deg, rgba(80, 120, 255, 0.35), rgba(40, 50, 120, 0.5));
}

.overlay-card button.secondary {
  background: rgba(255, 255, 255, 0.06);
  font-weight: 600;
}

.overlay-card button:disabled,
.powers button:disabled {
  opacity: 0.45;
  cursor: default;
}

.ad-progress {
  height: 6px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
  margin: 12px 0 4px;
}

.ad-progress > span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--cyan), var(--magenta));
}

.powers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  flex-shrink: 0;
}

.powers:has(#btn-revive:not(.hidden)) {
  grid-template-columns: 1fr 1fr 1fr;
}

.powers button {
  padding: 11px 8px;
  font-size: 13px;
  background: linear-gradient(180deg, rgba(40, 50, 90, 0.8), rgba(16, 18, 40, 0.9));
}

.powers button:hover:not(:disabled),
.overlay-card button:hover:not(:disabled),
.icon-btn:hover {
  border-color: rgba(106, 224, 255, 0.55);
}

.powers button.active {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold), 0 0 18px rgba(240, 195, 90, 0.35);
}

@media (min-width: 900px) {
  #app {
    max-width: 520px;
    padding-top: 16px;
    padding-bottom: 16px;
  }
}

@media (max-height: 700px) {
  .brand .tag {
    display: none;
  }
  .score-box span:last-child {
    font-size: 15px;
  }
}
