:root {
  --game-bg: linear-gradient(180deg, #0b1221 0%, #0f172a 45%, #101f3b 100%);
  --game-fg: #f7fbff;
  --game-subtle: rgba(250, 250, 255, 0.08);
  --game-primary: #0d9488;
  --game-accent: #22d3ee;
  --game-accent-secondary: #2dd4bf;
  --game-main: #10b981;
  --game-card-bg: rgba(15, 20, 41, 0.92);
  --game-card-muted: rgba(255, 255, 255, 0.72);
  --game-border: rgba(255, 255, 255, 0.14);
  --game-row-alt: rgba(15, 23, 42, 0.02);
  --game-radius: 16px;
  --game-pad: clamp(16px, 4vw, 32px);
  --game-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
  --game-cta-contrast: #ffffff;
}

@font-face {
  font-family: "Raleway";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/public/assets/fonts/Raleway-Regular.ttf") format("truetype");
}
@font-face {
  font-family: "Raleway";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/public/assets/fonts/Raleway-SemiBold.ttf") format("truetype");
}
@font-face {
  font-family: "Raleway";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/public/assets/fonts/Raleway-Bold.ttf") format("truetype");
}

body.game-body {
  margin: 0;
  font-family:
    "Raleway",
    system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    Arial,
    sans-serif;
  background: var(--game-bg);
  color: var(--game-fg);
  line-height: 1.5;
  text-align: center;
}

body.preview-mode {
  padding-top: 44px;
}

body.preview-mode::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 40;
  opacity: 0.18;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='280' height='200' viewBox='0 0 280 200'%3E%3Ctext x='0' y='60' fill='%23000' fill-opacity='0.25' font-size='36' font-family='Arial' transform='rotate(-20 0 60)'%3EPREVIEW%3C/text%3E%3C/svg%3E");
  background-repeat: repeat;
  mix-blend-mode: multiply;
}

.preview-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  padding: 10px 16px;
  background: var(--game-accent);
  color: var(--game-cta-contrast);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.18);
}

.game-body:not(.experience-ready) .pwa-shell,
.game-body:not(.experience-ready) footer,
.game-body:not(.experience-ready) .page-footer {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

html.is-demo-mode body.game-body {
  visibility: visible !important;
}
html.is-demo-mode body.game-body .pwa-shell,
html.is-demo-mode body.game-body footer,
html.is-demo-mode body.game-body .page-footer {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

.pwa-shell {
  min-height: 100vh;
  background: transparent;
  display: flex;
  justify-content: center;
}

.container {
  width: min(960px, 100%);
  margin: 0 auto;
  padding: var(--game-pad);
  padding-left: max(var(--game-pad), env(safe-area-inset-left));
  padding-right: max(var(--game-pad), env(safe-area-inset-right));
  position: relative;
}

.page-header {
  display: flex;
  align-items: center;
  gap: clamp(16px, 4vw, 32px);
  padding: clamp(16px, 3vw, 32px);
  margin: clamp(12px, 3vw, 32px) auto;
  border-radius: var(--game-radius);
  background: var(--game-card-bg);
  box-shadow: var(--game-shadow);
  border: 1px solid var(--game-border);
  text-align: center;
  color: var(--game-fg);
}

.page-header__media {
  flex: 0 0 clamp(160px, 30vw, 300px);
  position: relative;
}
.page-header__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--game-radius);
  display: block;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.15);
}
.hero-ribbon {
  position: relative;
  display: inline-flex;
  margin-top: 10px;
  padding: 6px 12px;
  background: rgba(15, 23, 42, 0.72);
  color: #e0f2fe;
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 999px;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.hero-ribbon:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 4px;
}

.magic-message-bubble {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.9);
  color: #e2e8f0;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.3);
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.01em;
  z-index: 99;
  animation: magic-pop 0.25s ease, magic-fade 0.4s ease 3s forwards;
}

@keyframes magic-pop {
  from {
    opacity: 0;
    transform: translate(-50%, -8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
}
@keyframes magic-fade {
  to {
    opacity: 0;
    transform: translate(-50%, -8px);
  }
}

.page-header__text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: center;
  align-items: center;
}

.page-header__eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.75rem;
  color: rgba(15, 23, 42, 0.7);
}

