/* Arrowscape */
@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;
  --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: #0f2a1e; --bg2: #061a12; --orb1: #31e981; --orb2: #7bd3ff; --orb3: #a3e635;
}
body.w1 { --bg1: #1c2d12; --bg2: #0a1507; --orb1: #a3e635; --orb2: #fbbf24; --orb3: #34d399; }
body.w2 { --bg1: #3a1a0d; --bg2: #1a0a05; --orb1: #fb923c; --orb2: #f43f5e; --orb3: #fbbf24; }
body.w3 { --bg1: #072f3a; --bg2: #04161c; --orb1: #22d3ee; --orb2: #34d399; --orb3: #60a5fa; }
body.w4 { --bg1: #10233f; --bg2: #070f1f; --orb1: #93c5fd; --orb2: #e0f2fe; --orb3: #a5b4fc; }
body.w5 { --bg1: #2a0f3f; --bg2: #0d0618; --orb1: #c084fc; --orb2: #f472b6; --orb3: #818cf8; }

* { 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-rows: auto 1fr auto; min-height: 100dvh; overflow: hidden;
  transition: background 0.6s;
  -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.32; mix-blend-mode: screen; transition: background 0.8s; }
.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, .toolbar, .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 svg { width: 34px; height: 34px; display: block; filter: drop-shadow(0 4px 10px rgba(0,0,0,.35)); }
.hud-level { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.hud-level span { font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--fg-2); font-weight: 700; }
.hud-level b { font-family: var(--font-display); font-size: 1.05rem; font-weight: 700; }
.hud-moves { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }
.hud-moves span { font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--fg-2); font-weight: 700; }
.hud-moves b { font-family: var(--font-display); font-size: 1.05rem; }
.hud-moves small { font-family: var(--font-body); font-size: 0.72rem; color: var(--fg-2); margin-left: 6px; font-weight: 500; }
.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 { min-height: 0; display: grid; place-items: center; padding: 6px 12px; }
#board { display: block; touch-action: none; border-radius: 28px; }

.toolbar { display: flex; justify-content: center; gap: 10px; padding: 10px 14px; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
.tool { display: inline-flex; align-items: center; gap: 8px; padding: 11px 18px; border-radius: 999px; border: 1px solid var(--line); background: var(--glass); font-weight: 700; font-size: 0.92rem; cursor: pointer; transition: background 0.15s, transform 0.15s, opacity 0.15s; backdrop-filter: blur(10px); }
.tool svg { width: 18px; height: 18px; }
.tool:hover:not(:disabled) { background: var(--glass-2); transform: translateY(-1px); }
.tool:disabled { opacity: 0.4; cursor: default; }
.tool-hint { background: var(--spawn); color: var(--ink-on-spawn); border-color: transparent; }
.tool-hint:hover:not(:disabled) { background: #4ff094; }
.pill { background: rgba(0, 0, 0, 0.18); border-radius: 999px; padding: 1px 8px; font-size: 0.78rem; }

.toast { position: fixed; left: 50%; bottom: 84px; 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; }
.card-wide { max-width: 520px; }
@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; }
.dir-u { background: linear-gradient(180deg, #3ddc97, #1fae72); }
.dir-r { background: linear-gradient(180deg, #5aa2ff, #2f6fe0); }
.dir-d { background: linear-gradient(180deg, #ff6b9d, #e0397a); }
.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); }

.world-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.world-tab { border: 1px solid var(--line); background: var(--glass); border-radius: 999px; padding: 7px 12px; font-size: 0.8rem; font-weight: 700; cursor: pointer; }
.world-tab[aria-selected="true"] { background: var(--fg); color: #111; border-color: transparent; }
.world-tab.locked { opacity: 0.45; }
.level-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.lvl { position: relative; aspect-ratio: 1; border-radius: 14px; border: 1px solid var(--line); background: var(--glass); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; font-family: var(--font-display); font-weight: 700; font-size: 1rem; transition: background 0.15s, transform 0.15s; }
.lvl:hover:not(:disabled) { background: var(--glass-2); transform: translateY(-2px); }
.lvl small { font-family: var(--font-body); font-size: 0.62rem; letter-spacing: 0.08em; color: #ffd166; }
.lvl.is-current { outline: 2px solid var(--spawn); outline-offset: 2px; }
.lvl:disabled { opacity: 0.35; cursor: default; }
.lvl:disabled::after { content: ""; position: absolute; right: 7px; top: 7px; width: 9px; height: 11px; border: 2px solid currentColor; border-radius: 3px 3px 2px 2px; border-top-width: 3px; opacity: 0.8; }
.level-grid + .muted { margin-top: 14px; font-size: 0.82rem; }

.card-win { text-align: center; }
.stars { display: flex; justify-content: center; gap: 8px; margin: 6px 0 12px; }
.stars span { font-size: 2.6rem; line-height: 1; color: rgba(255, 255, 255, 0.14); transform: scale(0.6); transition: transform 0.35s cubic-bezier(.2,.9,.2,1.4), color 0.3s, text-shadow 0.3s; }
.stars span.lit { color: #ffd166; transform: scale(1); text-shadow: 0 0 22px rgba(255, 209, 102, 0.7); }
.card-win .card-actions { justify-content: center; }

@media (max-width: 560px) {
  .hud { gap: 6px; padding: 8px 10px; grid-template-columns: auto minmax(0, 1fr) auto auto; }
  .hud-brand svg { width: 30px; height: 30px; }
  .hud-level b, .hud-moves b { font-size: 0.9rem; }
  .hud-level span, .hud-moves span { font-size: 0.62rem; }
  .hud-moves small { margin-left: 4px; font-size: 0.66rem; }
  .hud-actions { gap: 5px; }
  .icon-btn { width: 34px; height: 34px; }
  .icon-btn svg { width: 18px; height: 18px; }
  .tool { padding: 10px 14px; font-size: 0.85rem; }
  .stars span { font-size: 2.2rem; }
}
@media (prefers-reduced-motion: reduce) {
  .orb { animation: none; }
  .card { animation: none; }
}
