:root {
  --font: "Baloo 2", "Segoe UI", Arial, sans-serif;
  --ink: #23141a;
  --cyan1: #8ff3ff;
  --cyan2: #3fc6f2;
  --cyanS: #1f7fa6;
  --yel1: #ffe36b;
  --yel2: #f6b40c;
  --yelS: #b67a00;
  --panel: #e3cdc5;
  --head: #4a72da;
  --ui: 1;
}
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}
body {
  background: #afe597;
  color: var(--ink);
  font-family: var(--font);
  font-weight: 800;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
button {
  font-family: var(--font);
  font-weight: 800;
  color: inherit;
  cursor: pointer;
}
#cv {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
#ui {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}
#ui > *,
#ui .hud > * {
  pointer-events: auto;
}
#ui .hud,
#ui .notifs,
#ui .toasts,
#ui .tut,
#ui .finger {
  pointer-events: none;
}

/* ---------- Bộ đếm góc trái (dùng ảnh gốc, có bản CSS dự phòng) ---------- */
.hud {
  position: absolute;
  left: 10px;
  top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pill {
  position: relative;
  width: calc(170px * var(--ui));
  height: calc(61px * var(--ui));
  background: no-repeat 0 0 / 100% 100%;
}
.p-cash {
  background-image: url(assets/pill-cash.png);
}
.p-idle {
  background-image: url(assets/pill-idle.png);
}
.p-seed {
  background-image: url(assets/pill-seed.png);
}
.pill b {
  position: absolute;
  left: 36%;
  right: 6%;
  top: 0;
  bottom: 9%;
  display: grid;
  place-items: center;
  font-size: calc(19px * var(--ui));
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
}
.pill .ic {
  display: none;
}
.pill .info {
  position: absolute;
  right: calc(-30px * var(--ui));
  top: 50%;
  width: calc(28px * var(--ui));
  height: calc(28px * var(--ui));
  margin-top: calc(-16px * var(--ui));
  padding: 0;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: linear-gradient(var(--yel1), var(--yel2));
  font-size: calc(15px * var(--ui));
  line-height: 1;
  pointer-events: auto;
}

/* ---------- Nút ảnh ---------- */
.ibtn {
  position: relative;
  width: calc(76px * var(--ui));
  height: calc(76px * var(--ui));
  padding: 0;
  border: 0;
  background: no-repeat 50% 50% / contain;
  transition: transform 0.1s;
}
.ibtn:active {
  transform: translateY(4px);
}
.ibtn > span {
  display: none;
}
.b-set {
  position: absolute;
  right: 10px;
  top: 10px;
  background-image: url(assets/btn-set.png);
}
.b-shop {
  background-image: url(assets/btn-shop.png);
}
.b-up {
  background-image: url(assets/btn-up.png);
}
.b-up.on {
  background-image: url(assets/btn-up2.png);
}
.b-ach {
  position: absolute;
  right: 12px;
  bottom: 12px;
  background-image: url(assets/btn-ach.png);
}
.bl {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: flex;
  gap: 10px;
}
.notif {
  position: absolute;
  right: -6px;
  top: -10px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #3ddc6e;
  border: 3px solid var(--ink);
  color: #fff;
  font: 900 14px/20px var(--font);
  font-style: normal;
  animation: bob 0.8s ease-in-out infinite alternate;
}
.bang {
  position: absolute;
  right: 4px;
  top: -8px;
  color: #ff2b2b;
  font: 900 calc(34px * var(--ui)) / 1 var(--font);
  font-style: normal;
  -webkit-text-stroke: 2px #fff;
  paint-order: stroke fill;
  animation: bob 0.6s ease-in-out infinite alternate;
}
@keyframes bob {
  to {
    transform: translateY(-5px);
  }
}

/* ---------- Chế độ nâng cấp ---------- */
.uptitle {
  position: absolute;
  left: 50%;
  top: 12px;
  transform: translateX(-50%);
  padding: calc(10px * var(--ui)) calc(34px * var(--ui));
  border: 4px solid var(--ink);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.25);
  font-size: calc(24px * var(--ui));
  white-space: nowrap;
}
.uptitle .x {
  position: absolute;
  right: calc(-22px * var(--ui));
  top: calc(-14px * var(--ui));
}
.mults {
  position: absolute;
  right: 12px;
  bottom: 16px;
  display: flex;
  gap: 8px;
}
.mults button {
  min-width: calc(54px * var(--ui));
  height: calc(54px * var(--ui));
  padding: 0 4px;
  border: 3px solid var(--ink);
  border-radius: 8px;
  background: linear-gradient(var(--cyan1), var(--cyan2));
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.15), 0 4px 0 var(--cyanS);
  font-size: calc(17px * var(--ui));
}
.mults button.on {
  background: linear-gradient(var(--yel1), var(--yel2));
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.12), 0 4px 0 var(--yelS);
}

