/* Canteen Rush – only what's specific to this game.
   Header, segmented buttons and the rest come from /css/style.css. */

.cr-layout {
  gap: 14px;
}

/* Holders in the centred column need their own width */
.cr-holder,
.cr-race {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: min(100%, 960px);
}

/* ---------- Top bar: place, everyone on a track, time ---------- */

.cr-hud {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
}

.cr-place {
  flex: none;
  min-width: 52px;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.cr-place small {
  margin-left: 1px;
  font-size: 14px;
  color: var(--text-muted);
}

.cr-track {
  position: relative;
  flex: 1;
  height: 8px;
  margin: 0 8px;
  border-radius: 99px;
  background: var(--surface-2);
}

/* The canteen at the end of the track */
.cr-flag {
  position: absolute;
  top: -5px;
  right: -8px;
  width: 16px;
  height: 18px;
  border-radius: 3px;
  background: repeating-conic-gradient(#111 0 25%, #fff 0 50%) 0 0 / 8px 8px;
  border: 1px solid var(--border-strong);
}

.cr-dot {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  border: 2px solid var(--bg);
  transition: left 0.1s linear;
}

.cr-dot.is-me {
  z-index: 1;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  box-shadow: 0 0 0 2px var(--text);
}

.cr-clock {
  flex: none;
  min-width: 52px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* ---------- Game area ---------- */

.cr-stage {
  position: relative;
  width: 100%;
  touch-action: none;           /* taps are jumps, not scrolling or zooming */
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

.cr-view {
  width: 100%;
}

.cr-canvas {
  display: block;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
}

/* The item button, bottom right of the game */
.cr-item {
  position: absolute;
  left: 14px;               /* behind your runner: the right side is where the course comes from */
  bottom: 14px;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 18px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  background: rgba(20, 22, 30, 0.55);
  color: #fff;
  cursor: pointer;
  touch-action: none;
}

.cr-item:not(:disabled) {
  background: #8b5cf6;
  border-color: #fff;
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.35);
  animation: cr-pop 0.25s ease-out;
}

.cr-item:disabled {
  cursor: default;
  opacity: 0.7;
}

.cr-item-icon svg {
  display: block;
  width: 32px;
  height: 32px;
}

.cr-item-key {
  position: absolute;
  top: -8px;
  right: -8px;
  min-width: 20px;
  padding: 1px 5px;
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border-strong);
  font-size: 11px;
  font-weight: 700;
}

.cr-item:disabled .cr-item-key {
  display: none;
}

.cr-item-name {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  white-space: nowrap;
  padding: 4px 10px;
  border-radius: 99px;
  background: rgba(20, 22, 30, 0.7);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.cr-item-name.is-shown {
  opacity: 1;
}

@keyframes cr-pop {
  from { transform: scale(0.6); }
  to { transform: scale(1); }
}

/* ---------- Overlay: countdown and results ---------- */

.cr-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--overlay-light);
  text-align: center;
  pointer-events: none;         /* taps go through to the game… */
}

.cr-overlay p {
  margin: 0;
}

.cr-big {
  font-size: 30px;
}

.cr-overlay .game-actions {
  margin-top: 8px;
  pointer-events: auto;         /* …except on the buttons */
}

.cr-podium {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: min(100%, 340px);
  margin: 6px 0 0;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  list-style: none;
  text-align: left;
}

.cr-podium li {
  display: grid;
  grid-template-columns: 36px 12px 1fr auto;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.cr-podium li.is-me {
  font-weight: 700;
}

.cr-p-place {
  color: var(--text-muted);
  font-weight: 700;
}

.cr-p-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.cr-p-time {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- Keys + item list ---------- */

.cr-keys {
  max-width: 680px;
  margin: 0;
  text-align: center;
}

.cr-swatch {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 3px;
  background: #b07cff;
  vertical-align: -1px;
}

.cr-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 18px;
  max-width: 760px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cr-legend li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.cr-legend b {
  color: var(--text);
  font-weight: 600;
}

.cr-legend-icon svg {
  display: block;
  width: 16px;
  height: 16px;
  color: #b07cff;
}

kbd {
  display: inline-block;
  min-width: 22px;
  margin: 0 1px;
  padding: 1px 5px;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
}

/* ---------- Online setup ---------- */

.cr-setup {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: min(100%, 520px);
  text-align: center;
}

.cr-setup > p {
  margin: 0;
}

.cr-setup-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
}

.cr-lineup {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cr-lineup li {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 99px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
}

.cr-lineup li span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

/* ---------- Phones ---------- */

@media (max-width: 600px) {
  .cr-item {
    width: 58px;
    height: 58px;
    left: 10px;
    bottom: 10px;
  }
  .cr-item-name {
    font-size: 12px;
  }
  .cr-keys .cr-desktop {
    display: none;
  }
  .cr-big {
    font-size: 24px;
  }
}

/* Map and classmates pickers side by side, wrapping on phones */
.cr-pickers {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 0.75rem;
}
.cr-setup .cr-pickers { margin: 0.25rem 0 0.75rem; }
.cr-pickers[hidden] { display: none; }

/* Phone held sideways: fit the screen height (see css/style.css) */
@media (orientation: landscape) and (max-height: 540px) {
  .cr-holder { width: min(960px, var(--play-w), calc((var(--play-h) - 40px) * 16 / 7.6)); gap: 6px; }
  .cr-keys, .cr-legend { display: none; }
  .cr-pickers { flex-direction: column; align-items: center; }
}
@media (orientation: landscape) and (max-height: 540px) {
  :root { --land-side: 236px; }
}
/* With friends, phone held sideways */
@media (orientation: landscape) and (max-height: 540px) {
  .cr-race { width: min(960px, 100%, calc((var(--play-h) - 40px) * 16 / 7.6)); gap: 6px; }
}
