:root {
  --room: #0e1110;
  --ink: #f2f0e8;
  --chalk: rgba(244, 242, 232, 0.9);
  --slate-1: #2c3b39;
  --slate-2: #1b2423;
  --wood-1: #7a4f2a;
  --wood-2: #4a2e17;
  --marker: #17172b;
  --marker-red: #b3202a;
  --white-1: #fbfcfd;
  --white-2: #e6eaee;
  --alu-1: #e9ecef;
  --alu-2: #9aa3ab;
  --card: #fbfaf6;
  --card-ink: #1d1d1f;
  --muted: #6b6b70;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

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

body {
  background: radial-gradient(ellipse at 50% 30%, #1d2422 0%, var(--room) 70%);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
}

body[data-style="whiteboard"] {
  background: radial-gradient(ellipse at 50% 30%, #1a1d2e 0%, #0b0c14 70%);
}

button {
  font: inherit;
  color: inherit;
}

/* ---------- Layout shared by both boards ---------- */

.board {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: clamp(16px, 3vw, 40px) 16px;
}

.frame {
  position: relative;
  width: min(1240px, 100%);
  border-radius: 6px;
}

.surface {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: clamp(16px, 4vw, 64px);
}

.column {
  list-style: none;
  margin: 0;
  padding: 0;
}

.car {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: 0.12em 0.3em;
  border-radius: 4px;
  cursor: pointer;
  transform: rotate(var(--tilt, 0deg));
  transition: background-color 0.15s, transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.car:focus-visible {
  outline: 2px dashed currentColor;
  outline-offset: 2px;
}

.hint {
  margin: 44px 0 0;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.55);
  text-align: center;
}

/* Tray with chalk / markers and an eraser */
.tray {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: -26px;
  height: 18px;
  border-radius: 0 0 6px 6px;
}

.tray .stick,
.tray .eraser {
  position: absolute;
  bottom: 9px;
}

.tray .stick.a {
  left: 14%;
}

.tray .stick.b {
  left: 21%;
  transform: rotate(-6deg);
}

.tray .eraser {
  right: 12%;
  width: 92px;
  height: 22px;
  border-radius: 4px;
}

/* ---------- Chalkboard ---------- */

.board-chalkboard .frame {
  padding: clamp(10px, 1.6vw, 22px);
  background: linear-gradient(135deg, var(--wood-1), var(--wood-2) 40%, var(--wood-1) 70%, var(--wood-2));
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.6),
    inset 0 0 0 2px rgba(0, 0, 0, 0.35);
}

.board-chalkboard .surface {
  padding: clamp(14px, 2.4vw, 34px) clamp(14px, 3vw, 44px);
  border-radius: 3px;
  font-family: "Cabin Sketch", "Chalkboard SE", cursive;
  font-size: clamp(12px, min(1.45vw, 2.15vh), 21px);
  line-height: 1.32;
  text-transform: uppercase;
  color: var(--chalk);
  text-shadow:
    0 0 1px rgba(255, 255, 255, 0.55),
    0 0 6px rgba(255, 255, 255, 0.12);
  background:
    radial-gradient(ellipse 40% 25% at 70% 60%, rgba(255, 255, 255, 0.06), transparent 70%),
    radial-gradient(ellipse 35% 30% at 25% 30%, rgba(255, 255, 255, 0.05), transparent 70%),
    radial-gradient(ellipse 50% 18% at 55% 12%, rgba(255, 255, 255, 0.04), transparent 70%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    linear-gradient(160deg, var(--slate-1), var(--slate-2));
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.55);
}

.board-chalkboard .column {
  counter-reset: none;
}

.board-chalkboard .car {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  column-gap: 0.32em;
  letter-spacing: 0.03em;
}

.board-chalkboard .num {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 1.55em;
  height: 1.55em;
  margin-right: 0.15em;
  border: 2px solid var(--chalk);
  border-radius: 50% 46% 52% 48%;
  font-size: 0.78em;
  letter-spacing: 0;
  box-shadow: 0 0 3px rgba(255, 255, 255, 0.25);
}

.board-chalkboard .yr {
  min-width: 1.9em;
}

.board-chalkboard .dash {
  opacity: 0.85;
}

.board-chalkboard .car:hover,
.board-chalkboard .car:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  transform: rotate(var(--tilt, 0deg)) scale(1.02);
}

.board-chalkboard .tray {
  background: linear-gradient(var(--wood-1), var(--wood-2));
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.5);
}

