/* ==========================================================================
   games-history-royale.css — tryb Royale (historyczne loga)
   Wymaga: variables.css, layout.css
   ========================================================================== */

:root {
  --royale-form-win: #6cd896;
  --royale-form-draw: #eec170;
  --royale-form-loss: #f1757f;
  --royale-accent: #d4a017;
}

html:not([data-device="phone"]) .site-main:has(.games-page--royale-play),
html:not([data-device="phone"]) .site-main:has(.games-page--time-race-play),
html:not([data-device="phone"]) .site-main:has(.games-page--history-play) {
  width: min(calc(100% - 2 * var(--page-gutter)), var(--category-content-max, 1400px));
  max-width: var(--category-content-max, 1400px);
  margin-inline: auto;
  padding-top: var(--space-24);
  padding-inline: 0;
}

.games-sub-lobby__main--play {
  min-width: 0;
}

.royale-game {
  width: 100%;
  padding-bottom: 0;
}

.royale-game__shell {
  display: flex;
  flex-direction: column;
}

.royale-board {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-16);
  background: var(--surface-1);
  box-shadow: var(--shadow-sm);
}

html[data-theme="dark"] .royale-board {
  background: #1f1f1f;
  border-color: rgba(255, 255, 255, 0.1);
}

.royale-hud {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: var(--space-16);
  padding: var(--space-14) var(--space-16);
  border-bottom: 1px solid var(--border);
  background: transparent;
  box-shadow: none;
}

html[data-theme="dark"] .royale-hud {
  border-bottom-color: rgba(255, 255, 255, 0.1);
}

.royale-hud__left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-10);
  min-width: 0;
}

.royale-hud__mode {
  display: inline-flex;
  align-items: center;
  gap: var(--space-8);
  font-size: var(--fs-13);
  font-weight: var(--fw-700);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--royale-accent);
}

.royale-hud__lives {
  display: inline-flex;
  align-items: center;
  gap: var(--space-6);
}

.royale-hud__heart {
  font-size: 1rem;
  color: var(--royale-form-loss);
  transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-out);
}

.royale-hud__heart.is-lost {
  opacity: 0.2;
  transform: scale(0.88);
}

.royale-hud--time-race {
  grid-template-columns: minmax(0, 1fr) auto;
}

.royale-game--rush .royale-hud__left {
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-4);
}

.royale-hud__progress {
  font-family: var(--font-score);
  font-size: var(--fs-18);
  font-weight: var(--fw-700);
  line-height: 1;
  color: var(--fg);
}

.royale-hud__score {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-2);
}

.royale-hud__score-label {
  font-size: var(--fs-12);
  font-weight: var(--fw-600);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.royale-hud__score-value {
  font-family: var(--font-score);
  font-size: var(--fs-24);
  font-weight: var(--fw-700);
  line-height: 1;
  color: var(--fg);
}

.royale-timer {
  display: flex;
  align-items: center;
  gap: var(--space-12);
  padding: var(--space-12) var(--space-16);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-2) 55%, transparent);
}

html[data-theme="dark"] .royale-timer {
  border-bottom-color: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
}

.royale-timer__track {
  flex: 1;
  height: 10px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.royale-timer__fill {
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: var(--royale-form-win);
  transition: width 100ms linear, background var(--dur-2) var(--ease-out);
}

.royale-timer.is-warning .royale-timer__fill {
  background: var(--royale-form-draw);
}

.royale-timer.is-danger .royale-timer__fill {
  background: var(--royale-form-loss);
}

.royale-timer__value {
  min-width: 2ch;
  font-family: var(--font-score);
  font-size: var(--fs-18);
  font-weight: var(--fw-700);
  text-align: right;
  color: var(--fg);
}

.royale-stage {
  position: relative;
  flex: 1;
  min-height: 460px;
  padding: var(--space-24);
  overflow: hidden;
  background:
    radial-gradient(circle at 15% 12%, rgba(108, 216, 150, 0.12), transparent 38%),
    radial-gradient(circle at 85% 88%, rgba(241, 117, 127, 0.1), transparent 34%),
    linear-gradient(180deg, var(--surface-1), var(--surface-2));
  box-shadow: none;
  border: none;
  border-radius: 0;
}

html[data-theme="dark"] .royale-stage {
  background:
    radial-gradient(circle at 15% 12%, rgba(108, 216, 150, 0.08), transparent 38%),
    radial-gradient(circle at 85% 88%, rgba(241, 117, 127, 0.07), transparent 34%),
    linear-gradient(180deg, #1f1f1f, #171717);
}

.royale-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-16);
  min-height: 412px;
  text-align: center;
}

.royale-screen[hidden] {
  display: none !important;
}