/* ---------- Nút chung ---------- */
.x {
  width: calc(46px * var(--ui));
  height: calc(46px * var(--ui));
  padding: 0;
  border: 3px solid var(--ink);
  border-radius: 8px;
  background: linear-gradient(var(--cyan1), var(--cyan2));
  box-shadow: 0 4px 0 var(--cyanS);
  font-size: calc(22px * var(--ui));
  line-height: 1;
}
.btn {
  min-width: 130px;
  height: 52px;
  padding: 0 22px;
  border: 3px solid var(--ink);
  border-radius: 10px;
  background: linear-gradient(var(--cyan1), var(--cyan2));
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.13), 0 5px 0 var(--cyanS);
  font-size: 20px;
  line-height: 1;
}
.btn.yellow {
  background: linear-gradient(var(--yel1), var(--yel2));
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.1), 0 5px 0 var(--yelS);
}
.btn.red {
  background: linear-gradient(#ff8a8a, #e94848);
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.1), 0 5px 0 #9c2424;
  color: #fff;
}
.btn:disabled,
.btn.off {
  background: linear-gradient(#d3dbe6, #9fadc2);
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.1), 0 5px 0 #6b7a91;
  color: #4d5869;
  cursor: default;
}
.btn:not(:disabled):active,
.x:active {
  transform: translateY(3px);
}
.btn.sm {
  min-width: 96px;
  height: 40px;
  padding: 0 12px;
  font-size: 16px;
}

/* ---------- Hướng dẫn ---------- */
.tut {
  position: fixed;
  z-index: 40;
  pointer-events: none;
  left: 50%;
  top: calc(84px * var(--ui));
  transform: translateX(-50%);
  max-width: min(92vw, 640px);
  padding: 8px 22px;
  background: rgba(20, 16, 20, 0.62);
  color: #fff;
  font-size: calc(22px * var(--ui));
  line-height: 1.25;
  text-align: center;
  text-transform: uppercase;
  text-shadow: 0 2px 0 #000;
}
.finger {
  position: fixed;
  z-index: 40;
  pointer-events: none;
  width: calc(60px * var(--ui));
  height: calc(77px * var(--ui));
  margin: 0 0 0 calc(-14px * var(--ui));
  background: url(assets/finger.png) no-repeat 0 0 / contain;
  animation: tap 0.7s ease-in-out infinite alternate;
}
.finger.swipe {
  animation: swipe 1.1s ease-in-out infinite;
}
.finger span {
  display: none;
  font-size: calc(54px * var(--ui));
}
@keyframes tap {
  to {
    transform: translate(4px, 10px);
  }
}
@keyframes swipe {
  0%,
  100% {
    transform: translateX(-60px);
  }
  50% {
    transform: translateX(60px);
  }
}

/* ---------- Thông báo mở khoá (góc phải trên) ---------- */
.notifs {
  position: absolute;
  right: 12px;
  top: 96px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}
.unl {
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(330px, 80vw);
  padding: 9px 14px 9px 9px;
  border: 4px solid var(--ink);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.25);
  animation: drop 3.6s ease forwards;
}
.unl .fr {
  flex: none;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border: 3px solid var(--ink);
  border-radius: 8px;
  background: #bdf2ff;
}
.unl .fr img {
  max-width: 46px;
  max-height: 54px;
}
.unl .fr span {
  font-size: 38px;
}
.unl div {
  flex: 1;
  text-align: center;
  font-size: 16px;
  line-height: 1.2;
}
.unl div b {
  display: block;
  font-size: 30px;
}
@keyframes drop {
  0% {
    opacity: 0;
    transform: translateY(-120px);
  }
  10%,
  88% {
    opacity: 1;
    transform: none;
  }
  100% {
    opacity: 0;
    transform: translateY(-120px);
  }
}

