:root {
  --bg: #070b14;
  --ink: #f4f7ff;
  --muted: #9aa6c2;
  --glass: rgba(16, 22, 38, 0.72);
  --line: rgba(255, 255, 255, 0.1);
  --accent: #7c5cff;
  --accent-2: #4da3ff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: Outfit, "Segoe UI", system-ui, sans-serif;
  user-select: none;
}

.app {
  position: relative;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 20px 28px;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(124, 92, 255, 0.16), transparent 55%),
    var(--bg);
}

.aurora {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  pointer-events: none;
  z-index: 0;
}

.aurora-a {
  width: 420px;
  height: 420px;
  left: -80px;
  top: 80px;
  background: rgba(124, 92, 255, 0.22);
}

.aurora-b {
  width: 380px;
  height: 380px;
  right: -60px;
  bottom: 40px;
  background: rgba(77, 163, 255, 0.16);
}

.aurora-c {
  width: 260px;
  height: 260px;
  left: 40%;
  top: 30%;
  background: rgba(62, 232, 160, 0.08);
}

.topbar {
  position: relative;
  z-index: 2;
  width: min(1004px, calc(100vw - 32px));
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 14px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: 700 18px/1 Outfit, sans-serif;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.logo-mark {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, #fff 0 12%, transparent 13%),
    conic-gradient(#ff4d6d 0 90deg, #4da3ff 90deg 180deg, #3ee8a0 180deg 270deg, #ffc14d 270deg 360deg);
  box-shadow: 0 0 16px rgba(124, 92, 255, 0.45);
}

.status {
  flex: 1;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.keys, .clock {
  color: #6f7b96;
  font-size: 12px;
}

.ghost {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 14px;
  font: 500 13px Outfit, sans-serif;
  cursor: pointer;
}

.ghost:hover {
  background: rgba(255, 255, 255, 0.08);
}

.audio-btn.is-off {
  opacity: 0.45;
}

.audio-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 14px;
}

.audio-toggles .menu-btn {
  min-width: calc(50% - 4px);
}

.credit {
  margin: 8px 0 0;
  text-align: center;
  color: #8b95b3;
  font-size: 13px;
  letter-spacing: 0.04em;
}

.audio-toggles .menu-btn {
  margin: 0;
  flex: 1;
}

.audio-toggles .menu-btn:first-of-type {
  background: rgba(255, 255, 255, 0.08);
  box-shadow: none;
}

.audio-toggles .menu-btn:first-of-type:hover {
  background: rgba(255, 255, 255, 0.14);
}

.hidden { display: none; }

.stage {
  position: relative;
  z-index: 1;
  width: min(1004px, calc(100vw - 32px));
  border-radius: 22px;
  overflow: hidden;
  background: #0b1020;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08),
    0 30px 80px rgba(0, 0, 0, 0.45);
}

#game {
  display: block;
  width: 100%;
  height: auto;
  cursor: default;
  background: #080d18;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  background: transparent;
}

.overlay.has-ui {
  pointer-events: auto;
  background: rgba(6, 8, 16, 0.38);
  backdrop-filter: blur(8px);
}

/* Level-clear / finale: center over the board, not the HUD strip. */
.overlay.result-focus {
  justify-content: center;
  padding-right: calc(100% * 214 / 960);
}

.fireworks-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 6;
  opacity: 0;
  transition: opacity 200ms ease;
}

.fireworks-layer.on {
  opacity: 1;
}

.panel.wide {
  width: min(760px, 94%);
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 5px;
  margin: 8px 0 16px;
  max-height: min(58vh, 520px);
  overflow-y: auto;
}

.level-cell {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font: 700 12px Outfit, sans-serif;
  cursor: pointer;
}

