:root {
  --ink: #26313d;
  --muted: #617080;
  --leaf: #2f8f5b;
  --leaf-dark: #1f6f45;
  --sky: #8bd7f7;
  --sun: #ffd66b;
  --coral: #ef6f61;
  --violet: #7060d6;
  --blue: #337bd9;
  --gold: #f3b83f;
  --paper: rgba(255, 255, 255, 0.9);
  --shadow: 0 18px 48px rgba(33, 46, 60, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-rounded, "Nunito Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(180deg, rgba(139, 215, 247, 0.45), rgba(255, 251, 237, 0.96)),
    #f7f3e8;
}

button {
  font: inherit;
}

.game-shell {
  display: grid;
  grid-template-columns: minmax(300px, 0.82fr) minmax(430px, 1.18fr);
  gap: 24px;
  min-height: 100vh;
  padding: clamp(16px, 3vw, 32px);
}

.hero-panel,
.play-panel {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(38, 49, 61, 0.1);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.hero-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 620px;
  padding: clamp(20px, 4vw, 36px);
  background: linear-gradient(180deg, #bdeaff 0%, #eaf9df 56%, #86c766 100%);
}

.brand-row {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-mark {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  color: white;
  background: var(--leaf);
  font-weight: 900;
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.13);
}

.eyebrow,
.task-type,
.label {
  margin: 0;
  color: var(--leaf-dark);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2.3rem, 5vw, 4.7rem);
  line-height: 0.92;
  letter-spacing: 0;
}

.pasture {
  position: absolute;
  inset: 0;
}

.sun {
  position: absolute;
  top: 104px;
  right: 16%;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--sun);
  box-shadow: 0 0 0 16px rgba(255, 214, 107, 0.28);
}

.cloud {
  position: absolute;
  width: 118px;
  height: 42px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  animation: drift 9s ease-in-out infinite alternate;
}

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

.cloud::before {
  left: 24px;
  bottom: 18px;
  width: 48px;
  height: 48px;
}

.cloud::after {
  right: 18px;
  bottom: 12px;
  width: 62px;
  height: 62px;
}

.cloud-one {
  top: 170px;
  left: 10%;
}

.cloud-two {
  top: 250px;
  right: 10%;
  transform: scale(0.76);
  animation-delay: -2s;
}

.hill {
  position: absolute;
  left: 50%;
  bottom: -130px;
  width: 760px;
  height: 360px;
  border-radius: 50%;
  transform: translateX(-50%);
}

.hill-back {
  bottom: -88px;
  background: #b9dd70;
}

.hill-front {
  width: 900px;
  background: #82c96f;
}

.big-robot-lamb {
  position: absolute;
  left: 11%;
  bottom: 94px;
  width: 240px;
  height: 190px;
  animation: bob 2.5s ease-in-out infinite;
}

.bot-antenna {
  position: absolute;
  left: 58px;
  top: 4px;
  width: 10px;
  height: 34px;
  border-radius: 99px;
  background: var(--ink);
}

.bot-antenna::before {
  position: absolute;
  top: -13px;
  left: -8px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--coral);
  content: "";
}

.bot-head,
.bot-body,
.bot-face,
.bot-wheel {
  position: absolute;
}

.bot-head {
  left: 22px;
  top: 34px;
  width: 98px;
  height: 84px;
  border: 5px solid #f7fbfd;
  border-radius: 28px;
  background: #d8e9f0;
  box-shadow: inset 0 -8px 0 rgba(38, 49, 61, 0.08);
}

.bot-head::before,
.bot-head::after {
  position: absolute;
  top: 18px;
  width: 30px;
  height: 42px;
  border-radius: 50%;
  background: #fff4de;
  content: "";
}

.bot-head::before {
  left: -20px;
  transform: rotate(-22deg);
}

.bot-head::after {
  right: -20px;
  transform: rotate(22deg);
}

.bot-face {
  left: 47px;
  top: 62px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 34px 0 0 var(--ink), 17px 18px 0 -2px var(--coral);
  z-index: 2;
}

.bot-body {
  left: 88px;
  top: 78px;
  width: 128px;
  height: 78px;
  border: 5px solid #f7fbfd;
  border-radius: 32px;
  background: #edf4f7;
  box-shadow: inset 0 -10px 0 rgba(38, 49, 61, 0.08);
}

.bot-wheel {
  top: 148px;
  width: 42px;
  height: 42px;
  border: 8px solid var(--ink);
  border-radius: 50%;
  background: #dfe9ee;
}

.wheel-left {
  left: 88px;
}

.wheel-right {
  left: 166px;
}

.progress-card {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 14px;
  border-radius: 8px;
  background: var(--paper);
  backdrop-filter: blur(12px);
}

.progress-card strong {
  display: block;
  margin-top: 4px;
  font-size: 1.55rem;
}

.play-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: clamp(18px, 4vw, 36px);
  background: rgba(255, 255, 255, 0.94);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
}

.icon-button,
.command-button,
.primary-button,
.secondary-button {
  border: 0;
  cursor: pointer;
}

.icon-button {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: white;
  background: var(--violet);
  font-weight: 900;
}

.level-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.level-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #dce4e8;
}

.level-dot.complete {
  background: var(--gold);
}

.level-dot.active {
  outline: 4px solid rgba(47, 143, 91, 0.22);
  background: var(--leaf);
}

.mission-area {
  min-height: 118px;
}

.mission-area h2 {
  margin: 8px 0;
  font-size: clamp(1.65rem, 4vw, 2.8rem);
  line-height: 1.04;
  letter-spacing: 0;
}

.vietnamese {
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.16rem);
  line-height: 1.45;
}

