:root {
  color-scheme: light dark;
  --bg: #0d1b2a;
  --surface: #1b263b;
  --surface-light: #e0e1dd;
  --text: #e0e1dd;
  --accent: #e07a5f;
  --accent-strong: #f2cc8f;
  font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
  /* Remove mobile tap highlight globally */
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at top, rgba(14, 98, 199, 0.35), transparent 65%), var(--bg);
  color: var(--text);
}

.app-header,
.app-footer {
  text-align: center;
  padding: 1.5rem;
  background: rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.app-header h1 {
  margin: 0;
  font-size: clamp(2.2rem, 4vw, 3rem);
}

.tagline {
  margin-top: 0.5rem;
  color: var(--accent-strong);
  font-weight: 500;
}


.content {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 360px) minmax(0, 1fr);
  grid-template-areas:
    "controls arena"
    "scoreboard arena";
  gap: 1.5rem;
  padding: clamp(1rem, 4vw, 3rem);
  align-items: start;
  align-content: start;
}

.install-button {
  border: 1px solid rgba(242, 204, 143, 0.65);
  border-radius: 999px;
  padding: 0.6rem 1.4rem;
  background: rgba(13, 27, 42, 0.55);
  color: var(--surface-light);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25);
}

.install-button[hidden] {
  display: none;
}

.install-button:hover {
  transform: translateY(-1px);
  background: rgba(13, 27, 42, 0.7);
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.3);
}

.install-button:focus {
  outline: 2px solid rgba(242, 204, 143, 0.85);
  outline-offset: 2px;
}

.install-button:active {
  transform: translateY(0);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.28);
}

@media (max-width: 900px) {
  .content {
    grid-template-columns: 1fr;
    grid-template-areas:
      "controls"
      "arena"
      "scoreboard";
    gap: 1.25rem;
  }

  .controls {
    position: static;
    top: auto;
    align-self: stretch;
  }

  .arena {
    min-height: min(440px, 60vh);
  }

  .install-button {
    align-self: stretch;
  }
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  grid-area: scoreboard;
}

.score-card {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 1.25rem;
  text-align: center;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25);
}

.score-card--flash-personal {
  animation: score-card-flash-personal 0.9s ease-out;
}

.score-card--flash-personal-strong {
  animation: score-card-flash-personal-strong 1.2s ease-out;
}

.score-card--flash-global {
  animation: score-card-flash-global 1s ease-out;
}

.score-card--flash-global-strong {
  animation: score-card-flash-global-strong 1.25s ease-out;
}

.score {
  font-size: clamp(2.5rem, 5vw, 3.5rem);
  margin: 0.75rem 0 0;
  font-weight: 700;
}

.holder {
  margin: 0.35rem 0 0;
  font-size: 0.95rem;
  color: var(--accent-strong);
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 0.56rem;
  justify-content: center;
  grid-area: controls;
  position: sticky;
  top: clamp(0.75rem, 3vw, 1.5rem);
  align-self: start;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 20px;
  padding: clamp(0.64rem, 2.25vw, 1rem);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25);
}

.inline-score {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 0.6rem 0.9rem;
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.35);
}

.inline-score__label {
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.7);
}

.inline-score__value {
  font-size: clamp(1.8rem, 5vw, 2.5rem);
  font-weight: 700;
  color: #f2cc8f;
  text-shadow: 0 0 12px rgba(242, 204, 143, 0.45);
}

.reaction-inline {
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.8);
}

button {
  /* Remove tap highlight on all buttons */
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

.primary {
  border: none;
  border-radius: 999px;
  padding: 0.64rem 1.31rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--surface);
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.35);
}

.primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

.primary:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.4);
}

.player-input {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.71rem;
}

.player-input input {
  padding: 0.52rem 0.75rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
}

.player-input__notice {
  font-size: 0.65rem;
  color: rgba(224, 225, 221, 0.6);
  line-height: 1.3;
  margin-top: 0.25rem;
}

.player-input__notice a {
  color: var(--accent);
  text-decoration: none;
}

.player-input__notice a:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}

.status {
  min-height: 1.3rem;
  margin: 0;
}

