:root {
  color-scheme: dark;
  --bg: #bfefff;
  --panel: rgba(255, 255, 255, 0.95);
  --panel-strong: #fff8e8;
  --text: #121212;
  --muted: #343434;
  --line: rgba(0, 0, 0, 0.22);
  --gold: #ffd166;
  --pink: #ff6fb1;
  --blue: #2f9be6;
  --green: #79e6a3;
  --red: #ff7676;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 20% 18%, rgba(255, 255, 255, 0.92), transparent 10rem),
    radial-gradient(circle at 80% 14%, rgba(255, 255, 255, 0.72), transparent 13rem),
    linear-gradient(180deg, #69c9ff 0%, #c7f4ff 52%, #fff7dc 100%);
  color: var(--text);
}

button,
input {
  font: inherit;
}

.game-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
}

.screen {
  width: min(980px, 100%);
  display: none;
}

.screen.active {
  display: block;
  animation: pop-in 240ms ease-out;
}

.hero-card,
.quest-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 12px 14px 0 rgba(0, 0, 0, 0.18);
}

.hero-card {
  display: grid;
  grid-template-columns: minmax(310px, 1.1fr) minmax(280px, 0.9fr);
  gap: 24px;
  padding: clamp(18px, 4vw, 34px);
  align-items: center;
}

.quest-card {
  padding: clamp(22px, 5vw, 44px);
}

.portrait-wrap {
  position: relative;
  overflow: hidden;
  border: 4px solid #050505;
  border-radius: 8px;
  background: #ffffff;
}

.portrait-wrap::after {
  content: "Quest Host";
  position: absolute;
  left: 14px;
  bottom: 14px;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--gold);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.portrait-wrap img,
.story-grid img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.portrait-wrap.small {
  width: min(210px, 58vw);
  aspect-ratio: 1;
  margin: 0 auto 18px;
}

.speech,
.quest-card {
  position: relative;
}

.speech {
  padding: clamp(18px, 4vw, 34px);
  border: 4px solid #050505;
  border-radius: 48% 42% 46% 40% / 18% 16% 22% 20%;
  background: #ffffff;
}

.speech::before {
  content: "";
  position: absolute;
  left: -28px;
  top: 48%;
  width: 50px;
  height: 34px;
  background: #ffffff;
  border-left: 4px solid #050505;
  border-bottom: 4px solid #050505;
  transform: rotate(34deg);
}

.kicker,
.topline {
  color: #111111;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.78rem;
  font-weight: 900;
}

.topline {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 16px;
  margin-bottom: 22px;
  border-bottom: 3px solid #111111;
}

.progress-strip {
  height: 18px;
  margin: -8px 0 16px;
  border: 3px solid #111111;
  border-radius: 999px;
  overflow: hidden;
  background: #ffffff;
}

.progress-strip span {
  display: block;
  width: calc((var(--step) / 7) * 100%);
  height: 100%;
  background: repeating-linear-gradient(
    45deg,
    var(--pink),
    var(--pink) 10px,
    var(--gold) 10px,
    var(--gold) 20px
  );
}

.quest-log {
  margin: 0 0 20px;
  padding: 12px 14px;
  border: 3px solid #111111;
  border-radius: 8px;
  background: #fff8e8;
  font-weight: 800;
  line-height: 1.45;
  box-shadow: 4px 5px 0 rgba(0, 0, 0, 0.12);
}

h1,
h2 {
  margin: 14px 0 12px;
  line-height: 1.02;
}

h1 {
  font-size: clamp(2.4rem, 7vw, 5.8rem);
}

h2 {
  font-size: clamp(2rem, 5vw, 4rem);
}

.lead,
.hint,
.dialogue {
  color: var(--muted);
  line-height: 1.6;
  font-size: 1.05rem;
}

.dialogue {
  border-left: 5px solid var(--pink);
  padding-left: 14px;
}

.team-form,
.answer-form {
  display: grid;
  gap: 12px;
  margin-top: 24px;
}

label {
  color: var(--muted);
  font-weight: 800;
}

input {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: #ffffff;
  color: var(--text);
  outline: none;
}

input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 155, 230, 0.18);
}

