:root {
  --ink: #17324d;
  --muted: #50708d;
  --sky: #e9f7ff;
  --mint: #b9f3d0;
  --coral: #ff735c;
  --sun: #ffd35a;
  --violet: #7c66d9;
  --blue: #38a3ff;
  --green: #2bbf7a;
  --white: #ffffff;
  --shadow: 0 18px 44px rgba(33, 70, 105, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family:
    Inter, ui-rounded, "SF Pro Rounded", "PingFang TC", "Noto Sans TC", system-ui,
    sans-serif;
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 211, 90, 0.48), transparent 22rem),
    radial-gradient(circle at 88% 24%, rgba(185, 243, 208, 0.62), transparent 18rem),
    linear-gradient(135deg, #e8f8ff 0%, #fff8e5 52%, #ffe9e2 100%);
  overflow-x: hidden;
}

button {
  font: inherit;
}

.app-shell {
  width: min(1120px, calc(100% - 28px));
  min-height: 100dvh;
  margin: 0 auto;
  padding: 22px 0 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--coral);
  font-size: 0.85rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.5rem, 3.8vw, 2.6rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.music-button,
.reset-button,
.next-button {
  min-height: 54px;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  background: var(--white);
  box-shadow: 0 10px 24px rgba(23, 50, 77, 0.14);
  cursor: pointer;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.music-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-weight: 900;
}

.music-button:hover,
.reset-button:hover,
.next-button:hover,
.letter-button:hover {
  transform: translateY(-2px);
}

.music-button:active,
.reset-button:active,
.next-button:active,
.letter-button:active {
  transform: translateY(1px) scale(0.99);
}

.music-button[aria-pressed="true"] {
  background: var(--sun);
}

.music-icon {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
}

.music-icon svg {
  width: 100%;
  height: 100%;
  fill: var(--violet);
}

.music-icon .accent-stroke {
  fill: none;
  stroke: var(--coral);
  stroke-linecap: round;
  stroke-width: 3;
}

.game-layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.95fr);
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 16px;
}

.target-area,
.action-area,
.progress-area {
  position: relative;
  border: 3px solid rgba(255, 255, 255, 0.8);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.8);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.target-area {
  min-height: 560px;
  padding: clamp(22px, 4vw, 44px);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  background:
    linear-gradient(180deg, rgba(233, 247, 255, 0.95), rgba(255, 255, 255, 0.78)),
    var(--sky);
}

.sky-scene {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.star {
  position: absolute;
  width: 28px;
  height: 28px;
  background: var(--sun);
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 56%, 79% 91%, 50% 70%, 21% 91%, 32% 56%, 2% 35%, 39% 35%);
  filter: drop-shadow(0 7px 8px rgba(255, 153, 48, 0.22));
  animation: floaty 4.8s ease-in-out infinite;
}

.star-one {
  top: 12%;
  left: 13%;
}

.star-two {
  top: 19%;
  right: 18%;
  width: 38px;
  height: 38px;
  animation-delay: -1.4s;
}

.star-three {
  bottom: 18%;
  left: 20%;
  background: #ff9f68;
  animation-delay: -2.2s;
}

.cloud {
  position: absolute;
  width: 118px;
  height: 40px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow:
    24px -18px 0 4px rgba(255, 255, 255, 0.82),
    58px -10px 0 12px rgba(255, 255, 255, 0.82);
}

.cloud-one {
  top: 17%;
  left: 6%;
}

.cloud-two {
  right: 12%;
  bottom: 19%;
  transform: scale(0.8);
}

.picture-window {
  position: relative;
  z-index: 1;
  width: min(250px, 54vw);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--white);
  box-shadow: 0 12px 28px rgba(23, 50, 77, 0.12);
}

.picture-window svg {
  width: 78%;
  height: 78%;
  overflow: visible;
}

.target-title,
.target-place,
.target-word,
.message,
.score-line {
  letter-spacing: 0;
}

.target-title {
  position: relative;
  z-index: 1;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: clamp(1.05rem, 2.6vw, 1.45rem);
  font-weight: 900;
}

.target-letter {
  position: relative;
  z-index: 1;
  min-width: min(320px, 72vw);
  line-height: 0.9;
  color: var(--coral);
  font-size: clamp(7.5rem, 18vw, 15rem);
  font-weight: 1000;
  text-align: center;
  text-shadow:
    0 8px 0 var(--letter-shadow-color, var(--sun)),
    0 18px 36px rgba(23, 50, 77, 0.16);
}

.target-letter.pop {
  animation: pop 420ms ease;
}

.target-place {
  position: relative;
  z-index: 1;
  margin: 0;
  color: var(--ink);
  font-size: clamp(1.25rem, 2.8vw, 1.9rem);
  font-weight: 1000;
}

.target-word {
  position: relative;
  z-index: 1;
  margin: 0;
  color: var(--muted);
  font-size: clamp(1.05rem, 2.2vw, 1.45rem);
  font-weight: 1000;
}

.action-area {
  padding: clamp(16px, 2.6vw, 24px);
  display: grid;
  align-content: center;
  gap: 16px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.92), rgba(238, 255, 245, 0.86)),
    var(--white);
}

