@font-face {
  font-family: 'VeryVeryPunk';
  src: url('/fonts/very_very_punk/vvpf.otf') format('opentype');
  font-display: swap;
}
@font-face {
  font-family: 'Special Elite';
  src: url('/fonts/Special_Elite/SpecialElite-Regular.ttf') format('truetype');
  font-display: swap;
}

:root {
  --orange: #ff6600;
  --tape: #3a2614;
  --pencil: #f4e9b0;
  --line: #333;
  --dim: #777;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 16px;
  background: #000;
  color: #ddd;
  font-family: 'Special Elite', 'Courier New', monospace;
}

main { max-width: 960px; margin: 0 auto; }

header {
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

h1 {
  font-family: 'VeryVeryPunk', Impact, sans-serif;
  color: var(--orange);
  font-weight: normal;
  font-size: 2.6em;
  margin: 0;
}

h2 {
  font-size: 1.1em;
  font-weight: normal;
  color: var(--orange);
  margin: 0;
}

.pick-hint, .status, .help { color: var(--dim); }
.help { font-size: 0.9em; line-height: 1.7; }
kbd { border: 1px solid #555; padding: 0 4px; font-family: inherit; }

/* ---------- buttons ---------- */

button, .pick {
  font: inherit;
  background: var(--orange);
  color: #000;
  border: 2px solid #000;
  box-shadow: 2px 2px 0 #fff;
  padding: 6px 14px;
  cursor: pointer;
}
button:active:not(:disabled), .pick:active { transform: translate(2px, 2px); box-shadow: none; }
button:disabled { opacity: 0.35; cursor: default; }
button.disabled { opacity: 0.35; }
.razor { background: var(--pencil); }

.row { display: flex; gap: 8px; align-items: center; margin: 12px 0; flex-wrap: wrap; }
.gap { flex: 1; }

/* ---------- sections ---------- */

section {
  border: 2px solid var(--line);
  background: #0b0b0b;
  padding: 0 12px;
  margin-bottom: 16px;
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
}

/* ---------- deck ---------- */

.deck { position: relative; padding: 0; }
.deck.active { border-color: #5a3a1c; }
.deck.loading-target { border-color: var(--orange); border-style: dashed; }
.deck .row, .deck .status { padding: 0 12px; }
.deck .status { margin: -4px 0 10px; font-variant-numeric: tabular-nums; }
.deck-name { position: absolute; top: 8px; left: 12px; pointer-events: none; }
.deck.active .deck-name::after { content: ' ●'; font-size: 0.7em; }
.tape {
  display: block;
  width: 100%;
  height: 260px;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.tape.grabbing { cursor: grabbing; }

/* Phones: an empty source deck becomes the start screen. */
.deck-start { display: none; }
@media (max-width: 700px), (pointer: coarse) {
  .deck.empty .deck-start {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    position: absolute;
    inset: 0;
    z-index: 1;
    background: rgba(11, 11, 11, 0.82);
    text-align: center;
    color: #bbb;
    line-height: 1.5;
  }
  .deck-start .pick {
    font-family: 'VeryVeryPunk', Impact, sans-serif;
    font-size: 1.6em;
    padding: 12px 28px;
    transform: rotate(-2deg);
  }
}

.knob { display: flex; align-items: center; gap: 8px; margin-left: 8px; }
.knob svg { width: 52px; height: 52px; cursor: ns-resize; touch-action: none; }
.knob svg:focus { outline: 2px solid var(--orange); outline-offset: 2px; border-radius: 50%; }
.knob .label { display: flex; flex-direction: column; line-height: 1.2; }
.knob output { color: var(--orange); font-variant-numeric: tabular-nums; }

/* ---------- strips ---------- */

.strip {
  position: absolute;
  background: var(--tape);
  border-top: 2px solid #5a3a1c;
  border-bottom: 2px solid #5a3a1c;
  cursor: grab;
  touch-action: none;
  user-select: none;
  transform: rotate(var(--rot, 0deg));
  transition: transform 0.15s;
}
.strip canvas { display: block; width: 100%; height: 100%; pointer-events: none; }
.strip .label {
  position: absolute;
  left: 4px;
  bottom: 1px;
  font-size: 11px;
  color: var(--pencil);
  pointer-events: none;
  transition: transform 0.3s;
}
.strip.flipped .label { left: auto; right: 4px; top: 1px; bottom: auto; transform: rotate(180deg); }
.strip .flip {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 22px;
  height: 22px;
  padding: 0;
  font-size: 13px;
  line-height: 1;
  border-radius: 50%;
  box-shadow: none;
  border-width: 1px;
}
.strip-head {
  display: none;
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 2px;
  margin-left: -1px;
  background: var(--orange);
  pointer-events: none;
}
.strip.carried {
  position: fixed;
  z-index: 100;
  cursor: grabbing;
  transform: rotate(var(--rot, 0deg)) scale(1.06);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.7);
  transition: none;
}
.strip.dropping { animation: drop 0.35s ease-out; }
@keyframes drop {
  from { transform: translateY(-40px) rotate(-12deg) scale(1.1); opacity: 0; }
  to { transform: rotate(var(--rot, 0deg)); opacity: 1; }
}

/* ---------- bench ---------- */

#table {
  position: relative;
  height: 230px;
  margin-bottom: 12px;
  background:
    repeating-linear-gradient(90deg, transparent 0 39px, #161616 39px 40px),
    repeating-linear-gradient(0deg, transparent 0 39px, #161616 39px 40px);
  border: 1px dashed #2a2a2a;
}

#bench .bar { gap: 8px; }
#bin {
  margin-left: 8px;
  border: 2px dashed #555;
  color: var(--dim);
  padding: 4px 18px;
  transform: rotate(2deg);
}
#bin.hot { border-color: #f33; color: #f33; background: #200; }
.wiggle { animation: wiggle 0.4s; }
@keyframes wiggle {
  25% { transform: rotate(-6deg); }
  50% { transform: rotate(6deg); }
  75% { transform: rotate(-3deg); }
}

/* ---------- shelf ---------- */

#shelf { padding-bottom: 12px; }
#shelf h2 { padding: 10px 0 8px; }
#shelf-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; min-height: 44px; }
#shelf-row .hint { color: var(--dim); font-size: 0.9em; }
.shelf-tape {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 220px;
  padding: 6px 10px 6px 6px;
  background: #161616;
  border: 2px solid #444;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.shelf-tape:hover { border-color: var(--orange); }
.shelf-tape .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shelf-tape .len { color: var(--dim); font-size: 0.85em; }
.mini-reel {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle, #000 0 2px, #ddd 3px 6px, var(--tape) 7px 12px, #444 13px 14px);
}
.shelf-tape.carried {
  position: fixed;
  z-index: 100;
  cursor: grabbing;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.7);
}

/* ---------- advanced ---------- */

details { border-top: 1px solid var(--line); padding-top: 8px; }
summary { cursor: pointer; color: var(--orange); }
.knobs {
  display: grid;
  grid-template-columns: max-content 1fr 5em;
  gap: 6px 12px;
  align-items: center;
  margin-top: 12px;
}
.knobs output { color: var(--orange); text-align: right; }

/* ---------- file drop overlay ---------- */

#file-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.85);
  border: 4px dashed var(--orange);
  color: var(--orange);
  font-family: 'VeryVeryPunk', Impact, sans-serif;
  font-size: 3em;
  align-items: center;
  justify-content: center;
}
body.dragging-file #file-overlay { display: flex; }

@media (max-width: 600px) {
  body { padding: 8px; }
  .knob { margin-left: 0; }
  .tape { height: 220px; }
}
