:root {
  color-scheme: light;
  font-family: Inter, ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, sans-serif;
  --ink: #173c3a;
  --ink-soft: #476d66;
  --honey: #ffc928;
  --honey-dark: #ee9f17;
  --cream: #fff9dc;
  --leaf: #2d8b57;
  --sky: #68c8e8;
  --coral: #ff7b68;
  --panel: rgba(255, 252, 226, 0.94);
  --shadow: 0 16px 38px rgba(26, 88, 70, 0.22);
}

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

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: #184e54;
}

body {
  display: grid;
  place-items: center;
}

button {
  font: inherit;
}

button:focus-visible {
  outline: 4px solid white;
  outline-offset: 3px;
}

#app,
#game-shell {
  position: relative;
  width: 100%;
  height: 100%;
}

#game-shell {
  max-width: 600px;
  margin: 0 auto;
  overflow: hidden;
  background: var(--sky);
  box-shadow: 0 0 80px rgba(0, 0, 0, 0.35);
  isolation: isolate;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
}

.is-hidden {
  display: none !important;
}

.execution-paused * {
  animation-play-state: paused !important;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: max(34px, env(safe-area-inset-top)) 28px max(28px, env(safe-area-inset-bottom));
  text-align: center;
}

.overlay-menu {
  justify-content: flex-end;
  padding-bottom: max(42px, calc(env(safe-area-inset-bottom) + 24px));
  background: linear-gradient(180deg, rgba(68, 178, 222, 0.05) 5%, rgba(22, 91, 78, 0.08) 40%, rgba(16, 66, 52, 0.84) 100%);
}