.message {
  min-height: 2.5em;
  margin: 0;
  display: grid;
  place-items: center;
  color: var(--ink);
  font-size: clamp(1.25rem, 2.8vw, 1.8rem);
  font-weight: 1000;
  text-align: center;
}

.message.good {
  color: #108456;
}

.message.try {
  color: #b3402e;
}

.next-button {
  width: min(260px, 100%);
  justify-self: center;
  padding: 0 24px;
  color: var(--white);
  background: linear-gradient(180deg, #48cf91, var(--green));
  font-size: clamp(1.2rem, 2.8vw, 1.65rem);
  font-weight: 1000;
  box-shadow: 0 12px 24px rgba(43, 191, 122, 0.2);
}

.next-button[hidden] {
  display: none;
}

.letter-buttons {
  display: grid;
  grid-template-columns: repeat(6, minmax(44px, 1fr));
  gap: 8px;
}

.letter-button {
  aspect-ratio: 1;
  min-width: 0;
  border: 0;
  border-bottom: 6px solid rgba(23, 50, 77, 0.18);
  border-radius: 8px;
  color: var(--white);
  cursor: pointer;
  background: linear-gradient(180deg, color-mix(in srgb, var(--button-color) 76%, white), var(--button-color));
  font-size: clamp(1.55rem, 4.4vw, 3rem);
  font-weight: 1000;
  line-height: 1;
  text-shadow: 0 4px 0 rgba(23, 50, 77, 0.16);
  box-shadow: 0 8px 18px rgba(23, 50, 77, 0.12);
  transition:
    transform 160ms ease,
    filter 160ms ease,
    box-shadow 160ms ease;
}

.letter-button.is-target {
  outline: 4px solid var(--button-accent);
  outline-offset: 3px;
}

.letter-button:disabled {
  cursor: default;
  filter: grayscale(0.25);
  opacity: 0.58;
}

.letter-button.flash-good {
  animation: buttonWin 480ms ease;
}

.letter-button.flash-try {
  animation: wobble 340ms ease;
}

.progress-area {
  grid-column: 1 / -1;
  padding: 18px;
  display: grid;
  grid-template-columns: minmax(160px, auto) 1fr auto;
  align-items: center;
  gap: 16px;
  background: rgba(255, 255, 255, 0.84);
}

.score-line {
  display: grid;
  gap: 2px;
  font-size: 1rem;
  font-weight: 900;
}

.score-line span {
  color: var(--muted);
}

.score-line strong {
  font-size: 1.65rem;
}

.star-track {
  min-height: 58px;
  display: grid;
  grid-template-columns: repeat(13, minmax(14px, 1fr));
  gap: 7px;
}

.star-token {
  min-width: 0;
  aspect-ratio: 1;
  background: rgba(23, 50, 77, 0.12);
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 56%, 79% 91%, 50% 70%, 21% 91%, 32% 56%, 2% 35%, 39% 35%);
}

.star-token.filled {
  background: linear-gradient(180deg, color-mix(in srgb, var(--token-color) 58%, white), var(--token-color));
  filter: drop-shadow(0 7px 8px rgba(255, 153, 48, 0.28));
  animation: pop 320ms ease;
}

.star-token.current {
  background: linear-gradient(180deg, #ffffff, var(--sun));
  outline: 3px solid rgba(255, 211, 90, 0.6);
  outline-offset: 2px;
}

.reset-button {
  padding: 0 18px;
  font-weight: 1000;
}

.celebration {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.confetti {
  position: absolute;
  top: -18px;
  width: 14px;
  height: 22px;
  border-radius: 4px;
  animation: fall 900ms ease-out forwards;
}

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

  50% {
    transform: translateY(-12px) rotate(8deg);
  }
}

@keyframes pop {
  0% {
    transform: scale(0.9);
  }

  55% {
    transform: scale(1.08);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes buttonWin {
  0% {
    transform: scale(1);
    filter: brightness(1);
  }

  45% {
    transform: scale(1.08);
    filter: brightness(1.12);
  }

  100% {
    transform: scale(1);
    filter: brightness(1);
  }
}

@keyframes wobble {
  0%,
  100% {
    transform: translateX(0);
  }

  30% {
    transform: translateX(-8px);
  }

  60% {
    transform: translateX(8px);
  }
}

@keyframes fall {
  to {
    transform: translateY(105vh) rotate(320deg);
    opacity: 0;
  }
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 20px, 620px);
    padding-top: 12px;
  }

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

  .music-button {
    justify-content: center;
  }

  .game-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .target-area {
    min-height: 430px;
  }

  .progress-area {
    grid-column: auto;
    grid-template-columns: 1fr;
  }

  .reset-button {
    width: 100%;
  }
}

@media (max-width: 460px) {
  .target-area {
    min-height: 400px;
  }

  .picture-window {
    width: min(190px, 52vw);
  }

  .letter-buttons {
    grid-template-columns: repeat(6, minmax(42px, 1fr));
    gap: 7px;
  }

  .letter-button {
    border-bottom-width: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}
