:root {
  color-scheme: light;
  --ink: #1a140f;
  --muted: #5e5347;
  --wood: #b77f4b;
  --wood-dark: #3c2a1b;
  --leaf: #2f5d3c;
  --cream: #f7f0e6;
  --mist: rgba(248, 243, 234, 0.82);
  --shadow: rgba(26, 20, 15, 0.2);
  --accent: #edb763;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Figtree", "Segoe UI", sans-serif;
  background: radial-gradient(circle at 15% 15%, #fff4d7, transparent 45%),
    radial-gradient(circle at 80% 20%, #cbe9d0, transparent 42%),
    radial-gradient(circle at 50% 100%, #f0d4b4, transparent 55%),
    #f3e5d1;
  color: var(--ink);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

.canopy {
  position: fixed;
  inset: -20% -10% auto -10%;
  height: 55vh;
  background: radial-gradient(circle at 30% 40%, rgba(47, 93, 60, 0.5), transparent 60%),
    radial-gradient(circle at 70% 30%, rgba(47, 93, 60, 0.4), transparent 55%);
  filter: blur(20px);
  z-index: 0;
}

.grain {
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140' viewBox='0 0 140 140'><filter id='g'><feTurbulence type='fractalNoise' baseFrequency='.7' numOctaves='3' stitchTiles='stitch'/></filter><rect width='140' height='140' filter='url(%23g)' opacity='0.2'/></svg>");
  opacity: 0.18;
  mix-blend-mode: multiply;
  pointer-events: none;
  z-index: 1;
}

.back-link {
  position: fixed;
  top: 1.5rem;
  left: 1.5rem;
  text-decoration: none;
  font-size: 0.9rem;
  color: var(--wood-dark);
  padding: 0.35rem 0.75rem;
  background: var(--mist);
  border-radius: 999px;
  box-shadow: 0 10px 30px var(--shadow);
  z-index: 2;
}

.back-link:hover {
  transform: translateY(-1px);
}

.game {
  position: relative;
  z-index: 2;
  max-width: 1150px;
  margin: 0 auto;
  padding: 5rem 4vw 4rem;
  display: grid;
  gap: 2.5rem;
}

.intro {
  max-width: 680px;
  display: grid;
  gap: 1.2rem;
  animation: rise 0.8s ease-out;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.28rem;
  font-size: 0.75rem;
  color: var(--muted);
}

h1 {
  font-family: "Cinzel", serif;
  font-size: clamp(2.2rem, 3vw + 1rem, 3.4rem);
  color: var(--wood-dark);
}

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

.intro-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

button {
  font: inherit;
  border: none;
  cursor: pointer;
  border-radius: 999px;
  padding: 0.75rem 1.6rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button:focus-visible {
  outline: 2px solid var(--wood-dark);
  outline-offset: 2px;
}

.primary {
  background: var(--wood-dark);
  color: #fff;
  box-shadow: 0 12px 20px rgba(60, 42, 27, 0.35);
}

.ghost {
  background: transparent;
  color: var(--wood-dark);
  border: 1px solid rgba(60, 42, 27, 0.3);
}

.board {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
  gap: 1.8rem;
  align-items: start;
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

body.started .board {
  opacity: 1;
  transform: translateY(0);
}

.story-panel {
  background: var(--mist);
  border-radius: 24px;
  padding: 2rem;
  box-shadow: 0 20px 40px var(--shadow);
  display: grid;
  gap: 1.5rem;
  border: 1px solid rgba(60, 42, 27, 0.12);
}

.story-header {
  display: flex;
  gap: 1.2rem;
  align-items: center;
}

.floor-visual {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.2rem;
}

.floor-visual img {
  width: 100%;
  height: clamp(180px, 26vw, 240px);
  object-fit: cover;
  border-radius: 18px;
  border: 1px solid rgba(60, 42, 27, 0.12);
  box-shadow: 0 16px 30px rgba(26, 20, 15, 0.18);
}

.floor-visual figcaption {
  font-size: 0.85rem;
  color: var(--muted);
}

.floor-chip {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, #f6d7a4, #e9a963);
  font-family: "Cinzel", serif;
  font-size: 1.4rem;
  color: var(--wood-dark);
  box-shadow: 0 10px 24px rgba(183, 127, 75, 0.35);
}

.floor-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.2rem;
  color: var(--muted);
}

.floor-tag {
  font-size: 0.9rem;
  color: var(--leaf);
  font-weight: 600;
}

.floor-description {
  font-size: 1.05rem;
  line-height: 1.65;
  color: var(--wood-dark);
}

.choice {
  display: grid;
  gap: 0.5rem;
  text-align: left;
  background: #fff;
  border-radius: 18px;
  padding: 1rem 1.1rem;
  box-shadow: 0 10px 20px rgba(26, 20, 15, 0.1);
  border: 1px solid rgba(60, 42, 27, 0.08);
}

.choice-image {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid rgba(60, 42, 27, 0.12);
}

.choice span {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.18rem;
  color: var(--muted);
}

.choice strong {
  display: block;
  font-size: 1.05rem;
  color: var(--wood-dark);
}

.choice p {
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.5;
}

.choices {
  display: grid;
  gap: 0.85rem;
}

.choice-hint {
  font-size: 0.9rem;
  color: var(--muted);
}

.result {
  background: rgba(47, 93, 60, 0.1);
  border-radius: 16px;
  padding: 1rem 1.2rem;
  border: 1px solid rgba(47, 93, 60, 0.25);
  color: var(--leaf);
  font-weight: 600;
  animation: pop 0.4s ease;
}

.side-panel {
  display: grid;
  gap: 1rem;
}

.panel-card {
  background: rgba(255, 255, 255, 0.85);
  border-radius: 20px;
  padding: 1.5rem;
  box-shadow: 0 14px 30px var(--shadow);
  border: 1px solid rgba(60, 42, 27, 0.12);
  display: grid;
  gap: 0.8rem;
}

.panel-card h3 {
  font-family: "Cinzel", serif;
  font-size: 1.05rem;
  color: var(--wood-dark);
}

.inventory,
.log,
.ladder {
  list-style: none;
  display: grid;
  gap: 0.4rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.inventory-item {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 0.75rem;
  align-items: center;
}

.inventory-image {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid rgba(60, 42, 27, 0.12);
  box-shadow: 0 8px 16px rgba(26, 20, 15, 0.12);
}

.log li {
  padding-left: 1.2rem;
  position: relative;
}

.log li::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  position: absolute;
  left: 0;
  top: 0.45rem;
}

.progress {
  display: grid;
  gap: 0.6rem;
}

.progress-bar {
  height: 10px;
  border-radius: 999px;
  background: rgba(60, 42, 27, 0.12);
  overflow: hidden;
}

.progress-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #e7a64e, #c97b36);
  border-radius: inherit;
  width: 0%;
  transition: width 0.4s ease;
}

.progress-text {
  font-size: 0.85rem;
  color: var(--muted);
}

.ladder {
  display: grid;
  gap: 0.35rem;
}

.ladder li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.7rem;
  border-radius: 12px;
  background: rgba(247, 240, 230, 0.85);
  border: 1px solid rgba(60, 42, 27, 0.1);
  font-size: 0.85rem;
}

.ladder li.locked {
  opacity: 0.5;
}

.ladder li.current {
  background: rgba(183, 127, 75, 0.2);
  color: var(--wood-dark);
  font-weight: 600;
}

.ladder li.cleared {
  border-color: rgba(47, 93, 60, 0.4);
}

.panel-toggle {
  background: rgba(60, 42, 27, 0.08);
  border: 1px solid rgba(60, 42, 27, 0.2);
  color: var(--wood-dark);
  border-radius: 14px;
  padding: 0.65rem 1rem;
}

.side-panel.collapsed .panel-card {
  display: none;
}

.side-panel.collapsed .panel-toggle {
  background: rgba(183, 127, 75, 0.2);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pop {
  from {
    transform: scale(0.98);
    opacity: 0.6;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@media (max-width: 960px) {
  .board {
    grid-template-columns: 1fr;
  }

  .back-link {
    position: static;
    align-self: flex-start;
    margin-bottom: 1rem;
  }

  .game {
    padding-top: 3.5rem;
  }
}

@media (max-width: 720px) {
  .intro-actions {
    flex-direction: column;
    align-items: flex-start;
  }

  .story-panel {
    padding: 1.6rem;
  }

  .choice {
    padding: 0.9rem 1rem;
  }
}