.level-cell.next {
  background: linear-gradient(180deg, #8b6cff, #6a48f0);
}

.level-cell.locked {
  opacity: 0.28;
  cursor: default;
}

.level-cell .stars {
  font-size: 9px;
  letter-spacing: -0.04em;
  color: #ffc14d;
}

.score-table {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0 16px;
}

.score-row {
  display: grid;
  grid-template-columns: 32px 48px 1fr auto 72px 48px;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 8px 12px 8px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
}

.score-row.rank-1 { background: rgba(255, 193, 77, 0.22); }
.score-row.rank-2 { background: rgba(197, 206, 224, 0.16); }
.score-row.rank-3 { background: rgba(224, 138, 77, 0.16); }

.score-row .rank {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font: 700 14px Outfit, sans-serif;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.score-row.rank-1 .rank { background: #ffc14d; color: #1a1420; }
.score-row.rank-2 .rank { background: #c5cee0; color: #1a1420; }
.score-row.rank-3 .rank { background: #e08a4d; color: #1a1420; }

.score-row .num {
  display: grid;
  place-items: center;
  height: 28px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  font: 700 14px Outfit, sans-serif;
}

.score-row .name {
  font: 700 16px Outfit, sans-serif;
  text-align: left;
}

.score-row .stars {
  color: #ffc14d;
  font: 700 15px Outfit, sans-serif;
  letter-spacing: 0.04em;
}

.score-row .pts {
  font: 800 20px Outfit, sans-serif;
  text-align: right;
}

.score-row .time {
  color: #a4b0cc;
  font: 600 13px Outfit, sans-serif;
  text-align: right;
}

.score-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 160px;
  margin: 8px 0 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}

.score-empty strong {
  color: #fff;
  font: 700 20px Outfit, sans-serif;
}

.stars-line {
  text-align: center;
  margin: 0 0 10px;
  color: #ffc14d;
  font: 700 20px Outfit, sans-serif;
  letter-spacing: 0.08em;
}

.overlay.celebrate {
  background: rgba(4, 6, 14, 0.22);
  backdrop-filter: blur(2px);
}

.panel.result-panel {
  width: min(420px, 86%);
}

.panel.result-panel.celebrate {
  width: min(440px, 92%);
  background: rgba(12, 16, 32, 0.72);
  border-color: rgba(255, 209, 120, 0.28);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(255, 193, 77, 0.12),
    0 0 48px rgba(255, 180, 60, 0.12);
}

.result-kicker {
  margin: 0 0 6px;
  text-align: center;
  color: #a9b4d0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.result-title {
  text-align: center;
  margin: 0;
  font-size: 42px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.05;
  background: linear-gradient(180deg, #fff, #c8d2f0);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.result-title.celebrate-title {
  font-size: 48px;
  background: linear-gradient(180deg, #fff8e8, #ffc14d 55%, #ff8a4d);
  -webkit-background-clip: text;
  background-clip: text;
}

.result-stars {
  text-align: center;
  margin: 10px 0 4px;
  color: #ffc14d;
  font: 800 28px/1 Outfit, sans-serif;
  letter-spacing: 0.14em;
  text-shadow: 0 0 24px rgba(255, 193, 77, 0.35);
}

.result-level {
  text-align: center;
  margin: 0 0 18px;
  color: #d7deed;
  font: 600 17px Outfit, sans-serif;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 0 0 14px;
}

.result-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 6px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.07);
}

.result-stat strong {
  color: #fff;
  font: 800 20px Outfit, sans-serif;
  letter-spacing: -0.02em;
}

.result-stat span {
  color: #9aa6c2;
  font: 600 11px Outfit, sans-serif;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.result-score {
  text-align: center;
  margin: 0 0 16px;
  color: #e8edf8;
  font: 700 16px Outfit, sans-serif;
}

.result-pw {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 18px;
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(124, 92, 255, 0.16);
  border: 1px solid rgba(167, 140, 255, 0.28);
}

.result-pw span {
  color: #b7c2dc;
  font: 600 13px Outfit, sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.result-pw b {
  color: #fff;
  font: 800 20px/1 Outfit, sans-serif;
  letter-spacing: 0.14em;
}

.result-coming {
  text-align: center;
  margin: 0 0 18px;
  padding: 14px 16px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 193, 77, 0.18), rgba(255, 138, 77, 0.1));
  border: 1px solid rgba(255, 193, 77, 0.32);
  color: #ffe7a8;
  font: 700 17px Outfit, sans-serif;
  letter-spacing: 0.01em;
}


.panel {
  position: relative;
  width: min(440px, 88%);
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
  color: var(--ink);
  backdrop-filter: blur(18px);
}

.info-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #e8edf8;
  font: 700 16px/32px Georgia, "Times New Roman", serif;
  font-style: italic;
  text-align: center;
  cursor: pointer;
}

.info-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

.credits-block {
  margin: 0 0 18px;
  text-align: left;
}

.credits-block p {
  margin: 0 0 12px;
  color: #c5cee0;
  font-size: 14px;
  line-height: 1.5;
}

.credits-block strong {
  display: block;
  margin-bottom: 4px;
  color: #f4f7ff;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.panel-body {
  padding: 32px 28px 26px;
}

.eyebrow {
  margin: 0 0 8px;
  text-align: center;
  color: #a9b4d0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.brand {
  text-align: center;
  margin: 0 0 8px;
  font-size: 46px;
  font-weight: 800;
  letter-spacing: -0.04em;
  background: linear-gradient(180deg, #fff, #c8d2f0);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tag {
  text-align: center;
  margin: 0 0 22px;
  font-size: 15px;
  line-height: 1.45;
  color: var(--muted);
}

.menu-btn {
  display: block;
  width: 100%;
  margin: 8px 0;
  padding: 12px 14px;
  border: 0;
  border-radius: 14px;
  font: 600 15px Outfit, sans-serif;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
}

.menu-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.menu-btn:first-of-type {
  background: linear-gradient(180deg, #8b6cff, #6a48f0);
  box-shadow: 0 10px 24px rgba(124, 92, 255, 0.28);
}

.menu-btn:first-of-type:hover {
  background: linear-gradient(180deg, #9b80ff, #7454ff);
}

.help p {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.5;
  color: #d5dcf0;
}

.howto-panel {
  width: min(560px, 94vw);
}

.howto-art {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 520 / 220;
  border-radius: 16px;
  margin: 4px 0 14px;
}

.howto-title {
  text-align: center;
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.howto-dots {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 16px;
}

.howto-dots button {
  width: 7px;
  height: 7px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  cursor: pointer;
}

.howto-dots button.on {
  width: 16px;
  border-radius: 4px;
  background: #ffc14d;
}

.howto-nav {
  display: flex;
  gap: 10px;
}

.howto-nav .menu-btn {
  flex: 1;
  margin: 0;
}

.howto-nav .menu-btn:first-of-type {
  background: rgba(255, 255, 255, 0.08);
  box-shadow: none;
}

.howto-nav .menu-btn:only-child,
.howto-nav .menu-btn.primary,
.howto-nav .menu-btn:last-of-type {
  background: linear-gradient(180deg, #8b6cff, #6a48f0);
  box-shadow: 0 10px 24px rgba(124, 92, 255, 0.28);
}

.help kbd {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  font: 12px Outfit, sans-serif;
}

.pw-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 12px 0 16px;
}

.pw-row input {
  width: 46px;
  height: 52px;
  text-align: center;
  font: 700 20px Outfit, sans-serif;
  text-transform: uppercase;
  color: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
}

.pw-row input:focus {
  outline: 2px solid var(--accent);
}

body.trailer .clock,
body.trailer .keys,
body.trailer .audio-btn,
body.trailer #btn-close,
body.trailer #btn-pause,
body.trailer #icon-howto,
body.trailer #btn-iconise {
  display: none !important;
}

body.trailer .app {
  padding-top: 28px;
  padding-bottom: 18px;
}

body.trailer .topbar,
body.trailer .stage {
  width: min(1360px, calc(100vw - 72px));
}

body.trailer .status {
  text-align: right;
}

@media (max-width: 900px), (max-height: 720px) {
  .keys, .clock, .status { display: none; }
  .audio-btn { padding: 8px 10px; }
  .brand { font-size: 36px; }
  .app {
    padding: 8px;
    padding-left: max(8px, env(safe-area-inset-left));
    padding-right: max(8px, env(safe-area-inset-right));
  }
  .topbar, .stage { width: 100%; }
  .topbar { margin-bottom: 8px; gap: 8px; }
  .stage { border-radius: 14px; }
  #game { max-height: calc(100vh - 72px); }
}