.toasts {
  position: absolute;
  left: 50%;
  bottom: calc(110px * var(--ui));
  transform: translateX(-50%);
  width: 92vw;
  display: flex;
  flex-direction: column-reverse;
  gap: 6px;
  align-items: center;
}
.toast {
  padding: 8px 18px;
  border: 3px solid var(--ink);
  border-radius: 10px;
  background: #fff8c9;
  max-width: 92vw;
  font-size: 17px;
  text-align: center;
  animation: toast 3s ease forwards;
}
@keyframes toast {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  10%,
  85% {
    opacity: 1;
    transform: none;
  }
  100% {
    opacity: 0;
  }
}

/* ---------- Hộp thoại ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 14px;
  background: rgba(0, 0, 0, 0.5);
}
.panel {
  position: relative;
  width: min(440px, 100%);
  max-height: calc(100vh - 28px);
  display: flex;
  flex-direction: column;
  border: 4px solid var(--ink);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.3);
  animation: pop 0.28s cubic-bezier(0.3, 1.5, 0.5, 1);
}
@keyframes pop {
  from {
    transform: scale(0.7);
    opacity: 0;
  }
}
.panel > .x {
  position: absolute;
  right: -14px;
  top: -14px;
  z-index: 2;
}
.ph {
  flex: none;
  padding: 8px 46px 6px;
  border-bottom: 4px solid var(--ink);
  border-radius: 8px 8px 0 0;
  background: radial-gradient(circle at 12% 20%, #6c8ff0 0 7px, transparent 8px),
    radial-gradient(circle at 80% 30%, #6c8ff0 0 5px, transparent 6px), radial-gradient(circle at 60% 85%, #6c8ff0 0 4px, transparent 5px),
    var(--head);
  color: #fff;
  font-size: 30px;
  line-height: 1.15;
  text-align: center;
  text-shadow:
    0 3px 0 var(--ink),
    2px 0 0 var(--ink),
    -2px 0 0 var(--ink),
    0 -2px 0 var(--ink);
}
.pb {
  padding: 16px;
  overflow: auto;
  text-align: center;
}
.pb p {
  margin: 0 0 12px;
  font-size: 18px;
  line-height: 1.35;
}
.pb .sub {
  color: #2f4c86;
}
.pb .row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 6px;
}
.big {
  display: block;
  margin: 4px auto 10px;
  max-width: 150px;
  max-height: 150px;
}
.bigemo {
  display: block;
  font-size: 96px;
  line-height: 1.1;
}
.pb .card {
  margin: 0 auto 14px;
  padding: 12px;
  border: 3px solid var(--ink);
  border-radius: 10px;
  background: #fff59d;
  font-size: 18px;
  line-height: 1.5;
}
.pb .card b {
  color: #2f4c86;
}

/* cửa hàng */
.items {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 300px;
}
.item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px 9px 9px;
  border: 3px solid var(--ink);
  border-radius: 10px;
  background: #fff59d;
  text-align: left;
}
.item .fr {
  flex: none;
  display: grid;
  place-items: center;
  width: 70px;
  height: 70px;
  border: 3px solid var(--ink);
  border-radius: 9px;
  background: #bdf2ff;
}
.item .fr img {
  max-width: 50px;
  max-height: 58px;
}
.item .fr span {
  font-size: 40px;
}
.item .t {
  flex: 1;
  min-width: 0;
}
.item small {
  display: block;
  font-size: 13px;
  color: #a2471b;
  line-height: 1.1;
}
.item h4 {
  margin: 0 0 4px;
  font-size: 21px;
  line-height: 1.1;
}
.item .btn {
  width: 100%;
  min-width: 0;
  height: 38px;
  font-size: 17px;
}
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 12px;
  font-size: 18px;
}
.pager .x {
  position: static;
}
.empty {
  padding: 40px 10px;
  font-size: 18px;
  color: #6a4f4f;
}

/* thành tựu */
.achs {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}
.ach {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 8px;
  border: 3px solid var(--ink);
  border-radius: 10px;
  background: #fff;
}
.ach.ok {
  background: #fff59d;
}
.ach.done {
  opacity: 0.6;
}
.ach .ai {
  flex: none;
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  font-size: 34px;
}
.ach .ai img {
  width: 100%;
  height: 100%;
}
.ach .t {
  flex: 1;
  min-width: 0;
  font-size: 17px;
  line-height: 1.15;
}
.ach .t small {
  display: block;
  font-size: 13px;
  color: #6a4f4f;
  font-weight: 700;
}
.bar {
  height: 10px;
  margin-top: 5px;
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: #fff;
  overflow: hidden;
}
.bar i {
  display: block;
  height: 100%;
  background: #3ddc6e;
}
.ach .r {
  flex: none;
  width: 92px;
  text-align: center;
  font-size: 14px;
}

