/* ==========================================================================
   Word Racer Arena — Game Board & Effects
   Adapted from word-racer.html, namespaced with wr- prefixes so it can
   safely sit alongside Bootstrap and the rest of the site.
   ========================================================================== */

.wr-game-header { text-align: center; padding: 20px 0 18px; }
.wr-game-header .wordmark { font-size: clamp(24px, 6vw, 30px); font-weight: 800; letter-spacing: -1px; line-height: 1; }
.wr-game-header .wordmark span.w1 { color: var(--accent-violet); }
.wr-game-header .wordmark span.w2 { color: var(--ink); }
.wr-game-header .wordmark span.w3 { color: var(--accent-lime); }
.wr-game-header .tagline { font-size: 13px; color: #888; margin-top: 6px; }

.wr-landing-card {
  background: #fff; border-radius: 20px; padding: 26px 22px 30px;
  box-shadow: var(--shadow-card);
}
.wr-landing-card h2 { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.wr-landing-card p { font-size: 13px; color: #666; line-height: 1.6; margin-bottom: 20px; }
.wr-size-label { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: #aaa; margin-bottom: 10px; display: block; }

.wr-size-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 22px; }
.wr-size-btn {
  border: 2px solid var(--tile-border); border-radius: 12px; background: #fff;
  padding: 12px 4px; cursor: pointer; transition: all .18s; text-align: center;
  position: relative;
}
.wr-size-btn .sz-main { display: block; font-size: 18px; font-weight: 800; color: var(--ink); font-family: var(--font-mono); }
.wr-size-btn .sz-sub { display: block; font-size: 10px; color: #aaa; margin-top: 2px; font-weight: 500; }
.wr-size-btn:hover { border-color: var(--accent-violet-light); background: #f7f5ff; }
.wr-size-btn.active { border-color: var(--accent-violet); background: #f0ecff; }
.wr-size-btn.active .sz-main { color: var(--accent-violet); }

/* Locked state (6x6 on screens <768px) — disabled, dimmed, with a small
   lock badge in the corner. The browser's native :disabled already blocks
   clicks/focus; these rules are purely the visual treatment on top. */
.wr-size-btn-locked { cursor: not-allowed; opacity: .55; background: #f7f7f7; }
.wr-size-btn-locked:hover { border-color: var(--tile-border); background: #f7f7f7; }
.wr-size-lock {
  position: absolute; top: 4px; right: 6px;
  font-size: 10px; color: var(--text-faint);
}

.wr-btn-start {
  width: 100%; background: var(--accent-violet); color: #fff; border: none;
  border-radius: 14px; padding: 16px; font-size: 16px; font-weight: 700;
  font-family: var(--font-display); cursor: pointer; transition: all .18s;
}
.wr-btn-start:hover { background: var(--accent-violet-dark); transform: translateY(-1px); }
.wr-btn-start:disabled { opacity: .6; cursor: default; transform: none; }

/* ── Stats bar ── */
.wr-stats-bar { display: flex; align-items: center; background: var(--board-bg); border-radius: 16px 16px 0 0; padding: 14px 18px; }
.wr-stat-item { flex: 1; }
.wr-stat-item.right { text-align: right; }
.wr-stat-item.center { text-align: center; }
.wr-stat-label { font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: #5a5670; }
.wr-stat-value { font-family: var(--font-mono); font-size: 24px; font-weight: 700; line-height: 1; margin-top: 2px; }
.wr-timer { color: var(--accent-lime); }
.wr-timer.urgent { color: var(--accent-coral); animation: wr-pulse-timer .5s ease-in-out infinite alternate; }
@keyframes wr-pulse-timer { to { opacity: .5; } }
.wr-current-score { color: #fff; transition: transform .15s; }
.wr-current-score.bump { transform: scale(1.4); color: var(--accent-lime); }
.wr-last-word { font-size: 13px; font-weight: 700; color: var(--accent-sky); font-family: var(--font-mono); letter-spacing: .05em; min-height: 18px; }

/* ── Board pod: grid + svg share ONE positioned ancestor (the fix) ── */
.wr-board-pod { background: var(--board-bg); padding: 12px 12px 16px; }
.wr-board-pod-hero { border-radius: 18px; max-width: 320px; }
.wr-board-inner { background: var(--board-rim); border-radius: 18px; padding: 10px; position: relative; }

.wr-grid {
  display: grid; gap: clamp(4px, 1.6vw, 10px); position: relative;
  user-select: none; -webkit-user-select: none;
  /* Columns are allowed to shrink below their content's natural size
     (minmax(0, 1fr) rather than 1fr) — this is what was missing before
     and caused 5x5/6x6 boards to overflow past the dark board panel:
     a plain `repeat(N, 1fr)` track will not shrink below the min-content
     width of whatever's inside it, and .wr-tile had a hard min-width via
     clamp(58px, ...), so once N x 58px+gaps exceeded the panel's width,
     the extra columns spilled out past the rounded edge instead of
     shrinking to fit. */
  grid-template-columns: repeat(var(--wr-cols, 4), minmax(0, 1fr));
}
.wr-grid-4col { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* Applied to .wr-grid the instant a match ends (engine's
   _lockBoard()) — turns off pointer-events on the whole
   grid so no drag/touch/click can begin on any tile, and dims the tiles
   so it's visually obvious the board is locked while the score submission
   is in flight (and afterward, until a new match starts). */
.wr-grid-locked { pointer-events: none; }
.wr-grid-locked .wr-tile { opacity: .55; cursor: default; }
.wr-grid-locked .wr-tile:hover { transform: none; box-shadow: 0 4px 0 var(--tile-shadow), 0 2px 8px rgba(0,0,0,.12); }

.wr-path-svg {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 10; overflow: visible;
}
.wr-connection-line {
  fill: none; stroke: var(--accent-violet-light); stroke-width: 4;
  stroke-linecap: round; stroke-linejoin: round; opacity: .8;
  filter: drop-shadow(0 0 6px rgba(123,97,255,0.6));
}
.wr-connection-node { fill: var(--accent-violet-light); opacity: .9; }

.wr-tile {
  /* Width is 100% of its (now shrinkable) grid column, with `aspect-ratio`
     keeping it square — no more independent fixed clamp() floor that
     ignored how many columns actually need to fit. A small max-width still
     caps how large tiles get on small boards / wide screens. */
  width: 100%;
  max-width: 78px;
  aspect-ratio: 1 / 1;
  min-width: 0;
  background: var(--tile-face); border-radius: var(--radius-tile);
  border: 2px solid var(--tile-border);
  box-shadow: 0 4px 0 var(--tile-shadow), 0 2px 8px rgba(0,0,0,.12);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 800;
  /* Letter size scales down as more columns are packed into the same
     width, instead of relying on container-query units (cqw) which would
     need an extra container-type declaration to work at all. 22px at 4
     columns, shrinking toward ~14px at 6 columns; clamp() keeps it sane
     at any --wr-cols value that might be set. */
  font-size: clamp(14px, calc(26px - 2px * var(--wr-cols, 4)), 22px);
  color: var(--ink); cursor: pointer; position: relative; touch-action: none;
  letter-spacing: -.02em; z-index: 1;
  transition: transform .1s, background .12s, box-shadow .12s, border-color .12s;
}
.wr-tile:hover { transform: translateY(-2px); box-shadow: 0 6px 0 var(--tile-shadow), 0 4px 12px rgba(0,0,0,.14); }
.wr-tile.selected {
  background: var(--selected-bg); border-color: #6650e0; color: var(--selected-text);
  box-shadow: 0 4px 0 #5040c0, 0 2px 16px rgba(123,97,255,.5);
  transform: translateY(-3px) scale(1.05); z-index: 5;
}
.wr-tile.found-flash { animation: wr-tile-found .6s ease forwards; }
@keyframes wr-tile-found {
  0% { background: var(--found-bg); color: var(--found-text); transform: scale(1.15) translateY(-4px); box-shadow: 0 6px 0 #78b800, 0 0 24px rgba(168,255,62,.6); }
  60% { background: var(--found-bg); color: var(--found-text); transform: scale(1.08) translateY(-2px); }
  100% { background: var(--tile-face); color: var(--ink); transform: scale(1); box-shadow: 0 4px 0 var(--tile-shadow); }
}

/* ── Score burst / confetti / banner ── */
.wr-score-burst {
  position: fixed; pointer-events: none; font-family: var(--font-mono);
  font-size: 22px; font-weight: 800; color: var(--accent-lime);
  text-shadow: 0 2px 8px rgba(0,0,0,.3); z-index: 9999;
  animation: wr-burst-up .9s ease forwards; white-space: nowrap;
}
@keyframes wr-burst-up {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  60% { opacity: 1; transform: translateY(-50px) scale(1.2); }
  100% { opacity: 0; transform: translateY(-90px) scale(.8); }
}
.wr-confetti-dot { position: fixed; width: 8px; height: 8px; border-radius: 2px; pointer-events: none; z-index: 9998; animation: wr-confetti-fall .8s ease forwards; }
@keyframes wr-confetti-fall {
  0% { opacity: 1; transform: translateY(0) rotate(0) scale(1); }
  100% { opacity: 0; transform: translateY(var(--dy)) translateX(var(--dx)) rotate(var(--rot)) scale(.4); }
}
@keyframes wr-score-ring {
  0% { box-shadow: 0 0 0 0 rgba(168,255,62,.6); }
  50% { box-shadow: 0 0 0 10px rgba(168,255,62,0); }
  100% { box-shadow: 0 0 0 0 rgba(168,255,62,0); }
}
.score-ring { animation: wr-score-ring .5s ease; }

.wr-word-banner {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%) translateY(-80px);
  background: var(--accent-lime); color: var(--ink); font-family: var(--font-mono);
  font-size: 14px; font-weight: 700; padding: 10px 22px; border-radius: 30px;
  letter-spacing: .08em; z-index: 9995; box-shadow: var(--shadow-pop);
  transition: transform .3s cubic-bezier(.34,1.56,.64,1), opacity .3s; opacity: 0; white-space: nowrap;
}
.wr-word-banner.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ── Input tray ── */
.wr-input-tray { background: var(--board-bg); padding: 14px 14px 18px; border-radius: 0 0 16px 16px; display: flex; align-items: center; gap: 10px; }
.wr-word-input {
  flex: 1; background: #2a2738; border: 2px solid #3d3a55; border-radius: 12px; color: #fff;
  font-family: var(--font-mono); font-size: 15px; font-weight: 700; padding: 12px 16px;
  outline: none; letter-spacing: .08em; text-transform: uppercase; transition: border-color .15s;
}
.wr-word-input::placeholder { color: #4a4760; font-weight: 400; letter-spacing: .02em; text-transform: none; }
.wr-word-input:focus { border-color: var(--accent-violet-light); }
.wr-word-input.invalid { border-color: var(--accent-coral); animation: wr-shake .3s; }
.wr-word-input:disabled { opacity: .5; cursor: default; }
@keyframes wr-shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.wr-btn-submit {
  width: 48px; height: 48px; background: var(--accent-violet); border: none; border-radius: 12px;
  color: #fff; font-size: 20px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all .15s; flex-shrink: 0;
}
.wr-btn-submit:hover { background: var(--accent-violet-dark); transform: scale(1.05); }
.wr-btn-submit:active { transform: scale(.96); }
.wr-btn-submit:disabled { opacity: .5; cursor: default; transform: none; background: var(--accent-violet); }

/* ── Found words strip ── */
.wr-found-strip { margin-top: 12px; min-height: 40px; display: flex; flex-wrap: wrap; gap: 6px; padding: 0 4px; }
.wr-found-chip {
  background: #1a1825; color: var(--accent-lime); font-family: var(--font-mono); font-size: 11px;
  font-weight: 700; padding: 5px 10px; border-radius: 20px; letter-spacing: .06em;
  animation: wr-chip-pop .3s cubic-bezier(.34,1.56,.64,1) both;
}
@keyframes wr-chip-pop { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ── Game over overlay ── */
.wr-gameover-overlay {
  position: fixed; inset: 0; background: rgba(15,14,23,.88); z-index: 9990;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  backdrop-filter: blur(6px); opacity: 0; pointer-events: none; transition: opacity .4s;
}
.wr-gameover-overlay.show { opacity: 1; pointer-events: all; }
.wr-gameover-card {
  background: #fff; border-radius: 24px; padding: 36px 28px; width: 100%; max-width: 360px;
  text-align: center; transform: translateY(30px) scale(.95); transition: transform .4s cubic-bezier(.34,1.56,.64,1);
}
.wr-gameover-overlay.show .wr-gameover-card { transform: translateY(0) scale(1); }
.wr-gameover-emoji { font-size: 52px; margin-bottom: 12px; }
.wr-gameover-title { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.wr-final-score { font-family: var(--font-mono); font-size: 52px; font-weight: 700; color: var(--accent-violet); line-height: 1; margin: 12px 0; }
.wr-final-score-label { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: #aaa; font-weight: 700; }
.wr-gameover-words { margin: 18px 0 24px; font-size: 13px; color: #888; }

.hidden { display: none !important; }
.view-game { animation: wr-fade-in .4s ease; }
@keyframes wr-fade-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ── Full-screen game modal (phones, <768px) ──
   .view-game is relocated into this modal's body via JS in play.php — see
   that file's script for the relocation logic. Overrides Bootstrap's
   default modal chrome (white box, padding, border-radius) so the game
   fills the entire viewport edge-to-edge instead of looking like a dialog
   sitting on top of the page. */
.wr-game-modal .modal-content {
  background: var(--canvas);
  border: none;
  border-radius: 0;
  min-height: 100vh;
}
.wr-game-modal .modal-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.wr-game-modal .arena-shell,
.wr-game-modal .view-game {
  width: 100%;
}
.wr-game-modal .view-game.hidden { display: none !important; }
