:root {
  --sky: #63b5e9;
  --sun: #ffd84d;
  --grass: #73d564;
  --orange: #ff9c42;
  --berry: #ff6b8f;
  --navy: #e8f2ff;
  --cream: #0c1424;
  --card: rgba(14, 22, 38, 0.92);
  --panel: rgba(18, 28, 46, 0.94);
  --panel-strong: rgba(12, 20, 36, 0.98);
  --border-soft: rgba(138, 180, 255, 0.16);
  --shadow: 0 20px 44px rgba(0, 0, 0, 0.38);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 18px;
  --tap-size: 78px;
  font-family: "Trebuchet MS", "Segoe UI", "Arial Rounded MT Bold", Arial, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(99, 181, 233, 0.18), transparent 26%),
    radial-gradient(circle at top right, rgba(255, 216, 77, 0.12), transparent 18%),
    linear-gradient(180deg, #050914 0%, #0b1323 42%, #101a2f 100%);
  color: var(--navy);
}

body {
  padding: 16px;
}

button,
a {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  border: 0;
  cursor: pointer;
}

.app {
  max-width: 980px;
  margin: 0 auto;
  min-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.screen {
  display: block;
  animation: rise 220ms ease;
}

.panel {
  background: var(--card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-soft);
  overflow: hidden;
}

.hero {
  position: relative;
  padding: 30px 24px 26px;
  background: linear-gradient(180deg, rgba(8, 14, 28, 0.98), rgba(12, 20, 36, 0.96));
  color: var(--navy);
  text-align: center;
  border-bottom: 1px solid var(--border-soft);
}

.hero h1,
.game-header h2 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1;
  letter-spacing: 0.02em;
}

.hero p,
.mini-text {
  margin: 10px 0 0;
  font-size: clamp(1rem, 2.2vw, 1.15rem);
  line-height: 1.5;
  max-width: 38rem;
}

.hero-logo {
  display: block;
  width: min(100%, 460px);
  max-height: 180px;
  margin: 0 auto 6px;
  object-fit: contain;
}

.hero p {
  margin-left: auto;
  margin-right: auto;
}

.sun {
  position: absolute;
  pointer-events: none;
  top: 22px;
  right: 26px;
  width: 86px;
  height: 86px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff7a8 0%, var(--sun) 60%, #ffbf1c 100%);
  box-shadow: 0 0 0 10px rgba(255, 216, 77, 0.12);
}

.content {
  padding: 22px;
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.hub-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.hub-button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  padding: 28px 22px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow);
  color: #f9fbff;
  text-decoration: none;
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 900;
  letter-spacing: 0.02em;
  text-shadow: 0 4px 14px rgba(0, 0, 0, 0.32);
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}

.hub-button:hover,
.hub-button:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.42);
  filter: brightness(1.04);
}

.hub-button-learn {
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 243, 182, 0.34), transparent 20%),
    linear-gradient(180deg, #2f4866 0%, #1d304a 100%);
}

.hub-button-play {
  background:
    radial-gradient(circle at 82% 22%, rgba(255, 208, 117, 0.32), transparent 20%),
    linear-gradient(180deg, #513d74 0%, #2b2648 100%);
}

.category-stack {
  display: grid;
  gap: 26px;
}

.menu-category {
  display: grid;
  gap: 16px;
}

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

.category-heading h2 {
  margin: 0;
  font-size: clamp(1.3rem, 2.3vw, 1.85rem);
  color: #fff2c4;
  text-shadow: 0 3px 10px rgba(0, 0, 0, 0.28);
}

.category-heading::after {
  content: "";
  flex: 1;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 214, 117, 0.7), rgba(255, 214, 117, 0.04));
}

.category-top-bar {
  margin-bottom: 18px;
}

.category-top-bar-centered {
  justify-content: center;
}

.category-top-bar-centered .back-btn {
  min-width: 200px;
  margin: 0 auto;
}

