:root {
  --background: #fff8e6;
  --foreground: #1a1712;
  --ink: #1a1712;
  --gold: #f7c733;
  --amber: #f08b2f;
  --mint: #3eb59f;
  --paper: #fffdf7;
  --line: rgba(26, 23, 18, 0.16);
  --shadow: 0 20px 48px rgba(42, 30, 9, 0.14);
  font-family:
    system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--background);
}

body {
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at 8% 8%, rgba(62, 181, 159, 0.2), transparent 26rem),
    radial-gradient(circle at 92% 2%, rgba(228, 93, 118, 0.16), transparent 24rem),
    linear-gradient(180deg, #fff9ea 0%, #fff3cb 48%, #fce8a6 100%);
  color: var(--foreground);
}

button,
[role="button"] {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

.game-shell {
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
  padding: clamp(14px, 3vw, 28px);
  overflow-x: hidden;
}

.hero-band {
  width: min(1120px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(132px, 270px);
  align-items: center;
  gap: clamp(12px, 3vw, 28px);
  min-height: clamp(158px, 24vh, 240px);
}

.hero-copy {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: #7a490c;
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  max-width: 11em;
  color: var(--ink);
  font-size: clamp(2rem, 6vw, 5rem);
  font-weight: 1000;
  line-height: 0.96;
}

.lead {
  max-width: 36rem;
  margin: 12px 0 0;
  color: #5a4020;
  font-size: clamp(0.94rem, 2.3vw, 1.08rem);
  line-height: 1.75;
}

.mascot-frame {
  align-self: end;
  display: grid;
  justify-items: center;
  min-width: 0;
}

.mascot-frame img {
  width: min(100%, 265px);
  height: auto;
  filter: drop-shadow(0 18px 20px rgba(80, 48, 8, 0.2));
}

.play-surface {
  width: min(1120px, 100%);
  min-height: 0;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto auto auto minmax(270px, 1fr) auto;
  gap: 12px;
  padding: clamp(14px, 2.4vw, 22px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.control-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.difficulty {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  width: min(100%, 360px);
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff6d7;
}

.difficulty button,
.reset-button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  color: var(--ink);
  font-weight: 900;
}

.difficulty button {
  background: transparent;
}

.difficulty button.active {
  background: var(--ink);
  color: #fff8df;
}

.reset-button {
  min-width: 108px;
  padding: 0 16px;
  background: var(--mint);
  color: #063127;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.12);
}

.score-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.score-row span {
  min-width: 0;
  min-height: 48px;
  display: grid;
  align-content: center;
  gap: 1px;
  padding: 8px 10px;
  border: 1px solid rgba(26, 23, 18, 0.13);
  border-radius: 8px;
  background: #ffffffb8;
  color: #6a4d22;
  font-size: 0.78rem;
  font-weight: 800;
}

.score-row strong {
  color: var(--ink);
  font-size: clamp(1rem, 2.4vw, 1.28rem);
  line-height: 1.05;
  white-space: nowrap;
}

.guide-message {
  min-height: 38px;
  margin: 0;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #1a1712;
  color: #fff4cf;
  font-weight: 900;
  text-align: center;
  line-height: 1.35;
  padding: 9px 12px;
}

.guide-message.win {
  background: #0d6f5b;
  color: #effff9;
}

.tower-board {
  min-height: 270px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(7px, 2vw, 16px);
  padding-top: 4px;
}

.tower-zone {
  position: relative;
  min-width: 0;
  min-height: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
  align-items: end;
  justify-items: center;
  padding: 14px 7px 20px;
  border: 2px solid rgba(26, 23, 18, 0.1);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(255, 247, 218, 0.88)),
    repeating-linear-gradient(135deg, rgba(247, 199, 51, 0.14) 0 10px, transparent 10px 24px);
  cursor: pointer;
  outline: none;
  overflow: hidden;
}

.tower-zone:focus-visible {
  border-color: var(--mint);
  box-shadow: 0 0 0 4px rgba(62, 181, 159, 0.22);
}

.tower-zone.selected {
  border-color: var(--amber);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(255, 236, 168, 0.92)),
    repeating-linear-gradient(135deg, rgba(26, 23, 18, 0.08) 0 10px, transparent 10px 24px);
}

.tower-label {
  position: relative;
  z-index: 3;
  align-self: start;
  color: #6a4d22;
  font-size: clamp(0.72rem, 2vw, 0.88rem);
  font-weight: 900;
  line-height: 1.2;
}

.tower-post {
  position: absolute;
  bottom: 35px;
  left: 50%;
  width: clamp(12px, 2.5vw, 22px);
  height: calc(100% - 76px);
  transform: translateX(-50%);
  border-radius: 999px 999px 4px 4px;
  background: linear-gradient(90deg, #9c5b21, #d28b3a 48%, #7a3d18);
  box-shadow: inset 4px 0 8px rgba(255, 255, 255, 0.2);
}

.tower-base {
  position: absolute;
  right: 9%;
  bottom: 17px;
  left: 9%;
  height: 24px;
  border-radius: 999px;
  background: linear-gradient(180deg, #2b2a26, #12110f);
  box-shadow: 0 8px 14px rgba(0, 0, 0, 0.16);
}

.disk-stack {
  position: relative;
  z-index: 2;
  width: 100%;
  min-height: 188px;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  justify-content: flex-start;
  gap: 5px;
  padding-bottom: 28px;
  pointer-events: none;
}

.disk {
  height: clamp(28px, 5.6vw, 42px);
  min-width: 48px;
  border: 0;
  border-radius: 999px;
  background: var(--gold);
  box-shadow:
    inset 0 -6px 0 rgba(0, 0, 0, 0.16),
    inset 0 5px 0 rgba(255, 255, 255, 0.28),
    0 6px 10px rgba(37, 24, 7, 0.12);
  pointer-events: auto;
  touch-action: none;
  cursor: grab;
}

.disk.top-disk:active {
  cursor: grabbing;
}

.disk.drag-source {
  opacity: 0.38;
}

.disk-1,
.disk-3,
.disk-5 {
  background:
    linear-gradient(90deg, transparent 0 24%, rgba(20, 18, 16, 0.92) 24% 39%, transparent 39% 58%, rgba(20, 18, 16, 0.92) 58% 72%, transparent 72%),
    var(--gold);
}

.disk-2,
.disk-4,
.disk-6 {
  background:
    linear-gradient(90deg, transparent 0 18%, rgba(247, 199, 51, 0.95) 18% 32%, transparent 32% 62%, rgba(247, 199, 51, 0.95) 62% 78%, transparent 78%),
    #1d1c19;
}

.drag-ghost {
  position: fixed;
  z-index: 20;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0.92;
}

.rules-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  color: #6a4d22;
  font-size: 0.82rem;
  font-weight: 800;
}

.rules-row span {
  padding: 6px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.64);
}

.win-burst {
  position: fixed;
  right: clamp(14px, 3vw, 28px);
  bottom: clamp(14px, 3vw, 28px);
  z-index: 10;
  display: grid;
  gap: 2px;
  padding: 14px 18px;
  border: 2px solid rgba(255, 255, 255, 0.75);
  border-radius: 8px;
  background: #0d6f5b;
  color: #effff9;
  box-shadow: 0 16px 32px rgba(13, 111, 91, 0.28);
  animation: pop-in 340ms ease-out;
}

.win-burst strong {
  font-size: 1rem;
}

.win-burst span {
  font-size: 0.84rem;
  font-weight: 800;
}

@keyframes pop-in {
  from {
    transform: translateY(12px) scale(0.94);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@media (max-width: 780px) {
  .game-shell {
    gap: 10px;
    padding: 10px;
  }

  .hero-band {
    grid-template-columns: minmax(0, 1fr) minmax(92px, 34vw);
    min-height: 132px;
  }

  .lead {
    margin-top: 8px;
    line-height: 1.55;
  }

  .play-surface {
    grid-template-rows: auto auto auto minmax(300px, 1fr) auto;
    padding: 10px;
  }

  .control-strip {
    align-items: stretch;
  }

  .reset-button {
    min-width: 88px;
  }

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

  .score-row span {
    min-height: 44px;
  }

  .tower-board {
    min-height: 300px;
    gap: 6px;
  }

  .tower-zone {
    padding-inline: 4px;
  }

  .disk-stack {
    min-height: 215px;
    gap: 4px;
  }
}

@media (max-width: 430px) {
  .hero-band {
    gap: 6px;
  }

  .eyebrow {
    font-size: 0.68rem;
  }

  h1 {
    font-size: clamp(1.74rem, 10vw, 2.35rem);
  }

  .lead {
    font-size: 0.82rem;
  }

  .mascot-frame img {
    width: min(100%, 132px);
  }

  .control-strip {
    flex-direction: column;
  }

  .difficulty {
    width: 100%;
  }

  .reset-button {
    width: 100%;
  }

  .guide-message {
    font-size: 0.86rem;
  }

  .tower-board {
    min-height: 322px;
  }

  .disk {
    height: 30px;
    min-width: 40px;
  }

  .rules-row {
    font-size: 0.74rem;
  }
}