.timer {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.arena {
  position: relative;
  min-height: min(540px, 65vh);
  border-radius: 32px;
  background: rgba(0, 0, 0, 0.25);
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.15);
  box-shadow: inset 0 0 32px rgba(0, 0, 0, 0.45);
  grid-area: arena;
}

.leaderboard {
  grid-column: 1 / -1;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  padding: clamp(1rem, 3vw, 1.75rem);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.leaderboard__header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.leaderboard__header h2 {
  margin: 0;
  font-size: clamp(1.6rem, 3.5vw, 2.2rem);
}

.leaderboard__subtitle {
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: 0.03em;
  color: rgba(255, 255, 255, 0.75);
}

.leaderboard__podium {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  grid-template-rows: auto auto;
  gap: 1rem;
  margin-bottom: 2rem;
  align-items: end;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

.leaderboard__podium-place {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
}

.leaderboard__podium-place--first {
  grid-column: 2;
  grid-row: 1;
  order: 2;
}

.leaderboard__podium-place--second {
  grid-column: 1;
  grid-row: 1;
  order: 1;
}

.leaderboard__podium-place--third {
  grid-column: 3;
  grid-row: 1;
  order: 3;
}

.leaderboard__podium-player {
  background: rgba(0, 0, 0, 0.4);
  border-radius: 16px;
  padding: 1rem;
  margin-bottom: 0.5rem;
  width: 100%;
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.35);
  border: 2px solid transparent;
  position: relative;
}

.leaderboard__podium-place--first .leaderboard__podium-player {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.2), rgba(255, 215, 0, 0.1));
  border-color: rgba(255, 215, 0, 0.5);
  transform: scale(1.1);
  animation: podium-glow 2s ease-in-out infinite alternate;
}

.leaderboard__podium-place--second .leaderboard__podium-player {
  background: linear-gradient(135deg, rgba(192, 192, 192, 0.2), rgba(192, 192, 192, 0.1));
  border-color: rgba(192, 192, 192, 0.5);
}

.leaderboard__podium-place--third .leaderboard__podium-player {
  background: linear-gradient(135deg, rgba(205, 127, 50, 0.2), rgba(205, 127, 50, 0.1));
  border-color: rgba(205, 127, 50, 0.5);
}

.leaderboard__podium-crown {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.leaderboard__podium-rank {
  font-size: 0.9rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 0.25rem;
}

.leaderboard__podium-name {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 0.25rem;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.leaderboard__podium-score {
  font-weight: 800;
  font-size: 1.1rem;
  color: #f2cc8f;
  text-shadow: 0 0 10px rgba(242, 204, 143, 0.45);
}

.leaderboard__podium-base {
  width: 100%;
  height: 40px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 8px 8px 0 0;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-bottom: none;
  position: relative;
}

.leaderboard__podium-place--first .leaderboard__podium-base {
  height: 60px;
  background: linear-gradient(180deg, rgba(255, 215, 0, 0.3), rgba(255, 215, 0, 0.1));
  border-color: rgba(255, 215, 0, 0.3);
}

.leaderboard__podium-place--second .leaderboard__podium-base {
  height: 50px;
  background: linear-gradient(180deg, rgba(192, 192, 192, 0.3), rgba(192, 192, 192, 0.1));
  border-color: rgba(192, 192, 192, 0.3);
}

.leaderboard__podium-place--third .leaderboard__podium-base {
  height: 40px;
  background: linear-gradient(180deg, rgba(205, 127, 50, 0.3), rgba(205, 127, 50, 0.1));
  border-color: rgba(205, 127, 50, 0.3);
}

@keyframes podium-glow {
  0% {
    box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.35), 0 0 20px rgba(255, 215, 0, 0.3);
  }
  100% {
    box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.35), 0 0 30px rgba(255, 215, 0, 0.6);
  }
}

.leaderboard__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.leaderboard__item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 1rem;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.35);
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.35);
}

.leaderboard__rank {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-strong);
  width: 2.5ch;
  text-align: right;
}

.leaderboard__name {
  font-weight: 600;
  letter-spacing: 0.03em;
}

.leaderboard__score {
  font-weight: 700;
  color: #f2cc8f;
  text-shadow: 0 0 10px rgba(242, 204, 143, 0.45);
}

