:root {
  color-scheme: light;
  --ink: #171228;
  --muted: #6b607f;
  --paper: #f4edff;
  --panel: rgba(255, 253, 255, 0.9);
  --line: rgba(107, 80, 148, 0.18);
  --accent: #8b5cf6;
  --accent-dark: #6d28d9;
  --green: #8b5cf6;
  --blue: #6d5dfc;
  --yellow: #f0d7ff;
  --charcoal: #241936;
  --shadow: 0 30px 95px rgba(55, 36, 91, 0.26);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  position: relative;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(ellipse at 14% 18%, rgba(129, 82, 205, 0.46), transparent 24rem),
    radial-gradient(ellipse at 82% 10%, rgba(189, 168, 255, 0.62), transparent 30rem),
    radial-gradient(ellipse at 76% 88%, rgba(238, 174, 255, 0.42), transparent 28rem),
    radial-gradient(ellipse at 20% 82%, rgba(91, 56, 152, 0.26), transparent 23rem),
    linear-gradient(135deg, #fbf8ff 0%, #ede3ff 46%, #fff7ff 100%);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

body::before {
  opacity: 0.42;
  background:
    radial-gradient(circle at 16% 72%, rgba(83, 45, 135, 0.18) 0 7rem, transparent 14rem),
    radial-gradient(circle at 58% 18%, rgba(255, 255, 255, 0.75) 0 5rem, transparent 15rem),
    radial-gradient(circle at 86% 66%, rgba(136, 92, 198, 0.18) 0 6rem, transparent 16rem),
    linear-gradient(110deg, transparent 0 34%, rgba(255, 255, 255, 0.45) 45%, transparent 58%);
  filter: blur(7px);
}

body::after {
  opacity: 0.2;
  background:
    radial-gradient(circle at 24% 28%, rgba(255, 255, 255, 0.85) 0 0.12rem, transparent 0.2rem),
    radial-gradient(circle at 62% 48%, rgba(85, 57, 132, 0.34) 0 0.08rem, transparent 0.18rem),
    radial-gradient(circle at 78% 72%, rgba(255, 255, 255, 0.8) 0 0.1rem, transparent 0.22rem);
  background-size: 34px 34px, 46px 46px, 58px 58px;
}

body.perfect-score-active .game-panel {
  animation: perfectPanelPulse 900ms ease;
}

.perfect-burst {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  overflow: hidden;
}

.perfect-toast {
  position: absolute;
  left: 50%;
  top: clamp(86px, 14vh, 150px);
  transform: translateX(-50%);
  padding: 16px 22px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(245, 237, 255, 0.94)),
    linear-gradient(135deg, #8b5cf6, #f97316);
  color: var(--ink);
  box-shadow:
    0 24px 60px rgba(88, 28, 135, 0.28),
    0 0 0 8px rgba(139, 92, 246, 0.12);
  font-size: clamp(1.05rem, 3vw, 1.45rem);
  font-weight: 950;
  white-space: nowrap;
  animation: perfectToast 1.9s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.confetti-bit {
  position: absolute;
  left: var(--x);
  top: -18px;
  width: 10px;
  height: 18px;
  border-radius: 4px;
  opacity: 0;
  transform: translateY(0) translateX(0) rotate(0);
  animation: confettiFall 1.85s cubic-bezier(0.18, 0.74, 0.28, 1) var(--delay) forwards;
}

@keyframes perfectPanelPulse {
  0%,
  100% {
    box-shadow: var(--shadow);
  }

  42% {
    box-shadow:
      0 34px 100px rgba(55, 36, 91, 0.3),
      0 0 0 8px rgba(139, 92, 246, 0.18),
      0 0 90px rgba(250, 204, 21, 0.32);
  }
}

@keyframes perfectToast {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(-18px) scale(0.86);
  }

  16%,
  76% {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }

  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px) scale(0.96);
  }
}

@keyframes confettiFall {
  0% {
    opacity: 0;
    transform: translateY(0) translateX(0) rotate(0);
  }

  10% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translateY(108vh) translateX(var(--dx)) rotate(var(--spin));
  }
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 30px 0;
  display: grid;
  align-items: center;
}

.game-panel {
  position: relative;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.86), rgba(251, 247, 255, 0.74)),
    radial-gradient(circle at 12% 18%, rgba(172, 133, 255, 0.22), transparent 22rem),
    radial-gradient(circle at 92% 8%, rgba(255, 255, 255, 0.56), transparent 18rem);
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 30px;
  box-shadow: var(--shadow);
  padding: clamp(18px, 3vw, 34px);
  backdrop-filter: blur(22px) saturate(116%);
  overflow: hidden;
}