button,
.primary-action {
  border: 0;
  border-radius: 8px;
  padding: 13px 18px;
  cursor: pointer;
  border: 3px solid #111111;
  background: linear-gradient(135deg, var(--gold), #ff9f1c);
  color: #1a1205;
  font-weight: 900;
}

button:hover {
  transform: translateY(-1px);
}

.story-grid {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 22px;
  align-items: start;
}

.story-grid img {
  aspect-ratio: 1;
  border-radius: 8px;
  border: 4px solid #111111;
}

.letter-bank,
.choice-grid,
.combo-tray,
.profile-grid {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.letter-bank {
  grid-template-columns: repeat(auto-fit, minmax(42px, 1fr));
}

.letter-tile,
.choice-card,
.profile-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--text);
}

.letter-tile {
  display: grid;
  place-items: center;
  min-height: 46px;
  font-size: 1.2rem;
  font-weight: 900;
}

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

.profile-card {
  padding: 16px;
  text-align: left;
}

.profile-card strong {
  display: block;
  color: #0b69a8;
  font-size: 1.1rem;
  margin-bottom: 8px;
}

.profile-card span {
  color: var(--muted);
}

.choice-grid {
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

.choice-card {
  min-height: 58px;
}

.audio-card {
  display: grid;
  gap: 12px;
  margin: 22px 0;
  padding: 18px;
  border: 4px solid #111111;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 6px 7px 0 rgba(0, 0, 0, 0.14);
}

.audio-card span {
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.audio-card audio {
  width: 100%;
}

.combo-tray {
  min-height: 74px;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  padding: 12px;
  border: 1px dashed rgba(255, 209, 102, 0.58);
  border-radius: 8px;
  background: #fff8e8;
}

.coordinate-card {
  display: grid;
  gap: 12px;
  margin: 22px 0;
  padding: 18px;
  border: 4px solid #111111;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(47, 155, 230, 0.12) 1px, transparent 1px),
    linear-gradient(rgba(47, 155, 230, 0.12) 1px, transparent 1px),
    #ffffff;
  background-size: 24px 24px;
}

.coordinate-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.coordinate-row span {
  display: grid;
  place-items: center;
  width: 54px;
  min-height: 50px;
  border: 3px solid #111111;
  border-radius: 8px;
  background: var(--gold);
  font-weight: 900;
}

.lock-box {
  display: grid;
  grid-template-columns: repeat(8, minmax(38px, 74px));
  justify-content: center;
  gap: 12px;
  margin: 24px auto;
}

.lock-box span {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 0.78;
  border: 4px solid #111111;
  border-radius: 8px;
  background: linear-gradient(180deg, #fffef7, #ffd166);
  box-shadow: 5px 6px 0 rgba(0, 0, 0, 0.18);
}

.lock-box span::before {
  content: "?";
  font-size: clamp(2.4rem, 8vw, 4.3rem);
  font-weight: 900;
}

.lock-box span::after {
  content: "";
  position: absolute;
  top: -22px;
  left: 24%;
  width: 52%;
  height: 28px;
  border: 4px solid #111111;
  border-bottom: 0;
  border-radius: 999px 999px 0 0;
  background: transparent;
}

.clue-list {
  display: grid;
  gap: 12px;
  padding: 0;
  margin: 22px 0;
  list-style: none;
  text-align: left;
}

.clue-list li {
  padding: 14px;
  border: 3px solid #111111;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 4px 5px 0 rgba(0, 0, 0, 0.12);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

.button-row button:first-child {
  background: #111111;
  color: #ffffff;
}

.upload-card {
  display: grid;
  place-items: center;
  min-height: 150px;
  margin: 22px 0;
  border: 2px dashed rgba(124, 199, 255, 0.72);
  border-radius: 8px;
  background: #ffffff;
  cursor: pointer;
}

.upload-card span {
  color: var(--blue);
  font-size: 1.3rem;
  font-weight: 900;
}

.upload-card input {
  display: none;
}

.form-portal {
  gap: 12px;
  text-align: center;
}

.form-portal p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.form-portal a {
  display: inline-block;
  justify-self: center;
  text-decoration: none;
}

.checkbox-line {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 18px 0;
  padding: 14px;
  border: 3px solid #111111;
  border-radius: 8px;
  background: #ffffff;
}

.checkbox-line input {
  width: 22px;
  min-height: 22px;
  accent-color: var(--pink);
}

.selfie-preview {
  display: none;
  width: min(320px, 100%);
  max-height: 320px;
  object-fit: cover;
  margin: 0 0 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.selfie-preview.visible {
  display: block;
}

.feedback {
  min-height: 28px;
  margin: 18px 0 0;
  font-weight: 900;
}

.feedback.good {
  color: var(--green);
}

.feedback.bad {
  color: var(--red);
}

blockquote {
  margin: 24px 0;
  padding: 20px;
  border: 1px solid rgba(255, 209, 102, 0.5);
  border-radius: 8px;
  background: #fff8e8;
  color: var(--gold);
  font-size: clamp(1.3rem, 3vw, 2rem);
  font-weight: 900;
}

.finale,
.victory {
  text-align: center;
}

.dashboard-page {
  min-height: 100vh;
}

.dashboard-layout {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
  gap: 24px;
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
  align-items: start;
}

.dashboard-shell {
  min-width: 0;
}

.dashboard-hero,
.leaderboard-card,
.dashboard-stats article,
.dashboard-qr-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 8px 9px 0 rgba(0, 0, 0, 0.16);
}

.dashboard-qr-card {
  position: sticky;
  top: 28px;
  padding: 14px;
  background: #050505;
}

.dashboard-qr-card img {
  display: block;
  width: 100%;
  border-radius: 8px;
}

.dashboard-hero {
  display: flex;
  justify-content: space-between;
  gap: 22px;
  align-items: center;
  padding: clamp(20px, 4vw, 34px);
}

.dashboard-hero h1 {
  margin-top: 6px;
  font-size: clamp(2.1rem, 6vw, 4.8rem);
}

.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 22px 0;
}

.dashboard-stats article {
  padding: 18px;
  text-align: center;
}

.dashboard-stats span {
  display: block;
  font-size: clamp(1.8rem, 5vw, 3.2rem);
  font-weight: 900;
  line-height: 1;
}

.dashboard-stats p {
  margin: 8px 0 0;
  color: var(--muted);
  font-weight: 800;
}

.leaderboard-card {
  padding: clamp(18px, 4vw, 30px);
}

.leaderboard-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
}

.leaderboard-head h2 {
  margin: 4px 0 0;
  font-size: clamp(1.8rem, 4vw, 3rem);
}

.leaderboard-table-wrap {
  overflow-x: auto;
  border: 4px solid #111111;
  border-radius: 8px;
  background: #ffffff;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
}

.leaderboard-table th,
.leaderboard-table td {
  padding: 14px;
  border-bottom: 2px solid rgba(0, 0, 0, 0.12);
  text-align: left;
  vertical-align: middle;
}

.leaderboard-table th {
  background: #fff8e8;
  color: #111111;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.leaderboard-table tr:last-child td {
  border-bottom: 0;
}

.status-pill {
  display: inline-block;
  padding: 6px 10px;
  border: 2px solid #111111;
  border-radius: 999px;
  background: var(--gold);
  font-weight: 900;
  white-space: nowrap;
}

.selfie-state {
  display: inline-block;
  font-weight: 900;
}

.selfie-state.pending {
  color: var(--muted);
}

.selfie-state.uploaded {
  color: #126a34;
}

.selfie-thumb-link {
  display: inline-flex;
  gap: 9px;
  align-items: center;
  color: #111111;
  font-weight: 900;
  text-decoration: none;
}

.leaderboard-selfie {
  width: 58px;
  height: 58px;
  border: 3px solid #111111;
  border-radius: 8px;
  object-fit: cover;
  background: #fff8e8;
}

.delete-player {
  padding: 8px 10px;
  border: 2px solid #111111;
  border-radius: 8px;
  background: #ffe2e2;
  color: #111111;
  font-weight: 900;
  cursor: pointer;
}

.delete-player:hover {
  transform: translateY(-1px);
}

.showcase-page {
  min-height: 100vh;
  overflow: hidden;
  background: #050505;
  color: #ffffff;
}

.showcase-shell {
  min-height: 100vh;
}

.showcase-stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(300px, 1.2fr);
  align-items: center;
  gap: clamp(20px, 5vw, 70px);
  min-height: 100vh;
  padding: clamp(18px, 5vw, 58px);
  isolation: isolate;
}

.showcase-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.88), rgba(0, 0, 0, 0.28) 56%, rgba(0, 0, 0, 0.8)),
    radial-gradient(circle at 68% 40%, rgba(255, 209, 102, 0.22), transparent 24rem),
    #050505;
}

