/* Gridbloom: a night garden of glass blocks */
@font-face { font-family: "Unbounded"; font-weight: 700; font-display: swap; src: url("/assets/fonts/unbounded-700.woff2") format("woff2"); }
@font-face { font-family: "Unbounded"; font-weight: 800; font-display: swap; src: url("/assets/fonts/unbounded-800.woff2") format("woff2"); }
@font-face { font-family: "Sora"; font-weight: 500; font-display: swap; src: url("/assets/fonts/sora-500.woff2") format("woff2"); }
@font-face { font-family: "Sora"; font-weight: 700; font-display: swap; src: url("/assets/fonts/sora-700.woff2") format("woff2"); }

:root {
  --spawn: #31e981;
  --ink-on-spawn: #0b1a12;
  --accent: #ff7ad9;
  --fg: #f4f1ea;
  --fg-2: rgba(244, 241, 234, 0.72);
  --glass: rgba(255, 255, 255, 0.07);
  --glass-2: rgba(255, 255, 255, 0.12);
  --line: rgba(255, 255, 255, 0.14);
  --font-display: "Unbounded", system-ui, sans-serif;
  --font-body: "Sora", system-ui, sans-serif;
  --bg1: #1a1538; --bg2: #0a0916; --orb1: #ff7ad9; --orb2: #5aa2ff; --orb3: #31e981;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; color: var(--fg); font-family: var(--font-body); font-weight: 500;
  background: radial-gradient(1200px 700px at 50% 0%, var(--bg1), var(--bg2) 70%), var(--bg2);
  display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; min-height: 100dvh; overflow: hidden;
  -webkit-font-smoothing: antialiased; user-select: none; -webkit-user-select: none;
}
button { font: inherit; color: inherit; }
.bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.orb { position: absolute; width: 46vmax; height: 46vmax; border-radius: 50%; filter: blur(70px); opacity: 0.26; mix-blend-mode: screen; }
.o1 { background: var(--orb1); left: -12vmax; top: -10vmax; animation: drift1 26s ease-in-out infinite alternate; }
.o2 { background: var(--orb2); right: -14vmax; top: 20vmax; animation: drift2 31s ease-in-out infinite alternate; }
.o3 { background: var(--orb3); left: 30vmax; bottom: -22vmax; animation: drift3 37s ease-in-out infinite alternate; }
@keyframes drift1 { to { transform: translate(8vmax, 6vmax) scale(1.1); } }
@keyframes drift2 { to { transform: translate(-6vmax, 10vmax) scale(0.9); } }
@keyframes drift3 { to { transform: translate(-10vmax, -6vmax) scale(1.15); } }

.hud, .stage { position: relative; z-index: 1; }
.hud { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 12px; padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); }
.hud-brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.hud-title { font-family: var(--font-display); font-size: 1rem; font-weight: 800; margin: 0; letter-spacing: 0.01em; }
@media (max-width: 719px) { .hud-title { display: none; } }
.hud-brand svg { width: 34px; height: 34px; display: block; filter: drop-shadow(0 4px 10px rgba(0,0,0,.35)); }
.hud-score, .hud-best { display: flex; flex-direction: column; line-height: 1.1; }
.hud-score { align-items: center; }
.hud-best { align-items: flex-end; }
.hud-score span, .hud-best span { font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--fg-2); font-weight: 700; }
.hud-score b { font-family: var(--font-display); font-size: clamp(1.4rem, 5vw, 2rem); font-weight: 800; letter-spacing: -0.02em; transition: transform 0.12s; }
.hud-score b.bump { transform: scale(1.12); }
.hud-best b { font-family: var(--font-display); font-size: 1.05rem; color: var(--accent); }
body.demo .hud-actions { visibility: hidden; }
.hud-actions { display: flex; gap: 8px; }
.icon-btn { width: 40px; height: 40px; border-radius: 999px; border: 1px solid var(--line); background: var(--glass); display: grid; place-items: center; cursor: pointer; transition: background 0.15s, transform 0.15s; backdrop-filter: blur(10px); }
.icon-btn:hover { background: var(--glass-2); transform: translateY(-1px); }
.icon-btn svg { width: 20px; height: 20px; fill: currentColor; }
#btn-sound .ic-off { display: none; }
#btn-sound[aria-pressed="false"] .ic-on { display: none; }
#btn-sound[aria-pressed="false"] .ic-off { display: block; }