.game-board-wrap {
  display: grid;
  place-items: center;
  padding: 14px;
  border: 2px dashed rgba(38, 49, 61, 0.16);
  border-radius: 8px;
  background: #fffaf0;
}

.game-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(54px, 1fr));
  width: min(100%, 430px);
  aspect-ratio: 1;
  gap: 8px;
}

.grid-cell {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  border: 2px solid rgba(47, 143, 91, 0.16);
  border-radius: 8px;
  color: rgba(38, 49, 61, 0.58);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0.44)),
    #dff1d0;
  font-size: clamp(0.7rem, 2vw, 0.86rem);
  font-weight: 900;
  text-transform: uppercase;
}

.grid-cell.blocked {
  color: #fff6ea;
  background: #91674c;
}

.goal-cell {
  color: white;
  font-size: clamp(2rem, 8vw, 3.8rem);
  text-transform: none;
}

.goal-red {
  background: #ef6f61;
}

.goal-blue {
  background: #337bd9;
}

.goal-yellow {
  background: #f3b83f;
}

.goal-purple {
  background: #7060d6;
}

.goal-pink {
  background: #e96ba8;
}

.goal-rainbow {
  background: linear-gradient(135deg, #ef6f61, #f3b83f, #2f8f5b, #337bd9, #7060d6);
}

.goal-green {
  background: #2f8f5b;
}

.goal-heart {
  background: #e05b72;
}

.mini-robot {
  position: relative;
  width: 68%;
  height: 64%;
  border: 4px solid white;
  border-radius: 24%;
  background: #d7e8ef;
  box-shadow: 0 8px 14px rgba(38, 49, 61, 0.18);
}

.mini-robot::before,
.mini-robot::after {
  position: absolute;
  top: 27%;
  width: 14%;
  height: 14%;
  border-radius: 50%;
  background: var(--ink);
  content: "";
}

.mini-robot::before {
  left: 28%;
}

.mini-robot::after {
  right: 28%;
}

.mini-robot span {
  position: absolute;
  left: 50%;
  bottom: 18%;
  width: 26%;
  height: 10%;
  border-radius: 99px;
  background: var(--coral);
  transform: translateX(-50%);
}

.program-panel {
  display: grid;
  grid-template-columns: minmax(150px, 0.75fr) minmax(180px, 1fr);
  gap: 14px;
  align-items: stretch;
}

.command-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-areas:
    ". up ."
    "left down right";
  gap: 8px;
}

.command-button {
  min-height: 56px;
  border-radius: 8px;
  color: white;
  background: var(--blue);
  font-size: 2rem;
  font-weight: 900;
  box-shadow: inset 0 -5px 0 rgba(38, 49, 61, 0.16);
}

.command-button[data-command="up"] {
  grid-area: up;
}

.command-button[data-command="left"] {
  grid-area: left;
}

.command-button[data-command="right"] {
  grid-area: right;
}

.command-button[data-command="down"] {
  grid-area: down;
}

.sequence-box {
  min-width: 0;
  padding: 12px;
  border-radius: 8px;
  background: #eef7ff;
}

.program-slots {
  display: grid;
  grid-template-columns: repeat(7, minmax(30px, 1fr));
  gap: 6px;
  margin-top: 8px;
}

.program-slot {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 2px dashed rgba(38, 49, 61, 0.2);
  border-radius: 8px;
  color: white;
  background: rgba(255, 255, 255, 0.78);
  font-size: clamp(1.25rem, 4vw, 1.8rem);
  font-weight: 900;
}

.program-slot.filled {
  border-style: solid;
  border-color: var(--violet);
  background: var(--violet);
}

.action-row {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.primary-button,
.secondary-button {
  min-height: 48px;
  padding: 12px 16px;
  border-radius: 8px;
  font-weight: 900;
}

.primary-button {
  color: white;
  background: var(--ink);
}

.secondary-button {
  color: var(--ink);
  background: #edf2f5;
}

.command-button:hover,
.command-button:focus-visible,
.primary-button:hover,
.primary-button:focus-visible,
.secondary-button:hover,
.secondary-button:focus-visible,
.icon-button:hover,
.icon-button:focus-visible {
  transform: translateY(-2px);
  outline: 3px solid rgba(51, 123, 217, 0.25);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.feedback-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
}

.feedback {
  min-height: 48px;
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.35;
}

.finish-dialog {
  width: min(420px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

.finish-dialog::backdrop {
  background: rgba(38, 49, 61, 0.42);
}

.finish-content {
  padding: 30px;
  text-align: center;
  background: white;
}

.finish-badge {
  display: grid;
  place-items: center;
  width: 80px;
  height: 80px;
  margin: 0 auto 12px;
  border-radius: 50%;
  color: white;
  background: var(--gold);
  font-size: 2.6rem;
}

.finish-content h2 {
  margin-bottom: 8px;
  font-size: 2rem;
}

@keyframes drift {
  from {
    transform: translateX(-8px);
  }

  to {
    transform: translateX(12px);
  }
}

@keyframes bob {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-9px);
  }
}

@media (max-width: 920px) {
  .game-shell {
    grid-template-columns: 1fr;
  }

  .hero-panel {
    min-height: 410px;
  }

  .big-robot-lamb {
    transform: scale(0.82);
    transform-origin: bottom left;
  }
}

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

  .hero-panel,
  .play-panel {
    padding: 16px;
  }

  .topbar,
  .feedback-row {
    align-items: stretch;
    flex-direction: column;
  }

  .program-panel {
    grid-template-columns: 1fr;
  }

  .game-board-wrap {
    padding: 8px;
  }

  .game-board {
    gap: 6px;
  }

  .program-slots {
    grid-template-columns: repeat(7, minmax(28px, 1fr));
  }
}
