/* Holy Seven Seconds: game page and board.
   GenieSolos tokens only (css/style.css :root, dark remap at
   :root[data-theme="dark"]). No new colors: green/sun/violet/ink family,
   same as the rest of the site. Space Grotesk throughout (--sans). */

/* Text that sits on a bright fill (the brand gradient, violet). In dark
   theme --ink and --paper turn light while the fills stay bright, so the
   text flips to the near-black canvas token instead (14:1 or better). */
.h7s-main {
  --h7s-on-fill: var(--ink);
  --h7s-on-violet: var(--paper);
}
:root[data-theme="dark"] .h7s-main {
  --h7s-on-fill: var(--cream);
  --h7s-on-violet: var(--cream);
}

.h7s-main {
  max-width: var(--maxw);
  margin: 0 auto;
  /* .nav is position: fixed (css/style.css), so the page's first section
     clears it itself with top padding. */
  padding: calc(var(--nav-h) + 28px) clamp(16px, 4vw, 32px) 80px;
}

.h7s-title {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 600;
  font-size: clamp(1.9rem, 5vw, 2.7rem);
  color: var(--ink);
  margin: 0 0 6px;
}

.h7s-tagline {
  font-size: 1.05rem;
  color: var(--ink-2);
  margin: 0 0 20px;
  max-width: 46em;
}

.h7s-crumb {
  font-family: var(--mono);
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0 0 18px;
}

.h7s-crumb a {
  color: var(--muted);
  text-decoration: none;
}

.h7s-crumb a:hover,
.h7s-crumb a:focus-visible {
  color: var(--violet);
  text-decoration: underline;
}

.h7s-layout {
  display: grid;
  gap: clamp(24px, 4vw, 40px);
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}

@media (min-width: 900px) {
  .h7s-layout {
    grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.9fr);
  }
}

/* ---------- the game panel ---------- */

.h7s-game {
  position: relative;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: clamp(18px, 3.5vw, 30px);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.h7s-game.is-right {
  border-color: var(--green);
  box-shadow: 0 0 0 5px rgba(46, 212, 127, 0.2), var(--shadow-lg);
}

.h7s-game.is-wrong {
  border-color: var(--amber);
  box-shadow: 0 0 0 5px rgba(240, 163, 26, 0.22), var(--shadow-lg);
  animation: h7s-shake 0.42s ease;
}

@keyframes h7s-shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-9px); }
  40%      { transform: translateX(9px); }
  60%      { transform: translateX(-5px); }
  80%      { transform: translateX(5px); }
}

:root[data-theme="dark"] .h7s-game {
  box-shadow: var(--shadow-lg), 0 0 40px -18px rgba(0, 255, 156, 0.35);
}

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

.h7s-hud {
  display: flex;
  align-items: stretch;
  gap: 10px;
  margin-bottom: 18px;
}

.h7s-hud__stat {
  flex: 1 1 0;
  background: var(--band);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  padding: 8px 10px;
  text-align: center;
  min-width: 0;
}

.h7s-hud__stat--wide {
  flex-grow: 1.4;
}

.h7s-hud__label {
  display: block;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.3;
  color: var(--muted);
}

.h7s-hud__value {
  display: block;
  font-family: var(--sans);
  font-size: clamp(1.4rem, 5vw, 2rem);
  font-weight: 700;
  line-height: 1.15;
  color: var(--ink);
}

.h7s-hud__value.is-pop {
  animation: h7s-pop 0.4s cubic-bezier(0.34, 1.7, 0.5, 1);
  color: var(--green-deep);
}

@keyframes h7s-pop {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.32); }
  100% { transform: scale(1); }
}

.h7s-mute {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  line-height: 1;
}

.h7s-mute:hover { border-color: var(--violet); color: var(--violet); }
.h7s-mute.is-muted { color: var(--muted); }

/* ---------- timer ---------- */

.h7s-timer {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  transition: opacity 0.25s ease;
}

.h7s-timer.is-idle { opacity: 0.35; }

.h7s-timer__track {
  flex: 1 1 auto;
  height: 16px;
  background: var(--cream-2);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 2px 5px rgba(41, 36, 55, 0.18);
}

.h7s-timer__bar {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--green-bright), var(--sun-bright));
  transition: width 0.09s linear, background 0.2s ease;
}

.h7s-timer.is-low .h7s-timer__bar {
  background: linear-gradient(90deg, var(--amber), var(--sun-bright));
}

