/* ===== Boggle — game UI ===== */
:root { --cube: min(21vw, 84px); }
html, body { overflow-x: hidden; }
.wrap {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex; flex-direction: column; align-items: center;
  gap: 12px;
  padding: clamp(18px, 5vw, 34px) 14px 40px;
}
.head { width: 100%; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.title { margin: 0; font-size: clamp(24px, 6vw, 30px); letter-spacing: -.02em; }
.meta { display: flex; gap: 14px; font-size: 13.5px; color: var(--gc-text-muted); }
.meta__item b { color: var(--gc-text); font-variant-numeric: tabular-nums; }

.board {
  display: grid;
  grid-template-columns: repeat(4, var(--cube));
  grid-template-rows: repeat(4, var(--cube));
  gap: 8px;
  padding: 10px;
  background: var(--gc-surface-2);
  border: 1px solid var(--gc-border);
  border-radius: 14px;
  box-shadow: var(--gc-shadow);
}
.cube {
  appearance: none; cursor: pointer; font: inherit;
  border: 0; margin: 0; border-radius: 10px;
  background: linear-gradient(160deg, var(--gc-surface), var(--gc-surface-2));
  border: 1px solid var(--gc-border);
  color: var(--gc-text);
  font-size: calc(var(--cube) * 0.42); font-weight: 800; text-transform: uppercase;
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.06);
  transition: background .12s ease, transform .06s ease, box-shadow .12s ease;
}
.cube:hover { border-color: var(--gc-accent); }
.cube:active { transform: translateY(1px); }
.cube:focus-visible { outline: none; box-shadow: var(--gc-ring); }
.cube--sel {
  background: color-mix(in srgb, var(--gc-accent) 30%, var(--gc-surface));
  border-color: var(--gc-accent);
  box-shadow: inset 0 0 0 2px var(--gc-accent);
}
.cube--hint {
  background: color-mix(in srgb, #c9b458 30%, var(--gc-surface));
  border-color: #c9b458;
  animation: hintpulse 1s ease-in-out infinite;
}
@keyframes hintpulse {
  0%, 100% { box-shadow: inset 0 0 0 2px #c9b458; }
  50% { box-shadow: inset 0 0 0 4px #c9b458; }
}
.cube:disabled { cursor: default; }

.building { min-height: 34px; }
.building__word {
  font-size: 22px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  color: var(--gc-text);
}
.toast { min-height: 20px; font-size: 13.5px; font-weight: 600; color: var(--gc-text-muted); }
.toast--ok { color: #12a06e; }
.toast--bad { color: #e5484d; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; max-width: 380px; }
.btn {
  appearance: none; cursor: pointer; font: inherit; font-size: 13.5px; font-weight: 600;
  padding: 10px 12px; border-radius: 10px; flex: 1; white-space: nowrap;
  border: 1px solid var(--gc-border); background: var(--gc-surface); color: var(--gc-text);
  transition: transform .06s ease, border-color .15s ease;
}
.btn:hover { border-color: var(--gc-accent); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--gc-ring); }
.btn--primary { background: var(--gc-accent); border-color: var(--gc-accent); color: var(--gc-on-accent); }

.found {
  list-style: none; margin: 4px 0 0; padding: 0;
  width: 100%; max-width: 380px;
  display: flex; flex-wrap: wrap; gap: 6px;
}
.found:empty { display: none; }
.found li {
  font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
  background: var(--gc-surface-2); border: 1px solid var(--gc-border); color: var(--gc-text);
}
.found li b { color: #12a06e; font-variant-numeric: tabular-nums; }

.sub { margin: 0; color: var(--gc-text-muted); font-size: 13px; text-align: center; }

/* Overlay */
.overlay { position: fixed; inset: 0; z-index: 500; display: flex; align-items: center; justify-content: center; background: rgba(6, 12, 20, .55); backdrop-filter: blur(3px); padding: 16px; }
.overlay[hidden] { display: none; }
.overlay__card { width: min(92vw, 360px); text-align: center; padding: 26px 24px; border-radius: 16px; background: var(--gc-surface); border: 1px solid var(--gc-border); box-shadow: var(--gc-shadow-hi); animation: cardpop .3s ease; }
@keyframes cardpop { from { transform: scale(.9); opacity: 0; } }
.overlay__card h2 { margin: 0 0 6px; font-size: 26px; }
.overlay__card p { margin: 0 0 18px; color: var(--gc-text-muted); }
.overlay__actions { display: flex; gap: 10px; justify-content: center; }
.overlay__actions .btn { width: auto; flex: none; }

/* Rules modal — the full-screen overlay scrolls, never the card itself. */
.rules { position: fixed; inset: 0; z-index: 600; display: flex; padding: 16px; overflow-y: auto; overscroll-behavior: contain; }
.rules[hidden] { display: none; }
.rules__backdrop { position: fixed; inset: 0; background: rgba(6, 12, 20, .55); backdrop-filter: blur(3px); }
.rules__panel { position: relative; z-index: 1; margin: auto; width: min(92vw, 460px); padding: 24px 26px; border-radius: 16px; background: var(--gc-surface); border: 1px solid var(--gc-border); box-shadow: var(--gc-shadow-hi); }
.rules__title { margin: 0 0 12px; font-size: 22px; letter-spacing: -.01em; }
.rules__panel p { margin: 0 0 12px; color: var(--gc-text-muted); font-size: 14px; line-height: 1.55; }
.rules__panel p b { color: var(--gc-text); }
.rules__legend { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.rules__legend li { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--gc-text-muted); }
.rules__legend li b { color: var(--gc-text); }
.sc { flex: none; width: 30px; height: 26px; padding: 0 4px; display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; background: var(--gc-surface-2); border: 1px solid var(--gc-border); font-weight: 800; color: var(--gc-text); }
.rules__actions { display: flex; justify-content: center; margin-top: 4px; }
.rules__actions .btn { width: auto; flex: none; }

@media (prefers-reduced-motion: reduce) {
  .cube, .btn, .overlay__card { transition: none; animation: none; }
  .cube--hint { animation: none; box-shadow: inset 0 0 0 3px #c9b458; }
}
