/* Word Race boards + keyboard, shared by /wordrace.html and /play-word-race/ */
#wr-root {
  --tile: clamp(34px, min(11.5vw, (100dvh - 380px) / 6.6), 60px);
  --mini: calc(var(--tile) * 0.42);
  --g: #f5793a; --y: #4a9eff; --b: #3a3550; --go: #2fc46b; /* orange = right spot, blue = wrong spot (Wordle high-contrast) */
  position: relative; display: flex; flex-direction: column; align-items: center;
  gap: 8px; padding: 6px 0 4px; user-select: none; -webkit-user-select: none;
}
.wr-boards { display: flex; gap: clamp(10px, 3vw, 22px); align-items: flex-start; justify-content: center; }
.wr-side { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.wr-label { font: 600 12px/1.2 Rajdhani, sans-serif; letter-spacing: .04em; color: rgba(255,255,255,.75);
  max-width: calc(var(--tile) * 5.3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wr-tag { color: #2de2e6; text-transform: uppercase; }
.wr-solved { color: var(--go); font-weight: 700; }
.wr-board { display: grid; gap: 5px; }
.wr-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.wr-tile {
  width: var(--tile); height: var(--tile); box-sizing: border-box;
  border: 2px solid rgba(155,143,181,.28); border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font: 700 calc(var(--tile) * 0.55)/1 Rajdhani, sans-serif; color: #fff; text-transform: uppercase;
}
.wr-tile.wr-typed { border-color: rgba(45,226,230,.7); box-shadow: 0 0 8px rgba(45,226,230,.25); animation: wr-pop .08s ease-out; }
.wr-tile.wr-G { background: var(--g); border-color: var(--g); box-shadow: 0 0 10px rgba(245,121,58,.5); }
.wr-tile.wr-Y { background: var(--y); border-color: var(--y); box-shadow: 0 0 10px rgba(74,158,255,.5); }
.wr-tile.wr-B { background: var(--b); border-color: var(--b); }
.wr-tile.wr-flip { animation: wr-flip .45s ease-in-out backwards; }
.wr-mini .wr-board, .wr-board.wr-mini { gap: 3px; }
.wr-board.wr-mini .wr-row { gap: 3px; }
.wr-board.wr-mini .wr-tile { width: var(--mini); height: var(--mini); border-width: 1px; border-radius: 2px; font-size: calc(var(--mini) * 0.6); box-shadow: none; }
.wr-board.wr-mid .wr-tile { width: calc(var(--tile) * 0.8); height: calc(var(--tile) * 0.8); font-size: calc(var(--tile) * 0.44); }
.wr-right .wr-label { max-width: calc(var(--mini) * 5.6); font-size: 11px; }
.wr-spectator .wr-right .wr-label { max-width: calc(var(--tile) * 4.3); font-size: 12px; }
.wr-row.wr-shake { animation: wr-shake .35s; }
@keyframes wr-flip { 0% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }
@keyframes wr-pop { 0% { transform: scale(.9); } 100% { transform: scale(1); } }
@keyframes wr-shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }

.wr-status { font-size: 13px; color: rgba(255,255,255,.7); min-height: 18px; text-align: center; padding: 0 8px; }
.wr-keyboard { display: flex; flex-direction: column; gap: 6px; width: 100%; max-width: 500px; padding: 0 4px; box-sizing: border-box; }
.wr-krow { display: flex; gap: 5px; justify-content: center; }
.wr-key {
  flex: 1 1 0; max-width: 44px; height: clamp(40px, 6.2dvh, 54px); padding: 0;
  border: 1px solid rgba(155,143,181,.3); border-radius: 5px; background: rgba(155,143,181,.16);
  color: #fff; font: 700 15px/1 Rajdhani, sans-serif; cursor: pointer; touch-action: manipulation;
}
.wr-key.wr-wide { flex: 1.6 1 0; max-width: 72px; font-size: 18px; }
.wr-submit {
  margin: 4px auto 0; width: 100%; max-width: 480px; height: clamp(46px, 6.5dvh, 56px);
  border: 0; border-radius: 8px; background: rgba(47,196,107,.22); color: rgba(255,255,255,.45);
  font: 700 20px/1 Rajdhani, sans-serif; letter-spacing: .12em; text-transform: uppercase;
  cursor: pointer; touch-action: manipulation; transition: background .15s, box-shadow .15s, color .15s;
}
.wr-submit.ready { background: var(--go); color: #fff; box-shadow: 0 0 18px rgba(47,196,107,.6); }
.wr-submit:active { transform: translateY(1px); }
.wr-key:active { transform: translateY(1px); }
.wr-key.wr-G { background: var(--g); border-color: var(--g); }
.wr-key.wr-Y { background: var(--y); border-color: var(--y); }
.wr-key.wr-B { background: #221f30; border-color: #221f30; color: rgba(255,255,255,.4); }
.wr-toast {
  position: absolute; top: 34px; left: 50%; transform: translateX(-50%); z-index: 5;
  background: rgba(0,0,0,.88); border: 1px solid rgba(45,226,230,.45); color: #fff;
  padding: 7px 16px; border-radius: 6px; font-size: 13px; font-weight: 600;
  opacity: 0; transition: opacity .2s; pointer-events: none; white-space: nowrap;
}
.wr-toast.show { opacity: 1; }
#wr-endbar { display: flex; gap: 10px; align-items: center; justify-content: center; margin: 4px 0;
  background: rgba(0,0,0,.6); border-radius: 6px; padding: 6px 10px; font-size: 13px; }
.wr-endbar-btn { background: #f0a030; color: #111; border: 0; border-radius: 4px; padding: 5px 12px; font-weight: 700; cursor: pointer; }

@media (max-height: 500px) and (orientation: landscape) {
  #wr-root { --tile: clamp(26px, (100dvh - 70px) / 6.8, 44px); flex-direction: row; flex-wrap: wrap; justify-content: center; }
  .wr-keyboard { max-width: 420px; }
  .wr-key { height: 32px; }
  .wr-submit { height: 36px; font-size: 16px; }
}

/* Colour key */
.wr-legend { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; font: 600 14px/1 Rajdhani, sans-serif; color: rgba(255,255,255,.85); }
.wr-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.wr-legend-sw { width: 16px; height: 16px; border-radius: 3px; display: inline-block; }
.wr-legend-sw.wr-G { background: var(--g); }
.wr-legend-sw.wr-Y { background: var(--y); }
.wr-legend-sw.wr-B { background: var(--b); border: 1px solid rgba(155,143,181,.4); }

/* The ⋮ menu must sit above the boards (tiles make their own layers when they flip) */
#turn-bar, #status-bar { position: relative; z-index: 20; }
.wr-giveup { margin: 2px auto 0; background: none; border: 0; color: rgba(255,255,255,.5); font: 600 14px/1 Rajdhani, sans-serif;
  letter-spacing: .06em; text-transform: uppercase; padding: 8px 16px; cursor: pointer; touch-action: manipulation; }
.wr-giveup.armed { color: #ff6b6b; }

.wr-rating { color: rgba(255,255,255,.5); font-weight: 500; margin-left: 4px; }
.wr-wait { color: rgba(255,255,255,.5); font-style: italic; }

/* ── Desktop: two equal boards side by side, everything sized to the window height ── */
@media (min-width: 900px) and (min-height: 600px) {
  /* #game-row / #canvas-wrapper also get inline page styles: out-rank them */
  #game-layout #game-row #canvas-wrapper { width: min(860px, 100vw - 360px); display: flex; flex-direction: column; }
  #game-layout #game-row { align-items: stretch; }
  #wr-root {
    --tile: clamp(40px, min((100dvh - 500px) / 6.3, (min(860px, 100vw - 360px) - 70px) / 11), 72px);
    flex: 1; justify-content: center; gap: 12px;
  }
  .wr-boards { gap: clamp(28px, 4vw, 56px); }
  .wr-board.wr-mini, .wr-board.wr-mini .wr-row { gap: 5px; }
  .wr-board.wr-mini .wr-tile, .wr-board.wr-mid .wr-tile {
    width: var(--tile); height: var(--tile); border-width: 2px; border-radius: 4px; font-size: calc(var(--tile) * 0.55);
  }
  .wr-board.wr-mini .wr-tile.wr-G { box-shadow: 0 0 10px rgba(245,121,58,.5); }
  .wr-board.wr-mini .wr-tile.wr-Y { box-shadow: 0 0 10px rgba(74,158,255,.5); }
  .wr-label, .wr-right .wr-label, .wr-spectator .wr-right .wr-label { font-size: 17px; max-width: calc(var(--tile) * 5.6); }
  .wr-keyboard { max-width: 600px; gap: 7px; }
  .wr-key { max-width: 54px; height: clamp(44px, 5.4dvh, 56px); font-size: 17px; }
  .wr-key.wr-wide { max-width: 84px; }
  .wr-submit { max-width: 600px; }
  .wr-status { font-size: 15px; }
}