.page-header__title {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.8rem);
}

.page-header__subtitle {
  margin: 0;
  font-size: 1rem;
  color: var(--game-card-muted);
}

.helper-text {
  color: var(--game-card-muted);
  font-size: 0.9rem;
  margin: 4px 0 12px;
}

@media (max-width: 720px) {
  .page-header {
    flex-direction: column;
    text-align: center;
  }
  .page-header__media {
    width: 100%;
  }
}

.card {
  background: var(--game-card-bg);
  border-radius: var(--game-radius);
  padding: clamp(16px, 3vw, 24px);
  margin: 16px auto;
  box-shadow: 0 25px 45px rgba(3, 6, 16, 0.45);
  border: 1px solid var(--game-border);
  color: var(--game-fg);
  text-align: center;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.card h1,
.card h2,
.card h3 {
  text-align: center;
  margin-top: 0;
}

.experience-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 8px auto 4px;
}

.experience-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--game-border);
  background: var(--game-card-bg);
  color: var(--game-fg);
  text-decoration: none;
  font-weight: 700;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.12);
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease;
}

.experience-pill:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 26px rgba(15, 23, 42, 0.18);
}

.experience-pill.is-active {
  background: linear-gradient(
    135deg,
    var(--game-accent),
    var(--game-accent-secondary)
  );
  color: var(--game-cta-contrast);
  border-color: transparent;
  box-shadow: 0 14px 26px rgba(13, 148, 136, 0.35);
}

.experience-splash {
  position: fixed;
  inset: 0;
  background: var(--experience-splash-bg, rgba(7, 10, 20, 0.92));
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition:
    opacity 0.45s ease,
    visibility 0.45s ease;
}

.experience-splash--hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.experience-splash__card {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 24px;
  padding: 24px;
  display: flex;
  gap: 20px;
  align-items: center;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.35);
  max-width: min(640px, 90vw);
  width: 100%;
}

.experience-splash__media {
  flex: 0 0 180px;
}

.experience-splash__media img {
  width: 100%;
  height: auto;
  border-radius: 18px;
  display: block;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.3);
}

.experience-splash__text {
  flex: 1;
  text-align: center;
}

.experience-splash__eyebrow {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.75rem;
  color: rgba(15, 23, 42, 0.6);
}

.experience-splash__title {
  margin: 0;
  font-size: clamp(1.5rem, 2vw, 2.2rem);
}

.experience-splash__subtitle {
  margin: 6px 0 0;
  color: rgba(15, 23, 42, 0.65);
}

@media (max-width: 640px) {
  .experience-splash__card {
    flex-direction: column;
    text-align: center;
  }
  .experience-splash__text {
    text-align: center;
  }
}

button,
.cta,
.primary-cta {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 12px 18px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(
    135deg,
    var(--game-accent),
    var(--game-accent-secondary)
  );
  color: var(--game-cta-contrast);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 12px 18px rgba(13, 148, 136, 0.25);
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    opacity 0.15s ease;
}

button:hover,
.cta:hover,
.primary-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 24px rgba(13, 148, 136, 0.35);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ghost-link {
  border-radius: 14px;
  border: 1px solid rgba(15, 23, 42, 0.2);
  padding: 10px 16px;
  background: transparent;
  color: var(--game-fg);
  font-weight: 600;
  cursor: pointer;
}

.back-link {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 12px 18px;
  border-radius: 14px;
  background: linear-gradient(
    135deg,
    var(--game-accent),
    var(--game-accent-secondary)
  );
  color: var(--game-cta-contrast);
  text-decoration: none;
  font-weight: 600;
  box-shadow: 0 12px 18px rgba(13, 148, 136, 0.25);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 12px;
}

.quiz-footer,
.page-footer {
  margin: 24px auto;
  text-align: center;
  color: rgba(255, 255, 255, 0.9);
}

.page-footer small a {
  color: inherit;
}

