:root {
  --bg-sky-top: #8fd9ff;
  --bg-sky-bottom: #e8fbff;
  --grass-1: #94dc5a;
  --grass-2: #62bc39;
  --wood-1: #8f5b2d;
  --wood-2: #6c401f;
  --cream: #fff6d7;
  --ink: #4f3316;
  --muted: #7e5f38;
  --gold: #ffd44e;
  --gold-2: #ffb326;
  --leaf: #5dc84c;
  --leaf-dark: #3a942c;
  --panel-shadow: rgba(116, 74, 22, 0.24);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Manrope", "Trebuchet MS", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 14% 10%, rgba(255, 255, 255, 0.75), transparent 16%),
    radial-gradient(circle at 82% 16%, rgba(255, 255, 255, 0.66), transparent 12%),
    linear-gradient(180deg, var(--bg-sky-top), var(--bg-sky-bottom) 48%, #b8ec79 48%, #8bd75b 100%);
  overflow-x: hidden;
}

.sky-orb {
  position: fixed;
  border-radius: 999px;
  pointer-events: none;
  z-index: 0;
  opacity: 0.6;
}

.orb-left {
  inset: 60px auto auto 40px;
  width: 160px;
  height: 160px;
  background: radial-gradient(circle, rgba(255, 248, 177, 0.95), rgba(255, 208, 86, 0.86) 55%, rgba(255, 203, 69, 0) 72%);
}

.orb-right {
  inset: 90px 60px auto auto;
  width: 220px;
  height: 110px;
  background:
    radial-gradient(circle at 35% 50%, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.78) 36%, rgba(255, 255, 255, 0) 56%),
    radial-gradient(circle at 55% 48%, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.8) 36%, rgba(255, 255, 255, 0) 56%),
    radial-gradient(circle at 76% 54%, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.76) 34%, rgba(255, 255, 255, 0) 54%);
}

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding: 18px;
}

.frame {
  max-width: 1560px;
  margin: 0 auto;
  display: grid;
  gap: 16px;
}