.royale-screen__badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-8);
  padding: var(--space-8) var(--space-14);
  border-radius: var(--radius-pill);
  font-size: var(--fs-13);
  font-weight: var(--fw-700);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--royale-accent);
  background: color-mix(in srgb, var(--royale-accent) 14%, transparent);
}

.royale-screen__badge--end {
  color: var(--fg);
  background: var(--surface-2);
}

.royale-screen__title {
  margin: 0;
  font-family: var(--font-score);
  font-size: var(--fs-24);
  font-weight: var(--fw-700);
  line-height: var(--lh-tight);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--fg);
}

.royale-screen__text {
  margin: 0;
  max-width: 36ch;
  font-size: var(--fs-14);
  line-height: var(--lh-relaxed);
  color: var(--muted);
}

.royale-screen__result {
  margin: 0;
  font-size: var(--fs-16);
  color: var(--muted);
}

.royale-screen__result strong {
  display: block;
  margin-top: var(--space-8);
  font-family: var(--font-score);
  font-size: 2.5rem;
  font-weight: var(--fw-700);
  color: var(--fg);
}

.royale-screen__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-12);
  margin-top: var(--space-8);
}

.royale-countdown__value {
  font-family: var(--font-score);
  font-size: clamp(4rem, 18vw, 7rem);
  font-weight: var(--fw-700);
  line-height: 1;
  color: var(--fg);
  animation: royale-countdown-pop 800ms var(--ease-out);
}

@keyframes royale-countdown-pop {
  0% {
    opacity: 0;
    transform: scale(0.6);
  }
  60% {
    opacity: 1;
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

.royale-logo-frame {
  position: relative;
  width: min(100%, 420px);
  aspect-ratio: 4 / 3;
  margin-inline: auto;
  border-radius: var(--radius-16);
  overflow: hidden;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border);
}

.royale-logo-frame__image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: var(--space-24);
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.2));
}

.royale-logo-frame__flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--dur-2) var(--ease-out);
}

.royale-logo-frame__flash.is-correct {
  background: color-mix(in srgb, var(--royale-form-win) 42%, transparent);
  opacity: 1;
}

.royale-logo-frame__flash.is-wrong {
  background: color-mix(in srgb, var(--royale-form-loss) 42%, transparent);
  opacity: 1;
}

.royale-logo-frame__reveal {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: var(--space-16) var(--space-14);
  background: transparent;
  pointer-events: none;
}

.royale-logo-frame__reveal-name {
  margin: 0;
  max-width: 100%;
  font-family: var(--font-score);
  font-size: var(--fs-16);
  font-weight: var(--fw-700);
  line-height: var(--lh-tight);
  letter-spacing: 0.02em;
  text-align: center;
  color: var(--fg);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

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

.games-sub-lobby__loading {
  margin: var(--space-32) auto;
  text-align: center;
  font-size: var(--fs-14);
  color: var(--muted);
}

.royale-answer {
  width: min(100%, 420px);
  margin-top: var(--space-8);
}

.royale-answer__label {
  display: block;
  margin-bottom: var(--space-8);
  font-size: var(--fs-12);
  font-weight: var(--fw-600);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
}

.royale-answer__input {
  width: 100%;
  min-height: 52px;
  padding: var(--space-14) var(--space-16);
  border: 2px solid var(--border);
  border-radius: var(--radius-12);
  font-family: var(--font-sans);
  font-size: var(--fs-18);
  font-weight: var(--fw-500);
  color: var(--fg);
  background: var(--surface-1);
}

.royale-answer__input:focus,
.royale-answer__input:focus-visible {
  outline: none;
  border-color: var(--border);
  box-shadow: none;
}

.royale-answer__input:disabled {
  opacity: 0.6;
}

.royale-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: var(--space-12) var(--space-24);
  border: 1px solid transparent;
  border-radius: var(--radius-12);
  font-family: var(--font-sans);
  font-size: var(--fs-14);
  font-weight: var(--fw-700);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-out);
}

.royale-btn:hover {
  opacity: 0.92;
}

.royale-btn--primary {
  color: #333333;
  background: #ffffff;
}

html[data-theme="light"] .royale-btn--primary {
  color: #ffffff;
  background: #333333;
}

.royale-btn--ghost {
  color: var(--fg);
  background: transparent;
  border-color: var(--border);
}

@media (max-width: 640px) {
  .royale-hud {
    grid-template-columns: 1fr;
    justify-items: start;
  }

  .royale-hud__score {
    align-items: flex-start;
  }

  .royale-stage {
    min-height: 460px;
    padding: var(--space-16);
  }

  .royale-screen {
    min-height: 420px;
  }
}