.h7s-timer__clock {
  flex: 0 0 auto;
  min-width: 3.6em;
  margin: 0;
  text-align: right;
  font-family: var(--mono);
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.h7s-timer.is-low .h7s-timer__clock {
  color: var(--amber-deep);
  animation: h7s-blink 0.7s steps(2, end) infinite;
}

@keyframes h7s-blink { 50% { opacity: 0.4; } }

/* ---------- screens ---------- */

.h7s-screen {
  text-align: center;
}

.h7s-screen[hidden] { display: none; }

.h7s-screen__flag {
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--violet);
  margin: 0 0 8px;
}

.h7s-screen__flag--stop { color: var(--amber-deep); }

.h7s-screen__title {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.6rem, 4.5vw, 2.2rem);
  font-weight: 600;
  margin: 0 0 18px;
  color: var(--ink);
}

.h7s-screen__foot {
  font-size: 0.95rem;
  color: var(--muted);
  margin: 14px 0 0;
}

.h7s-rules {
  max-width: 480px;
  margin: 0 auto 22px;
  padding: 0;
  list-style: none;
  counter-reset: rule;
  text-align: left;
}

.h7s-rules li {
  counter-increment: rule;
  position: relative;
  padding: 9px 0 9px 46px;
  font-size: 1rem;
  color: var(--ink-2);
  border-bottom: 1px solid var(--line-soft);
}

.h7s-rules li:last-child { border-bottom: 0; }

.h7s-rules li::before {
  content: counter(rule);
  position: absolute;
  left: 0;
  top: 8px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--grad-brand);
  color: var(--h7s-on-fill);
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 30px;
  text-align: center;
}

.h7s-rules strong { color: var(--violet); }

.h7s-best-line {
  font-family: var(--mono);
  font-size: 0.95rem;
  color: var(--ink-2);
  margin: 0 0 20px;
}

.h7s-best-line strong {
  color: var(--green-deep);
  font-size: 1.1rem;
}

/* ---------- buttons ---------- */

.h7s-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  padding: 12px 30px;
  border-radius: 999px;
  border: 2px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.14s ease, box-shadow 0.2s ease,
              background-color 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}

.h7s-btn--go {
  background: var(--grad-brand);
  color: var(--h7s-on-fill);
  box-shadow: var(--shadow-md);
}

.h7s-btn--go:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* Light theme only: Start game, Lock it in, and Play again (all
   .h7s-btn--go) and a picked tile trade the green-yellow-violet grad-brand
   rainbow for solid green, exactly the fill, text color, and shadow
   css/style.css uses for .btn--solid. Dark theme keeps the rainbow above
   unchanged, per Gene's call: it stays as is. */
:root:not([data-theme="dark"]) .h7s-btn--go,
:root:not([data-theme="dark"]) .h7s-book__btn.is-picked {
  background: linear-gradient(100deg, var(--green-bright), #19B56A);
}
:root:not([data-theme="dark"]) .h7s-btn--go {
  color: #10331F;
  box-shadow: 0 14px 30px -12px rgba(23, 161, 94, .55);
}
:root:not([data-theme="dark"]) .h7s-btn--go:hover:not(:disabled) {
  box-shadow: 0 18px 38px -12px rgba(23, 161, 94, .65);
}
:root:not([data-theme="dark"]) .h7s-book__btn.is-picked .h7s-book__name {
  color: #10331F;
}

.h7s-btn--ghost {
  background: transparent;
  color: var(--ink-2);
  border-color: var(--line);
}

.h7s-btn--ghost:hover:not(:disabled) {
  border-color: var(--violet);
  color: var(--violet);
}

.h7s-btn:active:not(:disabled) { transform: translateY(1px); }

.h7s-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.h7s-btn:focus-visible,
.h7s-book__btn:focus-visible,
.h7s-mute:focus-visible {
  outline: 3px solid var(--violet);
  outline-offset: 3px;
}

/* ---------- play screen: the board ---------- */

.h7s-prompt {
  font-family: var(--sans);
  font-size: clamp(1.05rem, 3vw, 1.35rem);
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 18px;
}

.h7s-board {
  list-style: none;
  margin: 0 auto 18px;
  padding: 0;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.h7s-board[data-count="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.h7s-board[data-count="4"],
.h7s-board[data-count="5"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.h7s-board[data-count="6"],
.h7s-board[data-count="7"],
.h7s-board[data-count="8"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }

@media (min-width: 560px) {
  .h7s-board[data-count="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .h7s-board[data-count="5"] { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .h7s-board[data-count="9"],
  .h7s-board[data-count="10"] { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

.h7s-book { display: block; }

.h7s-book__btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 64px;
  padding: 14px 10px;
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: var(--r);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.14s ease, box-shadow 0.2s ease,
              background-color 0.2s ease, border-color 0.2s ease;
}

.h7s-book__btn:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--violet-bright);
}

.h7s-book__btn:active { transform: translateY(0); }

.h7s-book__name {
  font-family: var(--sans);
  font-size: clamp(0.95rem, 2.6vw, 1.2rem);
  font-weight: 700;
  line-height: 1.25;
  color: var(--ink);
  overflow-wrap: break-word;
  text-align: center;
}

.h7s-book__btn.is-picked {
  background: var(--grad-brand);
  border-color: var(--ink);
}

.h7s-book__btn.is-picked .h7s-book__name { color: var(--h7s-on-fill); }

.h7s-book__badge {
  position: absolute;
  top: -10px;
  left: -10px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--violet);
  color: var(--h7s-on-violet);
  border: 2px solid var(--paper);
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 700;
  line-height: 28px;
  text-align: center;
  transform: scale(0);
  transition: transform 0.2s cubic-bezier(0.34, 1.7, 0.5, 1);
}

.h7s-book__btn.is-picked .h7s-book__badge { transform: scale(1); }

.h7s-chosen {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink-2);
  margin: 0 0 18px;
  min-height: 1.6em;
}

.h7s-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.h7s-hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 16px 0 0;
}

.h7s-hint kbd {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--cream-2);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--ink);
}

