:root {
  --sky-top: #8edcff;
  --sky-mid: #c7f1ff;
  --sky-low: #f5fdff;
  --ink: #244059;
  --blue: #2f72da;
  --yellow: #ffd84d;
  --orange: #ffb443;
  --green: #8dde7c;
  --pink: #ff98b8;
  --paper: #fffdf4;
  --cloud: #ffffff;
  --shadow: 0 12px 0 rgba(36, 64, 89, 0.1), 0 22px 32px rgba(36, 64, 89, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100svh;
  font-family: "Comic Sans MS", "Chalkboard SE", "Marker Felt", cursive;
  color: var(--ink);
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 45%, var(--sky-low) 100%);
  overflow: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  z-index: 0;
  pointer-events: none;
}

body::before {
  left: -10vw;
  right: -10vw;
  bottom: -14vh;
  height: 24vh;
  background: #7fd35f;
  border-radius: 48% 52% 0 0 / 100% 100% 0 0;
}

body::after {
  left: 15vw;
  bottom: -10vh;
  width: 42vw;
  height: 18vh;
  background: #68bd4e;
  border-radius: 56% 44% 0 0 / 100% 100% 0 0;
}

.sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.cloud {
  position: absolute;
  background: var(--cloud);
  height: 48px;
  border-radius: 38px;
  box-shadow: 0 8px 0 rgba(255, 255, 255, 0.55);
  animation: drift 14s ease-in-out infinite;
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  background: var(--cloud);
  border-radius: 50%;
}

.cloud::before {
  width: 34px;
  height: 34px;
  left: 8px;
  top: -16px;
}

.cloud::after {
  width: 42px;
  height: 42px;
  right: 10px;
  top: -20px;
}

.cloud-a {
  width: 108px;
  top: 7%;
  left: 8%;
}

.cloud-b {
  width: 142px;
  top: 13%;
  right: 8%;
  animation-delay: -6s;
}

.wrap {
  position: relative;
  z-index: 1;
  width: min(1120px, calc(100vw - 18px));
  height: calc(100svh - 10px);
  margin: 5px auto;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
}

.hero,
.board,
.side {
  background: var(--paper);
  border: 4px solid rgba(36, 64, 89, 0.1);
  box-shadow: var(--shadow);
}

.hero {
  min-height: 104px;
  padding: 12px 16px;
  border-radius: 28px 34px 24px 32px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
}

.hero-copy {
  display: grid;
  gap: 8px;
}

.badge {
  width: fit-content;
  padding: 7px 11px;
  border-radius: 18px 20px 16px 22px;
  background: linear-gradient(135deg, #ffe77c, #fff6b8);
  border: 3px dashed rgba(36, 64, 89, 0.16);
  font-weight: 900;
}

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

h1 {
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 0.95;
  color: var(--blue);
  text-shadow: 0 4px 0 rgba(255, 216, 77, 0.6);
}

.hero p,
.status,
.helper,
.tiny-link {
  font-size: clamp(0.94rem, 1.8vw, 1.05rem);
}

.hero-scene {
  display: flex;
  align-items: end;
  gap: 12px;
}

.sun-face,
.logic-buddy {
  position: relative;
  flex: 0 0 auto;
}

.sun-face {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff7bf 0%, var(--yellow) 48%, var(--orange) 100%);
  box-shadow: 0 8px 0 rgba(36, 64, 89, 0.08);
}

.sun-face::before {
  content: "";
  position: absolute;
  width: 7px;
  height: 7px;
  left: 21px;
  top: 26px;
  background: var(--ink);
  border-radius: 50%;
  box-shadow: 22px 2px 0 var(--ink);
}

.sun-face::after {
  content: "";
  position: absolute;
  width: 25px;
  height: 12px;
  left: 22px;
  top: 40px;
  border-bottom: 4px solid var(--ink);
  border-radius: 0 0 18px 18px;
}

.logic-buddy {
  width: 66px;
  height: 60px;
  border-radius: 26px 22px 28px 20px;
  background: linear-gradient(135deg, #ff9db6, #ffd787);
  box-shadow: 0 8px 0 rgba(36, 64, 89, 0.08);
}

.logic-buddy::before {
  content: "";
  position: absolute;
  width: 7px;
  height: 7px;
  left: 18px;
  top: 22px;
  background: var(--ink);
  border-radius: 50%;
  box-shadow: 22px 0 0 var(--ink);
}

.logic-buddy::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 10px;
  left: 22px;
  top: 34px;
  border-bottom: 4px solid var(--ink);
  border-radius: 0 0 18px 18px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 10px;
  min-height: 0;
}

.board {
  min-height: 0;
  border-radius: 34px 24px 28px 38px;
  padding: 14px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 12px;
  overflow: hidden;
}

.story {
  padding: 12px 14px;
  border-radius: 22px 18px 24px 18px;
  background: linear-gradient(135deg, #ffeab0, #ffd6a7);
  border: 3px dashed rgba(36, 64, 89, 0.14);
  text-align: center;
  font-weight: 800;
}

.logic-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  align-items: center;
}