.leaderboard__empty {
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.7);
}

.countdown {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(13, 27, 42, 0.55);
  backdrop-filter: blur(6px);
  color: #f2cc8f;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  z-index: 20;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.countdown span {
  font-size: clamp(3rem, 12vw, 5.5rem);
  text-shadow: 0 0 28px rgba(242, 204, 143, 0.65);
  animation: countdown-pulse 0.95s ease-in-out infinite;
}

.pulse {
  --size: clamp(64px, 12vw, 96px);
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.95), rgba(224, 122, 95, 0.95));
  position: absolute;
  display: none;
  box-shadow: 0 0 25px rgba(224, 122, 95, 0.7);
  cursor: pointer;
  transition: transform 0.12s ease;
  
  /* Remove mobile tap highlight */
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.pulse:active {
  transform: scale(0.95);
}

.app-footer {
  font-size: 0.9rem;
  opacity: 0.8;
}

.cache-version {
  font-size: 0.75rem;
  opacity: 0.6;
  margin: 0.5rem 0 0 0;
  color: var(--accent);
  font-family: 'Courier New', monospace;
  text-decoration: none;
  border: none;
  outline: none;
  cursor: default; /* Hide that it's clickable */
}

.cache-version:hover,
.cache-version:focus,
.cache-version:active,
.cache-version:visited {
  color: var(--accent); /* Keep same color always */
  text-decoration: none;
  outline: none;
}

.buy-coffee-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  color: var(--accent);
  text-decoration: none;
  opacity: 0.7;
  transition: opacity 0.2s ease, color 0.2s ease;
  border-radius: 4px;
}

.buy-coffee-link--header {
  margin-top: 0;
  margin-bottom: 0.5rem;
  align-self: flex-end;
  font-size: 0.8rem;
  opacity: 0.8;
}

.buy-coffee-link:hover {
  opacity: 1;
  color: var(--accent-strong);
}

.buy-coffee-link svg {
  opacity: 0.8;
  transition: opacity 0.2s ease;
}

.buy-coffee-link:hover svg {
  opacity: 1;
}

@media (max-width: 600px) {
  .app-header,
  .app-footer {
    padding: 1rem;
  }

  .content {
    padding: 1.25rem 1rem 2.5rem;
  }

  .controls {
    position: static;
    top: auto;
    z-index: auto;
  }

  .arena {
    min-height: min(420px, 58vh);
  }

  .leaderboard__podium {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
  }

  .leaderboard__podium-player {
    padding: 0.75rem 0.5rem;
  }

  .leaderboard__podium-crown {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
  }

  .leaderboard__podium-name {
    font-size: 0.85rem;
  }

  .leaderboard__podium-score {
    font-size: 0.95rem;
  }

  .leaderboard__podium-place--first .leaderboard__podium-player {
    transform: scale(1.05);
  }

  .leaderboard__podium-base {
    height: 30px;
  }

  .leaderboard__podium-place--first .leaderboard__podium-base {
    height: 45px;
  }

  .leaderboard__podium-place--second .leaderboard__podium-base {
    height: 37px;
  }

  .leaderboard__podium-place--third .leaderboard__podium-base {
    height: 30px;
  }

  .leaderboard__item {
    grid-template-columns: auto 1fr;
    grid-template-areas: 'rank name' 'rank score';
    gap: 0.5rem 0.75rem;
  }

  .leaderboard__rank {
    grid-area: rank;
  }

  .leaderboard__name {
    grid-area: name;
  }

  .leaderboard__score {
    grid-area: score;
  }

  .score-card {
    padding: 1rem;
  }

  .inline-score {
    justify-content: space-between;
    padding: 0.55rem 0.8rem;
  }

  .reaction-inline {
    text-align: center;
  }
}

.offline {
  color: #ffd166;
}

.success {
  color: #95d5b2;
}

.error {
  color: #ef476f;
}

#celebration-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
}

