:root {
  color-scheme: dark;
  --ink: #effffb;
  --muted: #8ca6a0;
  --cyan: #62ffd3;
  --violet: #9d7bff;
  --danger: #ff7866;
  --panel: rgba(7, 17, 20, .78);
  --line: rgba(177, 255, 234, .16);
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #03080a;
  color: var(--ink);
  font-family: Inter, "Segoe UI", "PingFang SC", sans-serif;
}

button, a { -webkit-tap-highlight-color: transparent; }

#renderCanvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: 0;
  touch-action: none;
}

.glass {
  background: linear-gradient(145deg, rgba(13, 28, 31, .86), var(--panel));
  border: 1px solid var(--line);
  box-shadow: 0 18px 60px rgba(0, 0, 0, .3), inset 0 1px rgba(255, 255, 255, .04);
  backdrop-filter: blur(18px);
}

.eyebrow {
  display: block;
  margin: 0 0 5px;
  color: var(--cyan);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .16em;
}

/* loading */
.loading {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  background: radial-gradient(circle at 50% 35%, #153238, #04090b 52%);
  transition: opacity .55s ease, visibility .55s;
}
.loading.done { opacity: 0; visibility: hidden; pointer-events: none; }
.loading h1 { margin: 5px 0 20px; font-size: clamp(28px, 5vw, 48px); letter-spacing: -.03em; }
#loadingText { color: var(--muted); font-size: 12px; }
.retry-button {
  margin-top: 12px;
  padding: 10px 15px;
  border: 1px solid rgba(98, 255, 211, .35);
  border-radius: 9px;
  color: var(--ink);
  background: rgba(98, 255, 211, .1);
  font: 700 11px/1 sans-serif;
  cursor: pointer;
}
.loading-mark {
  display: grid;
  width: 68px;
  height: 68px;
  margin-bottom: 18px;
  place-items: center;
  border: 1px solid var(--cyan);
  border-radius: 20px;
  color: #04100d;
  background: var(--cyan);
  box-shadow: 0 0 50px rgba(98, 255, 211, .28);
  font: 900 38px/1 Georgia, serif;
}
.loading-track { width: min(420px, 76vw); height: 3px; overflow: hidden; background: rgba(255, 255, 255, .08); }
.loading-track span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--violet));
  transition: width .25s ease;
}

/* HUD */
.hud {
  position: fixed;
  z-index: 10;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  transition: opacity .3s;
}
.hud.hidden { opacity: 0; visibility: hidden; }
.hud-left { display: flex; align-items: center; gap: 14px; padding: 10px 16px; border-radius: 14px; }
.hud-score strong { display: block; font: 800 26px/1 monospace; }
.hud-combo {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(157, 123, 255, .4);
  background: rgba(157, 123, 255, .14);
  color: var(--violet);
  font: 800 14px/1 monospace;
  transition: transform .15s;
}
.hud-combo.pulse { transform: scale(1.18); }
.hud-right { padding: 10px 16px; border-radius: 14px; text-align: right; }
.hud-right strong { display: block; font: 800 22px/1 monospace; }

/* overlays */
.ov {
  position: fixed;
  z-index: 40;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(2, 6, 8, .55);
  overflow: auto;
}
.ov.show { display: flex; }
.pnl {
  width: min(440px, 100%);
  padding: 28px 26px;
  border-radius: 22px;
}
.pnl.center { text-align: center; }
.logo { margin: 4px 0 10px; font: 900 clamp(30px, 7vw, 44px)/1 Georgia, serif; letter-spacing: -.02em; color: var(--ink); }
.tagline { margin: 0 0 20px; color: var(--muted); font-size: 13px; }
.b-pri, .b-sec {
  cursor: pointer;
  border: 0;
  border-radius: 12px;
  font: 800 13px/1 sans-serif;
  letter-spacing: .03em;
}
.b-pri {
  width: 100%;
  padding: 15px;
  color: #04100d;
  background: linear-gradient(120deg, var(--cyan), #9effe0);
  box-shadow: 0 10px 30px rgba(98, 255, 211, .28);
}
.b-sec {
  padding: 12px 16px;
  color: var(--ink);
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--line);
}
.row { display: flex; gap: 10px; margin-top: 16px; }
.row .b-pri, .row .b-sec { flex: 1; }
.howto { margin: 20px 0 0; padding: 0; list-style: none; text-align: left; display: grid; gap: 10px; }
.howto li { padding: 10px 12px; border-radius: 10px; background: rgba(255, 255, 255, .04); font-size: 12px; color: var(--muted); }
.meta-row { margin-top: 18px; display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 12px; }
.text-link { color: var(--cyan); text-decoration: none; }
.meta-dot { color: var(--muted); }

.pnl-title { margin: 0 0 6px; font-size: 20px; }
.final-score { margin: 6px 0 14px; font: 900 52px/1 monospace; color: var(--cyan); }
.res-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 18px; }
.res-stats div { padding: 10px 6px; border-radius: 10px; background: rgba(255, 255, 255, .04); }
.res-stats b { display: block; font: 800 17px/1 monospace; color: var(--ink); }
.res-stats span { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; letter-spacing: .06em; text-transform: uppercase; }

.submit-row { display: flex; gap: 8px; margin: 4px 0 6px; }
.text-input {
  flex: 1;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: rgba(0, 0, 0, .25);
  font-size: 13px;
}
.soft { min-height: 16px; margin-bottom: 14px; color: var(--muted); font-size: 11px; }
.board-card { margin-bottom: 6px; padding: 12px; border-radius: 14px; background: rgba(0, 0, 0, .2); text-align: left; }
.card-title { margin-bottom: 8px; color: var(--muted); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.board-row { display: flex; align-items: center; gap: 10px; padding: 7px 4px; border-bottom: 1px solid rgba(255, 255, 255, .05); }
.board-row:last-child { border-bottom: 0; }
.board-rank { width: 24px; color: var(--muted); font: 700 11px/1 monospace; }
.board-name { font-size: 12px; }
.board-meta { color: var(--muted); font-size: 10px; }
.board-score { margin-left: auto; font: 800 13px/1 monospace; color: var(--cyan); }
.board-empty { padding: 10px 4px; color: var(--muted); font-size: 12px; }

.toast {
  position: fixed;
  z-index: 60;
  left: 50%;
  bottom: 86px;
  padding: 10px 15px;
  border: 1px solid rgba(98,255,211,.3);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(3,12,13,.9);
  font-size: 11px;
  opacity: 0;
  transform: translate(-50%, 10px);
  transition: .25s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.controls {
  position: fixed;
  z-index: 10;
  bottom: 18px;
  left: 18px;
  display: flex;
  gap: 13px;
  padding: 10px 13px;
  border-radius: 12px;
  color: var(--muted);
  font-size: 9px;
}
kbd { color: var(--ink); font: 800 9px/1 monospace; }

.duck-btn {
  display: none;
  position: fixed;
  z-index: 12;
  bottom: 34px;
  left: 50%;
  transform: translateX(-50%);
  width: 92px;
  height: 52px;
  border: 1px solid rgba(139, 217, 255, .4);
  border-radius: 16px;
  color: var(--ink);
  background: rgba(139, 217, 255, .14);
  font: 800 12px/1 sans-serif;
  letter-spacing: .04em;
  touch-action: none;
}

@media (max-width: 760px), (pointer: coarse) {
  .hide-mobile { display: none !important; }
  .duck-btn { display: block; }
  .pnl { padding: 22px 18px; }
  .res-stats { grid-template-columns: repeat(3, 1fr); }
}
