:root {
  color-scheme: light;
  --bg: #eef4f8;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #475569;
  --line: #d9e3ee;
  --blue: #0077b6;
  --blue-dark: #075985;
  --soft: #f8fafc;
  --danger: #b91c1c;
  --success: #166534;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 32px auto;
}

.tool-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
  padding: 28px;
}

.tool-header {
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 8px;
  font-size: clamp(1.8rem, 2.7rem, 2.7rem);
  letter-spacing: 0;
}

h2 {
  font-size: 1.05rem;
  margin-bottom: 14px;
}

h3 {
  font-size: 0.95rem;
  margin: 18px 0 10px;
}

.intro {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.65;
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 14px;
  margin-top: 22px;
}

.select-field {
  display: grid;
  gap: 7px;
  min-width: min(420px, 100%);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
}

select,
button {
  min-height: 44px;
  border-radius: 8px;
  font: inherit;
}

select {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: var(--ink);
  padding: 0 14px;
}

button,
.links a {
  border: 0;
  background: var(--blue);
  color: white;
  padding: 0 18px;
  font-weight: 850;
  cursor: pointer;
  text-decoration: none;
}

button:hover,
.links a:hover {
  background: var(--blue-dark);
  color: #fff;
}

.links a:focus-visible,
.links a:active {
  background: var(--blue-dark);
  color: #fff;
  outline: 3px solid rgba(14, 165, 233, 0.35);
  outline-offset: 2px;
}

.secondary-button {
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #075985;
  box-shadow: none;
}

.secondary-button:hover {
  border-color: #7dd3fc;
  background: #e0f2fe;
}

.status-card,
.layout-section,
.json-section,
.solution-section {
  margin-top: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 18px;
}

.status-card {
  display: grid;
  gap: 14px;
}

.status-card > div:first-child {
  display: grid;
  gap: 6px;
}

#level-note {
  color: var(--muted);
  line-height: 1.55;
}

.links,
.player-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.links a {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  border-radius: 8px;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #075985;
  padding: 0 12px;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-title-row h2 {
  margin-bottom: 0;
}

.replay-summary {
  color: var(--muted);
  font-weight: 800;
}

.bottle-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  max-width: 100%;
}

.bottle-card {
  display: grid;
  gap: 8px;
  justify-items: center;
  width: 56px;
}

.bottle {
  width: 46px;
  height: 126px;
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-start;
  overflow: hidden;
  border: 3px solid #91a4bc;
  border-top: 0;
  border-radius: 0 0 18px 18px;
  background: linear-gradient(#fff, #f8fafc);
}

.layer {
  height: 25%;
  border-top: 1px solid rgba(255, 255, 255, 0.42);
}

.layer.is-empty {
  background: transparent;
}

.bottle-label {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: #e0f2fe;
  color: #075985;
  font-weight: 850;
}

.json-output {
  margin: 0;
  overflow-x: auto;
  white-space: pre-wrap;
  color: #1e293b;
  font: 650 0.94rem/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.solution-output {
  color: var(--ink);
}

.solution-output.is-error {
  color: var(--danger);
}

.empty-replay {
  margin: 0;
  color: var(--danger);
  font-weight: 800;
}

.replay-player {
  display: grid;
  gap: 14px;
}

.step-progress {
  color: var(--muted);
  font-weight: 850;
}

.current-move {
  min-height: 34px;
  border-radius: 8px;
  background: #0f172a;
  color: #dcfce7;
  padding: 10px 12px;
  font: 750 0.95rem/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.replay-preview {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.player-controls button {
  min-width: 96px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.move-list {
  display: grid;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.move-row {
  width: 100%;
  min-height: 38px;
  border: 1px solid #dbeafe;
  background: #f8fafc;
  color: #1e293b;
  box-shadow: none;
  text-align: left;
  padding: 7px 10px;
  font-weight: 750;
}

.move-row:hover,
.move-row.is-active {
  border-color: #38bdf8;
  background: #e0f2fe;
  color: #075985;
}

.move-row.is-active {
  border-color: #075985;
  background: #075985;
  color: #fff;
  box-shadow: inset 4px 0 0 #facc15;
}

.links {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

@media (max-width: 680px) {
  .app-shell {
    width: min(100% - 18px, 1120px);
    margin: 9px auto;
  }

  .tool-panel {
    padding: 18px;
  }

  .section-title-row {
    align-items: flex-start;
    flex-direction: column;
  }

  button,
  .select-field,
  select,
  .player-controls button {
    width: 100%;
  }

  .links a {
    width: 100%;
    justify-content: center;
  }

  .bottle-preview {
    gap: 12px;
  }

  .bottle-card {
    width: 48px;
  }

  .bottle {
    width: 40px;
    height: 112px;
  }
}