.celebration {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.celebration::before,
.celebration::after {
  content: '';
  position: absolute;
  pointer-events: none;
}

.celebration__label {
  font-size: clamp(1.4rem, 4vw, 2.5rem);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #ffffff;
  text-shadow: 0 0 18px rgba(14, 98, 199, 0.6), 0 0 32px rgba(224, 122, 95, 0.65);
  animation: celebration-label 2.2s ease-out forwards;
}

.celebration--personal {
  animation: celebration-fade 1.1s ease-out forwards;
}

.celebration--personal::before {
  top: 18%;
  left: 50%;
  width: 180px;
  height: 180px;
  margin-left: -90px;
  border-radius: 50%;
  border: 3px solid var(--accent-strong);
  box-shadow: 0 0 24px rgba(242, 204, 143, 0.7), 0 0 60px rgba(224, 122, 95, 0.4);
  animation: celebration-ring 1.05s ease-out forwards;
}

.celebration--personal::after {
  top: 16%;
  left: 50%;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.8), 0 0 35px rgba(224, 122, 95, 0.8);
  animation: celebration-spark 1.1s ease-out forwards;
}

.celebration--global {
  animation: celebration-fade 1.6s ease-out forwards;
}

.celebration--global::before {
  width: 65vmin;
  height: 65vmin;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(224, 122, 95, 0.65) 0%, rgba(13, 27, 42, 0) 70%);
  filter: blur(0.6px);
  animation: celebration-wave 1.4s ease-out forwards;
}

.celebration--global::after {
  width: 100%;
  height: 100%;
  background-image: radial-gradient(circle at 20% 20%, rgba(242, 204, 143, 0.45) 0 8px, transparent 9px), radial-gradient(circle at 80% 32%, rgba(224, 122, 95, 0.55) 0 10px, transparent 11px), radial-gradient(circle at 40% 72%, rgba(255, 255, 255, 0.4) 0 7px, transparent 8px);
  background-size: 240px 240px, 320px 320px, 280px 280px;
  opacity: 0.85;
  animation: celebration-particles 1.6s ease-out forwards;
}

.celebration--massive {
  animation: celebration-massive 2.3s ease-out forwards;
}

.celebration--massive::before {
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, rgba(224, 122, 95, 0.5), rgba(13, 27, 42, 0.05) 65%, rgba(13, 27, 42, 0) 100%);
  animation: celebration-bloom 1.4s ease-out forwards;
}

.celebration--massive::after {
  width: 100%;
  height: 100%;
  background-image: linear-gradient(120deg, rgba(242, 204, 143, 0.75) 0 20%, rgba(224, 122, 95, 0.7) 20% 40%, rgba(149, 213, 178, 0.65) 40% 60%, rgba(255, 209, 102, 0.7) 60% 80%, rgba(224, 122, 95, 0.7) 80% 100%);
  background-size: 140% 600%;
  mix-blend-mode: screen;
  opacity: 0.85;
  animation: celebration-streamers 2.3s ease-out forwards;
}

.celebration--massive .celebration__label {
  padding: 0.35em 0.9em;
  border-radius: 999px;
  background: rgba(13, 27, 42, 0.45);
  border: 2px solid rgba(242, 204, 143, 0.6);
}

