*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

:root {
  --font: 'Baloo 2', 'Segoe UI Rounded', system-ui, sans-serif;
  --bg: #fdf3e4;
  --card: #fffaf1;
  --card2: #fff;
  --pink: #f06f8f;
  --pink2: #ff9fb6;
  --pink-soft: #ffd9e2;
  --brown: #6b4a3a;
  --brown2: #a3785f;
  --text: #4a352c;
  --muted: #94766a;
  --green: #4ea76b;
  --green-soft: #d9f2df;
  --yellow: #f8c75c;
  --orange: #f5873a;
  --red: #ef5b6e;
  --blue: #3d9bff;
  --purple: #8b5cf6;
  --line: rgba(107, 74, 58, .14);
  --sh: 0 6px 16px rgba(107, 74, 58, .14);
  --sh-sm: 0 2px 6px rgba(107, 74, 58, .18);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

[data-theme="matcha"] {
  --bg: #eef3e2;
  --card: #f8fbef;
  --pink: #4fa36d;
  --pink2: #8fcf9d;
  --pink-soft: #d7efd9;
}

[data-theme="dau"] {
  --bg: #fff0f2;
  --card: #fff8f9;
  --pink: #e8486b;
  --pink2: #ff93a8;
  --pink-soft: #ffd4dc;
}

[data-theme="dem"] {
  --bg: #2b2540;
  --card: #3a3356;
  --card2: #453d66;
  --text: #f1ebff;
  --muted: #b8aedc;
  --brown: #e8dfff;
  --brown2: #b8aedc;
  --pink: #a98bff;
  --pink2: #c4b0ff;
  --pink-soft: #51477a;
  --line: rgba(255, 255, 255, .14);
}

body {
  font-family: var(--font);
  color: var(--text);
  background: #d9c7ac;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overscroll-behavior: none;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  padding: 0;
}

button:disabled {
  opacity: .55;
  cursor: not-allowed;
}

:focus-visible {
  outline: 3px solid var(--pink2);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

h1,
h2,
h3,
h4,
h5,
p {
  margin: 0;
}

input,
textarea {
  font: inherit;
  color: inherit;
}

.app {
  position: relative;
  width: 100%;
  max-width: 520px;
  height: 100vh;
  height: var(--app-height, 100vh);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  box-shadow: 0 0 50px rgba(70, 40, 20, .35);
  overflow: hidden;
}

.view {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

.muted {
  color: var(--muted);
  font-size: 12.5px;
}

.pos {
  color: #2f9a52;
}

.neg {
  color: var(--red);
}

.money {
  color: #b7791f;
  font-weight: 800;
}

.grow {
  flex: 1;
  min-width: 0;
}

.center {
  text-align: center;
}

/* ===== Header ===== */
.hud {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 6px;
  padding: calc(6px + var(--safe-t)) 8px 5px;
  background: linear-gradient(#fff9ee, var(--bg));
  z-index: 6;
  position: relative;
}

.hud-l {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hbtn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--card2);
  box-shadow: var(--sh-sm);
  display: grid;
  place-items: center;
  font-size: 13px;
  transition: transform .12s;
}

.hbtn:active {
  transform: scale(.88);
}

.hbtn.pause {
  background: var(--pink-soft);
  color: var(--pink);
  font-weight: 900;
}

.hud-day {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  font-size: 13px;
  line-height: 1.15;
  min-width: 0;
  padding-top: 2px;
}

.hud-day b {
  font-size: 14px;
}

.hud-sub {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.wx {
  margin-top: 3px;
  padding: 1px 8px;
  border-radius: 999px;
  background: linear-gradient(#fff6c9, #ffe58c);
  font-size: 10.5px;
  font-weight: 800;
  box-shadow: var(--sh-sm);
  white-space: nowrap;
}

.hud-c {
  position: absolute;
  left: 50%;
  top: calc(8px + var(--safe-t));
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
  line-height: 1.05;
  max-width: 36%;
}

.hud-c small {
  display: block;
  color: var(--pink);
  font-weight: 800;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-c b {
  font-size: 17px;
  font-weight: 800;
}

.hud-r {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  grid-column: 3;
}

.hud-r-btns {
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: flex-end;
}

.chip-btn {
  padding: 1px 9px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  color: #fff;
  box-shadow: var(--sh-sm);
  white-space: nowrap;
}

.chip-btn.orange {
  background: linear-gradient(#ff9a52, #f26f1f);
}

.chip-btn.gold {
  background: linear-gradient(#ffc852, #f2a31f);
}

.hud-rate {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1;
}

.stars {
  letter-spacing: 0;
  font-size: 11px;
}

.stars i {
  font-style: normal;
  color: #d9ccc0;
}

.stars i.on {
  color: #f0a92f;
}

.hud-rate small {
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 700;
}

.awning {
  height: 18px;
  flex: none;
  position: relative;
  z-index: 5;
  background: repeating-linear-gradient(90deg, var(--pink) 0 30px, #fff 30px 60px);
  box-shadow: 0 3px 6px rgba(107, 74, 58, .15);
  border-radius: 0 0 14px 14px / 0 0 12px 12px;
}

/* ===== Buttons / chips / bars ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 14px;
  background: var(--card2);
  color: var(--brown);
  font-weight: 800;
  font-size: 14.5px;
  line-height: 1.15;
  box-shadow: var(--sh-sm);
  transition: transform .12s, filter .12s;
  user-select: none;
  text-align: center;
}

.btn:active {
  transform: scale(.95);
}

.btn.pri {
  background: linear-gradient(var(--pink2), var(--pink));
  color: #fff;
  box-shadow: 0 3px 0 rgba(160, 50, 80, .45), var(--sh-sm);
}

.btn.gold {
  background: linear-gradient(#ffd97a, #f8b93c);
  color: #6b4310;
}

.btn.blue {
  background: linear-gradient(#6bb8ff, #3d86f0);
  color: #fff;
}

.btn.orange {
  background: linear-gradient(#ffa35c, #f2711f);
  color: #fff;
}

.btn.green {
  background: linear-gradient(#7ad39a, #3da35f);
  color: #fff;
}

.btn.purple {
  background: linear-gradient(#b08cff, #7b4bf0);
  color: #fff;
}

.btn.grad {
  background: linear-gradient(90deg, #ec4899, #8b5cf6);
  color: #fff;
}

.btn.ghost {
  background: transparent;
  border: 2px solid var(--line);
  box-shadow: none;
}

.btn.soft {
  background: var(--card2);
}

.btn.danger {
  background: var(--red);
  color: #fff;
}

.btn.sm {
  min-height: 36px;
  padding: 5px 12px;
  font-size: 12.5px;
  border-radius: 12px;
}

.btn.big {
  min-height: 54px;
  padding: 10px 40px;
  font-size: 21px;
  border-radius: 18px;
}

.btn.block {
  width: 100%;
}

.btn.full {
  width: 100%;
  margin-top: 4px;
}

.chip {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 800;
  background: var(--card2);
  box-shadow: var(--sh-sm);
}

.chip.y {
  background: #fff1c2;
  color: #7a5312;
  border: 1.5px solid #f0c455;
}

.chip.green {
  background: var(--green-soft);
  color: #25693c;
  border: 1.5px solid #8fd1a1;
}

.bar {
  height: 10px;
  background: rgba(0, 0, 0, .09);
  border-radius: 99px;
  overflow: hidden;
}

.bar>i {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #7ad39a, #3da35f);
  transition: width .2s linear;
}

.bar.warn>i {
  background: linear-gradient(90deg, #ffd97a, #f8b93c);
}

.bar.danger>i {
  background: linear-gradient(90deg, #ff8a95, var(--red));
}

.tabs {
  display: flex;
  gap: 6px;
  padding: 2px 0 8px;
}

.tabs.scroll {
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  flex: 1 0 auto;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--card2);
  font-weight: 800;
  font-size: 13px;
  box-shadow: var(--sh-sm);
  white-space: nowrap;
  border: 2px solid transparent;
}

.tab.on {
  background: var(--pink);
  color: #fff;
}

/* ===== CTA dưới đáy ===== */
.cta {
  padding: 8px 12px calc(10px + var(--safe-b));
  background: linear-gradient(transparent, var(--bg) 35%);
  flex: none;
  z-index: 7;
}

.cta:empty {
  padding: 0;
}

.cta-btn {
  width: 100%;
  min-height: 56px;
  border-radius: 18px;
  background: linear-gradient(var(--pink2), var(--pink));
  color: #fff;
  font-weight: 800;
  font-size: 20px;
  box-shadow: 0 5px 0 rgba(160, 50, 80, .5), var(--sh);
  transition: transform .12s;
}

.cta-btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 rgba(160, 50, 80, .5);
}

.cta-btn.cta-red {
  background: linear-gradient(#f57a66, #e04a3c);
  box-shadow: 0 5px 0 rgba(150, 40, 30, .5), var(--sh);
  font-size: 17px;
  padding: 8px;
}

.cta-warn {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: #b8631a;
  margin-bottom: 4px;
}

/* ===== FX / toast ===== */
.fx {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 90;
  overflow: hidden;
}

.fx-float {
  position: absolute;
  transform: translateX(-50%);
  font-weight: 800;
  font-size: 16px;
  color: #b7791f;
  text-shadow: 0 1px 0 #fff, 0 0 7px #fff;
  animation: flyUp 1s ease-out forwards;
  white-space: nowrap;
}

.fx-float.g {
  color: #2d8c4e;
}

.fx-float.r {
  color: var(--red);
}

.fx-coin {
  position: absolute;
  font-size: 20px;
  animation: coinFly .8s ease-in forwards;
}

.fx-spark {
  position: absolute;
  font-size: 15px;
  animation: sparkFx .75s ease-out forwards;
}

.fx-ball {
  position: fixed;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  z-index: 85;
  pointer-events: none;
  box-shadow: inset -2px -2px 3px rgba(0, 0, 0, .25);
}

.toasts {
  position: fixed;
  top: calc(76px + var(--safe-t));
  left: 50%;
  transform: translateX(-50%);
  z-index: 95;
  width: min(92vw, 420px);
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

.toast {
  background: var(--brown);
  color: #fff;
  border-radius: 13px;
  padding: 9px 14px;
  font-weight: 700;
  font-size: 13.5px;
  box-shadow: var(--sh);
  animation: toastIn .25s ease both;
  text-align: center;
}

.toast.ok {
  background: var(--green);
}

.toast.err {
  background: var(--red);
}

.toast.gold {
  background: var(--yellow);
  color: #5c3d08;
}

.toast.out {
  animation: toastOut .26s ease both;
}

@keyframes toastIn {
  from {
    transform: translateY(-14px);
    opacity: 0
  }

  to {
    transform: none;
    opacity: 1
  }
}

@keyframes toastOut {
  to {
    transform: translateY(-14px);
    opacity: 0
  }
}

@keyframes flyUp {
  0% {
    transform: translate(-50%, 0) scale(.8);
    opacity: 0
  }

  15% {
    opacity: 1
  }

  100% {
    transform: translate(-50%, -72px) scale(1);
    opacity: 0
  }
}

@keyframes coinFly {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 1
  }

  100% {
    transform: translate(var(--dx), var(--dy)) scale(.5);
    opacity: 0
  }
}

@keyframes sparkFx {
  0% {
    transform: translate(-50%, -50%) scale(0) rotate(0);
    opacity: 1
  }

  100% {
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.2) rotate(180deg);
    opacity: 0
  }
}

@keyframes popIn {
  0% {
    transform: scale(.8);
    opacity: 0
  }

  70% {
    transform: scale(1.05);
    opacity: 1
  }

  100% {
    transform: scale(1)
  }
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0)
  }

  25% {
    transform: translateX(-5px)
  }

  75% {
    transform: translateX(5px)
  }
}

@keyframes floaty {

  0%,
  100% {
    transform: translateY(0)
  }

  50% {
    transform: translateY(-6px)
  }
}

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ===== Intro ===== */
.intro {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: linear-gradient(var(--pink-soft) 0%, #ffe2d2 38%, #fcd7ca 52%, #f5cdb9 100%);
  overflow: hidden;
  text-align: center;
}

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

.intro-sky .star {
  position: absolute;
  left: 10%;
  top: 5%;
  font-size: 34px;
  animation: floaty 3s ease-in-out infinite;
}

.intro-sky .cloud {
  position: absolute;
  font-size: 44px;
  opacity: .85;
  animation: floaty 5s ease-in-out infinite;
}

.intro-sky .c1 {
  left: -4%;
  top: 16%;
}

.intro-sky .c2 {
  right: 4%;
  top: 3%;
  animation-delay: -2s;
}

.intro-sky .bubble-tea {
  position: absolute;
  right: 5%;
  top: 6%;
  font-size: 70px;
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, .18));
  animation: floaty 3.5s ease-in-out infinite;
}

.intro-sky .pearl {
  position: absolute;
  left: 4%;
  top: 12%;
  font-size: 40px;
}

.intro {
  padding-top: var(--safe-t);
}

.intro-awning {
  width: 100%;
  height: clamp(90px, 15vh, 150px);
  margin-top: clamp(24px, 7vh, 70px);
  flex: none;
  background: repeating-linear-gradient(90deg, #f6a0b2 0 56px, #fff4f0 56px 112px);
  border-radius: 0 0 40px 40px / 0 0 52px 52px;
  box-shadow: 0 10px 18px rgba(150, 80, 70, .25);
  position: relative;
  z-index: 2;
}

.lanterns {
  display: flex;
  justify-content: space-around;
  width: 100%;
  font-size: 34px;
  z-index: 3;
  pointer-events: none;
  margin-top: -4px;
  flex: none;
  transform-origin: top center;
}

.lanterns span {
  display: inline-block;
  transform-origin: top center;
  animation: swing 3.4s ease-in-out infinite;
  filter: drop-shadow(0 4px 6px rgba(255, 120, 40, .45));
}

.lanterns span:nth-child(2) {
  animation-delay: -1.1s;
  font-size: 40px;
}

.lanterns span:nth-child(3) {
  animation-delay: -2.2s;
}

@keyframes swing {

  0%,
  100% {
    transform: rotate(-6deg)
  }

  50% {
    transform: rotate(6deg)
  }
}

@keyframes bob {

  0%,
  100% {
    transform: translateY(0) rotate(-3deg)
  }

  50% {
    transform: translateY(-9px) rotate(3deg)
  }
}

@keyframes zzz {
  0% {
    opacity: 0;
    transform: translate(0, 6px) scale(.7)
  }

  40% {
    opacity: 1
  }

  100% {
    opacity: 0;
    transform: translate(10px, -16px) scale(1.15)
  }
}

@keyframes sparkle {

  0%,
  100% {
    opacity: .2;
    transform: scale(.6)
  }

  50% {
    opacity: 1;
    transform: scale(1.15)
  }
}

.intro-title {
  position: relative;
  margin-top: auto;
  font-size: clamp(36px, 7.2vh, 52px);
  line-height: .95;
  font-weight: 800;
  color: #4a2f24;
  text-shadow: 0 3px 0 #fff, 0 0 18px rgba(255, 255, 255, .9);
  z-index: 4;
  letter-spacing: 1px;
  flex: none;
  animation: popIn .7s ease both;
}

.intro-counter {
  position: relative;
  margin: auto 6% 0;
  width: 88%;
  height: clamp(96px, 16vh, 140px);
  flex: none;
  border-radius: 18px;
  background: linear-gradient(#f6dcbd, #e0b78d);
  box-shadow: var(--sh), inset 0 -8px 0 rgba(150, 100, 60, .18);
  z-index: 3;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 14px 14px;
}

.intro-counter .cups {
  font-size: 34px;
  display: flex;
  gap: 6px;
}

.intro-counter .cups span {
  display: inline-block;
  animation: bob 3s ease-in-out infinite;
}

.intro-counter .cups span:nth-child(2) {
  animation-delay: -.7s;
}

.intro-counter .cups span:nth-child(3) {
  animation-delay: -1.4s;
}

.intro-counter .cups span:nth-child(4) {
  animation-delay: -2.1s;
}

.intro-counter .cat {
  font-size: 52px;
  position: relative;
  line-height: 1;
  animation: floaty 3.2s ease-in-out infinite;
}

.intro-counter .cat small {
  position: absolute;
  top: -8px;
  right: -10px;
  font-size: 13px;
  color: #8b6f5a;
  font-weight: 800;
  animation: zzz 2.4s ease-out infinite;
}

.intro-counter .plants {
  font-size: 40px;
  display: flex;
  gap: 4px;
  line-height: 1;
}

.intro-counter .plants span {
  display: inline-block;
  transform-origin: bottom center;
  animation: swing 4s ease-in-out infinite;
}

.intro-tag {
  position: relative;
  margin-top: 14px;
  font-weight: 700;
  color: #6a4a3c;
  z-index: 4;
  padding: 0 20px;
  text-shadow: 0 1px 0 #fff;
  flex: none;
  font-size: 15px;
  line-height: 1.3;
}

.intro-info {
  position: relative;
  margin-top: 6px;
  font-weight: 800;
  color: var(--pink);
  z-index: 4;
  font-size: 15px;
  flex: none;
}

.intro .btn.big {
  position: relative;
  margin-top: 12px;
  z-index: 4;
  min-width: 62%;
  flex: none;
  animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse {

  0%,
  100% {
    transform: scale(1)
  }

  50% {
    transform: scale(1.045)
  }
}

.intro .link {
  position: relative;
  margin: 10px 0 calc(34px + var(--safe-b));
  font-weight: 800;
  text-decoration: underline;
  color: var(--text);
  z-index: 4;
  flex: none;
  padding: 6px 16px;
}

.intro .ver {
  position: absolute;
  left: 14px;
  bottom: calc(10px + var(--safe-b));
  color: #8b6f5a;
  font-weight: 700;
  z-index: 4;
}

.intro-sky .spark {
  position: absolute;
  font-size: 18px;
  animation: sparkle 2.4s ease-in-out infinite;
}

.intro::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 28%;
  background: repeating-linear-gradient(90deg, #e8c6c0 0 46px, #efd3cd 46px 92px);
  z-index: 1;
}
