/* Vertex Dash — UI chrome. The game world is the canvas; menus float over it as chunky,
   ink-outlined panels. The look is deliberately single-theme (a neon arcade at night), so
   every colour is set explicitly and does not follow the OS light/dark preference. */
:root {
  color-scheme: dark;
  --ink: #0b0820;
  --ink-2: #16113a;
  --panel: #1d1650;
  --panel-2: #2b2178;
  --line: rgba(255, 255, 255, 0.14);
  --text: #ffffff;
  --muted: #b9b3e6;
  --cyan: #35d4ff;
  --green: #3dff6e;
  --pink: #ff4fd8;
  --gold: #ffd23f;
  --red: #ff4b4b;
  --grey: #8f95bd;
  --display: "Lilita One", "Arial Black", "Trebuchet MS", system-ui, sans-serif;
  --ui: "Fredoka", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }
html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--ink);
  color: var(--text);
  font-family: var(--ui);
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .card:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

#stage, #glstage, #hudstage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
#stage { background: var(--ink); }
#glstage, #hudstage { pointer-events: none; }

#ui { position: fixed; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }
#ui > .hud, #ui > .editor-ui, #ui > .toast { pointer-events: none; }

/* outlined game text */
.ol {
  font-family: var(--display);
  font-weight: 400;
  letter-spacing: 0.02em;
  text-shadow:
    0 3px 0 var(--ink), 2px 2px 0 var(--ink), -2px 2px 0 var(--ink),
    2px -2px 0 var(--ink), -2px -2px 0 var(--ink), 3px 0 0 var(--ink), -3px 0 0 var(--ink), 0 -2px 0 var(--ink);
}
.small { font-size: 13px; color: var(--muted); }
.err { color: #ff8a8a; }
.spacer { flex: 1; }
.row { display: flex; align-items: center; flex-wrap: wrap; }
.row.gap { gap: 10px; }
.row.center { justify-content: center; }

/* ---------- screens ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(16px + var(--sat)) calc(16px + var(--sar)) calc(16px + var(--sab)) calc(16px + var(--sal));
  background: radial-gradient(ellipse at 50% 45%, rgba(11, 8, 32, 0.15), rgba(11, 8, 32, 0.7));
  overflow-y: auto;
  animation: fadeIn 0.25s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- title ---------- */
.title-wrap {
  margin: auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding-block: 24px;
}
.logo {
  position: relative;
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(46px, 10.5vw, 132px);
  line-height: 0.95;
  letter-spacing: 0.015em;
  text-align: center;
  color: var(--ink);
  -webkit-text-stroke: 0.16em var(--ink);
  text-shadow: 0 0.1em 0 var(--ink), 0 0.14em 28px rgba(255, 90, 54, 0.45);
  transform: rotate(-2deg);
  animation: logoBob 3.2s ease-in-out infinite;
}
.logo::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  -webkit-text-stroke: 0;
  text-shadow: none;
  color: transparent;
  background: linear-gradient(180deg, #fffbe6 0%, #ffe23b 42%, #ff9f1c 78%, #ff5a36 100%);
  -webkit-background-clip: text;
  background-clip: text;
}
@keyframes logoBob { 50% { transform: rotate(-2deg) translateY(-6px); } }
.tagline { margin: 0; font-size: clamp(15px, 2.4vw, 22px); color: #cfe9ff; }

.title-row { display: flex; align-items: center; gap: clamp(14px, 4vw, 40px); margin-top: 18px; }
.title-labels {
  display: grid;
  grid-template-columns: 88px 140px 88px;
  gap: clamp(14px, 4vw, 40px);
  text-align: center;
  font-size: 17px;
  color: #eef;
}
.btn-play {
  width: 140px; height: 140px;
  border-radius: 50%;
  border: 7px solid var(--ink);
  background: radial-gradient(circle at 38% 30%, #b8ffc9 0%, #3dff6e 38%, #12c64a 100%);
  box-shadow: 0 9px 0 var(--ink), 0 0 50px rgba(61, 255, 110, 0.45), inset 0 -8px 0 rgba(0, 0, 0, 0.18);
  display: grid; place-items: center;
  transition: transform 0.12s ease;
  animation: playPulse 1.4s ease-in-out infinite;
}
.btn-play svg { width: 78%; height: 78%; }
.btn-play path { fill: #fff; stroke: var(--ink); stroke-width: 7; stroke-linejoin: round; }
@keyframes playPulse { 50% { box-shadow: 0 9px 0 var(--ink), 0 0 80px rgba(61, 255, 110, 0.7), inset 0 -8px 0 rgba(0, 0, 0, 0.18); } }
.btn-play:hover, .btn-square:hover, .btn-round:hover, .btn-circle:hover { transform: scale(1.07); }
.btn-play:active, .btn-square:active, .btn-round:active, .btn-circle:active { transform: translateY(5px) scale(0.97); }

.btn-square {
  width: 88px; height: 88px;
  border-radius: 22px;
  border: 5px solid var(--ink);
  box-shadow: 0 7px 0 var(--ink), inset 0 -6px 0 rgba(0, 0, 0, 0.2);
  display: grid; place-items: center;
  transition: transform 0.12s ease;
}
.btn-square svg { width: 62%; height: 62%; fill: #fff; stroke: var(--ink); stroke-width: 4; stroke-linejoin: round; }
.btn-pink { background: linear-gradient(180deg, #ff8be8, #e02fb8); }
.btn-cyan { background: linear-gradient(180deg, #8de9ff, #1aa8e0); }
.mini-icon { width: 60px; height: 60px; }

.title-foot {
  position: absolute;
  left: calc(16px + var(--sal)); right: calc(16px + var(--sar)); bottom: calc(16px + var(--sab));
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.btn-round {
  width: 54px; height: 54px;
  border-radius: 50%;
  border: 4px solid var(--ink);
  background: linear-gradient(180deg, #c6cbe8, #7f86b3);
  box-shadow: 0 5px 0 var(--ink);
  display: grid; place-items: center;
  transition: transform 0.12s ease;
}
.btn-round svg { width: 64%; height: 64%; fill: #fff; stroke: var(--ink); stroke-width: 3; }
.totals { display: flex; gap: 18px; font-size: 20px; align-items: center; }
.totals span { display: inline-flex; align-items: center; gap: 6px; }
.totals svg { width: 26px; height: 26px; }
.hint { position: absolute; bottom: calc(84px + var(--sab)); margin: 0; font-size: 14px; color: #dfe; opacity: 0.85; text-align: center; padding-inline: 16px; }

/* ---------- top bar ---------- */
.topbar { width: 100%; max-width: 1100px; display: flex; align-items: center; gap: 12px; }
.topbar h2 { margin: 0; font-size: clamp(28px, 5vw, 44px); flex: 0 1 auto; text-align: center; }
.topbar .spacer { flex: 1; }
.topbar h2 { position: absolute; left: 50%; transform: translateX(-50%); }
.btn-back {
  width: 56px; height: 56px;
  border-radius: 16px;
  border: 4px solid var(--ink);
  background: linear-gradient(180deg, #7dff9d, #1fcf55);
  box-shadow: 0 5px 0 var(--ink);
  display: grid; place-items: center;
}
.btn-back svg { width: 64%; fill: #fff; stroke: var(--ink); stroke-width: 4; stroke-linejoin: round; }
.btn-back:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }

/* ---------- level select ---------- */
.carousel { margin: auto 0; display: flex; align-items: center; gap: 12px; width: 100%; justify-content: center; padding-block: 16px; }
.arrow { background: none; border: 0; width: 56px; height: 90px; padding: 0; flex: none; }
.arrow svg { width: 100%; height: 100%; fill: #fff; stroke: var(--ink); stroke-width: 5; stroke-linejoin: round; filter: drop-shadow(0 4px 0 var(--ink)); }
.arrow:hover svg { fill: var(--gold); }
.arrow:active { transform: scale(0.92); }
.card-slot { width: min(640px, calc(100vw - 172px)); }
.card {
  position: relative;
  border: 5px solid var(--ink);
  border-radius: 26px;
  padding: 20px 22px 18px;
  box-shadow: 0 10px 0 var(--ink), inset 0 3px 0 rgba(255, 255, 255, 0.2);
  display: flex; flex-direction: column; gap: 14px;
  cursor: pointer;
  transition: transform 0.15s ease;
  animation: cardIn 0.28s cubic-bezier(.2, 1.4, .4, 1);
}
@keyframes cardIn { from { transform: scale(0.9); opacity: 0; } to { transform: none; opacity: 1; } }
.card:hover { transform: translateY(-4px); }
.card-head { display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap; }
.face { width: 76px; height: 76px; flex: none; filter: drop-shadow(0 4px 0 var(--ink)); }
.card-title { flex: 1 1 220px; min-width: 0; order: 0; }
.card-title h3 { margin: 0; font-size: clamp(28px, 4.6vw, 44px); line-height: 1; overflow-wrap: break-word; }
.card-title .meta { margin-top: 6px; font-size: 15px; font-weight: 600; color: rgba(255, 255, 255, 0.9); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35); }
.stars { display: flex; align-items: center; gap: 6px; font-size: 30px; flex: none; }
.stars svg { width: 34px; height: 34px; }
.coins-row { display: flex; gap: 8px; }
.coin-slot { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--ink); background: rgba(0, 0, 0, 0.3); }
.coin-slot.got { background: radial-gradient(circle at 35% 35%, #fff4b0, #ffd23f 45%, #e89b00); box-shadow: 0 0 12px rgba(255, 210, 63, 0.7); }
.bar-label { display: flex; justify-content: space-between; font-weight: 700; font-size: 14px; margin-bottom: 4px; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35); }
.bar { height: 18px; border-radius: 10px; border: 3px solid var(--ink); background: rgba(0, 0, 0, 0.35); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, #35d4ff, #3dff6e); box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.35); }
.bar.practice > i { background: linear-gradient(90deg, #3dff6e, #b7ff3b); }
.card-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.dots { display: flex; gap: 10px; justify-content: center; padding-block: 8px 16px; }
.dots i { width: 12px; height: 12px; border-radius: 50%; background: rgba(255, 255, 255, 0.3); border: 2px solid var(--ink); }
.dots i.on { background: #fff; transform: scale(1.25); }
.card.custom-card { background: linear-gradient(160deg, #3a2f8f, #1d1650); align-items: center; text-align: center; justify-content: center; min-height: 250px; }
.card.custom-card h3 { margin: 0; font-size: clamp(28px, 5vw, 44px); }
.card.custom-card p { margin: 0; color: var(--muted); font-weight: 600; }

/* ---------- panels & buttons ---------- */
.panel {
  margin: auto 0;
  width: min(560px, 100%);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 5px solid var(--ink);
  border-radius: 26px;
  box-shadow: 0 10px 0 var(--ink), inset 0 3px 0 rgba(255, 255, 255, 0.12);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.panel.wide { width: min(880px, 100%); }
.panel h2 { margin: 0; text-align: center; font-size: 34px; }
.panel h3 { margin: 4px 0 0; font-size: 20px; }
.btn {
  border: 4px solid var(--ink);
  border-radius: 16px;
  padding: 10px 20px;
  font-family: var(--display);
  font-size: 20px;
  letter-spacing: 0.02em;
  color: #fff;
  text-shadow: 0 2px 0 var(--ink), 1px 1px 0 var(--ink), -1px 1px 0 var(--ink);
  box-shadow: 0 5px 0 var(--ink), inset 0 -4px 0 rgba(0, 0, 0, 0.18);
  transition: transform 0.1s ease;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn-green { background: linear-gradient(180deg, #7dff9d, #1fcf55); }
.btn-cyan { background: linear-gradient(180deg, #8de9ff, #1aa8e0); }
.btn-grey { background: linear-gradient(180deg, #c6cbe8, #7f86b3); }
.btn-red { background: linear-gradient(180deg, #ff9a9a, #e0303a); }
.btn-pink { background: linear-gradient(180deg, #ff8be8, #e02fb8); }
.small-btn { font-size: 16px; padding: 6px 14px; border-width: 3px; box-shadow: 0 4px 0 var(--ink); }

.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; font-weight: 600; font-size: 17px; min-height: 40px; flex-wrap: wrap; }
.set-row.keys { align-items: flex-start; flex-direction: column; gap: 4px; }
.set-row.compact { min-height: 30px; font-size: 15px; }
input[type="range"] { -webkit-appearance: none; appearance: none; width: min(240px, 55%); height: 14px; border-radius: 8px; background: rgba(0, 0, 0, 0.4); border: 3px solid var(--ink); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; border-radius: 50%; background: var(--green); border: 3px solid var(--ink); }
input[type="range"]::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--green); border: 3px solid var(--ink); }
input.toggle { -webkit-appearance: none; appearance: none; width: 58px; height: 32px; border-radius: 18px; background: rgba(0, 0, 0, 0.45); border: 3px solid var(--ink); position: relative; cursor: pointer; transition: background 0.15s; flex: none; }
input.toggle::after { content: ""; position: absolute; top: 2px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #d7d9ee; transition: transform 0.15s; }
input.toggle:checked { background: var(--green); }
input.toggle:checked::after { transform: translateX(25px); background: #fff; }

/* ---------- HUD ---------- */
.hud { position: absolute; inset: 0; }
.btn-pause {
  pointer-events: auto;
  position: absolute;
  top: calc(10px + var(--sat)); right: calc(12px + var(--sar));
  width: 50px; height: 50px;
  border: 0; border-radius: 14px; background: rgba(11, 8, 32, 0.35);
  display: grid; place-items: center;
}
.btn-pause svg { width: 70%; fill: #fff; stroke: var(--ink); stroke-width: 4; }
.cp-buttons { pointer-events: auto; position: absolute; bottom: calc(18px + var(--sab)); left: 50%; transform: translateX(-50%); display: flex; gap: 22px; }
.btn-cp { width: 66px; height: 66px; border: 0; background: none; padding: 0; filter: drop-shadow(0 5px 0 var(--ink)); }
.btn-cp svg { width: 100%; height: 100%; }
.btn-cp path:first-child { fill: #3dff6e; stroke: var(--ink); stroke-width: 5; stroke-linejoin: round; }
.btn-cp.del path:first-child { fill: #6a728f; }
.btn-cp:active { transform: translateY(4px); }

/* ---------- overlays ---------- */
.overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: calc(16px + var(--sat)) calc(16px + var(--sar)) calc(16px + var(--sab)) calc(16px + var(--sal));
  background: rgba(11, 8, 32, 0.55);
  overflow-y: auto;
  animation: fadeIn 0.18s ease-out;
}
.overlay .panel { animation: cardIn 0.26s cubic-bezier(.2, 1.4, .4, 1); }
.bars { display: flex; flex-direction: column; gap: 10px; }
.pause-row { display: flex; justify-content: center; align-items: flex-start; gap: clamp(8px, 3vw, 18px); flex-wrap: wrap; }
.pbtn { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 96px; }
.pbtn .small { font-weight: 600; text-align: center; }
.btn-circle {
  width: 70px; height: 70px; border-radius: 50%;
  border: 5px solid var(--ink);
  box-shadow: 0 6px 0 var(--ink), inset 0 -5px 0 rgba(0, 0, 0, 0.18);
  display: grid; place-items: center;
  transition: transform 0.12s ease;
}
.btn-circle.big { width: 96px; height: 96px; }
.btn-circle svg { width: 60%; fill: #fff; stroke: var(--ink); stroke-width: 4; stroke-linejoin: round; }
.btn-mint { background: linear-gradient(180deg, #b7ffcb, #2ccf66); }
.btn-mint.on { background: linear-gradient(180deg, #fff5b0, #ffc21f); }
.btn-circle.btn-green { background: radial-gradient(circle at 38% 30%, #b8ffc9 0%, #3dff6e 38%, #12c64a 100%); }
.btn-circle.btn-grey { background: linear-gradient(180deg, #c6cbe8, #7f86b3); }

.panel.complete { text-align: center; align-items: stretch; }
.big-title { font-size: clamp(32px, 6vw, 48px) !important; color: var(--gold); }
.done-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.done-stats div { background: rgba(0, 0, 0, 0.28); border: 3px solid var(--ink); border-radius: 16px; padding: 10px 6px; }
.done-stats b { display: block; font-family: var(--display); font-weight: 400; font-size: 28px; font-variant-numeric: tabular-nums; }
.done-stats span { font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.done-coins { display: flex; justify-content: center; gap: 12px; }
.done-coins .coin-slot { width: 40px; height: 40px; }
.done-coins .coin-slot.new { animation: coinPop 0.6s cubic-bezier(.2, 1.8, .4, 1) both; }
@keyframes coinPop { from { transform: scale(0) rotate(-90deg); } to { transform: none; } }
.done-reward { margin: 0; font-size: 22px; color: var(--gold); min-height: 1em; }

/* ---------- custom levels ---------- */
.custom-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.custom-list li { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: rgba(0, 0, 0, 0.25); border: 3px solid var(--ink); border-radius: 16px; padding: 10px 12px; }
.custom-list .nm { flex: 1; min-width: 140px; }
.custom-list .nm b { display: block; font-family: var(--display); font-weight: 400; font-size: 22px; overflow-wrap: anywhere; }
.custom-list .empty { justify-content: center; color: var(--muted); font-weight: 600; }
.import-box { display: flex; flex-direction: column; gap: 8px; }
textarea, .ed-name, select {
  font: 600 14px var(--ui);
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  border: 3px solid var(--ink);
  border-radius: 12px;
  padding: 8px 10px;
  -webkit-user-select: text; user-select: text;
}
textarea { font-family: var(--mono); font-size: 12px; resize: vertical; width: 100%; }
select option { background: var(--panel); }

/* ---------- icon kit ---------- */
.kit { flex-direction: row; flex-wrap: wrap; align-items: flex-start; }
.kit-preview { display: flex; flex-direction: column; align-items: center; gap: 12px; flex: 0 0 200px; margin-inline: auto; }
#kit-big { width: 160px; height: 160px; background: radial-gradient(circle, rgba(255, 255, 255, 0.12), transparent 70%); border-radius: 20px; }
.kit-modes { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.kit-modes button { border: 3px solid var(--ink); border-radius: 10px; background: rgba(0, 0, 0, 0.3); padding: 4px 8px; font-weight: 600; font-size: 13px; text-transform: capitalize; }
.kit-modes button.on { background: var(--cyan); color: var(--ink); }
.kit-body { flex: 1 1 360px; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.kit-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; max-width: 460px; }
.kit-grid button { aspect-ratio: 1; border: 3px solid var(--ink); border-radius: 12px; background: rgba(0, 0, 0, 0.3); padding: 6px; max-width: 100%; }
.kit-grid button.on { background: rgba(255, 255, 255, 0.22); border-color: var(--gold); box-shadow: 0 0 0 2px var(--ink); }
.kit-grid canvas { width: 100%; height: 100%; display: block; }
.swatches { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 7px; max-width: 460px; }
.swatches button { aspect-ratio: 1; border: 3px solid var(--ink); border-radius: 10px; padding: 0; max-width: 100%; }
.swatches button.on { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--ink); transform: scale(1.06); }

/* ---------- editor ---------- */
.editor-ui { position: absolute; inset: 0; pointer-events: none; }
.editor-ui > * { pointer-events: auto; }
.ed-top {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: calc(8px + var(--sat)) calc(12px + var(--sar)) 8px calc(12px + var(--sal));
  background: linear-gradient(180deg, rgba(11, 8, 32, 0.92), rgba(11, 8, 32, 0.7));
  border-bottom: 3px solid var(--ink);
}
.ed-btn {
  width: 44px; height: 44px; border-radius: 12px; border: 3px solid var(--ink);
  background: linear-gradient(180deg, #4a3fa0, #2b2178); display: grid; place-items: center; flex: none; color: #fff;
}
.ed-btn svg { width: 64%; fill: #fff; }
.ed-btn.play { background: linear-gradient(180deg, #7dff9d, #1fcf55); }
.ed-btn.play svg { stroke: var(--ink); stroke-width: 4; stroke-linejoin: round; }
.ed-btn:active { transform: translateY(2px); }
.ed-name { width: min(220px, 40vw); font-family: var(--display); font-weight: 400; font-size: 18px; }
.ed-side {
  position: absolute; left: calc(10px + var(--sal)); top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 8px;
}
.ed-tool {
  width: 76px; padding: 9px 4px; border-radius: 14px; border: 3px solid var(--ink);
  background: rgba(29, 22, 80, 0.9); font-weight: 700; font-size: 14px; box-shadow: 0 4px 0 var(--ink);
}
.ed-tool.on { background: var(--gold); color: var(--ink); }
.ed-bottom {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 6px calc(10px + var(--sar)) calc(8px + var(--sab)) calc(10px + var(--sal));
  background: linear-gradient(0deg, rgba(11, 8, 32, 0.95), rgba(11, 8, 32, 0.78));
  border-top: 3px solid var(--ink);
}
.ed-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; }
.ed-tabs button { border: 3px solid var(--ink); border-radius: 10px; background: rgba(255, 255, 255, 0.08); padding: 4px 12px; font-weight: 700; font-size: 13px; flex: none; }
.ed-tabs button.on { background: var(--cyan); color: var(--ink); }
.ed-palette { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.ed-palette button { width: 54px; height: 54px; flex: none; border: 3px solid var(--ink); border-radius: 12px; background: rgba(255, 255, 255, 0.07); padding: 3px; }
.ed-palette button.on { background: rgba(255, 210, 63, 0.3); border-color: var(--gold); }
.ed-palette canvas { width: 100%; height: 100%; display: block; }
.ed-status { position: absolute; right: calc(12px + var(--sar)); top: calc(70px + var(--sat)); text-align: right; text-shadow: 0 2px 0 var(--ink); pointer-events: none; font-weight: 600; }
.ed-share-box {
  position: absolute; top: calc(72px + var(--sat)); left: 50%; transform: translateX(-50%);
  width: min(560px, calc(100% - 32px));
  background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 4px solid var(--ink); border-radius: 18px;
  padding: 14px; display: flex; flex-direction: column; gap: 8px; box-shadow: 0 8px 0 var(--ink);
}

.toast {
  position: absolute; left: 50%; bottom: calc(26px + var(--sab)); transform: translateX(-50%);
  background: var(--ink); border: 3px solid var(--gold); border-radius: 14px; padding: 10px 18px;
  font-weight: 700; max-width: calc(100% - 32px); text-align: center; pointer-events: none;
  animation: fadeIn 0.2s ease-out;
}

@media (max-width: 560px) {
  .title-row { gap: 12px; }
  .btn-play { width: 112px; height: 112px; }
  .btn-square { width: 74px; height: 74px; }
  .title-labels { grid-template-columns: 74px 112px 74px; gap: 12px; font-size: 15px; }
  .carousel { gap: 4px; }
  .arrow { width: 32px; height: 64px; }
  .card-slot { width: calc(100vw - 104px); }
  .card { padding: 16px 16px 14px; }
  .card-title { flex-basis: 100%; order: 2; }
  .face { width: 58px; height: 58px; }
  .done-stats b { font-size: 22px; }
  .ed-side { top: auto; bottom: calc(132px + var(--sab)); transform: none; flex-direction: row; left: 50%; transform: translateX(-50%); }
  .ed-tool { width: auto; padding: 7px 10px; }
  .hint { bottom: calc(80px + var(--sab)); }
}
@media (max-height: 520px) {
  .title-wrap { gap: 8px; padding-block: 8px; }
  .logo { font-size: clamp(40px, 8vw, 84px); }
  .btn-play { width: 104px; height: 104px; }
  .btn-square { width: 70px; height: 70px; }
  .title-labels { grid-template-columns: 70px 104px 70px; }
  .hint { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .logo, .btn-play { animation: none; }
  .card, .overlay .panel, .screen { animation: none; }
}