@keyframes celebration-fade {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes celebration-ring {
  0% {
    transform: scale(0.3);
    opacity: 1;
  }
  70% {
    opacity: 0.9;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

@keyframes celebration-spark {
  0% {
    transform: translate(-50%, -50%) scale(0.6);
    opacity: 1;
  }
  60% {
    transform: translate(-30%, -30%) scale(1.2);
    opacity: 0.9;
  }
  100% {
    transform: translate(20%, 20%) scale(0.2);
    opacity: 0;
  }
}

@keyframes celebration-wave {
  0% {
    transform: scale(0.6);
    opacity: 0.8;
  }
  70% {
    opacity: 0.75;
  }
  100% {
    transform: scale(1.1);
    opacity: 0;
  }
}

@keyframes celebration-particles {
  0% {
    opacity: 0.95;
    transform: translate3d(0, 0, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate3d(0, 3%, 0) scale(1.05);
  }
}

@keyframes celebration-bloom {
  0% {
    transform: scale(0.5);
    opacity: 0.9;
  }
  100% {
    transform: scale(1.25);
    opacity: 0;
  }
}

@keyframes celebration-streamers {
  0% {
    background-position: 0% -40%;
    opacity: 0.9;
  }
  100% {
    background-position: 100% 120%;
    opacity: 0;
  }
}

@keyframes celebration-label {
  0% {
    transform: translateY(-20px) scale(0.9);
    opacity: 0;
  }
  30% {
    opacity: 1;
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 0;
  }
}

@keyframes countdown-pulse {
  0% {
    transform: scale(0.8);
    opacity: 0.2;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(0.95);
    opacity: 0.1;
  }
}

@keyframes score-card-flash-personal {
  0% {
    transform: scale(1);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25);
    background: rgba(255, 255, 255, 0.08);
  }
  35% {
    transform: scale(1.04);
    box-shadow: 0 18px 36px rgba(242, 204, 143, 0.55);
    background: linear-gradient(135deg, rgba(242, 204, 143, 0.25), rgba(224, 122, 95, 0.2));
  }
  100% {
    transform: scale(1);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25);
    background: rgba(255, 255, 255, 0.08);
  }
}

@keyframes score-card-flash-personal-strong {
  0% {
    transform: scale(1);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25);
    background: rgba(255, 255, 255, 0.08);
  }
  25% {
    transform: scale(1.05);
    box-shadow: 0 24px 40px rgba(242, 204, 143, 0.65);
    background: linear-gradient(135deg, rgba(242, 204, 143, 0.3), rgba(224, 122, 95, 0.3));
  }
  55% {
    transform: scale(1.025);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25);
    background: rgba(255, 255, 255, 0.08);
  }
}

@keyframes score-card-flash-global {
  0% {
    transform: scale(1);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25);
    background: rgba(255, 255, 255, 0.08);
  }
  35% {
    transform: scale(1.045);
    box-shadow: 0 20px 42px rgba(149, 213, 178, 0.5);
    background: linear-gradient(135deg, rgba(149, 213, 178, 0.28), rgba(242, 204, 143, 0.22));
  }
  100% {
    transform: scale(1);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25);
    background: rgba(255, 255, 255, 0.08);
  }
}

@keyframes score-card-flash-global-strong {
  0% {
    transform: scale(1);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25);
    background: rgba(255, 255, 255, 0.08);
  }
  30% {
    transform: scale(1.06);
    box-shadow: 0 26px 48px rgba(149, 213, 178, 0.6);
    background: linear-gradient(135deg, rgba(149, 213, 178, 0.35), rgba(242, 204, 143, 0.3));
  }
  65% {
    transform: scale(1.03);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25);
    background: rgba(255, 255, 255, 0.08);
  }
}

@media (prefers-reduced-motion: reduce) {
  .celebration,
  .celebration::before,
  .celebration::after,
  .celebration__label {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.modal[hidden] {
  opacity: 0;
  pointer-events: none;
}

.modal__backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  pointer-events: none;
}

.modal__content {
  position: relative;
  background: var(--surface);
  border-radius: 16px;
  padding: 2rem;
  max-width: 500px;
  width: 100%;
  border: 1px solid rgba(242, 204, 143, 0.2);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  transform: scale(0.95);
  transition: transform 0.3s ease;
}

.modal__close {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(224, 225, 221, 0.2);
  background: rgba(224, 225, 221, 0.1);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  color: rgba(224, 225, 221, 0.8);
  z-index: 1;
}

.modal__close:hover {
  background: rgba(224, 225, 221, 0.15);
  color: var(--text);
  transform: scale(1.05);
}

.modal__close:focus {
  outline: 2px solid rgba(242, 204, 143, 0.5);
  outline-offset: 2px;
}

.modal__close:active {
  transform: scale(0.95);
  background: rgba(224, 225, 221, 0.2);
}

.modal:not([hidden]) .modal__close {
  animation: closeButtonPulse 0.6s ease-out;
}

@keyframes closeButtonPulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(224, 225, 221, 0.4);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 0 4px rgba(224, 225, 221, 0.1);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(224, 225, 221, 0);
  }
}

.modal:not([hidden]) .modal__content {
  transform: scale(1);
}

.modal__header {
  text-align: center;
  margin-bottom: 2rem;
}

