:root {
  --page: #f4ece0;
  --cabinet: #fff7ec;
  --cabinet-edge: #e6d8c4;
  --red: #d63447;
  --red-dark: #a8243a;
  --ink: #2b2226;
  --ink-2: #5d5157;
  --ink-3: #8a7d83;
  --screen: #2b2f3a;
  --screen-ink: #9df3ff;
  --led: #ff5d4d;
  --led-off: #3a1a1a;
  --glass: #dfe7ee;
  --cold: #2f6fd0;
  --hot: #d63447;
  --bar: #d63447;
  --grid: #e6d8c4;
  --good: #2f9e5b;
  --radius: 18px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #17141a;
    --cabinet: #221d24;
    --cabinet-edge: #3a3139;
    --ink: #f4ece0;
    --ink-2: #c9bcc2;
    --ink-3: #94878e;
    --glass: #2c333c;
    --bar: #ec5867;
    --grid: #3a3139;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: "Nunito", "Segoe UI Rounded", "Segoe UI", system-ui, sans-serif;
  line-height: 1.45;
}

a { color: var(--red); }

.sign {
  background: var(--red);
  color: #fff7ec;
  border-bottom: 6px solid var(--red-dark);
}

.sign-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.logo {
  font-weight: 900;
  font-size: 1.6rem;
  letter-spacing: 0.08em;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}