.game-card {
  position: relative;
  overflow: hidden;
  padding: 20px;
  min-height: 250px;
  border-radius: var(--radius-lg);
  text-align: left;
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.28);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  isolation: isolate;
}

.game-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  opacity: 1;
  z-index: -2;
}

.game-card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: transparent;
}

.snake-card {
  background: linear-gradient(180deg, #c7f68f 0%, #8fe178 100%);
}

.snake-card::before {
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 800 500'%3E%3Cdefs%3E%3ClinearGradient id='bg' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0%25' stop-color='%2397e2ff'/%3E%3Cstop offset='100%25' stop-color='%2379d86c'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect width='800' height='500' fill='url(%23bg)'/%3E%3Ccircle cx='676' cy='92' r='54' fill='%23ffe16b'/%3E%3Cpath d='M0 372 C109 319 194 348 277 324 C366 298 438 336 530 308 C619 279 697 315 800 274 L800 500 L0 500 Z' fill='%235bbd59'/%3E%3Cpath d='M0 407 C114 363 187 380 276 352 C360 325 471 367 567 338 C665 309 727 330 800 307 L800 500 L0 500 Z' fill='%2347a947'/%3E%3Crect x='552' y='186' width='34' height='34' rx='10' fill='%23ff5f7e'/%3E%3Cpath d='M568 188 C570 177 580 172 587 178' fill='none' stroke='%2328893c' stroke-width='5' stroke-linecap='round'/%3E%3Cpath d='M188 278 C230 230 303 227 352 259 C401 292 412 362 368 402 C325 441 244 437 198 401 C151 363 147 314 188 278 Z' fill='none' stroke='%2320a44c' stroke-width='32' stroke-linecap='round' stroke-linejoin='round'/%3E%3Ccircle cx='335' cy='286' r='7' fill='%23133a61'/%3E%3Ccircle cx='359' cy='286' r='7' fill='%23133a61'/%3E%3C/svg%3E");
}

.puzzle-card {
  background: linear-gradient(180deg, #ffe77d 0%, #ffb65f 100%);
}

.puzzle-card::before {
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 800 500'%3E%3Cdefs%3E%3ClinearGradient id='bg' x1='0' y1='0' x2='1' y2='1'%3E%3Cstop offset='0%25' stop-color='%23fff1a8'/%3E%3Cstop offset='100%25' stop-color='%23ffb05f'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect width='800' height='500' fill='url(%23bg)'/%3E%3Ccircle cx='128' cy='84' r='34' fill='%23ffffff' fill-opacity='0.55'/%3E%3Ccircle cx='705' cy='99' r='24' fill='%23ffffff' fill-opacity='0.45'/%3E%3Cg transform='translate(415 84)'%3E%3Crect x='0' y='0' width='102' height='102' rx='20' fill='%238ed9ff'/%3E%3Crect x='115' y='0' width='102' height='102' rx='20' fill='%2373d564'/%3E%3Crect x='230' y='0' width='102' height='102' rx='20' fill='%23ff9c42'/%3E%3Crect x='0' y='115' width='102' height='102' rx='20' fill='%23ffb4d0'/%3E%3Crect x='115' y='115' width='102' height='102' rx='20' fill='%23a5b8ff'/%3E%3Crect x='230' y='115' width='102' height='102' rx='20' fill='%239af0d2'/%3E%3Crect x='0' y='230' width='102' height='102' rx='20' fill='%23ffd84d'/%3E%3Crect x='115' y='230' width='102' height='102' rx='20' fill='%23ffa9a0'/%3E%3Crect x='230' y='230' width='102' height='102' rx='20' fill='%23fff7df' stroke='%23f0c56a' stroke-dasharray='12 10' stroke-width='6'/%3E%3Cg fill='%23133a61' font-family='Trebuchet MS, Arial, sans-serif' font-size='42' font-weight='700' text-anchor='middle'%3E%3Ctext x='51' y='63'%3E1%3C/text%3E%3Ctext x='166' y='63'%3E2%3C/text%3E%3Ctext x='281' y='63'%3E3%3C/text%3E%3Ctext x='51' y='178'%3E4%3C/text%3E%3Ctext x='166' y='178'%3E5%3C/text%3E%3Ctext x='281' y='178'%3E6%3C/text%3E%3Ctext x='51' y='293'%3E7%3C/text%3E%3Ctext x='166' y='293'%3E8%3C/text%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.truck-card {
  background: linear-gradient(180deg, #ffc86b 0%, #ff8f4d 100%);
}

.truck-card::before {
  background-image: url("../Images/monstertruck-puzzle.png");
}

.bubble-card {
  background: linear-gradient(180deg, #9cc7ff 0%, #6f88ff 100%);
}

.bubble-card::before {
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 800 500'%3E%3Cdefs%3E%3ClinearGradient id='bg' x1='0' y1='0' x2='1' y2='1'%3E%3Cstop offset='0%25' stop-color='%23a5d2ff'/%3E%3Cstop offset='100%25' stop-color='%237a82ff'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect width='800' height='500' fill='url(%23bg)'/%3E%3Cg opacity='0.95'%3E%3Ccircle cx='174' cy='108' r='42' fill='%23ffd45d'/%3E%3Ccircle cx='250' cy='168' r='42' fill='%23ff7b7b'/%3E%3Ccircle cx='336' cy='108' r='42' fill='%236ee7b7'/%3E%3Ccircle cx='412' cy='168' r='42' fill='%238ed9ff'/%3E%3Ccircle cx='498' cy='108' r='42' fill='%23c3a6ff'/%3E%3C/g%3E%3Cpath d='M400 392 L400 280' stroke='%23ffffff' stroke-width='16' stroke-linecap='round'/%3E%3Cpath d='M400 286 L372 330 M400 286 L428 330' stroke='%23ffffff' stroke-width='16' stroke-linecap='round'/%3E%3Ccircle cx='400' cy='402' r='28' fill='%23ff8c42'/%3E%3C/svg%3E");
}

.maze-card {
  background: linear-gradient(180deg, #73d564 0%, #4fc7ff 100%);
}

.maze-card::before {
  background-image: url("../Images/Doolhof.png");
}

.count-card {
  background: linear-gradient(180deg, #9ee6ff 0%, #7adf9d 100%);
}

.count-card::before {
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 800 500'%3E%3Cdefs%3E%3ClinearGradient id='bg' x1='0' y1='0' x2='1' y2='1'%3E%3Cstop offset='0%25' stop-color='%23aeeeff'/%3E%3Cstop offset='100%25' stop-color='%23b7f2a1'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect width='800' height='500' fill='url(%23bg)'/%3E%3Cg font-family='Trebuchet MS, Arial, sans-serif' font-weight='700' text-anchor='middle'%3E%3Ccircle cx='180' cy='190' r='48' fill='%23ffd45d'/%3E%3Ccircle cx='310' cy='150' r='48' fill='%23ff8eb1'/%3E%3Ccircle cx='440' cy='220' r='48' fill='%238ed9ff'/%3E%3Ccircle cx='570' cy='170' r='48' fill='%2373d564'/%3E%3Ccircle cx='700' cy='240' r='48' fill='%23ffb36b'/%3E%3Cg fill='%23172b43' font-size='54'%3E%3Ctext x='180' y='208'%3E1%3C/text%3E%3Ctext x='310' y='168'%3E2%3C/text%3E%3Ctext x='440' y='238'%3E3%3C/text%3E%3Ctext x='570' y='188'%3E4%3C/text%3E%3Ctext x='700' y='258'%3E5%3C/text%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.trace-card {
    background: linear-gradient(180deg, #ffb4d0 0%, #ffd86a 100%);
}

.trace-card::before {
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 800 500'%3E%3Cdefs%3E%3ClinearGradient id='bg' x1='0' y1='0' x2='1' y2='1'%3E%3Cstop offset='0%25' stop-color='%23ffc2d7'/%3E%3Cstop offset='100%25' stop-color='%23ffe887'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect width='800' height='500' fill='url(%23bg)'/%3E%3Cg fill='none' stroke='%23ffffff' stroke-width='18' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M228 120 L292 90 L292 374'/%3E%3Cpath d='M430 150 C430 108 468 88 508 88 C548 88 582 112 582 148 C582 186 556 210 516 240 C470 274 442 306 436 352 L592 352'/%3E%3C/g%3E%3Cpath d='M225 121 L292 91 L292 375' stroke='%238950ff' stroke-width='7' stroke-linecap='round' stroke-dasharray='14 12' fill='none'/%3E%3Cpath d='M430 150 C430 108 468 88 508 88 C548 88 582 112 582 148 C582 186 556 210 516 240 C470 274 442 306 436 352 L592 352' stroke='%2300b7ff' stroke-width='7' stroke-linecap='round' stroke-dasharray='14 12' fill='none'/%3E%3Ccircle cx='225' cy='121' r='18' fill='%2373d564'/%3E%3Ccircle cx='592' cy='352' r='18' fill='%23ff8c42'/%3E%3C/svg%3E");
}

.letter-trace-card {
    background: linear-gradient(180deg, #9fdcff 0%, #ffd78f 100%);
}

.letter-trace-card::before {
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 800 500'%3E%3Cdefs%3E%3ClinearGradient id='bg' x1='0' y1='0' x2='1' y2='1'%3E%3Cstop offset='0%25' stop-color='%23b8ecff'/%3E%3Cstop offset='100%25' stop-color='%23ffe4a8'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect width='800' height='500' fill='url(%23bg)'/%3E%3Cg fill='none' stroke='%23ffffff' stroke-width='18' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M215 360 L305 110 L395 360'/%3E%3Cpath d='M250 268 L360 268'/%3E%3Cpath d='M475 110 L475 360'/%3E%3Cpath d='M475 110 C610 110 610 235 475 235'/%3E%3Cpath d='M475 235 C625 235 620 360 475 360'/%3E%3C/g%3E%3Cpath d='M215 360 L305 110 L395 360' stroke='%232f7de1' stroke-width='7' stroke-linecap='round' stroke-dasharray='14 12' fill='none'/%3E%3Cpath d='M250 268 L360 268' stroke='%232f7de1' stroke-width='7' stroke-linecap='round' stroke-dasharray='14 12' fill='none'/%3E%3Cpath d='M475 110 L475 360' stroke='%23ff7d7d' stroke-width='7' stroke-linecap='round' stroke-dasharray='14 12' fill='none'/%3E%3Cpath d='M475 110 C610 110 610 235 475 235' stroke='%23ff7d7d' stroke-width='7' stroke-linecap='round' stroke-dasharray='14 12' fill='none'/%3E%3Cpath d='M475 235 C625 235 620 360 475 360' stroke='%23ff7d7d' stroke-width='7' stroke-linecap='round' stroke-dasharray='14 12' fill='none'/%3E%3Ccircle cx='215' cy='360' r='18' fill='%2373d564'/%3E%3Ccircle cx='620' cy='360' r='18' fill='%23ff9c42'/%3E%3C/svg%3E");
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 96px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(12, 20, 36, 0.76);
  color: #f6fbff;
  font-weight: 700;
  font-size: 0.95rem;
}

.card-title {
  margin: 18px 0 10px;
  font-size: clamp(1.8rem, 3.5vw, 2.6rem);
  line-height: 1;
  text-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.card-text {
  max-width: 18rem;
  font-size: 1rem;
  line-height: 1.4;
}

.play-btn,
.back-btn,
.shuffle-btn,
.restart-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 58px;
  padding: 14px 22px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 1.06rem;
  color: #f6fbff;
  background: linear-gradient(180deg, #1b2a45 0%, #132038 100%);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(138, 180, 255, 0.16);
}

.play-btn {
  background: linear-gradient(180deg, #24395f 0%, #192947 100%);
  margin-top: 18px;
}

.page-shell {
  display: grid;
  gap: 18px;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.back-btn {
  min-width: 168px;
  background: linear-gradient(180deg, #172742 0%, #101b31 100%);
}

.game-header {
  flex: 1;
  padding: 18px 22px;
  border-radius: var(--radius-xl);
  background: linear-gradient(135deg, rgba(20, 31, 52, 0.96), rgba(13, 22, 40, 0.96));
  box-shadow: var(--shadow);
  border: 1px solid var(--border-soft);
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.stats-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.stat-pill {
  flex: 1;
  min-width: 140px;
  padding: 14px 18px;
  border-radius: 999px;
  background: rgba(16, 27, 45, 0.95);
  font-weight: 800;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.24);
  border: 1px solid var(--border-soft);
}

.canvas-wrap,
.side-card,
.puzzle-board-card {
  padding: 18px;
  border-radius: var(--radius-xl);
  background: var(--panel);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-soft);
}

#snakeCanvas {
  display: block;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(235, 239, 234, 0.32), rgba(192, 205, 197, 0.18)),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: auto, 32px 32px, 32px 32px;
  border: 1px solid rgba(138, 180, 255, 0.16);
  box-shadow: inset 0 8px 20px rgba(0, 0, 0, 0.18);
  touch-action: none;
}

.snake-side-card {
  display: grid;
  gap: 16px;
  align-content: start;
}

.snake-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  max-width: 320px;
  touch-action: manipulation;
}

.snake-side-card .snake-controls {
  margin-top: 4px;
}

.snake-controls .control-btn:not(.blank) {
  background: linear-gradient(180deg, #c8d4cf 0%, #a9bbb2 100%);
  color: #233340;
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.16);
  border: 1px solid rgba(35, 51, 64, 0.12);
}

.control-btn {
  min-height: var(--tap-size);
  border-radius: 24px;
  background: linear-gradient(180deg, #ffd84d 0%, #ffb62a 100%);
  color: #113761;
  font-size: 1.8rem;
  font-weight: 900;
  box-shadow: 0 10px 18px rgba(255, 182, 42, 0.35);
  user-select: none;
  touch-action: manipulation;
}

.control-btn.blank {
  background: transparent;
  box-shadow: none;
  cursor: default;
}

.control-btn:active,
.shuffle-btn:active,
.restart-btn:active,
.back-btn:active,
.play-btn:active {
  transform: translateY(2px) scale(0.99);
}

.side-card h3,
.puzzle-board-card h3 {
  margin: 0 0 10px;
  font-size: 1.45rem;
}

.side-card p,
.puzzle-board-card p {
  margin: 0;
  line-height: 1.5;
}

.status-message {
  min-height: 30px;
  margin-top: 14px;
  font-weight: 800;
  color: #ff8eb1;
}

.puzzle-area {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) minmax(290px, 0.8fr);
}

.maze-layout {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.25fr) minmax(260px, 0.75fr);
  align-items: start;
}

.trace-layout {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
  align-items: start;
}

.maze-board-card,
.maze-side-card {
  position: relative;
}

.maze-top {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.maze-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  min-height: 320px;
  border-radius: 28px;
  overflow: hidden;
  border: 2px solid rgba(138, 180, 255, 0.18);
  background:
    radial-gradient(circle at top left, rgba(255, 214, 109, 0.2), transparent 24%),
    radial-gradient(circle at top right, rgba(255, 126, 207, 0.18), transparent 22%),
    linear-gradient(180deg, #132038 0%, #0f1930 100%);
  box-shadow: inset 0 10px 24px rgba(0, 0, 0, 0.28);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.maze-canvas,
.maze-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.maze-canvas {
  z-index: 1;
}

.maze-overlay {
  z-index: 2;
  touch-action: none;
  cursor: crosshair;
}

.maze-side-card {
    display: grid;
    gap: 14px;
}

.count-layout {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.15fr) minmax(240px, 0.85fr);
  align-items: start;
}

.count-top {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}

.count-side-card {
  display: grid;
  gap: 14px;
}

.bubble-layout {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.05fr) minmax(240px, 0.95fr);
  align-items: start;
}

.bubble-top {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}

.bubble-side-card {
  display: grid;
  gap: 14px;
}

.bubble-stage {
  display: flex;
  justify-content: center;
  padding: 12px;
  border-radius: 24px;
  background: rgba(9, 16, 30, 0.34);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.bubble-canvas {
  width: min(100%, 352px);
  height: auto;
  border-radius: 20px;
  background: linear-gradient(180deg, #10213c 0%, #0a1323 100%);
  touch-action: none;
}

.count-stage {
  min-height: 340px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 18px;
  align-items: center;
  justify-items: center;
  margin-bottom: 18px;
  padding: 18px;
  border-radius: 24px;
  background: rgba(9, 16, 30, 0.34);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.count-board-card {
  position: relative;
}

.count-checkmark {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 124px;
  height: 124px;
  border-radius: 999px;
  background: rgba(73, 193, 88, 0.92);
  color: #ffffff;
  font-size: 4.6rem;
  font-weight: 900;
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.28);
  transform: translate(-50%, -50%) scale(0.7);
  opacity: 0;
  pointer-events: none;
}

.count-checkmark.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  transition: opacity 180ms ease, transform 180ms ease;
}

.count-item {
  display: grid;
  place-items: center;
  width: 88px;
  height: 88px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 3rem;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.14);
}

.count-choice-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.count-choice-btn {
  min-height: 68px;
  border: 1px solid rgba(255, 214, 117, 0.24);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(19, 32, 55, 0.96), rgba(11, 20, 37, 0.96));
  color: #fff2c4;
  font-size: 1.7rem;
  font-weight: 900;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.count-choice-btn:hover,
.count-choice-btn:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(255, 214, 117, 0.5);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.26);
}

.count-choice-btn.correct {
  background: linear-gradient(180deg, #73d564 0%, #49c158 100%);
  color: #ffffff;
}

.count-choice-btn.wrong {
  background: linear-gradient(180deg, #ff8e8e 0%, #ea5a5a 100%);
  color: #ffffff;
}

.trace-top {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  margin-bottom: 16px;
}

.trace-board-card,
.trace-side-card {
  position: relative;
}

.trace-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 5 / 4;
  min-height: 460px;
  border-radius: 28px;
  overflow: hidden;
  border: 2px solid rgba(255, 206, 138, 0.38);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.45), transparent 24%),
    radial-gradient(circle at bottom right, rgba(255, 208, 119, 0.3), transparent 20%),
    linear-gradient(180deg, #fff9ec 0%, #fff4dc 100%);
  box-shadow: inset 0 10px 24px rgba(206, 162, 91, 0.12);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.trace-canvas,
.trace-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.trace-canvas {
  z-index: 1;
}

.trace-overlay {
  z-index: 2;
  touch-action: none;
  cursor: crosshair;
}

.trace-side-card {
  display: grid;
  gap: 16px;
  align-content: start;
}

.trace-number-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.trace-letter-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.trace-number-btn {
  min-height: 74px;
  border: 1px solid rgba(255, 214, 117, 0.24);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(19, 32, 55, 0.96), rgba(11, 20, 37, 0.96));
  color: #fff2c4;
  font-size: 1.9rem;
  font-weight: 900;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.trace-number-btn:hover,
.trace-number-btn:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(255, 214, 117, 0.5);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.26);
}

.trace-number-btn.active {
  background: linear-gradient(180deg, #ffd66d 0%, #ffb85c 100%);
  color: #172742;
  border-color: rgba(255, 230, 170, 0.82);
}

.trace-nav {
  display: flex;
  justify-content: center;
  gap: 14px;
}

.trace-arrow-btn {
  position: relative;
  width: 88px;
  min-width: 88px;
  min-height: 88px;
  padding: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #fff4c1 0%, #ffd978 100%);
  border: 4px solid rgba(255, 244, 193, 0.92);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.trace-arrow-btn::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-top: 16px solid transparent;
  border-bottom: 16px solid transparent;
  transform: translate(-50%, -50%);
}

.trace-arrow-btn-next::before {
  border-left: 24px solid #2f7de1;
  margin-left: 4px;
}

.trace-arrow-btn-prev::before {
  border-right: 24px solid #2f7de1;
  margin-left: -4px;
}

.trace-arrow-btn:hover,
.trace-arrow-btn:focus-visible {
  transform: translateY(-1px) scale(1.02);
}

.trace-arrow-btn:active {
  transform: translateY(1px) scale(0.98);
}

.trace-cheer {
  padding: 16px 18px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255, 221, 121, 0.22), rgba(255, 180, 208, 0.18));
  color: #ffe7a8;
  font-weight: 800;
  border: 1px solid rgba(255, 194, 122, 0.28);
}

.art-puzzle-area {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(220px, 0.62fr) minmax(0, 1.38fr);
}

.art-puzzle-top {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.piece-tray,
.board-grid {
  position: relative;
  display: block;
  width: 100%;
}

.art-piece {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  border: 3px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.24);
  background-repeat: no-repeat;
  background-size: 600% 400%;
  overflow: hidden;
  touch-action: manipulation;
}

.jigsaw-piece,
.jigsaw-slot {
  position: absolute;
  display: block;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
}

.jigsaw-piece {
  cursor: grab;
  touch-action: none;
  user-select: none;
  filter: drop-shadow(0 12px 18px rgba(0, 0, 0, 0.28));
}

.jigsaw-piece.dragging {
  z-index: 1000;
  pointer-events: none;
  filter: drop-shadow(0 16px 28px rgba(0, 0, 0, 0.36));
}

.jigsaw-piece.drag-origin {
  opacity: 0.2;
}

.jigsaw-piece.placed {
  cursor: default;
  filter: none;
}

.jigsaw-slot {
  pointer-events: none;
}

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

.art-piece::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 13px;
  border: 2px dashed rgba(255, 255, 255, 0.32);
  pointer-events: none;
}

.art-piece.selected {
  outline: 5px solid rgba(255, 216, 77, 0.95);
  transform: scale(1.03);
}

.art-piece:active {
  transform: scale(0.98);
}

.board-slot {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  border: 2px dashed rgba(138, 180, 255, 0.26);
  background: rgba(99, 181, 233, 0.14);
  overflow: hidden;
  touch-action: manipulation;
}

.board-slot.hint::after {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 10px;
  border: 2px dashed rgba(138, 180, 255, 0.16);
}

.board-slot.filled {
  border-style: solid;
  border-color: rgba(255, 255, 255, 0.92);
  background-repeat: no-repeat;
}

.art-win-banner {
  margin-top: 16px;
}

.truck-puzzle-area {
  grid-template-columns: 1fr;
}

.truck-puzzle-card {
  display: grid;
  gap: 16px;
  align-content: start;
}

.truck-puzzle-controls {
  justify-content: flex-start;
}

.help-toggle-btn,
.help-toggle-btn.shuffle-btn {
  background: linear-gradient(180deg, #8ed9ff 0%, #58b8f2 100%);
  color: #0b1323;
}

.help-toggle-btn[aria-pressed="true"],
.help-toggle-btn.shuffle-btn[aria-pressed="true"] {
  background: linear-gradient(180deg, #fff0a4 0%, #ffd84d 100%);
}

.truck-puzzle-stage {
  position: relative;
  min-height: 620px;
  width: 100%;
  overflow: hidden;
  border-radius: 28px;
  border: 1px solid rgba(138, 180, 255, 0.18);
  background:
    radial-gradient(circle at top left, rgba(99, 181, 233, 0.18), rgba(255, 255, 255, 0) 36%),
    linear-gradient(180deg, rgba(11, 19, 35, 0.95), rgba(18, 28, 46, 0.9));
  box-shadow: inset 0 10px 22px rgba(0, 0, 0, 0.24);
}

.piece-ring {
  position: absolute;
  inset: 0;
  min-height: 0;
  z-index: 2;
}

.piece-ring .jigsaw-piece {
  pointer-events: auto;
}

.truck-board-grid {
  position: absolute;
  z-index: 1;
  border-radius: 26px;
  border: 1px solid rgba(138, 180, 255, 0.2);
  background: rgba(11, 19, 35, 0.7);
  box-shadow:
    inset 0 10px 18px rgba(0, 0, 0, 0.24),
    0 16px 30px rgba(0, 0, 0, 0.22);
  isolation: isolate;
}

.truck-board-grid::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: url("../Images/monstertruck-puzzle.png");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0;
  transition: opacity 180ms ease;
  pointer-events: none;
}

.truck-board-grid.help-on::before {
  opacity: 0.34;
}

.puzzle-top {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.shuffle-btn,
.restart-btn {
  background: linear-gradient(180deg, #73d564 0%, #49c158 100%);
  color: #fff;
  min-width: 156px;
}

.puzzle-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  touch-action: manipulation;
}

.tile,
.tile-empty {
  aspect-ratio: 1 / 1;
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.6rem, 3vw, 2.3rem);
  font-weight: 900;
}

.tile {
  color: #0b1323;
  box-shadow: 0 12px 18px rgba(0, 0, 0, 0.24);
  transition: transform 140ms ease;
  touch-action: manipulation;
}

.tile:active {
  transform: scale(0.97);
}

.tile-empty {
  border: 2px dashed rgba(138, 180, 255, 0.2);
  background: rgba(99, 181, 233, 0.12);
}

.tile-1 { background: #8ed9ff; }
.tile-2 { background: #ffd84d; }
.tile-3 { background: #ff9c42; }
.tile-4 { background: #73d564; }
.tile-5 { background: #ffb4d0; }
.tile-6 { background: #a5b8ff; }
.tile-7 { background: #ffa9a0; }
.tile-8 { background: #9af0d2; }

.win-banner {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(51, 37, 5, 0.96), rgba(27, 21, 7, 0.96));
  font-size: 1.2rem;
  font-weight: 900;
  color: #ffd66d;
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 216, 77, 0.18);
}

.sparkles {
  display: inline-flex;
  gap: 6px;
  margin-left: 6px;
  vertical-align: middle;
}

.sparkles span {
  animation: twinkle 900ms ease-in-out infinite alternate;
}

.sparkles span:nth-child(2) {
  animation-delay: 200ms;
}

.sparkles span:nth-child(3) {
  animation-delay: 400ms;
}

.footer-note {
  text-align: center;
  padding: 4px 8px 18px;
  font-weight: 700;
  color: rgba(232, 242, 255, 0.72);
}

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

@keyframes twinkle {
  from {
    transform: translateY(0) scale(0.9);
    opacity: 0.75;
  }
  to {
    transform: translateY(-3px) scale(1.08);
    opacity: 1;
  }
}

@media (max-width: 860px) {
    .hub-actions,
    .menu-grid,
    .game-layout,
    .puzzle-area,
    .art-puzzle-area,
    .bubble-layout,
    .maze-layout,
    .count-layout,
    .trace-layout {
      grid-template-columns: 1fr;
    }

  .game-card {
    min-height: 0;
  }
}

@media (max-width: 560px) {
  body {
    padding: 10px;
  }

  .app {
    min-height: calc(100vh - 20px);
  }

  .hero,
  .content,
  .canvas-wrap,
  .side-card,
  .puzzle-board-card,
  .game-header {
    padding: 16px;
  }

  .sun {
    width: 68px;
    height: 68px;
    top: 20px;
    right: 16px;
  }

  .top-bar {
    align-items: stretch;
  }

  .back-btn {
    width: 100%;
  }

  .stat-pill {
      min-width: 100%;
  }

  .count-choice-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .control-btn {
    min-height: 72px;
    border-radius: 20px;
  }

  .truck-puzzle-stage {
    min-height: 500px;
  }

  .snake-side-card .snake-controls {
    max-width: none;
  }
}
