* {
  box-sizing: border-box;
}

:root {
  --paper: #fff4df;
  --paper-2: #fde7bd;
  --ink: #2d241c;
  --muted: #775d45;
  --brown: #8d5129;
  --brown-dark: #5c331d;
  --gold: #d99a3c;
  --green: #566f44;
  --red: #b84a36;
  --shadow: 0 22px 70px rgba(71, 42, 20, .24);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Georgia, 'Times New Roman', serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 15%, rgba(255,255,255,.7), transparent 30%),
    radial-gradient(circle at 80% 5%, rgba(255,219,154,.6), transparent 28%),
    linear-gradient(135deg, #f8dfb1 0%, #f7ead3 48%, #d7e1bd 100%);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(93,55,26,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(93,55,26,.04) 1px, transparent 1px);
  background-size: 38px 38px;
  pointer-events: none;
}

.game-shell {
  width: min(1280px, 96vw);
  margin: 0 auto;
  padding: 28px 0 36px;
  position: relative;
}

.top-panel {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  padding: 24px 28px;
  border: 2px solid rgba(93,55,26,.2);
  border-radius: 28px;
  background: rgba(255, 250, 239, .75);
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: .16em;
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: clamp(34px, 5vw, 62px);
  line-height: 1;
}

.lead {
  max-width: 760px;
  margin: 12px 0 0;
  font-size: 18px;
  color: var(--muted);
}

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

.reset-btn, .sound-btn, .next-btn, .finish-card button {
  border: 0;
  border-radius: 999px;
  padding: 13px 20px;
  background: var(--brown-dark);
  color: white;
  cursor: pointer;
  font-weight: 700;
  font-size: 16px;
  box-shadow: 0 10px 24px rgba(92, 51, 29, .22);
}

.reset-btn:hover, .sound-btn:hover, .next-btn:hover, .finish-card button:hover {
  transform: translateY(-1px);
}

.stage {
  display: grid;
  grid-template-columns: minmax(220px, 320px) 1fr;
  gap: 26px;
  margin-top: 26px;
  align-items: stretch;
}

.hero-card {
  position: relative;
  border-radius: 30px;
  background: linear-gradient(180deg, rgba(255,250,239,.86), rgba(255,231,194,.72));
  border: 2px solid rgba(93,55,26,.18);
  min-height: 700px;
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.quote-box {
  width: calc(100% - 30px);
  margin: 18px 15px 0;
  padding: 16px;
  border-radius: 20px;
  background: #fffdf5;
  border: 1px solid rgba(93,55,26,.18);
  font-size: 17px;
  line-height: 1.35;
  color: var(--brown-dark);
  box-shadow: 0 10px 30px rgba(93,55,26,.12);
  z-index: 2;
}

.hero {
  width: 94%;
  max-height: 620px;
  object-fit: contain;
  object-position: bottom center;
  filter: drop-shadow(0 18px 24px rgba(54, 31, 16, .25));
}

.doors-area {
  border-radius: 30px;
  padding: 28px;
  background: rgba(255, 250, 239, .68);
  border: 2px solid rgba(93,55,26,.16);
  box-shadow: var(--shadow);
}

.doors-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(115px, 1fr));
  gap: 18px;
  min-height: 700px;
  align-items: center;
}

.door-card {
  position: relative;
  min-height: 430px;
  min-width: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  color: inherit;
}

.door-card.locked {
  cursor: not-allowed;
  filter: grayscale(.55) saturate(.65);
  opacity: .62;
}