.board-chalkboard .tray .stick {
  width: 46px;
  height: 9px;
  border-radius: 4px;
  background: linear-gradient(#fff, #d9d6cc);
}

.board-chalkboard .tray .eraser {
  background: linear-gradient(#c8b27c 0 35%, #3a3a3a 35%);
}

/* ---------- Whiteboard ---------- */

.board-whiteboard .frame {
  padding: clamp(8px, 1vw, 14px);
  background: linear-gradient(135deg, var(--alu-1), var(--alu-2) 50%, var(--alu-1));
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.6),
    inset 0 0 0 1px rgba(0, 0, 0, 0.25);
}

.board-whiteboard .frame::before,
.board-whiteboard .frame::after {
  content: "";
  position: absolute;
  top: -4px;
  width: 22px;
  height: 22px;
  border-radius: 3px;
  background: #3a4a8c;
}

.board-whiteboard .frame::before {
  left: -4px;
}

.board-whiteboard .frame::after {
  right: -4px;
}

.board-whiteboard .surface {
  grid-template-columns: 1fr 1.1fr;
  grid-template-rows: auto 1fr;
  padding: clamp(14px, 2.2vw, 32px) clamp(16px, 3vw, 48px) clamp(18px, 3vw, 44px);
  font-family: "Permanent Marker", "Marker Felt", cursive;
  font-size: clamp(15px, min(1.9vw, 3vh), 28px);
  line-height: 1.25;
  text-transform: uppercase;
  color: var(--marker);
  background:
    radial-gradient(ellipse 30% 14% at 30% 22%, rgba(40, 60, 120, 0.05), transparent 70%),
    radial-gradient(ellipse 26% 16% at 78% 70%, rgba(40, 40, 60, 0.05), transparent 70%),
    linear-gradient(170deg, var(--white-1), var(--white-2));
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.12);
}

.board-whiteboard .wanted {
  grid-column: 1;
  grid-row: 1;
  margin: 0 0 0.35em;
  font-weight: 400;
  font-size: 2.3em;
  letter-spacing: 0.04em;
  line-height: 1;
  transform: rotate(-1deg);
  position: relative;
  width: max-content;
}

.board-whiteboard .wanted::after {
  content: "";
  position: absolute;
  left: 0;
  right: -20%;
  bottom: -0.32em;
  height: 0.12em;
  border-radius: 99px;
  background: var(--marker);
  transform: rotate(-0.6deg);
}

.board-whiteboard .column:nth-of-type(1) {
  grid-column: 1;
  grid-row: 2;
}

.board-whiteboard .column:nth-of-type(2) {
  grid-column: 2;
  grid-row: 1 / span 2;
}

.board-whiteboard li {
  margin: 0.22em 0;
}

.board-whiteboard li.small {
  font-size: 0.72em;
}

.board-whiteboard li.big {
  font-size: 1.22em;
}

.board-whiteboard li.indent {
  padding-left: 1.4em;
}

.board-whiteboard li.gap {
  margin-top: 1.1em;
}

.board-whiteboard .car {
  letter-spacing: 0.05em;
}

.board-whiteboard .car::before {
  content: "•";
  margin-right: 0.35em;
}

.board-whiteboard li.nodot .car::before {
  content: "";
  margin: 0;
}

.board-whiteboard .txt {
  position: relative;
}

.board-whiteboard li.crossed .txt::after {
  content: "";
  position: absolute;
  left: -0.15em;
  right: -0.25em;
  top: 52%;
  height: 0.14em;
  border-radius: 99px;
  background: var(--marker);
  transform: rotate(-1.2deg);
}

.board-whiteboard .car:hover,
.board-whiteboard .car:focus-visible {
  background: rgba(40, 70, 200, 0.07);
  transform: rotate(var(--tilt, 0deg)) scale(1.02);
}