.showcase-bg {
  position: absolute;
  inset: -24px;
  z-index: -3;
  background-position: center;
  background-size: cover;
  filter: blur(26px) saturate(1.25);
  opacity: 0.5;
  transform: scale(1.08);
  transition: background-image 300ms ease, opacity 300ms ease;
}

.showcase-film-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 26px;
  background: repeating-linear-gradient(90deg, #111111 0 18px, #f4f4f4 18px 28px, #111111 28px 44px);
  opacity: 0.72;
}

.showcase-film-line.top {
  top: 0;
}

.showcase-film-line.bottom {
  bottom: 0;
}

.showcase-copy {
  max-width: 520px;
}

.showcase-copy .kicker {
  color: var(--gold);
}

.showcase-copy h1 {
  margin: 10px 0 16px;
  font-size: clamp(2.8rem, 8vw, 6.8rem);
  text-shadow: 0 6px 32px rgba(0, 0, 0, 0.7);
}

.showcase-copy p {
  color: rgba(255, 255, 255, 0.82);
  font-size: clamp(1.05rem, 2vw, 1.45rem);
  font-weight: 800;
  line-height: 1.45;
}

.showcase-frame {
  position: relative;
  width: min(620px, 100%);
  margin: 0;
  justify-self: center;
  padding: clamp(10px, 2vw, 18px);
  border: 4px solid #ffffff;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.52);
  transform: rotate(1deg);
}

