:root {
  --bg-dark: #120907;
  --bg-panel: rgba(28, 13, 10, 0.88);
  --bg-soft: rgba(255, 244, 214, 0.14);
  --accent: #ffcb6b;
  --accent-strong: #ff9333;
  --accent-cold: #9ad8ff;
  --text: #fff6e6;
  --text-dark: #2d160f;
  --success: #80f0a9;
  --danger: #ff8b8b;
  --shadow: 0 1.2rem 2.6rem rgba(0, 0, 0, 0.45);
  --radius: 1.5rem;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top, rgba(255, 154, 73, 0.22), transparent 32%),
    linear-gradient(135deg, #150806, #24110b 45%, #120907 100%);
  color: var(--text);
}

body {
  min-height: 100dvh;
}

button,
input {
  font: inherit;
}

.top-actions {
  position: fixed;
  top: 0.55rem;
  right: 0.55rem;
  z-index: 30;
  display: flex;
  gap: 0.55rem;
}

.app {
  width: 100%;
  height: 100dvh;
  padding: clamp(0.65rem, 1.8vw, 1.15rem);
}

.screen {
  width: 100%;
  height: 100%;
  display: grid;
  gap: clamp(0.55rem, 1vw, 0.95rem);
  background: linear-gradient(160deg, rgba(255, 215, 147, 0.08), rgba(0, 0, 0, 0.18));
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: calc(var(--radius) + 0.35rem);
  padding: clamp(0.7rem, 1.8vw, 1.15rem);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(125deg, rgba(255, 203, 107, 0.08), transparent 32%),
    radial-gradient(circle at bottom right, rgba(154, 216, 255, 0.1), transparent 28%);
  pointer-events: none;
}

.landing-screen {
  grid-template-columns: 1.05fr 0.95fr;
  align-items: stretch;
}

.narrative-screen,
.feedback-screen,
.final-screen {
  grid-template-columns: 1fr 1fr;
  align-items: stretch;
}

.level-screen,
.question-screen,
.summary-screen {
  grid-template-rows: auto 1fr auto;
}

.panel,
.image-panel,
.question-panel,
.cards-panel,
.hint-panel {
  position: relative;
  z-index: 1;
  background: var(--bg-panel);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  backdrop-filter: blur(0.2rem);
}

.panel,
.question-panel,
.hint-panel {
  padding: clamp(0.9rem, 2vw, 1.35rem);
}

.landing-copy,
.narrative-copy,
.feedback-copy,
.final-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.9rem;
}

.eyebrow {
  margin: 0;
  font-size: clamp(0.95rem, 1.9vw, 1.2rem);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.8rem, 3.4vw, 2.9rem);
  line-height: 1.05;
}

h2 {
  font-size: clamp(1.45rem, 2.7vw, 2.15rem);
}

h3 {
  font-size: clamp(1.15rem, 2.1vw, 1.55rem);
}

.subtitle,
.info-text,
.story-text,
.question-text,
.summary-text,
.hint-list,
.password-help {
  font-size: clamp(1.08rem, 1.85vw, 1.4rem);
  line-height: 1.5;
}

.narrative-copy h2 {
  font-size: clamp(1.9rem, 3.5vw, 2.8rem);
}

.narrative-copy .story-text {
  font-size: clamp(1.45rem, 2.55vw, 2rem);
  line-height: 1.62;
}

.question-panel h3 {
  font-size: clamp(1.35rem, 2.35vw, 1.8rem);
}

.question-panel .question-text {
  font-size: clamp(1.4rem, 2.45vw, 1.95rem);
  line-height: 1.58;
}

.credits {
  color: #ffe3aa;
  font-weight: 700;
  font-size: clamp(1.05rem, 1.8vw, 1.35rem);
}

.image-panel {
  min-height: 0;
  overflow: hidden;
}

.image-panel img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.question-image-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.8rem;
  min-height: 100%;
}

.question-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 1rem;
}

.screen-actions,
.footer-actions,
.feedback-actions,
.password-actions {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button,
.choice-button,
.card-button,
.fullscreen-button {
  border: none;
  border-radius: 999px;
  padding: 0.9rem 1.35rem;
  cursor: pointer;
  font-weight: 800;
  font-size: clamp(1rem, 1.7vw, 1.25rem);
  transition: transform 0.18s ease, filter 0.18s ease, background 0.18s ease;
}

.primary-button,
.choice-button,
.fullscreen-button {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #34190a;
}

.secondary-button {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.primary-button:hover,
.secondary-button:hover,
.choice-button:hover,
.card-button:hover,
.fullscreen-button:hover {
  transform: translateY(-1px) scale(1.01);
  filter: brightness(1.05);
}

.fullscreen-button {
  padding: 0.72rem 1.05rem;
  font-size: clamp(0.95rem, 1.4vw, 1.1rem);
  box-shadow: var(--shadow);
}

.fullscreen-button.is-muted {
  background: rgba(255, 255, 255, 0.18);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.hidden-action {
  display: none;
}

.story-text {
  padding: 1rem;
  background: var(--bg-soft);
  border-radius: 1rem;
}

.level-header,
.question-header,
.summary-header {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: center;
  position: relative;
  z-index: 1;
}

.badge-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.badge {
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  background: rgba(255, 203, 107, 0.14);
  border: 1px solid rgba(255, 203, 107, 0.3);
  color: #ffe4ad;
  font-size: clamp(0.92rem, 1.5vw, 1.15rem);
  font-weight: 700;
}

.cards-panel {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(0.45rem, 0.9vw, 0.8rem);
  padding: clamp(0.8rem, 1.5vw, 1.05rem);
}

.card-button {
  position: relative;
  min-height: clamp(10.8rem, 24vw, 13rem);
  aspect-ratio: 1 / 1.08;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0;
}

.card-button.locked {
  opacity: 0.4;
  cursor: not-allowed;
}

.card-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.8rem;
  text-align: center;
}

.card-face img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.8);
}