.leaderboards,
.leaderboard-card,
.puzzle-card {
  width: min(960px, 100%);
  max-width: 100%;
}

.leaderboard-card,
.puzzle-card {
  overflow-x: auto;
}

.leaderboard-card table {
  min-width: 100%;
  table-layout: fixed;
}

.puzzle-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  text-align: center;
}

.puzzle-header h2 {
  margin: 0 0 6px;
}

.intro-copy {
  margin: 0;
  color: var(--game-card-muted);
}

.puzzle-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.leaderboard-card table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

.leaderboard-card th,
.leaderboard-card td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  text-align: left;
  font-size: 0.95rem;
}

.leaderboard-card tbody tr:nth-child(odd) {
  background: #f8fafc;
}

.player-name-row {
  margin-top: 12px;
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.04);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 600;
  color: var(--game-card-muted);
}

.player-name-row strong {
  color: var(--game-fg);
}

.name-trigger {
  border: none;
  background: transparent;
  color: var(--game-primary);
  font-weight: 600;
  cursor: pointer;
}

.name-trigger:hover {
  color: var(--game-accent);
}

.name-trigger:focus-visible {
  outline: 2px solid var(--game-primary);
  border-radius: 999px;
  outline-offset: 2px;
}

.quiz-error,
.game-error {
  color: #b91c1c;
  font-weight: 600;
  text-align: center;
  margin: 0;
}

.completion-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 10, 18, 0.4);
  backdrop-filter: blur(4px);
  padding: 16px;
  z-index: 50;
}

.completion-card {
  background: #fff;
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--game-shadow);
  text-align: center;
}

.completion-modal[hidden] {
  display: none;
}

.player-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 2300;
}

.player-modal[hidden] {
  display: none;
}

.player-modal__card {
  background: #ffffff;
  border-radius: 20px;
  padding: clamp(20px, 5vw, 32px);
  width: min(420px, 100%);
  box-shadow: 0 25px 60px rgba(15, 23, 42, 0.25);
}

.player-modal__card h2 {
  margin-top: 0;
}

.player-modal__label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
  margin-top: 12px;
}

.player-modal__label input {
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.15);
  font-size: 1rem;
}

.player-modal__label input:focus-visible {
  outline: 2px solid var(--game-primary);
  border-color: var(--game-primary);
}

.player-modal__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
  justify-content: center;
}

.player-name-error {
  min-height: 1.2rem;
  color: #b91c1c;
  font-size: 0.9rem;
  margin: 8px 0 0;
}

.page-footer small {
  color: rgba(255, 255, 255, 0.8);
}

.game-links {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: 1fr;
  gap: 14px;
  padding: 0;
  margin: 0;
}

.game-link-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px;
  min-height: 180px;
  height: 100%;
  font-size: 1.1rem;
  text-decoration: none;
  color: #f8fafc;
  text-align: center;
  border-radius: 18px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.12);
  box-shadow: 0 18px 30px rgba(3, 6, 16, 0.55);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  transition:
    transform 0.2s ease,
    border-color 0.2s ease,
    background 0.2s ease;
}

.game-link-card__icon {
  width: clamp(120px, 30vw, 140px);
  height: clamp(120px, 30vw, 140px);
  object-fit: contain;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.35));
  opacity: 0.95;
}

.game-link-card__label {
  display: block;
  font-weight: 700;
  letter-spacing: 0.01em;
}

html.is-demo-mode body.game-body .game-link-card {
  color: #ffffff;
  background: rgba(7, 10, 24, 0.9);
  border-color: rgba(255, 255, 255, 0.2);
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.6);
}

html.is-demo-mode body.game-body .game-link-card:hover,
html.is-demo-mode body.game-body .game-link-card:focus-visible {
  background: rgba(12, 16, 36, 0.95);
  border-color: rgba(255, 255, 255, 0.4);
}
.game-link-card:hover,
.game-link-card:focus-visible {
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.18);
}

@media (max-width: 640px) {
  .card {
    padding: 16px;
  }
  .puzzle-header {
    flex-direction: column;
    align-items: stretch;
  }
  .puzzle-actions {
    justify-content: flex-start;
  }
}
