:root {
  color-scheme: light;
  --ink: #18362f;
  --muted: #6d7663;
  --orange: #f3812b;
  --orange-dark: #da6720;
  --gold: #f7d776;
  --cream: #fff0bd;
  --cream-deep: #e2c06a;
  --green: #238857;
  --green-soft: #74bf68;
  --sky: #cdefff;
  --paper: rgba(255, 255, 255, 0.88);
  --line: rgba(118, 85, 28, 0.16);
  --shadow: 0 18px 42px rgba(95, 64, 21, 0.22);
  --radius: 8px;
  font-family:
    Inter, "Hiragino Kaku Gothic ProN", "Yu Gothic", "YuGothic", Meiryo,
    system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #d9f4ff;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0) 18rem),
    linear-gradient(180deg, #f3ac5e 0, #d4a25e 22rem, #7fc977 22rem, #318e58 100%);
  overflow-x: hidden;
}

button {
  appearance: none;
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  font: inherit;
}

canvas {
  display: block;
}

.brand-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 58px;
  color: #fff;
  background: linear-gradient(180deg, var(--orange), var(--orange-dark));
  box-shadow: 0 4px 0 rgba(137, 70, 18, 0.16);
}

.brand-bar strong {
  font-size: 1.36rem;
  font-weight: 1000;
  line-height: 1;
  text-shadow: 0 2px 0 rgba(113, 55, 18, 0.25);
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 3px solid rgba(255, 255, 255, 0.74);
  border-radius: 50%;
  color: #fff;
  font-size: 1.2rem;
  font-weight: 1000;
  background:
    radial-gradient(circle at 36% 30%, rgba(255, 255, 255, 0.9) 0 12%, transparent 13%),
    linear-gradient(135deg, #85d56a, #1f8052);
  box-shadow: inset 0 -3px 0 rgba(13, 83, 48, 0.2);
}

.app-shell {
  width: min(100% - 24px, 820px);
  margin: 0 auto;
  padding: 14px 0 42px;
}

.game-machine {
  position: relative;
  display: grid;
  justify-items: center;
}

h1 {
  width: 1px;
  height: 1px;
  margin: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.bubble-row {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 150px minmax(170px, 1fr) 150px;
  gap: 18px;
  align-items: center;
  width: min(100%, 700px);
  margin-top: 14px;
}

.hud-bubble {
  position: relative;
  display: grid;
  width: 150px;
  height: 150px;
  place-items: center;
  align-content: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 24%, rgba(255, 255, 255, 0.96) 0 9%, transparent 10%),
    radial-gradient(circle at 72% 76%, rgba(255, 255, 255, 0.56) 0 7%, transparent 8%),
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.92), rgba(255, 246, 221, 0.7) 58%, rgba(255, 255, 255, 0.38));
  box-shadow:
    inset 0 -9px 0 rgba(197, 149, 74, 0.14),
    inset 0 0 18px rgba(255, 255, 255, 0.9),
    0 16px 28px rgba(114, 77, 20, 0.16);
}

.hud-bubble span {
  color: #fff;
  font-size: 1.35rem;
  font-weight: 1000;
  line-height: 1;
  text-shadow:
    0 2px 0 rgba(109, 70, 31, 0.35),
    0 0 8px rgba(109, 70, 31, 0.22);
}

.score-bubble strong {
  display: block;
  width: 128px;
  margin-top: 8px;
  overflow: hidden;
  color: #fff;
  font-size: 2rem;
  font-weight: 1000;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  text-align: center;
  text-overflow: clip;
  white-space: nowrap;
  text-shadow:
    0 3px 0 rgba(109, 70, 31, 0.28),
    0 0 10px rgba(109, 70, 31, 0.2);
}

.next-bubble {
  gap: 1px;
}

.next-bubble canvas {
  width: 66px;
  height: 66px;
  margin: 2px 0 0;
}