/* ---------- game over ---------- */

.h7s-reason {
  font-size: 1.05rem;
  color: var(--ink-2);
  margin: 0 0 14px;
}

.h7s-final {
  font-family: var(--sans);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 6px;
}

.h7s-final__num {
  display: inline-block;
  min-width: 1.4em;
  margin-left: 6px;
  font-size: clamp(2.2rem, 7vw, 3.2rem);
  font-weight: 800;
  line-height: 1;
  color: var(--violet);
  vertical-align: -0.14em;
}

.h7s-newbest {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--violet-deep);
  background: var(--lilac);
  border-radius: 999px;
  padding: 4px 14px;
  margin: 0 0 18px;
}

.h7s-newbest[hidden] { display: none; }

.h7s-best-final {
  font-size: 0.95rem;
  color: var(--muted);
  margin: 0 0 20px;
}

.h7s-answerbox {
  max-width: 640px;
  margin: 0 auto 24px;
  padding: 16px;
  background: var(--band);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
}

.h7s-answerbox__label {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 12px;
}

.h7s-answer {
  list-style: none;
  counter-reset: answer;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.h7s-answer__item {
  counter-increment: answer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 6px 6px;
  background: var(--paper);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
}

.h7s-answer__item::before {
  content: counter(answer);
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--violet);
  color: var(--h7s-on-violet);
  font-size: 0.85rem;
  line-height: 24px;
  text-align: center;
}

.h7s-over-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.h7s-share__msg {
  display: block;
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--green-deep);
}

.h7s-share__msg[hidden] { display: none; }

/* ---------- confetti ---------- */

.h7s-confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.h7s-confetti__bit {
  position: absolute;
  top: -16px;
  width: 10px;
  height: 14px;
  border-radius: 2px;
  background: var(--green-bright);
  opacity: 0;
  animation: h7s-fall 1.25s ease-in forwards;
}

.h7s-confetti__bit.is-alt { background: var(--violet-bright); }

@keyframes h7s-fall {
  0%   { opacity: 1; transform: translate3d(0, 0, 0) rotate(0deg); }
  100% { opacity: 0; transform: translate3d(var(--drift, 0), 420px, 0) rotate(var(--spin, 360deg)); }
}

/* ---------- sidebar: how to play / best / credit ---------- */

.h7s-side {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.h7s-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.h7s-card h2 {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 10px;
}

.h7s-card p {
  font-size: 0.95rem;
  color: var(--ink-2);
  margin: 0 0 8px;
}

.h7s-card p:last-child { margin-bottom: 0; }

.h7s-credit a {
  color: var(--violet);
  font-weight: 600;
}

.h7s-more {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--violet);
  text-decoration: none;
}

.h7s-more:hover,
.h7s-more:focus-visible { text-decoration: underline; }

/* ---------- accessibility ---------- */

.h7s-status {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- narrow phones ---------- */

@media (max-width: 480px) {
  /* No keyboard to press 1-9 on. */
  .h7s-hint { display: none; }
}

@media (max-width: 380px) {
  .h7s-hud__label { font-size: 0.62rem; }
  .h7s-controls { flex-direction: column; align-items: stretch; }
  .h7s-btn { width: 100%; }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .h7s-game.is-wrong,
  .h7s-hud__value.is-pop,
  .h7s-timer.is-low .h7s-timer__clock,
  .h7s-confetti__bit {
    animation: none;
  }

  .h7s-btn,
  .h7s-book__btn,
  .h7s-book__badge {
    transition: none;
  }

  .h7s-btn--go:hover:not(:disabled),
  .h7s-book__btn:hover {
    transform: none;
  }
}
