@font-face {
  font-family: "VT323";
  src: url("../../assets/fonts/VT323-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "VT323";
  src: url("../../assets/fonts/VT323-Regular.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #10131f;
  --panel: #171c2c;
  --panel-2: #20283c;
  --line: #344058;
  --text: #f2f6ff;
  --muted: #a8b3c9;
  --accent: #00d4a6;
  --danger: #ff5b6e;
  --gold: #ffc857;
  --shadow: rgba(0, 0, 0, .36);
  --board-shell: #0b0f19;
  --key-bg: #101725;
  --touch-bg: #243049;
  --overlay-bg: rgba(9, 13, 22, .78);
  --grid-a: rgba(255,255,255,.035);
  --grid-b: rgba(255,255,255,.03);
  --glow-a: rgba(0, 212, 166, .22);
  --glow-b: rgba(255, 200, 87, .18);
  --cell: 34px;
  --board-scale: 1;
  --board-outer-width: 364px;
  --board-outer-height: 704px;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(90deg, var(--grid-a) 1px, transparent 1px) 0 0 / var(--cell) var(--cell),
    linear-gradient(var(--grid-b) 1px, transparent 1px) 0 0 / var(--cell) var(--cell),
    radial-gradient(circle at 18% 16%, var(--glow-a), transparent 32%),
    radial-gradient(circle at 84% 68%, var(--glow-b), transparent 28%),
    var(--bg);
  display: grid;
  place-items: center;
  padding: 24px;
  overflow-x: hidden;
}

body > :not(.theme-page-fade) {
  position: relative;
  z-index: 1;
}

.theme-page-fade {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.shell {
  width: min(100%, 980px);
  display: grid;
  grid-template-columns: minmax(300px, auto) 280px;
  gap: 22px;
  align-items: start;
}

.stage {
  display: grid;
  justify-content: center;
  gap: 14px;
}

.board-scale-box {
  width: var(--board-outer-width);
  height: var(--board-outer-height);
}

.board-scale-content {
  width: var(--board-outer-width);
  height: var(--board-outer-height);
  transform: scale(var(--board-scale));
  transform-origin: top left;
}

.board-wrap {
  position: relative;
  border: 2px solid var(--line);
  background: var(--board-shell);
  box-shadow: 0 22px 70px var(--shadow), inset 0 0 0 1px rgba(255,255,255,.06);
  padding: 10px;
  border-radius: 8px;
}

canvas {
  display: block;
  image-rendering: pixelated;
}

#board {
  width: calc(var(--cell) * 10);
  height: calc(var(--cell) * 20);
  background: #0d1220;
}

.overlay {
  position: absolute;
  inset: 10px;
  display: none;
  text-align: center;
  background: var(--overlay-bg);
  backdrop-filter: blur(2px);
  overflow: auto;
  padding: 24px;
}

.overlay.show {
  display: grid;
  place-items: center;
}

.overlay-panel {
  display: none;
  width: min(100%, 260px);
  gap: 14px;
}

.overlay-panel.active {
  display: grid;
}

.overlay h1 {
  margin: 0 0 12px;
  font-size: clamp(30px, 6vw, 54px);
  letter-spacing: 0;
  line-height: 1;
}

.overlay .menu-title {
  font-family: "VT323", "OCR A Extended", "Courier New", monospace;
  font-size: clamp(54px, 11vw, 86px);
  font-weight: 400;
  line-height: .82;
}

.overlay p {
  margin: 0 0 18px;
  color: var(--muted);
}

.overlay-actions {
  display: grid;
  gap: 10px;
}

.mode-picker {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
  text-align: left;
}

.mode-picker small {
  min-height: 32px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.settings-block {
  display: grid;
  gap: 10px;
  text-align: left;
}

.score-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style-position: inside;
  text-align: left;
}

.score-list li {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--key-bg);
}

.help-list {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  text-align: left;
}

.side {
  display: grid;
  gap: 14px;
}

.title {
  margin: 0;
  font-family: "VT323", "OCR A Extended", "Courier New", monospace;
  font-weight: 700;
  font-size: clamp(54px, 11vw, 86px);
  line-height: .95;
  letter-spacing: 0;
}

.subtitle {
  display: block;
  margin: 6px 0 4px;
  color: var(--muted);
  line-height: 1.5;
}

.panel {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.02)), var(--panel);
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 14px 30px rgba(0,0,0,.18);
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat {
  min-height: 68px;
  border: 1px solid rgba(255,255,255,.08);
  background: var(--panel-2);
  border-radius: 6px;
  padding: 10px;
}

.label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 7px;
}

.value {
  font-size: 25px;
  font-weight: 800;
  line-height: 1;
}

.previews {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  align-items: stretch;
}

.preview-block {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 8px;
}

.theme-panel {
  display: grid;
  gap: 10px;
}

.theme-head {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: start;
}

#themeName {
  display: block;
  font-size: 18px;
  line-height: 1.15;
}

select {
  min-height: 38px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: var(--key-bg);
  font: inherit;
  font-weight: 700;
  padding: 0 10px;
}

.theme-description {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.setting-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--key-bg);
  color: var(--text);
}

.setting-row span {
  display: grid;
  gap: 3px;
}

.setting-row small {
  color: var(--muted);
  font-size: 12px;
}

.setting-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.range-setting {
  grid-template-columns: 1fr;
}

.range-setting input[type="range"] {
  width: 100%;
  height: 24px;
}