.overlay-upgrade,
.overlay-game-over,
.overlay-panel,
.overlay-system {
  background: rgba(19, 58, 54, 0.68);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.overlay-panel {
  z-index: 60;
  background: rgba(19, 58, 54, 0.86);
}

.overlay-system {
  z-index: 100;
  background: linear-gradient(165deg, #55bfe2, #2c8f71 60%, #1a5a4b);
}

.overlay-system h2 {
  margin-bottom: 14px;
}

.overlay-game-over::before,
.overlay-upgrade::before {
  content: "";
  position: absolute;
  width: 150%;
  height: 52%;
  top: 23%;
  background: radial-gradient(circle, rgba(255, 216, 68, 0.23), transparent 64%);
  pointer-events: none;
}

.eyebrow {
  position: relative;
  margin: 0 0 8px;
  color: #fff5b5;
  font-size: clamp(11px, 2.5vw, 14px);
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1,
h2,
p {
  text-wrap: balance;
}

h1 {
  position: relative;
  margin: 0;
  color: white;
  font-size: clamp(54px, 14vw, 84px);
  font-weight: 1000;
  line-height: 0.82;
  letter-spacing: -0.075em;
  text-shadow: 0 7px 0 rgba(27, 77, 58, 0.26), 0 14px 28px rgba(18, 58, 45, 0.28);
}

h1 span {
  color: var(--honey);
  font-size: 0.9em;
}

h2 {
  position: relative;
  margin: 0 0 24px;
  color: white;
  font-size: clamp(34px, 9vw, 52px);
  font-weight: 950;
  line-height: 0.95;
  letter-spacing: -0.045em;
}

.menu-copy {
  position: relative;
  max-width: 430px;
  margin: 18px 0 14px;
  color: rgba(255, 255, 255, 0.92);
  font-size: clamp(15px, 3.8vw, 19px);
  font-weight: 650;
  line-height: 1.35;
}

.brand-mark {
  position: absolute;
  top: 13%;
  left: 50%;
  width: 130px;
  height: 100px;
  transform: translateX(-50%);
  filter: drop-shadow(0 12px 18px rgba(24, 78, 59, 0.2));
  animation: brand-float 2.6s ease-in-out infinite;
}

.brand-bee {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.brand-bee img {
  display: block;
  width: 92px;
  height: 92px;
}

.brand-wing {
  position: absolute;
  top: 15px;
  width: 42px;
  height: 59px;
  border: 3px solid rgba(255, 255, 255, 0.84);
  border-radius: 70% 30% 70% 30%;
  background: rgba(225, 250, 255, 0.46);
}

.brand-wing-left {
  left: 4px;
  transform: rotate(-37deg);
}

.brand-wing-right {
  right: 4px;
  transform: rotate(37deg) scaleX(-1);
}

.best-score-card {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 2px 0 14px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.best-score-card strong {
  color: white;
  font-size: 22px;
  letter-spacing: -0.03em;
}

.primary-button,
.secondary-button,
.upgrade-card {
  position: relative;
  border: 0;
  cursor: pointer;
  user-select: none;
}

.primary-button {
  display: flex;
  width: min(100%, 380px);
  min-height: 64px;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 16px 24px;
  border: 3px solid rgba(255, 255, 255, 0.68);
  border-radius: 22px;
  background: linear-gradient(180deg, #ffdc43, #f7b51b);
  color: #3f350b;
  box-shadow: 0 8px 0 #c57a17, 0 18px 34px rgba(22, 51, 38, 0.3);
  font-size: 17px;
  font-weight: 1000;
  letter-spacing: 0.04em;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.primary-button span:last-child {
  font-size: 25px;
}

.primary-button:active {
  transform: translateY(6px) scale(0.99);
  box-shadow: 0 2px 0 #c57a17, 0 8px 18px rgba(22, 51, 38, 0.25);
}

.secondary-button {
  margin-top: 18px;
  padding: 10px 18px;
  background: transparent;
  color: rgba(255, 255, 255, 0.86);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.1em;
}

.secondary-button-panel {
  min-height: 42px;
  margin-top: 15px;
  border: 2px solid rgba(255, 255, 255, 0.36);
  border-radius: 15px;
  background: rgba(15, 67, 55, 0.26);
}

.compact-button {
  min-height: 56px;
  margin-top: 22px;
}

.control-hint {
  margin: 18px 0 0;
  color: rgba(255, 255, 255, 0.68);
  font-size: 12px;
  font-weight: 750;
}

.icon-button {
  position: absolute;
  z-index: 30;
  top: max(14px, env(safe-area-inset-top));
  display: grid;
  width: 43px;
  height: 43px;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.48);
  border-radius: 50%;
  background: rgba(22, 78, 66, 0.35);
  color: white;
  box-shadow: 0 8px 18px rgba(21, 77, 66, 0.14);
  font-size: 13px;
  font-weight: 1000;
  cursor: pointer;
  backdrop-filter: blur(6px);
}

.language-button {
  left: max(14px, env(safe-area-inset-left));
  width: 64px;
  padding: 0 8px;
  appearance: none;
  text-align: center;
  text-align-last: center;
}

.language-button option {
  color: #173f37;
  background: white;
  font-weight: 800;
}

.sound-button {
  right: max(14px, env(safe-area-inset-right));
  font-size: 22px;
}

.sound-button.in-game {
  top: auto;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  width: 38px;
  height: 38px;
  border-color: rgba(255, 255, 255, 0.32);
  background: rgba(22, 78, 66, 0.24);
  font-size: 19px;
}

.hosted .sound-button {
  display: none;
}

.hosted .language-button {
  right: max(14px, env(safe-area-inset-right));
  left: auto;
}

.help-grid {
  position: relative;
  display: grid;
  width: min(100%, 440px);
  gap: 10px;
}

.help-grid article {
  display: grid;
  min-height: 92px;
  grid-template-columns: 56px 1fr;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border: 2px solid rgba(255, 255, 255, 0.66);
  border-radius: 21px;
  background: rgba(255, 252, 226, 0.95);
  color: var(--ink);
  text-align: left;
  box-shadow: 0 6px 0 rgba(119, 76, 23, 0.34);
}

.help-grid article > span {
  font-size: 36px;
  text-align: center;
}

.help-grid strong {
  display: block;
  margin-bottom: 3px;
  font-size: 16px;
  font-weight: 1000;
}

.help-grid p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.loading-bee {
  width: 108px;
  height: 108px;
  margin-bottom: 22px;
  animation: loading-float 1.4s ease-in-out infinite;
}

.loading-bee img {
  width: 100%;
  height: 100%;
}

.loading-track {
  width: min(70%, 280px);
  height: 9px;
  margin-top: 14px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  background: rgba(16, 67, 54, 0.25);
}

.loading-track span {
  display: block;
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: var(--honey);
  animation: loading-sweep 1.1s ease-in-out infinite alternate;
}

.pause-symbol,
.error-symbol {
  display: grid;
  width: 84px;
  height: 84px;
  place-items: center;
  margin-bottom: 20px;
  border: 4px solid white;
  border-radius: 50%;
  background: rgba(20, 80, 67, 0.35);
  color: white;
  font-size: 42px;
  font-weight: 1000;
  box-shadow: var(--shadow);
}

.error-symbol {
  background: var(--coral);
}

.system-copy {
  max-width: 390px;
  margin: 0;
  color: rgba(255, 255, 255, 0.88);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.45;
}

#hud {
  position: absolute;
  z-index: 5;
  inset: max(12px, env(safe-area-inset-top)) 12px auto;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: start;
  gap: 8px;
  pointer-events: none;
}

.hud-pill {
  display: flex;
  min-height: 50px;
  flex-direction: column;
  justify-content: center;
  padding: 7px 13px 6px;
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 17px;
  background: rgba(20, 84, 72, 0.69);
  color: white;
  box-shadow: 0 8px 18px rgba(24, 81, 61, 0.16);
  backdrop-filter: blur(6px);
}

.hud-score {
  max-width: 160px;
}

.hud-score small {
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 7px;
  font-weight: 950;
  line-height: 1;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.hud-time {
  align-items: center;
}

.hud-bees {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  min-width: 82px;
  padding-inline: 10px;
}

.bee-stack {
  display: flex;
  min-width: 40px;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}

.bee-stack small {
  color: rgba(255, 255, 255, 0.72);
  font-size: 7px;
  font-weight: 950;
  line-height: 1;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.hud-label {
  color: rgba(255, 255, 255, 0.7);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.hud-pill strong {
  font-size: 20px;
  font-weight: 1000;
  line-height: 1;
}

.combo-pill {
  position: absolute;
  top: 63px;
  left: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border-radius: 12px;
  background: #fff4a4;
  color: #7b480d;
  box-shadow: 0 6px 14px rgba(102, 62, 12, 0.18);
  animation: combo-pop 180ms ease-out;
}

.combo-pill strong {
  font-size: 18px;
  font-weight: 1000;
}

.combo-pill span {
  font-size: 8px;
  font-weight: 1000;
  letter-spacing: 0.1em;
}

.upgrade-options {
  position: relative;
  display: grid;
  width: min(100%, 450px);
  gap: 11px;
}

.upgrade-card {
  display: grid;
  width: 100%;
  min-height: 106px;
  grid-template-columns: 68px 1fr auto;
  align-items: center;
  gap: 13px;
  padding: 14px 16px;
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 24px;
  background: var(--panel);
  color: var(--ink);
  text-align: left;
  box-shadow: 0 8px 0 rgba(187, 128, 30, 0.56), var(--shadow);
  transition: transform 100ms ease, box-shadow 100ms ease;
}

.upgrade-card:active {
  transform: translateY(5px);
  box-shadow: 0 3px 0 rgba(187, 128, 30, 0.56), 0 8px 18px rgba(26, 88, 70, 0.18);
}

.upgrade-icon {
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  border-radius: 20px;
  background: linear-gradient(145deg, #fff4ac, #ffd53f);
  font-size: 34px;
  box-shadow: inset 0 -5px 0 rgba(215, 137, 18, 0.18);
}

.upgrade-text strong,
.upgrade-text span {
  display: block;
}

.upgrade-text strong {
  margin-bottom: 4px;
  font-size: 18px;
  font-weight: 1000;
  letter-spacing: -0.025em;
}

.upgrade-text span {
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
}

.upgrade-arrow {
  color: #c77f15;
  font-size: 25px;
  font-weight: 1000;
}

.result-score {
  position: relative;
  display: flex;
  width: min(100%, 390px);
  flex-direction: column;
  margin: 4px 0 15px;
  padding: 22px 20px 18px;
  border: 3px solid rgba(255, 255, 255, 0.72);
  border-radius: 28px;
  background: linear-gradient(145deg, #fff8c8, #ffd747);
  color: #53400a;
  box-shadow: 0 9px 0 #c98018, var(--shadow);
}

.result-score span,
.result-grid span {
  font-size: 9px;
  font-weight: 1000;
  letter-spacing: 0.15em;
}

.result-score strong {
  font-size: clamp(52px, 15vw, 78px);
  font-weight: 1000;
  line-height: 1;
  letter-spacing: -0.06em;
}

.result-grid {
  position: relative;
  display: grid;
  width: min(100%, 390px);
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 7px 0 20px;
}

.result-grid div {
  display: flex;
  min-height: 76px;
  flex-direction: column;
  justify-content: center;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.13);
  color: white;
}

.result-grid span {
  color: rgba(255, 255, 255, 0.66);
}

.result-grid strong {
  margin-top: 4px;
  font-size: 26px;
  font-weight: 1000;
}

.new-best {
  position: absolute;
  z-index: 2;
  top: 30%;
  right: 7%;
  margin: 0;
  padding: 9px 13px;
  border: 3px solid white;
  border-radius: 13px;
  background: var(--coral);
  color: white;
  box-shadow: 0 5px 0 #b64b42;
  font-size: 12px;
  font-weight: 1000;
  transform: rotate(7deg);
  animation: new-best-pop 500ms cubic-bezier(0.18, 1.5, 0.4, 1);
}

.announcement {
  position: absolute;
  z-index: 25;
  top: 19%;
  left: 50%;
  min-width: 230px;
  padding: 12px 22px;
  border: 3px solid white;
  border-radius: 18px;
  background: linear-gradient(180deg, #ffdd42, #f5aa17);
  color: #5a3705;
  box-shadow: 0 8px 0 #c97917, 0 18px 30px rgba(45, 70, 31, 0.26);
  font-size: 15px;
  font-weight: 1000;
  letter-spacing: 0.04em;
  text-align: center;
  transform: translateX(-50%);
  animation: announcement-in 350ms cubic-bezier(0.18, 1.4, 0.35, 1);
}

.drag-hint {
  position: absolute;
  z-index: 6;
  inset: auto 0 16%;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: white;
  pointer-events: none;
  filter: drop-shadow(0 3px 8px rgba(28, 65, 45, 0.4));
}

.drag-hint span {
  width: 8px;
  height: 8px;
  margin-top: 4px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  animation: hint-dots 1.25s ease-in-out infinite;
}

.drag-hint span:nth-child(2) { animation-delay: 80ms; opacity: 0.72; }
.drag-hint span:nth-child(3) { animation-delay: 160ms; opacity: 0.42; }

.drag-hint p {
  margin: 8px 0 0;
  font-size: 13px;
  font-weight: 850;
}

#screen-flash {
  position: absolute;
  z-index: 50;
  inset: 0;
  background: white;
  opacity: 0;
  pointer-events: none;
}

#screen-flash.flash {
  animation: screen-flash 280ms ease-out;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@keyframes brand-float {
  0%, 100% { transform: translate(-50%, 0) rotate(-2deg); }
  50% { transform: translate(-50%, -12px) rotate(2deg); }
}

@keyframes combo-pop {
  from { transform: scale(0.65); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes new-best-pop {
  from { transform: rotate(7deg) scale(0); }
  to { transform: rotate(7deg) scale(1); }
}

@keyframes announcement-in {
  from { transform: translateX(-50%) scale(0.7); opacity: 0; }
  to { transform: translateX(-50%) scale(1); opacity: 1; }
}

@keyframes hint-dots {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes screen-flash {
  0% { opacity: 0; }
  25% { opacity: 0.45; }
  100% { opacity: 0; }
}

@keyframes loading-sweep {
  from { transform: translateX(-5%); }
  to { transform: translateX(145%); }
}

@keyframes loading-float {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-12px) rotate(2deg); }
}

@media (min-aspect-ratio: 3/4) and (min-width: 700px) {
  #game-shell {
    width: min(56.25vh, 600px);
    height: min(100vh, 1066px);
    border-radius: 24px;
  }
}

@media (max-height: 690px) {
  .brand-mark { top: 8%; transform: translateX(-50%) scale(0.78); }
  .menu-copy { margin-top: 12px; }
  .control-hint { margin-top: 12px; }
  .upgrade-card { min-height: 88px; padding: 10px 14px; }
  .upgrade-icon { width: 55px; height: 55px; }
  .upgrade-options { gap: 8px; }
  .result-score { padding: 14px; }
  .result-grid { margin-bottom: 12px; }
  .help-grid article { min-height: 70px; padding-block: 8px; }
  .compact-button { margin-top: 14px; }
}

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