@import url("https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;700&family=Nunito:wght@500;700&display=swap");

:root {
  color-scheme: light;
  --bg-top: #f7f1e7;
  --bg-bottom: #e7f0f7;
  --ink: #1d2b33;
  --panel: #ffffff;
  --frame: #fefcf7;
  --rim: #e1e8ee;
  --accent: #ffb363;
  --shadow: 0 18px 40px rgba(33, 44, 54, 0.14);
  --palette-shadow: 0 10px 20px rgba(33, 44, 54, 0.12);
  --dot-size: 54px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Nunito", "Trebuchet MS", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 12%, rgba(255, 255, 255, 0.7), transparent 45%),
    radial-gradient(circle at 88% 8%, rgba(255, 255, 255, 0.6), transparent 50%),
    linear-gradient(160deg, var(--bg-top), var(--bg-bottom));
}

.app {
  min-height: 100vh;
  display: block;
  padding: 0;
}

.stage {
  width: 100vw;
  height: 100vh;
  display: grid;
  grid-template-rows: 80vh 15vh;
  gap: 0;
  justify-items: stretch;
  align-items: stretch;
  padding: 2vh 3vw 3vh;
  box-sizing: border-box;
}

.canvas {
  width: 100%;
  height: 100%;
  background: var(--panel);
  border-radius: 28px;
  padding: clamp(16px, 2.4vh, 28px);
  box-shadow: var(--shadow);
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  position: relative;
  overflow: hidden;
}

.canvas::after {
  content: "";
  position: absolute;
  inset: 18px;
  border-radius: 24px;
  border: 2px solid rgba(255, 179, 99, 0.25);
  pointer-events: none;
}

.canvas-frame {
  width: 100%;
  height: 100%;
  background: linear-gradient(145deg, var(--frame), #f3f7fb);
  border-radius: 24px;
  border: 2px solid var(--rim);
  padding: clamp(14px, 2.2vh, 26px);
  display: grid;
  place-items: center;
  position: relative;
}

.canvas-frame svg {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  display: block;
}

body.is-complete .canvas-frame svg {
  animation: celebration-shake 0.6s ease-in-out 2;
}

.palette {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
}

.palette-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
  align-content: center;
  background: var(--panel);
  border-radius: 999px;
  padding: 16px 20px;
  box-shadow: var(--palette-shadow);
  min-height: calc(var(--dot-size) + 12px);
  width: min(1100px, 92vw);
}

.palette-dot {
  appearance: none;
  width: var(--dot-size);
  height: var(--dot-size);
  border-radius: 999px;
  border: 3px solid #ffffff;
  padding: 0;
  display: grid;
  place-items: center;
  font-family: "Baloo 2", "Nunito", "Trebuchet MS", sans-serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  text-shadow: 0 2px 4px rgba(20, 30, 38, 0.35);
  cursor: pointer;
  box-shadow: 0 6px 12px rgba(30, 41, 51, 0.18);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.palette-dot.is-active {
  transform: translateY(-2px);
  box-shadow:
    0 0 0 4px rgba(255, 179, 99, 0.35),
    0 6px 12px rgba(30, 41, 51, 0.18);
}

.palette-dot:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}

.continue-hint {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: var(--palette-shadow);
  font-family: "Baloo 2", "Nunito", "Trebuchet MS", sans-serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--ink);
  opacity: 0;
  transform: translateY(6px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  border: none;
  cursor: default;
}

.continue-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 74px;
  height: 28px;
  padding: 0 10px;
  border-radius: 12px;
  border: 2px solid rgba(29, 43, 51, 0.25);
  background: #ffffff;
  box-shadow: inset 0 -2px 0 rgba(29, 43, 51, 0.15);
  text-transform: uppercase;
  position: relative;
}

.continue-key::before {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  height: 3px;
  bottom: 6px;
  background: rgba(29, 43, 51, 0.35);
  border-radius: 999px;
}

body.is-complete .continue-hint {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  cursor: pointer;
}

@media (max-width: 720px) {
  :root {
    --dot-size: 40px;
  }

  .app {
    padding: 0;
  }

  .stage {
    height: 100dvh;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  }

  .canvas {
    flex: 1 1 auto;
    min-height: 0;
  }

  .palette {
    height: auto;
    gap: 10px;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .canvas {
    padding: clamp(12px, 2.2vh, 20px);
  }

  .palette-row {
    border-radius: 24px;
    width: 100%;
    padding: 12px;
    gap: 10px;
  }

  .continue-hint {
    font-size: 14px;
    padding: 8px 12px;
  }
}

@keyframes celebration-shake {
  0% {
    transform: translate(0, 0) rotate(0deg);
  }
  20% {
    transform: translate(-4px, 2px) rotate(-1deg);
  }
  40% {
    transform: translate(4px, -2px) rotate(1deg);
  }
  60% {
    transform: translate(-3px, -1px) rotate(-0.8deg);
  }
  80% {
    transform: translate(3px, 1px) rotate(0.8deg);
  }
  100% {
    transform: translate(0, 0) rotate(0deg);
  }
}