.card-label {
  position: absolute;
  left: 0.55rem;
  right: 0.55rem;
  bottom: 0.55rem;
  background: rgba(20, 9, 7, 0.8);
  padding: 0.5rem 0.55rem;
  border-radius: 1rem;
  font-size: clamp(1rem, 1.35vw, 1.15rem);
  line-height: 1.15;
  text-align: center;
  white-space: normal;
}

.card-open {
  flex-direction: column;
  gap: 0.55rem;
  background: linear-gradient(160deg, rgba(255, 227, 173, 0.92), rgba(255, 191, 111, 0.92));
  color: var(--text-dark);
  font-weight: 800;
  font-size: clamp(1.02rem, 1.5vw, 1.2rem);
}

.question-grid,
.final-grid,
.summary-main {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: clamp(0.55rem, 1vw, 0.95rem);
  min-height: 0;
  position: relative;
  z-index: 1;
}

.question-panel,
.hint-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.9rem;
}

.timer-box {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: rgba(154, 216, 255, 0.12);
  color: #d3efff;
  padding: 0.6rem 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(154, 216, 255, 0.24);
  font-weight: 800;
  font-size: clamp(1rem, 1.5vw, 1.2rem);
}

.timer-box.warning {
  background: rgba(255, 139, 139, 0.12);
  color: #ffd7d7;
  border-color: rgba(255, 139, 139, 0.25);
}

.choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.choice-button {
  min-height: 4rem;
  font-size: clamp(1.12rem, 1.9vw, 1.35rem);
}

.question-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.7rem;
}

.progress-row {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.progress-dot {
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.14);
}

.progress-dot.correct {
  background: var(--success);
}

.progress-dot.wrong {
  background: var(--danger);
}

.hint-list {
  padding-left: 1rem;
}

.hint-list li + li {
  margin-top: 0.45rem;
}

.password-boxes {
  display: flex;
  gap: 0.55rem;
  justify-content: center;
}

.password-boxes input {
  width: clamp(3.5rem, 8.5vw, 4.5rem);
  height: clamp(3.5rem, 8.5vw, 4.5rem);
  text-align: center;
  font-size: clamp(1.6rem, 3.2vw, 2.2rem);
  text-transform: uppercase;
  border-radius: 1rem;
  border: 2px solid rgba(255, 203, 107, 0.35);
  background: rgba(255, 248, 230, 0.94);
  color: #34190a;
  font-weight: 800;
}

.password-boxes input:focus {
  outline: 3px solid rgba(154, 216, 255, 0.55);
}

.status-message {
  min-height: 1.4rem;
  font-weight: 700;
  color: #ffe3aa;
}

.status-message.error {
  color: #ffc2c2;
}

.muted {
  color: rgba(255, 246, 230, 0.78);
}

@media (max-width: 950px), (max-height: 600px) {
  .screen {
    padding: 0.6rem;
    gap: 0.55rem;
  }

  .panel,
  .question-panel,
  .hint-panel {
    padding: 0.7rem;
  }

  .story-text,
  .subtitle,
  .info-text,
  .question-text,
  .summary-text,
  .hint-list,
  .password-help {
    font-size: clamp(0.95rem, 1.7vw, 1.15rem);
  }

  .narrative-copy h2 {
    font-size: clamp(1.55rem, 2.95vw, 2.2rem);
  }

  .narrative-copy .story-text {
    font-size: clamp(1.16rem, 2.05vw, 1.55rem);
  }

  .question-panel h3 {
    font-size: clamp(1.15rem, 2vw, 1.45rem);
  }

  .question-panel .question-text {
    font-size: clamp(1.18rem, 2.05vw, 1.55rem);
  }

  .card-button {
    min-height: clamp(8.2rem, 20vw, 10rem);
  }
}

@media (max-width: 760px) and (orientation: portrait) {
  .landing-screen,
  .narrative-screen,
  .feedback-screen,
  .final-screen,
  .question-grid,
  .summary-main,
  .final-grid {
    grid-template-columns: 1fr;
  }

  .image-panel {
    min-height: 28vh;
  }
}

@media (max-height: 430px) {
  .cards-panel {
    padding: 0.55rem;
  }

  .card-button {
    min-height: 7rem;
  }

  .primary-button,
  .secondary-button,
  .choice-button,
  .fullscreen-button {
    padding: 0.72rem 1rem;
  }

  .top-actions {
    gap: 0.4rem;
  }

  .story-text,
  .subtitle,
  .info-text,
  .question-text,
  .summary-text,
  .hint-list,
  .password-help {
    font-size: 0.95rem;
    line-height: 1.35;
  }

  .narrative-copy h2 {
    font-size: 1.35rem;
  }

  .narrative-copy .story-text,
  .question-panel .question-text {
    font-size: 1.08rem;
  }
}