.game-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.34;
  background:
    radial-gradient(circle at 8% 52%, rgba(109, 40, 217, 0.18) 0 8rem, transparent 17rem),
    radial-gradient(circle at 72% 82%, rgba(216, 180, 254, 0.38) 0 8rem, transparent 19rem),
    linear-gradient(70deg, transparent 0 36%, rgba(255, 255, 255, 0.55) 44%, transparent 58%);
}

.game-panel > * {
  position: relative;
  z-index: 1;
}

.topbar,
.history-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2.25rem, 8vw, 5.75rem);
  line-height: 0.88;
  letter-spacing: 0;
  text-wrap: balance;
  color: #171228;
  text-shadow: 0 10px 32px rgba(109, 40, 217, 0.16);
}

.streak-pill {
  min-width: max-content;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border: 1px solid rgba(107, 80, 148, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 12px 30px rgba(55, 36, 91, 0.12);
  font-weight: 800;
}

.player-pill {
  min-width: 150px;
  min-height: 58px;
  display: inline-grid;
  align-content: center;
  gap: 2px;
  padding: 9px 16px;
  border: 1px solid rgba(107, 80, 148, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  box-shadow: 0 12px 30px rgba(55, 36, 91, 0.12);
  text-align: left;
}

.player-pill span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
}

.player-pill strong {
  max-width: 16ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-actions {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.streak-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: var(--charcoal);
  color: #fff;
  font-weight: 900;
}

.score-info-wrap {
  position: relative;
}

.info-button {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(107, 80, 148, 0.18);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.84);
  color: var(--charcoal);
  box-shadow: 0 12px 30px rgba(55, 36, 91, 0.13);
  font-weight: 900;
  cursor: pointer;
}

.info-button:hover,
.info-button:focus-visible,
.info-button[aria-expanded="true"] {
  background: var(--charcoal);
  color: #fff;
  outline: none;
  transform: translateY(-1px);
}

.score-rule {
  position: absolute;
  top: 58px;
  left: 50%;
  z-index: 6;
  width: min(300px, calc(100% - 36px));
  margin: 0;
  padding: 13px 15px;
  border: 1px solid rgba(107, 80, 148, 0.18);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  color: #4d3b67;
  box-shadow: 0 18px 42px rgba(55, 36, 91, 0.17);
  font-size: 0.86rem;
  font-weight: 800;
  line-height: 1.35;
  text-align: center;
  transform: translateX(-50%);
  backdrop-filter: blur(16px);
}

.hero-grid {
  --round-card-height: clamp(600px, 70vh, 650px);
  margin-top: 30px;
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.75fr);
  gap: 20px;
  align-items: stretch;
}

.challenge-card,
.scoreboard,
.history-panel {
  border: 1px solid rgba(107, 80, 148, 0.16);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: 0 20px 52px rgba(55, 36, 91, 0.13);
}

.challenge-card {
  height: var(--round-card-height);
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(260px, 0.95fr) minmax(320px, 1.05fr);
}

.challenge-media {
  position: relative;
  height: 100%;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background: #fff;
  overflow: hidden;
}

.challenge-media::before {
  content: none;
}

.challenge-media::after {
  content: "";
  position: absolute;
  inset: 20px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 22px;
  pointer-events: none;
}

.challenge-media img {
  display: block;
  position: relative;
  z-index: 1;
  width: 100%;
  height: 430px;
  max-width: 100%;
  max-height: calc(100% - 44px);
  padding: 0;
  border-radius: 0;
  background: transparent;
  object-fit: contain;
  object-position: center;
  transform: none;
  filter: drop-shadow(0 28px 34px rgba(67, 42, 108, 0.28));
}

.challenge-content,
.scoreboard {
  padding: clamp(20px, 2.6vw, 34px);
}