.door-shape {
  height: 310px;
  width: 100%;
  border-radius: 72px 72px 12px 12px;
  background:
    linear-gradient(90deg, rgba(255,255,255,.18), transparent 32%, rgba(0,0,0,.08) 100%),
    linear-gradient(180deg, #ba7440, #7e4628);
  border: 4px solid #5f321d;
  box-shadow: inset 0 0 0 7px rgba(255,231,178,.2), 0 16px 30px rgba(65,36,18,.22);
  position: relative;
  overflow: hidden;
  transition: transform .18s ease, opacity .18s ease;
}

.door-card:not(.locked):hover .door-shape {
  transform: translateY(-6px) rotate(-1deg);
}

.door-shape::before, .door-shape::after {
  content: "";
  position: absolute;
  top: 26px;
  bottom: 26px;
  width: 38%;
  border: 2px solid rgba(70,35,17,.42);
  border-radius: 48px 48px 8px 8px;
}

.door-shape::before { left: 12px; }
.door-shape::after { right: 12px; }

.door-number {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  background: #fff1c7;
  border: 3px solid #5f321d;
  border-radius: 50%;
  font-size: 24px;
  font-weight: 900;
}

.knob {
  position: absolute;
  top: 158px;
  right: 22px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffd05c;
  border: 2px solid #5f321d;
  z-index: 2;
}

.lock {
  position: absolute;
  left: 50%;
  bottom: 52px;
  transform: translateX(-50%);
  width: 46px;
  height: 38px;
  border-radius: 9px;
  background: #2d241c;
  display: grid;
  place-items: center;
  color: #fff1c7;
  font-size: 20px;
}

.lock::before {
  content: "";
  position: absolute;
  top: -22px;
  width: 28px;
  height: 28px;
  border: 6px solid #2d241c;
  border-bottom: 0;
  border-radius: 20px 20px 0 0;
}

.unlocked .lock, .completed .lock { display: none; }

.completed .door-shape {
  background:
    linear-gradient(90deg, rgba(255,255,255,.18), transparent 32%, rgba(0,0,0,.08) 100%),
    linear-gradient(180deg, #6f8a56, #435c36);
}

.door-title {
  box-sizing: border-box;
  width: 100%;
  min-height: 86px;
  margin-top: 16px;
  padding: 12px 8px;
  border-radius: 18px;
  background: rgba(255,255,255,.72);
  border: 1px solid rgba(93,55,26,.14);
  font-size: 14px;
  line-height: 1.2;
  font-weight: 700;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
  hyphens: auto;
}

.door-status {
  display: block;
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 400;
}

.modal, .finish-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(32, 22, 15, .58);
  z-index: 10;
}

.modal-card, .finish-card {
  width: min(860px, 94vw);
  max-height: 92vh;
  overflow-y: auto;
  background: #fff9ec;
  border-radius: 28px;
  border: 2px solid rgba(93,55,26,.22);
  padding: 28px;
  box-shadow: 0 30px 90px rgba(20, 13, 8, .45);
  position: relative;
}

.close-btn {
  position: absolute;
  top: 14px;
  right: 18px;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: #efe0c4;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-right: 42px;
}

.door-label {
  margin: 0;
  color: var(--green);
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 12px;
  font-weight: 900;
}

.progress-text {
  color: var(--muted);
  font-size: 14px;
}

.modal-card h2 {
  margin: 16px 0 18px;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.18;
}

.question-images {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin: 0 auto 18px;
}

.question-image {
  width: 100%;
  max-height: 330px;
  object-fit: contain;
  display: block;
  margin: 0 auto;
  border-radius: 18px;
  border: 1px solid rgba(93,55,26,.16);
  background: #f8ead1;
}

.answers {
  display: grid;
  gap: 12px;
}

.answer-btn {
  width: 100%;
  text-align: left;
  border: 2px solid rgba(93,55,26,.16);
  background: #fffdf6;
  border-radius: 18px;
  padding: 15px 16px;
  font-size: 18px;
  font-family: inherit;
  cursor: pointer;
  color: var(--ink);
}

.answer-btn:hover:not(:disabled) {
  border-color: var(--gold);
  background: #fff4d7;
}

.answer-btn.correct {
  border-color: #436f34;
  background: #e8f4dc;
}

.answer-btn.wrong {
  border-color: #a83d2a;
  background: #f9ded8;
}

.answer-btn:disabled {
  cursor: default;
}

.feedback {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 16px;
  background: #f3e4c7;
  color: var(--brown-dark);
  font-size: 17px;
  font-weight: 700;
}

.next-btn {
  margin-top: 18px;
}

.hidden {
  display: none !important;
}

.finish-card {
  text-align: center;
  max-width: 560px;
}

.finish-card h2 {
  margin: 0 0 10px;
  font-size: 42px;
}

.finish-card p {
  color: var(--muted);
  font-size: 18px;
}

@media (max-width: 1050px) {
  .stage {
    grid-template-columns: 1fr;
  }
  .hero-card {
    min-height: auto;
    flex-direction: row;
    justify-content: space-between;
    padding: 12px 18px 0;
  }
  .hero {
    width: 210px;
    max-height: 310px;
  }
  .quote-box {
    max-width: 560px;
  }
  .doors-grid {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
    min-height: auto;
  }
  .door-card {
    min-height: 390px;
  }
}

@media (max-width: 640px) {
  .top-panel {
    flex-direction: column;
    padding: 20px;
  }
  .top-actions {
    width: 100%;
    justify-content: flex-start;
  }
  .doors-area {
    padding: 16px;
  }
  .doors-grid {
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }
  .door-card {
    min-height: 335px;
  }
  .door-shape {
    height: 235px;
    border-radius: 54px 54px 10px 10px;
  }
  .door-title {
    font-size: 14px;
  }
  .hero-card {
    display: block;
    text-align: center;
  }
  .hero {
    width: 180px;
  }
  .modal-card {
    padding: 22px 16px;
  }
}