.panel {
  border-radius: 28px;
  border: 5px solid #8f602f;
  background: linear-gradient(180deg, #fff7de, #ffeeb7);
  box-shadow:
    0 12px 0 #b27837,
    0 24px 36px var(--panel-shadow);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 18px 18px;
  background:
    linear-gradient(180deg, rgba(255, 250, 222, 0.9), rgba(255, 236, 171, 0.9)),
    linear-gradient(90deg, #7f4b23, #a66a31);
}

.eyebrow {
  color: #ac6a26;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
}

h1,
h2 {
  margin: 0;
  font-family: "Marcellus", Georgia, serif;
}

h1 {
  font-size: clamp(1.8rem, 1.45rem + 1vw, 2.6rem);
  color: #6e421e;
  text-shadow: 0 2px 0 rgba(255, 248, 219, 0.95);
}

.subtitle,
.panel-copy {
  margin: 8px 0 0;
  line-height: 1.45;
  color: var(--muted);
}

.score-cluster {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.score-box {
  min-width: 152px;
  padding: 10px 14px 11px;
  border-radius: 20px;
  border: 4px solid #915926;
  background: linear-gradient(180deg, #fff6cf, #ffd65f);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.55);
  display: grid;
  justify-items: end;
}

.score-box.secondary {
  background: linear-gradient(180deg, #e8fff1, #96ef8d);
}

.score-label {
  color: #8c5725;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.score-value {
  font-size: 2rem;
  color: #623917;
}

.score-value.accent {
  color: #2f8b2c;
}

.score-goal {
  color: #7a552b;
  font-size: 0.82rem;
  font-weight: 700;
}

.layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 300px;
  gap: 16px;
  align-items: start;
}

.rail {
  display: grid;
  gap: 16px;
}

.controls-panel,
.stats-panel,
.objective-panel,
.legend-panel {
  padding: 16px;
}

.panel-title {
  color: #6d431d;
  font-family: "Marcellus", Georgia, serif;
  font-size: 1.08rem;
}

.piece-picker {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.piece-btn {
  border: 4px solid #8f5a2a;
  border-radius: 20px;
  background: linear-gradient(180deg, #fff8dd, #f8d972);
  color: var(--ink);
  text-align: left;
  padding: 10px 11px;
  cursor: pointer;
  box-shadow: 0 6px 0 #c98b3c;
  transition: transform 100ms ease, box-shadow 100ms ease, border-color 100ms ease;
}

.piece-btn:hover {
  transform: translateY(-2px);
}

.piece-btn[data-active="true"] {
  border-color: #53b93f;
  background: linear-gradient(180deg, #f6ffdc, #b4eb76);
  box-shadow: 0 6px 0 #7ec53e;
}

.piece-btn[disabled] {
  opacity: 0.52;
  cursor: not-allowed;
  transform: none;
}

.piece-main {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 0.92rem;
}

.piece-meta,
.piece-note,
.legend-bonus {
  color: #7e5f38;
  font-size: 0.8rem;
  font-weight: 700;
}

.piece-note {
  margin-top: 4px;
  line-height: 1.28;
}

.actions {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.btn {
  border: 4px solid #8f5a2a;
  border-radius: 18px;
  padding: 12px 14px;
  background: linear-gradient(180deg, #ffe37d, #ffbe36);
  color: #6a401b;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 6px 0 #ca882d;
}

.btn.ghost {
  background: linear-gradient(180deg, #fff8de, #ffe6a8);
}

.breakdown {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  padding: 6px 11px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ecffd8, #c4f18f);
  border: 3px solid #7ab940;
  color: #4f6a1f;
  font-size: 0.8rem;
  font-weight: 800;
}

.progress-shell {
  margin-top: 14px;
}

.progress-track {
  width: 100%;
  height: 18px;
  border-radius: 999px;
  border: 3px solid #8f5a2a;
  background: #fff3bf;
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #7de8ff, #7fdc56 70%, #ffe06d);
  transition: width 220ms ease;
}

.status-bar {
  margin: 14px 0 0;
  padding: 13px 14px;
  border-radius: 18px;
  border: 4px solid #8f5a2a;
  background: linear-gradient(180deg, #fffdf0, #fff0bb);
  color: #71532c;
  font-weight: 700;
  line-height: 1.42;
}

.center-stage {
  min-width: 0;
}

.stage-shell {
  position: relative;
  padding: 14px;
  overflow: hidden;
  min-height: 800px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.38), rgba(255, 244, 201, 0.42)),
    linear-gradient(180deg, #d7f6ff, #c8f39d 48%, #86d84d 100%);
}

.stage-shell::before {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: 24px;
  background:
    radial-gradient(circle at 22% 16%, rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0) 20%),
    radial-gradient(circle at 82% 18%, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0) 18%),
    linear-gradient(180deg, #9bddff, #c8f8ff 44%, #83d75c 44%, #7acb4c 100%);
  border: 4px solid rgba(255, 255, 255, 0.55);
}

.game-stage {
  position: relative;
  z-index: 1;
  width: 100%;
  aspect-ratio: 900 / 760;
  border-radius: 24px;
  overflow: hidden;
}

.game-stage svg {
  display: block;
  width: 100%;
  height: 100%;
}

.win-banner {
  position: absolute;
  top: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  width: min(420px, calc(100% - 36px));
  padding: 16px 16px 14px;
  border-radius: 24px;
  border: 5px solid #8b5728;
  background: linear-gradient(180deg, #fff9e1, #ffe38a);
  text-align: center;
  box-shadow: 0 10px 0 #ca8a2f, 0 20px 28px rgba(129, 89, 20, 0.2);
}

.win-banner h2 {
  margin-top: 6px;
  color: #6a401b;
}

.win-banner p {
  margin: 8px 0 14px;
  color: #7e5f38;
  font-weight: 700;
}

.objective-title {
  margin-top: 12px;
  font-family: "Marcellus", Georgia, serif;
  font-size: 1.18rem;
  color: #6d431d;
}

.legend-stack {
  margin-top: 14px;
  display: grid;
  gap: 8px;
}

.legend-card {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 18px;
  border: 4px solid #9c6a34;
  background: linear-gradient(180deg, #fffbe8, #ffeab2);
}

.legend-copy {
  display: grid;
  gap: 2px;
}

.legend-name {
  font-weight: 800;
  font-size: 0.92rem;
  color: #6a421b;
}

.legend-text {
  color: #7f6037;
  font-size: 0.8rem;
  line-height: 1.32;
  font-weight: 700;
}

.legend-bonus {
  color: #4f8a21;
}

.html-icon,
.legend-icon {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(84, 117, 45, 0.34);
  backdrop-filter: blur(8px);
  display: none;
  place-items: center;
  padding: 18px;
  z-index: 30;
}

.overlay.show {
  display: grid;
}

.overlay-card {
  width: min(580px, 100%);
  padding: 22px;
  border-radius: 28px;
  border: 5px solid #8f5a2a;
  background: linear-gradient(180deg, #fff9e2, #ffe8a8);
  box-shadow: 0 12px 0 #c98b3c, 0 28px 42px rgba(116, 74, 22, 0.26);
}

.overlay-card h2 {
  margin-top: 8px;
  color: #6b411b;
  font-size: 1.6rem;
}

.overlay-card p,
.overlay-list {
  color: #7d5f37;
  line-height: 1.5;
  font-weight: 700;
}

.overlay-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.overlay-actions {
  margin-top: 18px;
  display: flex;
  gap: 10px;
}

.iso-stage text {
  user-select: none;
}

.iso-tile {
  cursor: pointer;
}

.iso-tile:hover .tile-top {
  filter: brightness(1.04);
}

.tile-shadow {
  opacity: 0.14;
}

.mana-line {
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (max-width: 1260px) {
  .layout {
    grid-template-columns: 280px minmax(0, 1fr) 280px;
  }
}

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

  .stage-shell {
    min-height: auto;
  }

  .score-cluster {
    justify-content: flex-start;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 12px;
  }

  .topbar {
    flex-direction: column;
  }

  .piece-picker,
  .actions {
    grid-template-columns: 1fr;
  }

  .overlay-actions {
    flex-direction: column;
  }
}
