/* Gridlock — scoped under .game-gridlock. A steel-blue moulded tray with recessed wells. */

.game-gridlock { --title: var(--steel); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .game-gridlock { --title: #9DB9CF; }
}
:root[data-theme="dark"] .game-gridlock { --title: #9DB9CF; }

.game-gridlock main { padding-block: 8px 48px; }

.game-title { font-family: var(--font-display); font-size: clamp(30px, 6vw, 44px); color: var(--title); }
.game-lede { color: var(--ink-2); margin-top: 6px; }

.status { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin: 10px 0 4px; font-weight: 600; }
.status .muted { color: var(--ink-2); font-weight: 500; }
.status b { font-family: var(--font-display); font-size: 22px; font-weight: 400; color: var(--title); }

/* The tray */
.tray {
  width: min(100%, 460px);
  margin: 8px auto 0;
  padding: clamp(14px, 4vw, 24px);
  padding-right: calc(clamp(14px, 4vw, 24px) + 6px);   /* room for the notch to read as a gap in the wall */
  border-radius: var(--radius-toy);
  background: linear-gradient(160deg, #5C7B93 0%, var(--steel) 45%, #2A3E4F 100%);
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,.18),
    inset 0 -3px 0 rgba(0,0,0,.45),
    0 24px 30px -18px rgba(29,35,51,.7),
    0 2px 4px rgba(29,35,51,.3);
  user-select: none;
  -webkit-user-select: none;
}
.lot {
  position: relative;
  aspect-ratio: 1;
  border-radius: 14px;
  background: #1E2E3B;
  box-shadow: inset 0 3px 8px rgba(0,0,0,.8), inset 0 -1px 0 rgba(255,255,255,.06);
}
.wells { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(6, 1fr); grid-template-rows: repeat(6, 1fr); }
.well {
  display: block;
  margin: 4px;
  border-radius: 7px;
  background: #24384A;
  box-shadow: inset 0 2px 3px rgba(0,0,0,.5);
  transition: background .12s ease;
}
.well.lane { background: #35516A; box-shadow: inset 0 2px 3px rgba(0,0,0,.5), inset 0 0 0 2px rgba(255,255,255,.18); cursor: pointer; }

/* The notch: a gap cut in the right wall at the exit row */
.exit {
  position: absolute;
  right: -10px;
  top: calc(2 * 100% / 6 + 4px);
  height: calc(100% / 6 - 8px);
  width: 10px;
  background: #1E2E3B;
  border-radius: 0 6px 6px 0;
  box-shadow: inset 0 3px 6px rgba(0,0,0,.7);
}

/* Cars: glossy blocks positioned in cell fractions, sized by --w/--h */
.cars { position: absolute; inset: 0; }
.car {
  position: absolute;
  left: calc(var(--c) * 100% / 6);
  top: calc(var(--r) * 100% / 6);
  width: calc(var(--w) * 100% / 6);
  height: calc(var(--h) * 100% / 6);
  padding: 5px;
  border: 0;
  background: transparent;
  cursor: grab;
  touch-action: none;
  transition: left .18s ease, top .18s ease;
}
.car.dragging { transition: none; cursor: grabbing; z-index: 2; }
.car .body {
  display: block;
  width: 100%; height: 100%;
  border-radius: 9px;
  background: radial-gradient(circle at 30% 25%, rgba(255,255,255,.35) 0%, transparent 40%), var(--paint);
  box-shadow:
    inset 0 2px 2px rgba(255,255,255,.35),
    inset 0 -4px 6px rgba(0,0,0,.35),
    0 3px 0 var(--paint-dark),
    0 5px 8px rgba(0,0,0,.45);
  position: relative;
}
.car .body::after {                        /* windshield */
  content: '';
  position: absolute;
  background: rgba(20,30,40,.55);
  border-radius: 4px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25);
}
.car.h .body::after { top: 18%; bottom: 18%; right: 22%; width: 18%; }
.car.v .body::after { left: 18%; right: 18%; top: 22%; height: 18%; }
.car:active .body, .car.dragging .body { transform: translateY(1px); }
.car.selected .body { outline: 3px solid rgba(255,255,255,.9); outline-offset: 1px; }
.car:focus-visible { outline: none; }
.car:focus-visible .body { outline: 3px solid #fff; outline-offset: 1px; }
.car.shake { animation: shake .3s ease; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
.car.out .body { transform: translateX(45%); transition: transform .5s cubic-bezier(.4, 0, 1, 1); }   /* drives into the notch */

/* Paint: the red car and five muted plastics, assigned by id mod 5 */
.car.red     { --paint: #D8342B; --paint-dark: #8E1F19; }
.car.paint-0 { --paint: #6A7B8C; --paint-dark: #3E4A57; }   /* slate */
.car.paint-1 { --paint: #7E8A4A; --paint-dark: #4B532B; }   /* olive */
.car.paint-2 { --paint: #D2A23A; --paint-dark: #8A6A20; }   /* mustard */
.car.paint-3 { --paint: #3E8F8A; --paint-dark: #245652; }   /* teal */
.car.paint-4 { --paint: #7A4E7E; --paint-dark: #4A2E4D; }   /* plum */

/* Controls and hint */
.controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 22px; }
.hint { text-align: center; color: var(--ink-2); margin: 14px auto 0; min-height: 1.5em; max-width: 46ch; }
.free-controls { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; margin-top: 16px; }
.opts { display: inline-flex; gap: 6px; }

.verdict { font-family: var(--font-display); font-size: 34px; color: var(--title); line-height: 1.05; }
.verdict.win { color: var(--ok); }

@media (max-width: 480px) {
  .status b { font-size: 20px; }
  .controls .btn { flex: 1 1 40%; }
  .well { margin: 3px; }
  .car { padding: 4px; }
}
