/* Timeline Builder: sits on the same dark "arcade cabinet" base as the hub
   (arcade.css), with parchment-toned panels for the menu and bright pixel
   feedback during play. Tokens from styles.css, primitives from pixel-ui.css. */

.tb-header {
  --adventure-bg-image: none;
}

.tb-shell {
  width: var(--content);
  margin: 0 auto;
  padding: clamp(20px, 4vw, 40px) 0 clamp(56px, 8vw, 96px);
}

.tb-shell .status-panel,
.tb-shell .error-panel {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.05);
  color: #ffffff;
}

.tb-howto-button {
  margin-top: 18px;
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.3);
  color: #ffffff;
}

.tb-howto-button:hover {
  background: rgba(255, 255, 255, 0.18);
}

.tb-icon-button {
  width: 44px;
  height: 44px;
  padding: 0;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.tb-icon-button[aria-pressed="false"] {
  color: rgba(255, 255, 255, 0.45);
}

.tb-icon-button svg {
  width: 20px;
  height: 20px;
}

/* ---------- Menu ---------- */

.tb-menu {
  display: grid;
  gap: 20px;
  max-width: 920px;
  margin: 0 auto;
}

.tb-panel {
  --notch: 12px;
  border: 1px solid #e3c98a;
  background: linear-gradient(165deg, #fff8e8, #ffffff 120%);
  color: var(--ink);
  padding: clamp(18px, 2.4vw, 26px);
}

.tb-panel-label {
  margin: 0 0 14px;
  color: var(--gold);
  font-size: 0.72rem;
}

.tb-mode-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.tb-mode-button {
  background: #eef2f7;
  color: var(--ink);
  padding: 0.7rem 1.2rem;
}

.tb-mode-button.is-selected {
  background: var(--primary);
  color: #ffffff;
}

.tb-mode-detail {
  margin: 14px 0 0;
  color: var(--muted);
}

.tb-category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.tb-category-card {
  --notch: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  font-weight: 800;
  text-align: left;
  padding: 14px;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.tb-category-card.is-selected {
  border-color: var(--primary);
  background: #eef4ff;
  box-shadow: 0 0 0 2px var(--primary) inset;
}

.tb-category-card:hover {
  border-color: var(--primary);
}

.tb-best-badge {
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 900;
}

.tb-endless-notice {
  margin: 0;
  color: var(--ink-soft);
}

.tb-best {
  margin: 10px 0 0;
  color: var(--gold);
}

.tb-start-row {
  text-align: center;
  margin-top: 4px;
}

.tb-start-button {
  min-width: 220px;
  font-size: 1.05rem;
}

.tb-start-hint {
  margin: 10px 0 0;
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.85rem;
}

/* ---------- HUD ---------- */

.tb-hud {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: clamp(14px, 2.5vw, 28px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
  padding: 14px 18px;
  margin-bottom: 20px;
}

.tb-hud-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tb-hud-label {
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.tb-hud-value {
  color: #ffd166;
  font-size: 1.15rem;
  font-weight: 900;
}

#tbTimer {
  font-family: "Press Start 2P", ui-monospace, monospace;
  font-size: 0.95rem;
}

.tb-hud-actions {
  margin-left: auto;
}

/* ---------- Timeline & tray ---------- */

.tb-section-label {
  margin: 0 0 10px;
  color: rgba(255, 255, 255, 0.78);
  font-weight: 800;
}

.tb-timeline-wrap {
  margin-bottom: 26px;
}

.tb-timeline {
  display: flex;
  align-items: stretch;
  gap: 2px;
  min-height: 100px;
  overflow-x: auto;
  border: 1px dashed rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  padding: 14px 10px;
}

.timeline-gap {
  position: relative;
  flex: 0 0 16px;
  align-self: stretch;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}

.timeline-gap::after {
  content: "";
  position: absolute;
  inset: 10px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.14);
  transition: background 120ms ease, transform 120ms ease;
}

.timeline-gap:hover::after,
.timeline-gap.gap-active::after,
.timeline-gap.is-active-target::after,
.timeline-gap:focus-visible::after {
  background: #ffd166;
  transform: scaleX(1.8);
}

.timeline-card {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 132px;
  border: 1px solid #e3c98a;
  border-radius: 10px;
  background: linear-gradient(160deg, #fff8e8, #ffffff);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  padding: 10px 12px;
  animation: pixel-pop-in 220ms ease;
}

.timeline-card-year {
  color: var(--gold);
  font-size: 0.8rem;
  font-weight: 900;
}

.timeline-card-title {
  font-size: 0.86rem;
  line-height: 1.3;
}

.tb-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.tray-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  width: 168px;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  background: linear-gradient(160deg, #16294a, #0f1e38);
  color: #ffffff;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  padding: 12px 14px;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease, opacity 160ms ease;
}

.tray-card:hover {
  border-color: #ffd166;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.35);
  transform: translateY(-3px);
}

.tray-card.is-picked-up,
.tray-card[aria-pressed="true"] {
  border-color: #ffd166;
  box-shadow: 0 0 0 2px #ffd166;
}

.tray-card.is-lifted {
  opacity: 0.35;
}

.tray-card-grip {
  width: 26px;
  height: 6px;
  border-radius: 3px;
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.5) 0 4px, transparent 4px 8px);
}

.tray-card-title {
  font-weight: 800;
  font-size: 0.92rem;
  line-height: 1.3;
}

.tray-card-tag {
  color: #ffd166;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.drag-ghost {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 200;
  opacity: 0.94;
  pointer-events: none;
  transform: rotate(-2deg) scale(1.04);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
}

.flash-correct {
  animation: tb-flash-correct 420ms ease;
}

.flash-incorrect {
  animation: tb-flash-incorrect 420ms ease;
}

@keyframes tb-flash-correct {
  0% { box-shadow: 0 0 0 0 rgba(19, 122, 75, 0); }
  35% { box-shadow: 0 0 0 6px rgba(19, 122, 75, 0.55); }
  100% { box-shadow: 0 0 0 0 rgba(19, 122, 75, 0); }
}

@keyframes tb-flash-incorrect {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

/* ---------- Pause overlay ---------- */

.tb-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: grid;
  place-items: center;
  background: rgba(6, 12, 24, 0.74);
  backdrop-filter: blur(3px);
}

.tb-overlay-panel {
  --notch: 14px;
  max-width: 360px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: #101c34;
  color: #ffffff;
  text-align: center;
  padding: clamp(26px, 4vw, 36px);
}

/* styles.css sets h2/h3 to the dark --ink token globally; both of these
   panels sit on a dark background and need to override that back to white. */
.tb-overlay-panel h2,
.tb-end h2 {
  color: #ffffff;
}

.tb-overlay-actions {
  display: grid;
  gap: 10px;
  margin-top: 22px;
}

/* ---------- End screen ---------- */

.tb-end {
  --notch: 18px;
  max-width: 640px;
  margin: 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: linear-gradient(160deg, #16294a, #0f1e38);
  color: #ffffff;
  text-align: center;
  padding: clamp(28px, 4vw, 46px);
}

.tb-end .eyebrow {
  color: #ffd166;
}

.tb-new-high-score {
  margin: -6px 0 0;
  color: #ffd166;
  font-weight: 900;
}

.tb-end-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 14px;
  margin: 26px 0;
}

.tb-end-stats > div {
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.07);
  padding: 14px;
}

.tb-end-stats strong {
  display: block;
  margin-top: 6px;
  color: #ffd166;
  font-size: 1.35rem;
}

.tb-end-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.confetti-canvas {
  position: fixed;
  inset: 0;
  z-index: 300;
  pointer-events: none;
}

@media (max-width: 640px) {
  .tb-hud {
    justify-content: space-between;
  }

  .tb-hud-actions {
    margin-left: 0;
  }

  .tray-card {
    width: calc(50% - 6px);
  }
}
