/* Rock Paper Scissors — mode toggle, arena, throw buttons, and stats extras.
   Shared page, button, and stats styles live in /assets/site.css. The yellow
   stays yellow in dark mode. White text is unreadable on yellow, so this game
   switches the shared "ink" (page text, header, links) to near-black. */

body.game-rps {
  --game-bg: #FFC61A;
  --game-deep: #C99400;
  --game-accent: #A65A00;         /* big numbers and links on white cards */
  --game-ink: #1F1A0E;
  --game-ink-rgb: 31, 26, 14;
  --game-on-white: #1F1A0E;
  --game-focus: #1F1A0E;
  --card-line: #F6EBCB;
  --win: #1B7F3B;
  --lose: #C0282D;
  --tie: #4F4A40;
  --hand: min(36vw, 160px);
  --throw: min(28vw, 120px);
}

/* Desktop and wide: the game column grows to 640px; hands and buttons scale up. */
@media (min-width: 900px) {
  body.game-rps { --hand: 210px; --throw: 170px; }
}

.rps-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 440px;
  padding: 6px 16px 0;
  text-align: center;
}

@media (min-width: 900px) { .rps-col { max-width: 672px; } }

/* ── Mode toggle: a dark pill ──────────────────────────── */

.rps-mode {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--game-ink);
}

.rps-mode label { position: relative; cursor: pointer; }

.rps-mode input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.rps-mode span {
  display: block;
  min-width: 96px;
  padding: 9px 18px;
  border-radius: 999px;
  color: var(--game-bg);
  font: 800 15px/1 var(--ws-font);
}

.rps-mode input:checked + span { background: #FFFFFF; color: var(--game-ink); }
.rps-mode input:focus-visible + span { outline: 3px solid #FFFFFF; outline-offset: 2px; }
.rps-mode input:disabled + span { cursor: default; }

.rps-caption {
  margin: 8px 0 0;
  font-size: 14px;
  font-weight: 600;
  opacity: 0.8;
}

/* ── Scoreboard ────────────────────────────────────────── */

.rps-score {
  margin: 14px 0 0;
  font-size: clamp(17px, 4.8vw, 21px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.rps-streak {
  min-height: 1.3em;
  margin: 2px 0 0;
  font-size: 14px;
  font-weight: 600;
}

/* ── Arena ─────────────────────────────────────────────── */

.rps-arena {
  display: flex;
  justify-content: center;
  gap: max(6vw, 20px);
  margin-top: 10px;
}

@media (min-width: 900px) { .rps-arena { gap: 64px; } }

.rps-side {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 26px;             /* room for the ready badge */
}

.rps-badge {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 13px;
  font-weight: 700;
  opacity: 0.7;
}

.rps-badge[hidden] { display: none; }

.rps-label {
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.rps-hand {
  display: grid;
  place-items: center;
  width: var(--hand);
  height: var(--hand);
  border: 3px solid var(--game-ink);
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 6px 0 var(--game-deep);
}

.rps-hand .emoji {
  font-size: calc(var(--hand) * 0.52);
  line-height: 1;
}

.rps-hand.is-shaking { animation: rps-shake 900ms ease-in-out; }

@keyframes rps-shake {
  0%, 33.3%, 66.6%, 100% { transform: translateY(0); }
  16.6%, 50%, 83.3% { transform: translateY(-22px); }
}

.rps-hand.is-win-W { animation: rps-pulse-win 1.2s ease-out 2; }
.rps-hand.is-win-L { animation: rps-pulse-lose 1.2s ease-out 2; }

@keyframes rps-pulse-win {
  0%   { box-shadow: 0 6px 0 var(--game-deep), 0 0 0 0 rgba(27, 127, 59, 0.75); }
  100% { box-shadow: 0 6px 0 var(--game-deep), 0 0 0 22px rgba(27, 127, 59, 0); }
}

@keyframes rps-pulse-lose {
  0%   { box-shadow: 0 6px 0 var(--game-deep), 0 0 0 0 rgba(192, 40, 45, 0.75); }
  100% { box-shadow: 0 6px 0 var(--game-deep), 0 0 0 22px rgba(192, 40, 45, 0); }
}

.rps-hand.is-win-W { border-color: var(--win); }
.rps-hand.is-win-L { border-color: var(--lose); }

/* ── Result and thinking line ──────────────────────────── */

.rps-result {
  min-height: 1.25em;
  margin: 18px 0 0;
  font-size: clamp(26px, 7.4vw, 34px);
  font-weight: 900;
  line-height: 1.2;
}

.rps-result.is-W { color: var(--win); }
.rps-result.is-L { color: var(--lose); }
.rps-result.is-T { color: var(--tie); }

.rps-thinking {
  min-height: 2.6em;
  margin: 4px 0 0;
  font-size: 15px;
  font-style: italic;
  font-weight: 600;
  line-height: 1.3;
  opacity: 0.72;
}

/* ── Throw buttons ─────────────────────────────────────── */

.rps-throws {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 8px;
}

@media (min-width: 900px) { .rps-throws { gap: 20px; } }

.rps-throw {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: var(--throw);
  aspect-ratio: 1;
  padding: 6px;
  border: 3px solid var(--game-ink);
  border-radius: 22px;
  background: #FFFFFF;
  color: var(--game-ink);
  cursor: pointer;
  box-shadow: 0 5px 0 var(--game-deep);
  transition: transform 80ms ease, box-shadow 80ms ease, opacity 150ms ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.rps-throw .emoji { font-size: calc(var(--throw) * 0.42); line-height: 1.05; }

.rps-throw-label { font: 800 clamp(14px, 4vw, 17px)/1 var(--ws-font); }

@media (min-width: 900px) { .rps-throw-label { font-size: 20px; } }

.rps-throw .kbd {
  position: absolute;
  top: 8px;
  right: 8px;
  margin: 0;
}

.rps-throw:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--game-deep); }
.rps-throw:disabled { opacity: 0.55; cursor: default; }

/* ── Stats page extras ─────────────────────────────────── */

.rps-legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--card-muted); }
.rps-legend i { display: inline-block; width: 10px; height: 10px; margin-right: 5px; border-radius: 2px; vertical-align: -1px; }

.rps-verdicts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 10px; }
.rps-verdicts h3 { margin: 0 0 2px; font-size: 13px; color: var(--card-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.rps-verdicts .verdict { font-size: 16px; }

.rps-headline { font-size: 18px; font-weight: 800; }
.rps-headline + .detail { margin-top: 4px; }

.rps-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.rps-pair h3 { margin: 0 0 2px; font-size: 13px; color: var(--card-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.rps-pair .big-number { font-size: 38px; }

.table td.rps-mode-smart, .table td.rps-mode-random { text-align: left; }

@media (hover: hover) and (pointer: fine) {
  .rps-throw:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 7px 0 var(--game-deep); }
  .rps-mode label:hover input:not(:checked):not(:disabled) + span { background: rgba(255, 255, 255, 0.12); }
}

@media (prefers-reduced-motion: reduce) {
  .rps-hand.is-shaking, .rps-hand.is-win-W, .rps-hand.is-win-L { animation: none; }
  .rps-throw { transition: none; }
}