.stage { position: relative; min-height: 0; display: grid; place-items: center; padding: 4px 10px 10px; }
#board { display: block; touch-action: none; }
.combo { position: absolute; left: 50%; top: 18%; transform: translateX(-50%); font-family: var(--font-display); font-weight: 800; font-size: clamp(1.3rem, 5vw, 2rem); color: var(--accent); text-shadow: 0 4px 20px rgba(255, 122, 217, 0.6); pointer-events: none; animation: popup 0.8s cubic-bezier(.2,.9,.2,1) forwards; }
.combo[hidden] { display: none; }
@keyframes popup { 0% { opacity: 0; transform: translateX(-50%) scale(0.6); } 25% { opacity: 1; transform: translateX(-50%) scale(1.1); } 100% { opacity: 0; transform: translateX(-50%) translateY(-28px) scale(1); } }

.toast { position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%) translateY(10px); z-index: 20; background: rgba(10, 14, 20, 0.86); border: 1px solid var(--line); color: var(--fg); padding: 10px 16px; border-radius: 999px; font-size: 0.9rem; font-weight: 700; backdrop-filter: blur(10px); opacity: 0; transition: opacity 0.2s, transform 0.2s; pointer-events: none; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast[hidden] { display: none; }

.overlay { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 16px; background: rgba(4, 8, 12, 0.55); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.overlay[hidden] { display: none; }
.card { width: 100%; max-width: 440px; background: linear-gradient(180deg, rgba(28, 34, 46, 0.96), rgba(16, 20, 28, 0.98)); border: 1px solid var(--line); border-radius: 26px; padding: 26px 24px 22px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5); animation: pop 0.28s cubic-bezier(.2,.9,.2,1.2); max-height: calc(100dvh - 32px); overflow: auto; }
@keyframes pop { from { transform: scale(0.92) translateY(10px); opacity: 0; } }
.kicker { margin: 0 0 6px; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--spawn); }
.card h2 { margin: 0 0 14px; font-family: var(--font-display); font-weight: 800; font-size: 1.5rem; letter-spacing: -0.02em; line-height: 1.1; }
.muted { color: var(--fg-2); margin: 0; line-height: 1.55; font-size: 0.95rem; }
.card-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 20px; border-radius: 999px; border: 1.5px solid transparent; font-weight: 700; font-size: 0.95rem; cursor: pointer; text-decoration: none; color: inherit; transition: transform 0.15s, box-shadow 0.15s; }
.btn-primary { background: var(--spawn); color: var(--ink-on-spawn); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(49, 233, 129, 0.35); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover { border-color: var(--fg); }
.how { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.how li { display: flex; gap: 14px; align-items: flex-start; color: var(--fg-2); line-height: 1.5; font-size: 0.95rem; }
.how-ic { flex: none; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: #fff; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35); }
.how-ic svg { width: 26px; height: 26px; fill: currentColor; }
.ic-a { background: linear-gradient(180deg, #5aa2ff, #2f6fe0); }
.ic-b { background: linear-gradient(180deg, #ff7ad9, #d13aa5); }
.ic-c { background: linear-gradient(180deg, #ffd166, #e0a52e); }
.keys { margin: 18px 0 0; font-size: 0.8rem; color: var(--fg-2); }
kbd { font-family: inherit; font-weight: 700; font-size: 0.78em; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; background: var(--glass); }
.card-over { text-align: center; }
.over-score { margin: 4px 0 10px; }
.over-score b { display: block; font-family: var(--font-display); font-weight: 800; font-size: 3rem; letter-spacing: -0.03em; line-height: 1; color: var(--accent); }
.over-score span { display: block; margin-top: 6px; font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--fg-2); font-weight: 700; }
.card-over .card-actions { justify-content: center; }

@media (max-width: 560px) {
  .hud { gap: 8px; padding: 8px 10px; }
  .hud-brand svg { width: 30px; height: 30px; }
  .hud-actions { gap: 5px; }
  .icon-btn { width: 34px; height: 34px; }
  .icon-btn svg { width: 18px; height: 18px; }
}
@media (max-width: 420px) {
  .hud { gap: 6px; padding-left: 8px; padding-right: 8px; grid-template-columns: auto minmax(0, 1fr) auto auto; }
  .hud-actions { gap: 4px; }
  .icon-btn { width: 32px; height: 32px; }
  .icon-btn svg { width: 17px; height: 17px; }
  .hud-brand svg { width: 28px; height: 28px; }
  .lvl-name { display: none; }
}
@media (prefers-reduced-motion: reduce) { .orb { animation: none; } .card { animation: none; } }