.challenge-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.category-badge {
  display: inline-flex;
  align-items: center;
  padding: 9px 13px;
  border-radius: 999px;
  background: linear-gradient(135deg, #241936, #6d28d9);
  color: #fff;
  box-shadow: 0 10px 26px rgba(109, 40, 217, 0.2);
}

.challenge-content h2 {
  margin: 20px 0 12px;
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: clamp(1.65rem, 2.8vw, 2.55rem);
  line-height: 1.06;
  text-wrap: balance;
}

.challenge-content p {
  color: var(--muted);
  font-size: 1.04rem;
  line-height: 1.55;
}

.guess-form {
  margin-top: 22px;
  display: grid;
  gap: 12px;
}

.guess-form label {
  color: var(--ink);
  font-weight: 900;
  letter-spacing: 0.01em;
}

.guess-input-row {
  position: relative;
}

.guess-input-row input {
  width: 100%;
  min-height: 64px;
  padding: 0 62px 0 18px;
  border: 2px solid rgba(36, 25, 54, 0.9);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  font-size: clamp(1.3rem, 4vw, 2rem);
  font-weight: 900;
  outline: none;
}

.guess-input-row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 5px rgba(139, 92, 246, 0.18);
}

.currency {
  position: absolute;
  right: 22px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 1.6rem;
  font-weight: 900;
}