.slot,
.sample,
.tray-block {
  min-height: 98px;
  border-radius: 24px 20px 28px 18px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.8);
  border: 3px solid rgba(36, 64, 89, 0.08);
}

.sample {
  box-shadow: inset 0 0 0 3px rgba(47, 114, 218, 0.08);
}

.slot {
  border-style: dashed;
  background: rgba(212, 240, 255, 0.72);
  transition: transform 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

.slot.over {
  background: #fff6be;
  transform: scale(1.02);
}

.slot.correct {
  background: #dff9c6;
  animation: happyBounce 420ms ease;
}

.slot.wrong {
  background: #ffd8df;
  animation: softShake 360ms ease;
}

.block-face {
  width: min(82px, 100%);
  aspect-ratio: 1;
  border-radius: 22px;
  border: 4px solid rgba(36, 64, 89, 0.12);
  box-shadow: 0 8px 0 rgba(36, 64, 89, 0.08);
  display: grid;
  place-items: center;
  font-size: 2rem;
  font-weight: 900;
  color: rgba(36, 64, 89, 0.78);
}

.block-face.circle {
  border-radius: 50%;
}

.block-face.diamond {
  border-radius: 18px;
  transform: rotate(45deg);
}

.block-face.diamond > span {
  transform: rotate(-45deg);
}

.block-face.triangle {
  width: 0;
  height: 0;
  background: transparent !important;
  border-left: 40px solid transparent;
  border-right: 40px solid transparent;
  border-bottom: 74px solid;
  border-top: 0;
  border-radius: 0;
  box-shadow: none;
  border-left-color: transparent !important;
  border-right-color: transparent !important;
  border-bottom-color: currentColor;
  color: inherit;
}

.block-face.triangle > span {
  display: none;
}

.block-face.square {
  border-radius: 18px;
}

.tray {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.tray-block {
  cursor: grab;
  background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(246, 250, 255, 0.88));
}

.tray-block.selected {
  outline: 4px solid rgba(47, 114, 218, 0.22);
  transform: translateY(-3px);
}

.tray-block.used {
  opacity: 0.35;
  pointer-events: none;
}

.status {
  min-height: 1.5em;
  text-align: center;
  color: var(--blue);
  font-weight: 900;
}

.status.good {
  color: #258a47;
}

.status.bad {
  color: #d44c6c;
}

.action-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.action-btn {
  border: 3px solid rgba(36, 64, 89, 0.08);
  border-radius: 18px 22px 18px 24px;
  padding: 11px 16px;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 900;
  cursor: pointer;
  background: linear-gradient(135deg, var(--blue), #68a3ff);
  color: white;
  box-shadow: 0 9px 0 rgba(36, 64, 89, 0.12);
}

.action-btn.secondary {
  background: linear-gradient(135deg, #ff9eb5, #ffcf7d);
  color: var(--ink);
}

.side {
  min-height: 0;
  border-radius: 30px 38px 24px 34px;
  padding: 14px;
  display: grid;
  gap: 10px;
  align-content: start;
}

.score-box {
  background: white;
  padding: 12px;
  border-radius: 20px 28px 18px 24px;
  text-align: center;
  box-shadow: inset 0 0 0 3px rgba(47, 114, 218, 0.08);
}

.score-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 800;
  opacity: 0.84;
}

.score-value {
  display: block;
  margin-top: 4px;
  font-size: 2rem;
  font-weight: 900;
}

.stars {
  min-height: 1.4em;
  text-align: center;
  font-size: 1.7rem;
  letter-spacing: 0.12em;
}

.helper {
  padding: 10px 12px;
  border-radius: 18px 24px 18px 22px;
  background: linear-gradient(135deg, rgba(141, 222, 124, 0.34), rgba(255, 245, 173, 0.62));
  text-align: center;
  font-weight: 800;
  line-height: 1.3;
}

.tiny-links {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tiny-link {
  text-decoration: none;
  color: var(--ink);
  font-weight: 900;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.84);
  border: 2px solid rgba(36, 64, 89, 0.08);
}

@keyframes drift {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(14px); }
}

@keyframes happyBounce {
  0% { transform: scale(1); }
  40% { transform: scale(1.05) translateY(-4px); }
  100% { transform: scale(1); }
}

@keyframes softShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  50% { transform: translateX(7px); }
  75% { transform: translateX(-5px); }
}

@media (max-width: 860px) {
  .wrap {
    width: min(100vw - 10px, 1120px);
    height: calc(100svh - 8px);
    margin: 4px auto;
    gap: 8px;
  }

  .hero {
    padding: 10px 12px;
  }

  .hero p {
    font-size: 0.86rem;
  }

  .layout {
    grid-template-columns: minmax(0, 1fr) 210px;
    gap: 8px;
  }

  .board,
  .side {
    padding: 10px;
    gap: 8px;
  }

  .logic-row {
    gap: 8px;
  }

  .slot,
  .sample,
  .tray-block {
    min-height: 84px;
  }

  .block-face {
    width: 66px;
  }
}