.logo span { color: #ffd2d8; font-size: 0.9em; }

nav { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }

nav a {
  color: #2b2226;
  background: #fff7ec;
  border-radius: 999px;
  padding: 6px 16px;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 3px 0 var(--red-dark);
}

nav a[aria-current="page"] { background: #ffd23f; }

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  font-size: 0.85rem;
  background: rgba(0, 0, 0, 0.18);
  padding: 4px 12px;
  border-radius: 999px;
}

.dot { width: 10px; height: 10px; border-radius: 50%; background: #9a9a9a; }
.dot.on { background: #4dff88; box-shadow: 0 0 8px #4dff88; }

main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

.machine {
  display: grid;
  grid-template-columns: minmax(280px, 400px) 1fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 820px) {
  .machine { grid-template-columns: 1fr; }
}

.panel {
  background: var(--cabinet);
  border: 2px solid var(--cabinet-edge);
  border-radius: var(--radius);
  padding: 18px;
}

.head .bezel {
  background: #d9d4cf;
  border-radius: 22px;
  padding: 12px;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.12);
}

.head .bezel img {
  display: block;
  width: 100%;
  aspect-ratio: 1000 / 460;
  border-radius: 14px;
  background: var(--screen);
}

.status-strip {
  margin-top: 14px;
  background: #1c1416;
  color: var(--led);
  font-family: "Consolas", "Courier New", monospace;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  min-height: 3.2em;
}

.status-strip .big { font-weight: 700; font-size: 1.05rem; }
.status-strip .sub { color: #ff9d92; font-size: 0.85rem; }

.holding {
  margin-top: 12px;
  display: none;
  align-items: center;
  gap: 10px;
  background: #fff3c4;
  color: #5b4500;
  border-radius: 12px;
  padding: 8px 12px;
  font-weight: 800;
}

.holding.show { display: flex; }

.join {
  margin-top: 12px;
  display: none;
  background: var(--cold);
  color: #fff;
  border-radius: 12px;
  padding: 12px 14px;
}

.join.show { display: block; }
.join-text { font-weight: 700; margin-bottom: 10px; }

.join-button {
  display: inline-block;
  background: #fff;
  color: var(--cold);
  font-weight: 900;
  text-decoration: none;
  border-radius: 999px;
  padding: 6px 16px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);
}

.join-button:hover, .join-button:focus-visible { background: #ffd23f; color: #2b2226; }
.holding img { height: 44px; }

.counter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: #1c1416;
  border-radius: 12px;
  padding: 10px 16px;
  margin-bottom: 16px;
}

.counter .label { color: #ff9d92; font-weight: 800; letter-spacing: 0.1em; font-size: 0.8rem; }

.digits {
  font-family: "Consolas", "Courier New", monospace;
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 700;
  color: var(--led);
  letter-spacing: 0.12em;
  text-shadow: 0 0 10px rgba(255, 93, 77, 0.55);
}

.digits .lead { color: var(--led-off); text-shadow: none; }

.window {
  background: var(--glass);
  border-radius: 14px;
  padding: 14px 12px 6px;
  border: 4px solid #cfc8c0;
}

.shelf {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.slot {
  position: relative;
  text-align: center;
}

.slot img {
  display: block;
  margin: 0 auto;
  height: clamp(90px, 14vw, 140px);
  object-fit: contain;
  transition: transform 0.25s;
}

.slot.flash img { transform: translateY(-8px) scale(1.06); }

.tag {
  margin-top: 4px;
  border-radius: 6px;
  color: #fff;
  font-weight: 800;
  font-size: 0.78rem;
  padding: 3px 4px;
  line-height: 1.2;
}

.tag.cold { background: var(--cold); }
.tag.hot { background: var(--hot); }
.tag .name { display: flex; align-items: center; justify-content: center; min-height: 2.3em; font-size: 0.74rem; line-height: 1.15; }
.tag .n { font-family: "Consolas", monospace; }

.no1 {
  position: absolute;
  top: -6px;
  right: 6%;
  background: #ffd23f;
  color: #5b3b00;
  font-weight: 900;
  font-size: 0.7rem;
  padding: 2px 7px;
  border-radius: 999px;
  transform: rotate(8deg);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
}

.controls {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-top: 16px;
}

.random {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ff8a8a, #e23c3c 60%, #b82a2a);
  border: 5px solid #d9d4cf;
  flex: none;
  transition: transform 0.1s;
}

.random.pressed { transform: scale(0.88); }

.random-label {
  font-weight: 900;
  color: var(--red);
  letter-spacing: 0.06em;
}

.tray {
  margin-top: 14px;
  height: 108px;
  background: #3a3a40;
  border-radius: 12px;
  position: relative;
  overflow: hidden;
  border: 4px solid #cfc8c0;
}

.tray .flap {
  position: absolute;
  inset: 0 0 auto 0;
  height: 26px;
  background: #57575f;
  color: #c9c9d0;
  font-weight: 900;
  font-size: 0.75rem;
  letter-spacing: 0.3em;
  display: grid;
  place-items: center;
  z-index: 1;
}

.tray img {
  position: absolute;
  left: 50%;
  top: 68px;
  height: 92px;
  transform: translate(-50%, -50%) rotate(90deg);
  opacity: 0;
}

.tray img.rest { opacity: 1; }
.tray img.drop { animation: drop 0.7s ease-in forwards; }

@keyframes drop {
  0% { opacity: 1; transform: translate(-50%, calc(-50% - 110px)) rotate(90deg); }
  70% { opacity: 1; transform: translate(-50%, calc(-50% + 6px)) rotate(90deg); }
  85% { transform: translate(-50%, calc(-50% - 3px)) rotate(87deg); }
  100% { opacity: 1; transform: translate(-50%, -50%) rotate(90deg); }
}

.ticker {
  margin-top: 24px;
}

.ticker h2, .section h2 {
  font-size: 1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin: 0 0 10px;
}

.ticker ol {
  list-style: none;
  margin: 0;
  padding: 0;
  background: #1c1416;
  border-radius: 12px;
  font-family: "Consolas", "Courier New", monospace;
  color: var(--led);
  max-height: 320px;
  overflow: auto;
}

.ticker li {
  padding: 8px 14px;
  border-bottom: 1px solid #31191b;
  display: flex;
  gap: 12px;
}

.ticker li .when { color: #b06a62; flex: none; min-width: 6.5em; }
.ticker li.new { animation: glow 1.6s ease-out; }
.ticker .empty { color: #b06a62; }

@keyframes glow {
  from { background: #4a1f1f; }
  to { background: transparent; }
}

footer {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px 40px;
  color: var(--ink-3);
  font-size: 0.85rem;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.tile .value { font-size: 2rem; font-weight: 900; line-height: 1.1; }
.tile .label { color: var(--ink-2); font-weight: 700; font-size: 0.9rem; }
.tile .note { color: var(--ink-3); font-size: 0.8rem; }

.section { margin-bottom: 32px; }

.filters { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }

.filters button {
  font: inherit;
  font-weight: 800;
  border: 2px solid var(--cabinet-edge);
  background: var(--cabinet);
  color: var(--ink);
  border-radius: 999px;
  padding: 4px 14px;
  cursor: pointer;
}

.filters button[aria-pressed="true"] { background: var(--ink); color: var(--cabinet); border-color: var(--ink); }

.rank { display: grid; gap: 2px; }

.rank-row {
  display: grid;
  grid-template-columns: 34px minmax(110px, 170px) 1fr 70px;
  align-items: center;
  gap: 10px;
  padding: 4px 6px;
  border-radius: 8px;
}

.rank-row:hover, .rank-row:focus-visible { background: rgba(214, 52, 71, 0.07); outline: none; }
.rank-row img { height: 34px; justify-self: center; }
.rank-row .name { font-weight: 800; }
.rank-row .count { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); font-weight: 700; }
.rank-row .track { height: 14px; border-left: 1px solid var(--grid); }
.rank-row .fill { height: 100%; background: var(--bar); border-radius: 0 4px 4px 0; min-width: 2px; }

.hours {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  align-items: end;
  height: 180px;
  border-bottom: 1px solid var(--grid);
  position: relative;
}

.hour { height: 100%; display: flex; align-items: flex-end; padding: 0 1px; cursor: default; }
.hour:hover .bar, .hour:focus-visible .bar { filter: brightness(1.15); }
.hour:focus-visible { outline: 2px solid var(--ink-3); outline-offset: -2px; }
.hour .bar { width: 100%; background: var(--bar); border-radius: 4px 4px 0 0; min-height: 0; }

.hour-axis {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  color: var(--ink-3);
  font-size: 0.75rem;
  margin-top: 4px;
}

.peak-note { color: var(--ink-2); font-size: 0.9rem; margin-top: 8px; }

.tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--ink);
  color: var(--cabinet);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.1s;
  white-space: nowrap;
}

.tooltip.show { opacity: 1; }

details.table { margin-top: 10px; color: var(--ink-2); }
details.table summary { cursor: pointer; font-weight: 700; }
details.table table { border-collapse: collapse; margin-top: 8px; font-variant-numeric: tabular-nums; }
details.table td, details.table th { padding: 3px 12px 3px 0; text-align: left; }

.diary { display: grid; gap: 14px; }
.entry h3 { margin: 0 0 4px; }
.entry .meta { color: var(--ink-3); font-size: 0.85rem; margin-bottom: 8px; }
.entry p { margin: 0; }

.about {
  display: grid;
  grid-template-columns: minmax(220px, 360px) 1fr;
  gap: 28px;
  align-items: start;
}

.about img { width: 100%; }

@media (max-width: 520px) {
  .tag .name { font-size: 0.64rem; }
  .tag { padding: 3px 2px; }
}

@media (max-width: 760px) {
  .about { grid-template-columns: 1fr; }
  .rank-row { grid-template-columns: 28px 1fr 60px; }
  .rank-row .track { grid-column: 2 / 4; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .tray img.drop { opacity: 1; transform: translate(-50%, -50%) rotate(90deg); }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