button {
  min-height: 48px;
  border: 0;
  border-radius: 18px;
  cursor: pointer;
  font-weight: 900;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.guess-form button {
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  color: white;
  box-shadow: 0 16px 30px rgba(124, 58, 237, 0.28);
}

.guess-form button:hover,
.guess-form button:focus-visible {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.guess-form button:disabled {
  cursor: not-allowed;
  background: #a6a0b8;
  box-shadow: none;
}

.scoreboard {
  position: relative;
  height: var(--round-card-height);
  min-height: 0;
  overflow: hidden;
  display: grid;
  align-content: start;
  gap: 9px;
  padding: clamp(18px, 2.2vw, 28px);
  background:
    linear-gradient(rgba(255, 255, 255, 0.92), rgba(252, 248, 255, 0.88)) padding-box,
    linear-gradient(150deg, rgba(139, 92, 246, 0.52), rgba(216, 180, 254, 0.42)) border-box;
}

.scoreboard h2 {
  margin: 0;
  font-size: 1.45rem;
}

.score-ring {
  width: min(176px, 70vw);
  aspect-ratio: 1;
  margin: 2px auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, #fffdf8 0 55%, transparent 56%),
    conic-gradient(var(--green) var(--score-deg, 0deg), #eee8f8 0deg);
  box-shadow:
    inset 0 0 0 1px rgba(107, 80, 148, 0.06),
    0 18px 34px rgba(124, 58, 237, 0.13);
}

.score-ring span {
  font-size: clamp(2.6rem, 6vw, 4.2rem);
  font-weight: 900;
  line-height: 0.85;
}

.score-ring small {
  margin-top: -42px;
  color: var(--muted);
  font-weight: 900;
}

#scoreHint {
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.35;
  text-align: center;
}

.source-note {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
}

.source-note a {
  color: var(--blue);
  text-decoration: none;
}

.source-note a:hover,
.source-note a:focus-visible {
  text-decoration: underline;
}

.award-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.award-list span {
  padding: 8px 10px;
  border: 1px solid rgba(139, 92, 246, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 900;
}

.stat-grid,
.mini-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.stat-grid div,
.mini-stats div {
  min-width: 0;
  padding: 10px;
  border: 1px solid rgba(107, 80, 148, 0.14);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
}

.stat-grid span,
.mini-stats span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.stat-grid strong,
.mini-stats strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 1.06rem;
}

.secondary-button,
.next-button {
  background: var(--charcoal);
  color: white;
  box-shadow: 0 14px 26px rgba(36, 25, 54, 0.17);
}

.next-button {
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  box-shadow: 0 14px 26px rgba(124, 58, 237, 0.23);
}

.secondary-button:hover,
.secondary-button:focus-visible,
.next-button:hover,
.next-button:focus-visible {
  transform: translateY(-1px);
}

#shareText {
  width: 100%;
  min-height: 96px;
  resize: none;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
  line-height: 1.35;
}

.nickname-gate {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(23, 18, 40, 0.42);
  backdrop-filter: blur(14px);
}

.nickname-gate[hidden] {
  display: none;
}

.nickname-card {
  width: min(440px, 100%);
  display: grid;
  gap: 14px;
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 30px 90px rgba(36, 25, 54, 0.3);
}

.nickname-card h2 {
  margin-bottom: 0;
  font-size: clamp(1.8rem, 7vw, 2.6rem);
}

.nickname-card p:not(.eyebrow) {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.nickname-card label {
  font-weight: 900;
}

.nickname-card input {
  min-height: 58px;
  padding: 0 16px;
  border: 2px solid rgba(36, 25, 54, 0.9);
  border-radius: 18px;
  background: #fff;
  color: var(--ink);
  font-size: 1.2rem;
  font-weight: 850;
}

.nickname-card button {
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  color: #fff;
}

.category-strip {
  margin: 18px 0;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.category-chip {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid rgba(107, 80, 148, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  white-space: nowrap;
  box-shadow: 0 8px 18px rgba(55, 36, 91, 0.08);
}

.category-chip.active {
  background: linear-gradient(135deg, #241936, #6d28d9);
  color: white;
}

.history-panel {
  padding: 20px;
}

.history-panel h2 {
  margin-bottom: 0;
  font-size: 1.35rem;
}

.mini-stats {
  width: min(560px, 100%);
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.trophy-case {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-start;
}

.trophy {
  position: relative;
  min-height: 54px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 8px 13px 8px 9px;
  border: 1px solid rgba(107, 80, 148, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  box-shadow: 0 10px 24px rgba(55, 36, 91, 0.1);
  cursor: default;
}

.trophy.unlocked {
  border-color: rgba(139, 92, 246, 0.34);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(245, 237, 255, 0.9));
}

.trophy.locked {
  color: rgba(255, 255, 255, 0.72);
  background: linear-gradient(135deg, rgba(36, 25, 54, 0.95), rgba(61, 45, 82, 0.94));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
  filter: saturate(0.25);
}

.trophy-icon {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 50%;
  background: var(--charcoal);
  color: #fff;
  font-size: 1.18rem;
  font-weight: 950;
}

.trophy.unlocked .trophy-icon {
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  box-shadow: 0 10px 22px rgba(124, 58, 237, 0.24);
}

.trophy-name {
  max-width: 17ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.86rem;
  font-weight: 950;
}

.trophy-tip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  z-index: 8;
  width: min(240px, 72vw);
  padding: 11px 12px;
  border: 1px solid rgba(107, 80, 148, 0.18);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  box-shadow: 0 18px 38px rgba(55, 36, 91, 0.18);
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.3;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition:
    opacity 150ms ease,
    transform 150ms ease;
}

.trophy-tip::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  width: 12px;
  height: 12px;
  border-right: 1px solid rgba(107, 80, 148, 0.18);
  border-bottom: 1px solid rgba(107, 80, 148, 0.18);
  background: rgba(255, 255, 255, 0.96);
  transform: translate(-50%, -6px) rotate(45deg);
}

.trophy:hover,
.trophy:focus-visible {
  outline: none;
  transform: translateY(-1px);
}

.trophy:hover .trophy-tip,
.trophy:focus-visible .trophy-tip {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 900px) {
  .app-shell {
    width: min(100% - 20px, 680px);
    align-items: start;
    padding: 10px 0;
  }

  .game-panel {
    border-radius: 20px;
  }

  .topbar,
  .history-panel {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .hero-grid {
    grid-template-columns: 1fr;
    gap: 14px;
    margin-top: 22px;
  }

  .challenge-card {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
  }

  .challenge-media {
    height: min(58vh, 360px);
    min-height: 240px;
  }

  .challenge-media img {
    height: 300px;
    max-height: calc(100% - 32px);
  }

  .mini-stats {
    grid-template-columns: 1fr;
  }

  .trophy-case {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .trophy {
    justify-content: flex-start;
  }

  .scoreboard {
    height: auto;
    min-height: 0;
    overflow: visible;
  }
}

@media (max-width: 520px) {
  .app-shell {
    width: 100%;
    padding: 0;
  }

  .game-panel {
    min-height: 100vh;
    padding: 12px;
    border-radius: 0;
  }

  .topbar {
    gap: 12px;
  }

  h1 {
    font-size: clamp(3rem, 16vw, 4.7rem);
  }

  .streak-pill {
    padding: 9px 12px;
  }

  .player-pill {
    min-height: 52px;
    min-width: 100%;
  }

  .challenge-content,
  .scoreboard {
    padding: 18px;
  }

  .challenge-content h2 {
    font-size: clamp(1.75rem, 9vw, 2.35rem);
  }

  .guess-input-row input {
    min-height: 58px;
  }

  .score-ring {
    width: min(170px, 58vw);
  }

  .trophy-case {
    grid-template-columns: 1fr;
  }
}