.modal__header h2 {
  margin: 0 0 0.5rem 0;
  font-size: 1.8rem;
  color: var(--text);
}

.modal__achievement {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 0.5rem;
  min-height: 1.5rem;
}

.modal__achievement--personal {
  color: var(--accent);
}

.modal__achievement--global {
  color: var(--accent-strong);
  text-shadow: 0 0 8px rgba(242, 204, 143, 0.3);
}

.modal__achievement--warning {
  color: #ff6b6b;
  text-shadow: 0 0 8px rgba(255, 107, 107, 0.3);
  font-size: 1.0rem;
}

.modal__stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: rgba(224, 225, 221, 0.05);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
  border: 1px solid rgba(224, 225, 221, 0.1);
}

.stat-card__label {
  display: block;
  font-size: 0.85rem;
  color: rgba(224, 225, 221, 0.7);
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.stat-card__value {
  display: block;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
}

/* Chart variant of stat card */
.stat-card--chart {
  grid-column: 1 / -1; /* Span full width */
  padding: 1rem 0.75rem;
}

.stat-card__chart {
  margin-top: 0.75rem;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100px;
}

.chart-placeholder {
  color: rgba(224, 225, 221, 0.5);
  font-size: 0.9rem;
  text-align: center;
}

.reaction-chart {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.1);
  padding: 5px;
}

.reaction-chart text {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 10px;
  fill: rgba(224, 225, 221, 0.6);
}

.modal__actions {
  display: flex;
  justify-content: center;
}

.modal__actions .primary {
  min-width: 140px;
  font-size: 1.1rem;
  padding: 0.8rem 2rem;
}

/* Legal Pages Styling */
.legal-content {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25);
  grid-template-columns: 1fr;
  grid-template-areas: "content";
}

.legal-section {
  line-height: 1.7;
  font-size: 0.95rem;
}

.legal-section h2 {
  color: var(--accent-strong);
  margin: 2rem 0 1rem 0;
  font-size: 1.4rem;
  border-bottom: 1px solid rgba(242, 204, 143, 0.3);
  padding-bottom: 0.5rem;
}

.legal-section h3 {
  color: var(--accent);
  margin: 1.5rem 0 0.75rem 0;
  font-size: 1.1rem;
}

.legal-section ul, .legal-section ol {
  padding-left: 1.5rem;
  margin: 0.75rem 0;
}

.legal-section li {
  margin: 0.5rem 0;
}

.privacy-notice {
  background: rgba(224, 122, 95, 0.15);
  border: 1px solid rgba(224, 122, 95, 0.3);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
}

.privacy-notice h3 {
  margin: 0 0 0.5rem 0;
  color: var(--accent-strong);
  font-size: 1rem;
}

.privacy-notice p {
  margin: 0;
  font-weight: 500;
}

.contact-info {
  background: rgba(27, 38, 59, 0.4);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin: 1rem 0;
}

.contact-info a {
  color: var(--accent);
  text-decoration: none;
}

.contact-info a:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}

.privacy-footer {
  background: rgba(149, 213, 178, 0.1);
  border: 1px solid rgba(149, 213, 178, 0.2);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin: 2rem 0 0 0;
  text-align: center;
}

.privacy-footer p {
  margin: 0;
  font-weight: 600;
  color: var(--text);
}

@media (max-width: 768px) {
  .legal-content {
    padding: 1.5rem;
    margin: 1rem;
  }
  
  .legal-section {
    font-size: 0.9rem;
  }
  
  .legal-section h2 {
    font-size: 1.3rem;
  }
}

@media (max-width: 600px) {
  .modal__content {
    padding: 1.5rem;
    margin: 1rem;
  }
  
  .modal__close {
    top: 12px;
    left: 12px;
    width: 32px;
    height: 32px;
  }
  
  .modal__stats {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  
  .stat-card {
    padding: 0.75rem;
  }
  
  .stat-card__value {
    font-size: 1.2rem;
  }
  
  .stat-card__chart {
    margin-top: 0.5rem;
    min-height: 80px;
  }
  
  .reaction-chart {
    width: 100%;
    max-width: 280px;
  }
}