.showcase-frame img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: 8px;
  background: #171717;
  opacity: 0;
  transition: opacity 260ms ease, transform 5200ms linear;
}

.showcase-frame img.is-visible {
  opacity: 1;
  transform: scale(1.035);
}

.showcase-frame figcaption {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 14px 4px 2px;
  color: #111111;
  font-weight: 900;
}

.showcase-frame small {
  color: #555555;
  text-align: right;
}

.showcase-controls {
  position: absolute;
  left: clamp(18px, 5vw, 58px);
  bottom: 44px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.showcase-controls button {
  min-width: 86px;
  background: rgba(255, 255, 255, 0.92);
  color: #111111;
}

.showcase-feedback {
  position: absolute;
  right: clamp(18px, 5vw, 58px);
  bottom: 48px;
  max-width: min(420px, calc(100% - 36px));
  margin: 0;
  color: rgba(255, 255, 255, 0.78);
  font-weight: 800;
  text-align: right;
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.99);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 760px) {
  .hero-card,
  .story-grid {
    grid-template-columns: 1fr;
  }

  .portrait-wrap {
    max-height: 430px;
  }

  .profile-grid {
    grid-template-columns: 1fr;
  }

  .topline {
    display: grid;
  }

  .lock-box {
    grid-template-columns: repeat(4, minmax(42px, 64px));
  }

  .dashboard-layout {
    grid-template-columns: 1fr;
    width: min(1180px, calc(100% - 32px));
  }

  .dashboard-qr-card {
    position: static;
    max-width: 320px;
    margin: 0 auto;
  }

  .dashboard-hero,
  .leaderboard-head {
    display: grid;
  }

  .dashboard-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .showcase-page {
    overflow: auto;
  }

  .showcase-stage {
    grid-template-columns: 1fr;
    align-content: center;
    padding-bottom: 132px;
  }

  .showcase-frame {
    transform: none;
  }

  .showcase-controls,
  .showcase-feedback {
    left: 18px;
    right: 18px;
    bottom: 34px;
  }

  .showcase-feedback {
    bottom: 88px;
    text-align: left;
  }
}