.swatches {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.swatch {
  display: grid;
  place-items: center;
  min-width: 0;
  aspect-ratio: 1;
  border-radius: 5px;
  color: rgba(0, 0, 0, .72);
  font-size: 12px;
  font-weight: 900;
  text-shadow: 0 1px rgba(255, 255, 255, .18);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.25), inset 0 -7px 0 rgba(0,0,0,.12);
}

.effect-tests {
  display: grid;
  gap: 8px;
}

.dev-panel {
  display: grid;
  gap: 8px;
}

.effect-test-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.effect-test-grid button {
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  background: var(--key-bg);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 0 6px;
  cursor: pointer;
}

.effect-test-grid button:hover {
  color: var(--text);
  border-color: var(--accent);
}

#hold {
  width: 100%;
  border-radius: 6px;
  background: #101725;
  border: 1px solid rgba(255,255,255,.08);
}

#hold {
  width: 112px;
  height: 112px;
}

.next-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(52px, 52px));
  gap: 8px;
  align-content: start;
  justify-content: start;
  max-width: 232px;
}

.next-slot {
  position: relative;
  width: 52px;
  height: 52px;
  border: 1px solid rgba(255,255,255,.08);
  border-left: 2px solid transparent;
  border-radius: 6px;
  background: var(--key-bg);
  padding: 0;
  overflow: hidden;
  transition: opacity .16s ease, border-color .16s ease, background .16s ease;
}

.next-slot.is-current {
  border-left-color: var(--accent);
  background: color-mix(in srgb, var(--key-bg), var(--accent) 10%);
}

.next-index {
  position: absolute;
  top: 4px;
  left: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
}

.next-slot canvas {
  width: 52px;
  height: 52px;
  border-radius: 4px;
  background: #101725;
}

.controls {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.key {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 26px;
  padding: 0 8px;
  margin-right: 6px;
  color: var(--text);
  border: 1px solid var(--line);
  border-bottom-width: 3px;
  border-radius: 5px;
  background: var(--key-bg);
  font-weight: 700;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  color: #07120f;
  background: var(--accent);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: transform .12s ease, filter .12s ease;
  touch-action: manipulation;
}

button:hover {
  filter: brightness(1.08);
}

button:active {
  transform: translateY(1px) scale(.99);
}

.secondary {
  color: var(--text);
  background: var(--touch-bg);
}

.danger {
  color: #fff;
  background: var(--danger);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.dev-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  color: color-mix(in srgb, var(--muted), transparent 18%);
  font-size: 11px;
  line-height: 1.2;
}

.side > .dev-links {
  display: none;
}

.effect-tests .dev-links {
  padding-top: 2px;
}

.dev-links span {
  color: color-mix(in srgb, var(--muted), transparent 38%);
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.dev-links a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.dev-links a:hover {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.touch {
  display: none;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  justify-items: stretch;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

.touch button {
  min-width: 0;
  color: var(--text);
  background: var(--touch-bg);
  font-size: 20px;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

.touch button.is-pressed {
  filter: brightness(1.16);
  transform: translateY(1px) scale(.99);
}

.touch-pad {
  width: fit-content;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel), transparent 18%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.04);
  padding: 8px;
}

.touch-move {
  display: grid;
  grid-template-columns: repeat(3, 42px);
  grid-template-rows: repeat(2, 42px);
  gap: 6px;
  place-content: center;
}

.touch-move button,
.touch-rotate button,
.touch-hold {
  width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0;
}

.touch-move button {
  width: 42px;
  height: 42px;
  min-height: 42px;
}

.touch-up {
  grid-column: 2;
  grid-row: 1;
}

.touch-left {
  grid-column: 1;
  grid-row: 2;
}

.touch-down {
  grid-column: 2;
  grid-row: 2;
}

.touch-right {
  grid-column: 3;
  grid-row: 2;
}

.touch-up {
  background: var(--gold);
  color: #171007;
}

.touch-hold {
  align-self: center;
  justify-self: center;
  border-radius: 50%;
  background: var(--accent);
  color: #07120f;
}

.touch-rotate {
  display: grid;
  grid-template-columns: 54px;
  min-height: 107px;
  gap: 8px;
  place-content: center;
}

.touch-rotate button {
  width: 54px;
  height: 88px;
  min-height: 88px;
}

@media (max-width: 760px) {
  body {
    padding: 14px;
    align-items: start;
  }

  html,
  body,
  .shell {
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: manipulation;
  }

  select,
  input,
  textarea {
    user-select: auto;
    -webkit-user-select: auto;
    touch-action: manipulation;
  }

  :root {
    --cell: 34px;
  }

  .shell {
    width: min(100%, calc(100vw - 28px));
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .stage {
    gap: 10px;
    width: 100%;
    min-width: 0;
    justify-items: center;
  }

  .board-scale-box {
    width: calc(var(--board-outer-width) * var(--board-scale));
    height: calc(var(--board-outer-height) * var(--board-scale));
  }

  .side {
    min-width: 0;
    max-width: 100%;
    width: 100%;
  }

  .side > *,
  .panel,
  .actions,
  .effect-test-grid {
    min-width: 0;
    max-width: 100%;
  }

  .title {
    font-size: 32px;
  }

  .subtitle,
  .controls {
    display: none;
  }

  .touch {
    display: grid;
    width: calc(var(--board-outer-width) * var(--board-scale));
    max-width: 100%;
  }

  .previews {
    grid-template-columns: auto 1fr;
    gap: 12px;
  }

  #hold {
    width: 112px;
    height: 112px;
  }

  .next-list {
    grid-template-columns: repeat(auto-fit, minmax(52px, 52px));
  }
}
