:root {
  color-scheme: light;
  font-family: "Arial Rounded MT Bold", "Noto Sans TC", system-ui, sans-serif;
  color: #4a2918;
  background: #ffcf88;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

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

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  overscroll-behavior-x: none;
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 255, 255, 0.88), transparent 11rem),
    radial-gradient(circle at 86% 18%, rgba(255, 126, 173, 0.35), transparent 13rem),
    linear-gradient(180deg, #ffe3f1 0%, #ffedb5 45%, #ffb56e 100%);
}

button,
select {
  font: inherit;
}

.hidden {
  display: none !important;
}

.bakery-game {
  width: min(100%, 840px);
  min-height: 100vh;
  margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top)) 12px calc(36px + env(safe-area-inset-bottom));
  display: grid;
  align-content: start;
  gap: 12px;
}

.topbar {
  display: grid;
  grid-template-columns: 46px 1fr auto;
  gap: 10px;
  align-items: center;
}

.home-link,
.soft-btn,
.result-card button,
.result-card a {
  min-height: 44px;
  border: 0;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #fff8d8, #ffba58);
  color: #4a2918;
  box-shadow: 0 7px 0 #9d5626, 0 12px 20px rgba(86, 45, 20, 0.22);
  font-weight: 950;
  text-decoration: none;
}

.title-block p,
.title-block h1 {
  margin: 0;
}

.title-block p {
  font-size: 0.72rem;
  font-weight: 950;
  color: rgba(74, 41, 24, 0.65);
}

.title-block h1 {
  font-size: clamp(1.35rem, 5vw, 2.3rem);
  line-height: 1;
}

.language-picker {
  min-width: 112px;
  display: grid;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 900;
}

.language-picker select {
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 8px 9px;
  background: rgba(255, 250, 225, 0.96);
  color: #4a2918;
  font-weight: 900;
}

.menu-panel,
.play-panel {
  display: grid;
  gap: 12px;
}

.cover {
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 430px;
  border-radius: 22px;
  object-fit: cover;
  box-shadow: 0 12px 0 #9d5626, 0 20px 38px rgba(86, 45, 20, 0.22);
}

.menu-copy {
  border-radius: 20px;
  padding: 14px;
  display: grid;
  gap: 4px;
  background: rgba(255, 251, 226, 0.88);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.55), 0 8px 18px rgba(86,45,20,.16);
}

.menu-copy strong {
  font-size: 1.35rem;
}

.menu-copy span,
.hint-text {
  color: rgba(74, 41, 24, 0.72);
  font-weight: 900;
}

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

.stage-card {
  min-height: 112px;
  border: 0;
  border-radius: 18px;
  padding: 12px;
  display: grid;
  gap: 6px;
  text-align: left;
  background: linear-gradient(145deg, #fff8dc, #ffc56d);
  color: #4a2918;
  box-shadow: 0 8px 0 #a95f2b, 0 14px 22px rgba(86, 45, 20, 0.16);
  font-weight: 950;
}

.stage-card b {
  font-size: 1.55rem;
}

.stage-card.locked {
  filter: grayscale(1);
  opacity: 0.58;
}

.play-head {
  display: grid;
  grid-template-columns: auto 1fr 1fr;
  gap: 8px;
  align-items: center;
}

.hud-pill {
  min-height: 44px;
  border-radius: 14px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 16px rgba(86, 45, 20, 0.15);
  font-weight: 950;
}

.order-bar {
  min-height: 72px;
  border-radius: 20px;
  padding: 10px;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  background: rgba(255, 248, 218, 0.92);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.55), 0 8px 18px rgba(86,45,20,.14);
}

.order-chip {
  min-width: 92px;
  border-radius: 999px;
  padding: 8px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: #fff;
  font-weight: 950;
  box-shadow: inset 0 -4px rgba(0,0,0,.08);
}

.order-dot {
  width: 24px;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 3px solid rgba(74, 41, 24, 0.28);
}

.bubble-board {
  width: min(100%, 560px);
  margin: 0 auto;
  aspect-ratio: 1;
  border-radius: 24px;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 7px;
  background:
    radial-gradient(circle at 22% 18%, rgba(255, 255, 255, 0.72), transparent 8rem),
    linear-gradient(180deg, #9b572d, #6f371e);
  box-shadow: inset 0 0 0 5px rgba(255, 241, 183, 0.35), 0 18px 34px rgba(86,45,20,.24);
}

.bubble {
  border: 0;
  border-radius: 999px;
  position: relative;
  display: grid;
  place-items: center;
  background: var(--bubble);
  box-shadow: inset -8px -10px rgba(80, 31, 20, 0.17), inset 7px 7px rgba(255,255,255,.55), 0 8px 0 rgba(55, 24, 15, 0.18);
  transition: transform .18s ease, opacity .18s ease;
  cursor: pointer;
  touch-action: manipulation;
}

.bubble span {
  position: relative;
  z-index: 1;
  font-size: clamp(1rem, 4.8vw, 1.85rem);
  filter: drop-shadow(0 2px 0 rgba(255, 255, 255, 0.45));
  pointer-events: none;
}

.bubble::after {
  content: "";
  position: absolute;
  left: 22%;
  top: 17%;
  width: 24%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(255,255,255,.72);
}

.bubble:active {
  transform: scale(.92);
}

.bubble.pop {
  animation: bubble-pop .32s ease forwards;
}

.bubble.drop {
  animation: bubble-drop .26s cubic-bezier(.18,.82,.3,1.08);
}

.board-float {
  position: fixed;
  z-index: 20;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(74, 41, 24, 0.9);
  color: #fff6bd;
  font-weight: 950;
  transform: translate(-50%, -50%);
  pointer-events: none;
  animation: float-up .85s ease forwards;
}

.result-panel,
.loading-panel {
  position: fixed;
  inset: 0;
  z-index: 30;
  padding: 20px;
  display: grid;
  place-items: center;
  background: rgba(74, 41, 24, 0.38);
  backdrop-filter: blur(8px);
}

.result-card,
.loading-card {
  width: min(100%, 390px);
  border-radius: 24px;
  padding: 20px;
  display: grid;
  gap: 12px;
  text-align: center;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 38px rgba(74, 41, 24, 0.24);
  font-weight: 950;
  animation: panel-in .24s ease both;
}

.stars {
  color: #ffb000;
  font-size: 1.45rem;
  letter-spacing: 2px;
}

.loading-card div {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(74, 41, 24, 0.12);
}

.loading-card i {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #ff78a9, #ffd85e);
  transition: width .2s ease;
}

@keyframes bubble-pop {
  to {
    opacity: 0;
    transform: scale(1.35) rotate(10deg);
  }
}

@keyframes bubble-drop {
  from { transform: translateY(var(--drop-y, -72px)) scale(.94); }
  to { transform: translateY(0) scale(1); }
}

@keyframes float-up {
  to {
    opacity: 0;
    transform: translate(-50%, -130%);
  }
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(.96);
  }
}

@media (max-width: 560px) {
  .bakery-game {
    padding-inline: 8px;
  }

  .topbar {
    grid-template-columns: 42px 1fr;
  }

  .language-picker {
    grid-column: 1 / -1;
    grid-template-columns: auto 1fr;
    align-items: center;
  }

  .stage-grid {
    grid-template-columns: 1fr 1fr;
  }

  .bubble-board {
    gap: 5px;
    padding: 8px;
  }
}