.board-whiteboard .tray {
  background: linear-gradient(var(--alu-1), var(--alu-2));
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.5);
}

.board-whiteboard .tray .stick {
  width: 70px;
  height: 12px;
  border-radius: 3px 6px 6px 3px;
  background: linear-gradient(90deg, #111 0 22%, #e8e8e8 22%);
}

.board-whiteboard .tray .stick.b {
  background: linear-gradient(90deg, var(--marker-red) 0 22%, #e8e8e8 22%);
}

.board-whiteboard .tray .eraser {
  background: linear-gradient(#2a3a8a 0 55%, #d8d2c0 55%);
}

/* ---------- Small screens: one column ---------- */

@media (max-width: 760px) {
  .board {
    justify-content: flex-start;
  }

  .surface,
  .board-whiteboard .surface {
    grid-template-columns: 1fr;
    grid-template-rows: none;
  }

  .board-chalkboard .surface {
    font-size: 16px;
  }

  .board-whiteboard .surface {
    font-size: 19px;
  }

  .board-whiteboard .column:nth-of-type(1),
  .board-whiteboard .column:nth-of-type(2) {
    grid-column: 1;
    grid-row: auto;
  }

  .board-whiteboard .wanted {
    grid-column: 1;
    font-size: 2.1em;
  }

  .car {
    padding: 0.28em 0.3em;
  }

  .tray .eraser {
    width: 64px;
  }
}

/* ---------- Car dialog ---------- */

dialog {
  width: min(880px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: var(--card);
  color: var(--card-ink);
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.7);
  overflow: auto;
}

dialog::backdrop {
  background: rgba(5, 7, 6, 0.72);
  backdrop-filter: blur(3px);
}

dialog[open] {
  animation: pop 0.18s ease-out;
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

.dialog-close-form {
  position: absolute;
  top: 8px;
  right: 8px;
  margin: 0;
  z-index: 2;
}

.dialog-close {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.car-photo {
  margin: 0;
  background: #111;
  aspect-ratio: 3 / 2;
  display: grid;
  place-items: center;
}

body[data-style="whiteboard"] .car-photo {
  background: #2a2c33;
}

.car-photo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 0.2s;
}

.car-photo img.loaded {
  opacity: 1;
}

.car-info {
  padding: 18px 22px 8px;
}

.car-kicker {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

#car-title {
  margin: 0 0 12px;
  font-size: clamp(22px, 3.2vw, 30px);
  line-height: 1.15;
}

body[data-style="chalkboard"] #car-title {
  font-family: "Cabin Sketch", system-ui, sans-serif;
}

body[data-style="whiteboard"] #car-title {
  font-family: "Permanent Marker", system-ui, sans-serif;
  font-weight: 400;
}

#car-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px 24px;
  margin: 0 0 12px;
}

#car-details dt {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

#car-details dd {
  margin: 2px 0 0;
  font-size: 17px;
}

.car-credit,
.car-note {
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--muted);
}

.car-credit a {
  color: inherit;
}

.car-nav {
  display: flex;
  justify-content: space-between;
  padding: 4px 16px 16px;
}

.car-nav button {
  min-width: 56px;
  height: 44px;
  border: 1px solid #d6d3c9;
  border-radius: 10px;
  background: #fff;
  color: var(--card-ink);
  font-size: 20px;
  cursor: pointer;
}

.car-nav button:hover {
  background: #f0eee6;
}

/* ---------- Picker (preview URLs only) ---------- */

.picker {
  display: grid;
  place-content: center;
  gap: 16px;
  min-height: 100vh;
  padding: 16px;
  text-align: center;
}

.picker h1 {
  margin: 0 0 8px;
  font-family: "Cabin Sketch", sans-serif;
}

.pick {
  display: block;
  padding: 18px 28px;
  border-radius: 10px;
  text-decoration: none;
  font-size: 22px;
}

.pick-chalk {
  background: var(--slate-1);
  color: var(--chalk);
  font-family: "Cabin Sketch", sans-serif;
}

.pick-white {
  background: var(--white-1);
  color: var(--marker);
  font-family: "Permanent Marker", sans-serif;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
