:root {
  --ink: #08110d;
  --ink-soft: #12231b;
  --panel: #10251c;
  --paper: #f4efe5;
  --muted: #9da89f;
  --orange: #f45b32;
  --lime: #dff28a;
  --green: #63bca4;
  --line: rgba(244, 239, 229, 0.14);
  --sans: "Aptos", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --mono: "Cascadia Mono", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--paper);
  background:
    radial-gradient(circle at 10% 0%, rgba(99, 188, 164, 0.18), transparent 26rem),
    radial-gradient(circle at 95% 80%, rgba(244, 91, 50, 0.13), transparent 24rem),
    var(--ink);
  font-family: var(--sans);
}

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

button {
  font: inherit;
}

:focus-visible {
  outline: 3px solid var(--lime);
  outline-offset: 3px;
}

.game-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 18px 0 24px;
}

.game-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
}

.game-brand {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 10px;
  color: var(--paper);
  font-weight: 760;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand-icon {
  position: relative;
  width: 30px;
  height: 30px;
  overflow: hidden;
  border-radius: 50%;
  background: var(--paper);
}

.brand-icon::before,
.brand-icon::after {
  position: absolute;
  left: 50%;
  content: "";
  transform: translateX(-50%);
}

.brand-icon::before {
  top: 5px;
  width: 5px;
  height: 17px;
  border-radius: 3px;
  background: var(--orange);
}

.brand-icon::after {
  bottom: 6px;
  width: 16px;
  height: 3px;
  border-radius: 2px;
  background: var(--ink);
}

.hud {
  display: flex;
  gap: 22px;
  font-family: var(--mono);
}

.hud span {
  display: grid;
  justify-items: center;
}

.hud b {
  color: var(--lime);
  font-size: 1rem;
}

.hud small {
  color: var(--muted);
  font-size: 0.61rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  justify-self: end;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--paper);
  cursor: pointer;
}

.icon-button:hover {
  border-color: var(--paper);
}

.game-layout {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr) 220px;
  gap: 23px;
  align-items: center;
}

.level-panel {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px 0;
}

.eyebrow {
  margin: 0 0 13px;
  color: var(--orange);
  font-family: var(--mono);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.level-copy h1 {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-size: clamp(1.8rem, 3.3vw, 3rem);
  font-weight: 650;
  letter-spacing: -0.04em;
  line-height: 1;
}

.level-copy > p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 0.77rem;
  line-height: 1.55;
}

.level-map {
  display: grid;
  grid-template-columns: repeat(5, 24px);
  gap: 8px;
  margin-top: 28px;
}

.level-dot {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.55rem;
  cursor: pointer;
}

.level-dot.is-current {
  border-color: var(--orange);
  color: var(--paper);
  box-shadow: 0 0 0 4px rgba(244, 91, 50, 0.12);
}

.level-dot.is-complete {
  border-color: var(--green);
  background: rgba(99, 188, 164, 0.12);
  color: var(--lime);
}

.board-wrap {
  position: relative;
  min-width: 0;
  padding: clamp(10px, 2vw, 20px);
  border: 1px solid var(--line);
  border-radius: 26px;
  background: rgba(16, 37, 28, 0.72);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.28);
}

.board-wrap::before {
  position: absolute;
  inset: 7px;
  border: 1px solid rgba(244, 239, 229, 0.06);
  border-radius: 20px;
  content: "";
  pointer-events: none;
}

#board {
  display: block;
  width: 100%;
  aspect-ratio: 9 / 7;
  border-radius: 14px;
  background: #0a1510;
  touch-action: manipulation;
}

.control-panel {
  display: grid;
  gap: 20px;
  align-content: center;
}

.control-block {
  padding-bottom: 17px;
  border-bottom: 1px solid var(--line);
}