.next-bubble strong {
  max-width: 112px;
  overflow: hidden;
  color: #795221;
  font-size: 0.76rem;
  font-weight: 900;
  line-height: 1.12;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-button {
  justify-self: center;
  min-width: 180px;
  min-height: 58px;
  padding: 0 28px;
  color: #fff;
  font-size: 1.08rem;
  font-weight: 1000;
  background: linear-gradient(180deg, #fa9a3d, #e77827);
  border: 3px solid rgba(255, 207, 126, 0.42);
  box-shadow:
    inset 0 -4px 0 rgba(135, 66, 18, 0.18),
    0 12px 20px rgba(111, 71, 24, 0.18);
  text-shadow: 0 2px 0 rgba(126, 65, 20, 0.24);
  transition:
    transform 0.16s ease,
    filter 0.16s ease;
}

.leaderboard-button:hover,
#sound-toggle:hover,
.game-overlay button:hover {
  filter: brightness(1.04);
  transform: translateY(-1px);
}

.leaderboard-button:active,
#sound-toggle:active,
.game-overlay button:active {
  transform: translateY(1px);
}

.meta-row {
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  width: min(100%, 640px);
  margin: 8px auto 2px;
}

.meta-row div {
  min-width: 0;
  padding: 7px 10px;
  border: 1px solid rgba(255, 235, 181, 0.52);
  border-radius: var(--radius);
  background: rgba(121, 82, 33, 0.2);
  color: #fff;
  text-align: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.meta-row span {
  display: block;
  font-size: 0.64rem;
  font-weight: 900;
  line-height: 1.1;
  text-transform: uppercase;
}

.meta-row strong {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  font-size: 0.94rem;
  font-weight: 1000;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drop-character {
  position: relative;
  z-index: 3;
  width: 124px;
  height: 74px;
  margin: 5px 0 -22px;
}

.drop-face {
  position: absolute;
  inset: 7px 6px 0;
  border: 5px solid rgba(255, 226, 130, 0.72);
  border-radius: 54% 46% 49% 51% / 60% 55% 45% 40%;
  background:
    radial-gradient(circle at 40% 43%, #704d2c 0 3px, transparent 4px),
    radial-gradient(circle at 61% 43%, #704d2c 0 3px, transparent 4px),
    radial-gradient(ellipse at 50% 58%, transparent 0 11px, #704d2c 12px 14px, transparent 15px),
    linear-gradient(180deg, #fff7c8, #ffe487);
  box-shadow: 0 8px 0 rgba(112, 69, 18, 0.14);
}

.drop-visor {
  position: absolute;
  right: 21px;
  bottom: 5px;
  width: 38px;
  height: 18px;
  border-radius: 999px;
  background: linear-gradient(180deg, #f3fff3, #62ba6a);
  transform: rotate(-10deg);
  box-shadow: inset 0 -3px 0 rgba(31, 128, 82, 0.22);
}

.game-stage {
  position: relative;
  width: min(100%, 540px);
  aspect-ratio: 3 / 4;
  border: 15px solid var(--gold);
  border-top-width: 18px;
  border-bottom-width: 10px;
  border-radius: 8px;
  background: var(--cream);
  box-shadow:
    inset 12px 0 0 rgba(160, 127, 50, 0.22),
    inset -12px 0 0 rgba(160, 127, 50, 0.22),
    0 22px 45px rgba(72, 54, 21, 0.18);
  touch-action: none;
  overflow: hidden;
}

.game-stage::before {
  position: absolute;
  top: -18px;
  right: -15px;
  left: -15px;
  height: 34px;
  content: "";
  border: 9px solid #ffe992;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  opacity: 0.95;
  pointer-events: none;
}

#game-canvas {
  width: 100%;
  height: 100%;
}

.game-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  padding: 24px;
  color: #fff;
  text-align: center;
  background: rgba(93, 57, 22, 0.62);
  backdrop-filter: blur(8px);
}

.game-overlay[hidden] {
  display: none;
}

.game-overlay p {
  margin: 0;
  font-size: 2rem;
  font-weight: 1000;
  line-height: 1;
}

.game-overlay strong {
  display: block;
  font-size: 3rem;
  line-height: 1;
}

.game-overlay button,
#sound-toggle {
  min-height: 44px;
  padding: 0 18px;
  color: #fff;
  font-weight: 1000;
  background: linear-gradient(180deg, #2d9b62, #157348);
  box-shadow: inset 0 -4px 0 rgba(20, 83, 53, 0.24);
  transition:
    transform 0.16s ease,
    filter 0.16s ease;
}

.under-controls {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
  width: min(100%, 540px);
  margin-top: 12px;
}

.ad-slot {
  display: grid;
  min-height: 74px;
  place-items: center;
  align-content: center;
  gap: 3px;
  border: 2px dashed rgba(113, 86, 42, 0.2);
  border-radius: var(--radius);
  color: #6f673f;
  background:
    repeating-linear-gradient(
      -45deg,
      rgba(255, 255, 255, 0.36) 0,
      rgba(255, 255, 255, 0.36) 8px,
      rgba(255, 246, 208, 0.36) 8px,
      rgba(255, 246, 208, 0.36) 16px
    ),
    rgba(255, 255, 255, 0.74);
}

.ad-slot span {
  font-size: 0.88rem;
  font-weight: 1000;
}

.ad-slot small {
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.evolution-panel {
  width: min(100%, 760px);
  margin: 20px auto 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.evolution-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.evolution-head span,
.evolution-head strong {
  color: #6c4f24;
  font-weight: 1000;
}

.evolution-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.evolution-list li {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 7px;
  align-items: center;
  min-height: 54px;
  padding: 7px;
  border: 1px solid rgba(113, 86, 42, 0.12);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.76);
}

.mini-item {
  width: 38px;
  height: 38px;
}

.evolution-list span {
  min-width: 0;
  overflow: hidden;
  color: #4f4224;
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1.18;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.evolution-list small {
  grid-column: 2;
  color: #85724a;
  font-size: 0.68rem;
  font-weight: 1000;
}

@media (max-width: 720px) {
  .brand-bar {
    min-height: 54px;
  }

  .app-shell {
    width: min(100% - 14px, 560px);
    padding-top: 8px;
  }

  .bubble-row {
    grid-template-columns: 112px 1fr 112px;
    gap: 8px;
    margin-top: 8px;
  }

  .hud-bubble {
    width: 112px;
    height: 112px;
  }

  .hud-bubble span {
    font-size: 1rem;
  }

  .score-bubble strong {
    width: 94px;
    font-size: 1.5rem;
  }

  .next-bubble canvas {
    width: 50px;
    height: 50px;
  }

  .next-bubble strong {
    max-width: 88px;
    font-size: 0.66rem;
  }

  .leaderboard-button {
    min-width: 132px;
    min-height: 48px;
    padding: 0 14px;
    font-size: 0.9rem;
  }

  .meta-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: min(100%, 440px);
  }

  .drop-character {
    width: 102px;
    height: 62px;
    margin-bottom: -18px;
  }

  .game-stage {
    border-width: 11px;
    border-top-width: 15px;
    border-bottom-width: 8px;
  }

  .under-controls {
    grid-template-columns: 1fr;
  }

  .evolution-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 420px) {
  .bubble-row {
    grid-template-columns: 96px 1fr 96px;
  }

  .hud-bubble {
    width: 96px;
    height: 96px;
  }

  .leaderboard-button {
    min-width: 110px;
    padding: 0 10px;
  }

  .meta-row {
    gap: 6px;
  }

  .meta-row div {
    padding: 6px 7px;
  }

  .evolution-list {
    grid-template-columns: 1fr;
  }
}

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