/* quà hằng ngày */
.days {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.day {
  padding: 8px 4px;
  border: 3px solid var(--ink);
  border-radius: 10px;
  background: #fff;
  font-size: 15px;
}
.day:last-child {
  grid-column: 2;
}
.day .e {
  display: block;
  height: 46px;
  font-size: 34px;
  line-height: 46px;
}
.day .e img {
  height: 44px;
  vertical-align: middle;
}
.day.got {
  background: #c9f5c0;
  opacity: 0.7;
}
.day.now {
  background: #fff59d;
  box-shadow: 0 0 0 3px #f6b40c;
}

/* cài đặt */
.opts {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.opts .btn {
  width: 100%;
}
.opts textarea {
  width: 100%;
  height: 92px;
  resize: none;
  padding: 8px;
  border: 3px solid var(--ink);
  border-radius: 8px;
  font: 600 12px/1.3 Consolas, monospace;
  user-select: text;
  -webkit-user-select: text;
}
.opts .msg {
  min-height: 22px;
  font-size: 15px;
  color: #2f4c86;
}
.opts a {
  color: #2f4c86;
}

/* ---------- Màn hình tiêu đề ---------- */
.title {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4vh;
}
.logo {
  width: min(520px, 82vw);
  aspect-ratio: 594 / 364;
  background: url(assets/title.png) no-repeat 50% 50% / contain;
  animation: float 2.4s ease-in-out infinite alternate;
}
.logo b {
  display: none;
}
@keyframes float {
  to {
    transform: translateY(-10px);
  }
}
.play {
  width: 110px;
  height: 100px;
  border: 4px solid var(--ink);
  border-radius: 14px;
  background: linear-gradient(var(--cyan1), var(--cyan2));
  box-shadow: inset 0 -8px 0 rgba(0, 0, 0, 0.12), 0 7px 0 var(--cyanS);
}
.play i {
  display: block;
  width: 0;
  height: 0;
  margin-left: 38px;
  border-style: solid;
  border-width: 24px 0 24px 38px;
  border-color: transparent transparent transparent var(--ink);
}
.play:active {
  transform: translateY(4px);
}
.title .back {
  position: absolute;
  left: 14px;
  top: 12px;
  color: #2b5a1d;
  font-size: 16px;
  text-decoration: none;
}

/* ---------- Bản dự phòng khi không có bộ hình gốc ---------- */
.noimg .pill {
  background: none;
}
.noimg .pill::before {
  content: "";
  position: absolute;
  left: 22%;
  right: 0;
  top: 18%;
  bottom: 18%;
  border: 3px solid var(--ink);
  border-radius: 0 30px 30px 0;
  background: #a6ecf7;
}
.noimg .pill .ic {
  display: grid;
  place-items: center;
  position: absolute;
  left: 0;
  top: 0;
  width: calc(61px * var(--ui));
  height: calc(61px * var(--ui));
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--yel1);
  font-size: calc(28px * var(--ui));
  font-style: normal;
  z-index: 1;
}
.noimg .ibtn {
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: linear-gradient(var(--cyan1), var(--cyan2));
  box-shadow: 0 5px 0 var(--cyanS);
}
.noimg .b-up.on {
  background: linear-gradient(var(--yel1), var(--yel2));
  box-shadow: 0 5px 0 var(--yelS);
}
.noimg .ibtn > span {
  display: block;
  font-size: calc(36px * var(--ui));
}
.noimg .finger {
  background: none;
}
.noimg .finger span {
  display: block;
}
.noimg .logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: none;
}
.noimg .logo b {
  display: block;
  font-size: min(84px, 14vw);
  line-height: 0.95;
  color: #5ce0ff;
  -webkit-text-stroke: 8px var(--ink);
  paint-order: stroke fill;
}
.noimg .logo b + b {
  color: #ff6a6a;
}

@media (max-aspect-ratio: 1/1) {
  .tut {
    top: calc(212px * var(--ui));
  }
  .notifs {
    top: calc(212px * var(--ui));
  }
}
@media (max-width: 640px), (max-height: 520px) {
  .btn {
    height: 46px;
    font-size: 18px;
  }
  .ph {
    font-size: 25px;
  }
  .item .fr {
    width: 58px;
    height: 58px;
  }
  .items {
    min-height: 0;
  }
}