.control-label {
  margin: 0 0 7px;
  color: var(--lime);
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.control-copy {
  margin: 0;
  color: var(--muted);
  font-size: 0.77rem;
  line-height: 1.55;
}

.control-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.control-row button:first-child {
  grid-column: 1 / -1;
}

.primary-button,
.secondary-button {
  min-height: 39px;
  border-radius: 9px;
  font-size: 0.76rem;
  font-weight: 750;
  cursor: pointer;
}

.primary-button {
  border: 1px solid var(--lime);
  background: var(--lime);
  color: var(--ink);
}

.primary-button:hover {
  background: #efffa7;
}

.secondary-button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--paper);
}

.secondary-button:hover {
  border-color: var(--paper);
}

kbd {
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.63rem;
}

.par-note,
.best-note {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.67rem;
}

.par-note strong,
.best-note strong {
  color: var(--paper);
  font-size: 1rem;
}

.par-note small {
  flex-basis: 100%;
  color: var(--muted);
  font-size: 0.6rem;
}

.win-panel {
  position: absolute;
  inset: 15%;
  z-index: 3;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 30px;
  border: 1px solid rgba(223, 242, 138, 0.5);
  border-radius: 18px;
  background: rgba(8, 17, 13, 0.96);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.55);
  text-align: center;
}

.win-kicker {
  margin: 0 0 7px;
  color: var(--lime);
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
}

.win-panel h2 {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-size: clamp(2rem, 5vw, 3.4rem);
  letter-spacing: -0.04em;
}

.win-stars {
  margin: 0;
  color: var(--orange);
  letter-spacing: 0.15em;
}

.win-detail {
  margin: 7px 0 20px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.7rem;
}

.game-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 20px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.61rem;
  letter-spacing: 0.03em;
}

.game-footer a {
  color: var(--muted);
  text-decoration: none;
}

.game-footer a:hover {
  color: var(--paper);
}

.help-modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(7px);
}

.help-card {
  width: min(440px, 100%);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: 0 35px 100px rgba(0, 0, 0, 0.55);
}

.help-card h2 {
  margin: 0 0 14px;
  font-family: var(--serif);
  font-size: 2.35rem;
  letter-spacing: -0.04em;
}

.help-card p,
.help-card li {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.6;
}

.help-card ul {
  margin: 18px 0 24px;
  padding-left: 20px;
}

.help-card .primary-button {
  width: 100%;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  padding: 11px 15px;
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font-size: 0.76rem;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
  transform: translateY(180%);
  transition: transform 180ms ease;
}

.toast.is-visible {
  transform: none;
}

@media (max-width: 900px) {
  .game-layout {
    grid-template-columns: 1fr;
  }

  .level-panel {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: end;
    padding: 0;
  }

  .level-map {
    grid-template-columns: repeat(5, 22px);
    gap: 6px;
    margin: 0;
  }

  .level-dot {
    width: 22px;
    height: 22px;
  }

  .control-panel {
    grid-template-columns: 1.25fr 1fr;
    align-items: start;
  }

  .control-block {
    grid-row: span 2;
    padding: 0 18px 0 0;
    border-right: 1px solid var(--line);
    border-bottom: 0;
  }
}

@media (max-width: 580px) {
  .game-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 10px;
  }

  .game-header {
    grid-template-columns: 1fr auto auto;
  }

  .hud {
    gap: 12px;
  }

  .hud b {
    font-size: 0.88rem;
  }

  .level-panel {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .level-map {
    grid-template-columns: repeat(10, 1fr);
  }

  .board-wrap {
    padding: 8px;
    border-radius: 18px;
  }

  .control-panel {
    grid-template-columns: 1fr;
  }

  .control-block {
    padding: 0 0 15px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .control-row {
    grid-template-columns: repeat(3, 1fr);
  }

  .control-row button:first-child {
    grid-column: auto;
  }

  .par-note,
  .best-note {
    padding: 8px 0;
  }

  .win-panel {
    inset: 8%;
    padding: 18px;
  }

  .game-footer {
    display: grid;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
