:root {
  color-scheme: light;
  --bg: #f7f7f4;
  --panel: #ffffff;
  --ink: #1d1d1b;
  --muted: #65685f;
  --line: #d7d8d0;
  --accent: #2f6f5e;
  --accent-ink: #ffffff;
  --warn: #8b5e24;
  --board-light: #f0d9b5;
  --board-dark: #b58863;
  --legal-move: rgba(37, 99, 235, 0.28);
  --legal-capture: rgba(214, 69, 45, 0.34);
}

* {
  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;
}

button,
select {
  font: inherit;
}

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

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
  font-weight: 760;
  letter-spacing: 0;
}

p {
  margin: 8px 0 0;
  color: var(--muted);
}

.move-status {
  min-height: 24px;
  color: var(--warn);
  font-size: 15px;
}

.timer-text {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

.streak-text {
  color: #2563eb;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.jump-control {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.selectors {
  display: flex;
  align-items: end;
  gap: 10px;
}

.header-controls {
  display: grid;
  justify-items: end;
  gap: 10px;
}

.login-form,
.user-panel {
  display: flex;
  align-items: center;
  gap: 8px;
}

.login-form input {
  width: 150px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  padding: 8px 10px;
}

.login-form button,
.user-panel button,
.board-theme-controls button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  padding: 8px 10px;
  cursor: pointer;
}

.board-theme-controls {
  display: flex;
  align-items: center;
  justify-content: end;
  gap: 8px;
}

.color-control {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.color-control input {
  width: 34px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  padding: 2px;
  cursor: pointer;
}

.user-panel span {
  color: var(--muted);
  font-size: 14px;
}

.jump-control select {
  min-width: 96px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  padding: 8px 10px;
}

.problem-stage {
  display: flex;
  justify-content: center;
  padding: 28px 0 18px;
}

.board-panel {
  min-width: 0;
  width: min(560px, 100%);
}

.board {
  width: 100%;
  aspect-ratio: 1;
  /* Keep touch gestures on the board from scrolling the page so pieces can be
     dragged (and tapped) on mobile instead of panning the whole board. */
  touch-action: none;
}

.board img {
  touch-action: none;
}

.board .white-1e1d7 {
  background-color: var(--board-light);
}

.board .black-3c85d {
  background-color: var(--board-dark);
}

.board .square-55d63 {
  position: relative;
}

.board .highlight-legal::after,
.board .highlight-capture::after,
.board .highlight-selected::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.board .highlight-legal::after {
  background: radial-gradient(circle, var(--legal-move) 0 22%, transparent 24%);
}

.board .highlight-capture::after {
  box-shadow: inset 0 0 0 5px var(--legal-capture);
}

.board .highlight-selected::after {
  box-shadow: inset 0 0 0 4px rgba(47, 111, 94, 0.42);
}

.board-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 42px;
  padding-top: 12px;
  color: var(--muted);
  font-size: 15px;
}

.solution-full {
  margin-top: 8px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
}

.full-animation-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  color: var(--muted);
  font-size: 14px;
}

.full-animation-toggle input {
  width: 16px;
  height: 16px;
}

.controls {
  display: flex;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.controls button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  padding: 10px 14px;
  cursor: pointer;
}

.controls button:hover:not(:disabled) {
  border-color: var(--accent);
}

.controls button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

#flipButton {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100vw - 20px, 560px);
    padding: 18px 0;
  }

  .topbar,
  .header-controls,
  .selectors,
  .login-form,
  .user-panel,
  .board-theme-controls,
  .controls {
    align-items: stretch;
    justify-items: stretch;
    flex-direction: column;
  }

  .login-form input {
    width: 100%;
  }

  .problem-stage {
    padding-top: 20px;
  }

  h1 {
    font-size: 24px;
  }

  .board-meta {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }
}
