:root {
  color-scheme: light;
  --ink: #242229;
  --muted: #67606b;
  --paper: #f7f4ee;
  --panel: #fffdfa;
  --plum: #4a244f;
  --blue: #2d6f8f;
  --green: #4f7d48;
  --rose: #bd4e5c;
  --gold: #c98d2c;
  --line: #ddd3c5;
  --shadow: 0 18px 42px rgba(74, 36, 79, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(125deg, rgba(45, 111, 143, 0.16), transparent 42%),
    linear-gradient(300deg, rgba(201, 141, 44, 0.18), transparent 38%),
    var(--paper);
}

button,
a {
  font: inherit;
}

.shell {
  width: min(1120px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 20px 0 34px;
}

.top-nav {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.top-nav a {
  color: var(--plum);
  text-decoration: none;
  font-weight: 850;
  padding: 9px 12px;
  border: 2px solid rgba(74, 36, 79, 0.15);
  background: rgba(255, 253, 250, 0.82);
}

.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: end;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--rose);
  font-size: 0.8rem;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  color: var(--plum);
  font-size: clamp(2.1rem, 8vw, 4.7rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.lede {
  max-width: 760px;
  margin-bottom: 0;
  color: #48434d;
  font-size: clamp(1rem, 2vw, 1.18rem);
  line-height: 1.5;
}

.scoreboard,
.move-log {
  display: grid;
  grid-template-columns: auto auto;
  gap: 6px 14px;
  padding: 14px;
  border: 2px solid rgba(74, 36, 79, 0.14);
  background: rgba(255, 253, 250, 0.86);
  box-shadow: var(--shadow);
}

.scoreboard span,
.move-log span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.scoreboard strong,
.move-log strong {
  justify-self: end;
  color: var(--plum);
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}

.stage-panel,
.side-panel {
  border: 2px solid rgba(74, 36, 79, 0.13);
  background: rgba(255, 253, 250, 0.9);
  box-shadow: var(--shadow);
}

.stage-panel {
  padding: 18px;
}

.side-panel {
  padding: 16px;
  display: grid;
  gap: 16px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  margin-bottom: 18px;
}

.panel-head h2,
.side-panel h2 {
  margin-bottom: 5px;
  font-size: 1.15rem;
}

.panel-head p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.45;
}

button {
  min-height: 44px;
  border: 0;
  background: var(--plum);
  color: white;
  font-weight: 850;
  padding: 11px 13px;
  cursor: pointer;
}

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

button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.4);
  opacity: 0.55;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.formation-block {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.formation-block h3 {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0;
}

.line {
  display: grid;
  grid-template-columns: repeat(5, minmax(58px, 1fr));
  gap: 10px;
}

.dancer {
  min-height: 116px;
  display: grid;
  place-items: center;
  gap: 6px;
  padding: 10px 6px;
  border: 2px solid rgba(36, 34, 41, 0.12);
  background: var(--panel);
  box-shadow: inset 0 -8px 0 rgba(36, 34, 41, 0.04);
}

.dancer .symbol {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: white;
  font-size: 1.55rem;
  font-weight: 900;
}

.dancer strong {
  color: var(--ink);
  font-size: 0.92rem;
  text-align: center;
}

.dancer small {
  color: var(--muted);
  font-weight: 800;
}

.target .dancer {
  border-style: dashed;
  background: rgba(247, 244, 238, 0.72);
}

.dancer.a .symbol { background: var(--rose); }
.dancer.b .symbol { background: var(--blue); }
.dancer.c .symbol { background: var(--green); }
.dancer.d .symbol { background: var(--gold); }
.dancer.e .symbol { background: var(--plum); }

.cards {
  display: grid;
  gap: 9px;
}

.card {
  width: 100%;
  min-height: 66px;
  display: grid;
  gap: 3px;
  justify-items: start;
  text-align: left;
  background: #2f5f72;
}

.card strong {
  font-size: 0.98rem;
}

.card span {
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.82rem;
  line-height: 1.25;
}

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

.actions button {
  background: #5b5963;
}

.message {
  min-height: 54px;
  margin: 0;
  padding: 12px;
  color: #3e3942;
  line-height: 1.4;
  background: #f2eadf;
  border-left: 5px solid var(--gold);
}

.line.solved .dancer {
  animation: bounce 360ms ease both;
}

@keyframes bounce {
  0% { transform: translateY(0); }
  45% { transform: translateY(-8px); }
  100% { transform: translateY(0); }
}

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

  .scoreboard {
    width: min(100%, 260px);
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100% - 20px, 1120px);
    padding-top: 12px;
  }

  .top-nav,
  .panel-head,
  .actions {
    flex-direction: column;
    display: grid;
    grid-template-columns: 1fr;
  }

  .line {
    grid-template-columns: repeat(5, minmax(48px, 1fr));
    gap: 6px;
  }

  .dancer {
    min-height: 94px;
    padding: 7px 3px;
  }

  .dancer .symbol {
    width: 38px;
    height: 38px;
    font-size: 1.25rem;
  }

  .dancer strong {
    font-size: 0.76rem;
  }
}
