/* Clicker Brainrot — sáng, vui, kiểu tiệm kem Ý */
:root {
  --ink: #2b1d3a;
  --muted: #7a6b8c;
  --card: #fff;
  --line: #f0e4f3;
  --pink: #ff4f8b;
  --gold: #ffb020;
  --green: #14b86a;
  --shadow: 0 10px 30px rgba(92, 40, 120, 0.12);
}
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
[hidden] {
  display: none !important;
}
html,
body {
  margin: 0;
  height: 100%;
  font-family: "Be Vietnam Pro", system-ui, sans-serif;
  color: var(--ink);
  background: #fff5ec;
}
button {
  font: inherit;
  color: inherit;
}
.app {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse at 30% 0%, #ffe3f0, transparent 60%),
    radial-gradient(ellipse at 90% 100%, #dff0ff, transparent 60%),
    #fff7ee;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ---------- tiêu đề ---------- */
.top {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
}
.back {
  text-decoration: none;
  color: var(--muted);
  font-weight: 700;
  font-size: 14px;
  padding: 7px 11px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(92, 40, 120, 0.08);
  white-space: nowrap;
}
.top h1 {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-family: "Baloo 2", sans-serif;
  font-size: 26px;
  line-height: 1;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.top h1 span {
  background: linear-gradient(90deg, #14b86a, #ffb020, #ff4f8b);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.icon-btn {
  width: 38px;
  height: 38px;
  flex: none;
  border: 0;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(92, 40, 120, 0.1);
  font-weight: 800;
  font-size: 16px;
  cursor: pointer;
}

/* ---------- bố cục ---------- */
.main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 440px);
  gap: 14px;
  padding: 0 14px 14px;
}
.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 0;
  padding: 12px;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.55);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.wallet {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: "Baloo 2", sans-serif;
  font-size: clamp(34px, 6vw, 54px);
  font-weight: 800;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.wallet .coin {
  font-size: 0.8em;
  filter: drop-shadow(0 3px 4px rgba(200, 130, 0, 0.35));
}
.rates {
  display: flex;
  gap: 8px;
  font-weight: 700;
  font-size: 14px;
  color: var(--muted);
}
.rates i {
  font-style: normal;
  opacity: 0.5;
}
#cps {
  color: var(--green);
}

/* ---------- sân khấu ---------- */
.arena {
  --rc: #8b95a7;
  position: relative;
  flex: 1;
  width: 100%;
  min-height: 220px;
  display: grid;
  place-items: center;
}
.rays {
  position: absolute;
  width: min(92%, 520px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, color-mix(in srgb, var(--rc) 28%, transparent) 0 10deg, transparent 10deg 22deg);
  mask: radial-gradient(circle, #000 25%, transparent 70%);
  -webkit-mask: radial-gradient(circle, #000 25%, transparent 70%);
  animation: spin 24s linear infinite;
  pointer-events: none;
}
.arena::before {
  content: "";
  position: absolute;
  width: min(60%, 340px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--rc) 35%, #fff), transparent 70%);
  pointer-events: none;
}
.arena.mythic .rays {
  background: repeating-conic-gradient(from 0deg, #ff4f8b55 0 10deg, transparent 10deg 20deg, #ffb02055 20deg 30deg, transparent 30deg 40deg, #14b86a55 40deg 50deg, transparent 50deg 60deg);
}
.arena.frenzy .rays {
  animation-duration: 3s;
  background: repeating-conic-gradient(from 0deg, #ff6a3d88 0 10deg, transparent 10deg 20deg, #ffd23f88 20deg 30deg, transparent 30deg 40deg);
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.hero {
  position: absolute;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  z-index: 1;
  height: min(100%, 380px);
  max-width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  animation: bob 2.6s ease-in-out infinite;
}
.hero img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 16px 18px rgba(60, 20, 80, 0.28));
  pointer-events: none;
  -webkit-user-drag: none;
}
.hero.boop img {
  animation: boop 0.18s ease-out;
}
.hero:active img {
  transform: scale(0.94);
}
@keyframes bob {
  50% {
    transform: translateY(-8px) rotate(-1.5deg);
  }
}
@keyframes boop {
  0% {
    transform: scale(0.9, 0.86);
  }
  60% {
    transform: scale(1.06, 1.08);
  }
  100% {
    transform: scale(1);
  }
}
.floaters {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}
.fl {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: "Baloo 2", sans-serif;
  font-weight: 800;
  font-size: 26px;
  color: #fff;
  -webkit-text-stroke: 1.5px #2b1d3a;
  paint-order: stroke fill;
  text-shadow: 0 3px 0 #2b1d3a;
  white-space: nowrap;
  animation: rise 0.9s ease-out forwards;
}
.fl.hot {
  color: #ffd23f;
  font-size: 32px;
}
@keyframes rise {
  0% {
    opacity: 0;
    transform: translate(-50%, -30%) scale(0.6);
  }
  15% {
    opacity: 1;
    transform: translate(-50%, -60%) scale(1.1);
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx)), -260%) scale(0.95);
  }
}
.spark {
  position: absolute;
  font-size: 18px;
  transform: translate(-50%, -50%);
  animation: spark 0.7s ease-out forwards;
}
@keyframes spark {
  to {
    opacity: 0;
    transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) rotate(200deg) scale(0.6);
  }
}
.hero-name {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  text-align: center;
  margin: 2px 0 8px;
}
.hero-name b {
  font-family: "Baloo 2", sans-serif;
  font-size: 22px;
  line-height: 1.1;
}
.chip {
  --rc: #8b95a7;
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  background: var(--rc);
  white-space: nowrap;
}
.combo {
  position: relative;
  width: min(100%, 420px);
  height: 26px;
  border-radius: 999px;
  background: #fff;
  box-shadow: inset 0 2px 6px rgba(92, 40, 120, 0.12);
  overflow: hidden;
}
.combo i {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: linear-gradient(90deg, #ffd23f, #ff9a3d, #ff4f8b);
  border-radius: 999px;
}
.combo span {
  position: relative;
  display: block;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  line-height: 26px;
  color: var(--ink);
}
.combo.hot {
  animation: pulse 0.5s ease-in-out infinite alternate;
}
@keyframes pulse {
  to {
    box-shadow: 0 0 0 4px rgba(255, 106, 61, 0.35);
  }
}

/* ---------- cửa hàng ---------- */
.shop {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.75);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 8px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.tabs button {
  border: 0;
  border-radius: 14px;
  padding: 9px 4px;
  background: none;
  font-weight: 800;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.tabs button b {
  font-size: 11px;
  opacity: 0.8;
}
.tabs button.on {
  background: var(--ink);
  color: #fff;
}
.panel {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px;
  -webkit-overflow-scrolling: touch;
}
.buymode {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}
.buymode span {
  margin-right: 4px;
}
.buymode button {
  border: 0;
  border-radius: 10px;
  padding: 5px 11px;
  background: #fff;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(92, 40, 120, 0.1);
}
.buymode button.on {
  background: var(--pink);
  color: #fff;
}
.row {
  --rc: #8b95a7;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px;
  margin-bottom: 8px;
  border-radius: 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 5px solid var(--rc);
}
.thumb {
  width: 58px;
  height: 58px;
  border-radius: 14px;
  background: radial-gradient(circle, color-mix(in srgb, var(--rc) 22%, #fff), #fff 75%);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.thumb.ico {
  font-size: 30px;
  background: #fff4dc;
}
.row.locked .thumb img {
  filter: brightness(0) opacity(0.55);
}
.row.locked .nm {
  color: var(--muted);
}
.info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.l1 {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}
.nm {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lv {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}
.l2 {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.meta,
.desc {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.desc {
  white-space: normal;
}
.meta {
  color: var(--green);
}
.ms {
  position: relative;
  height: 12px;
  border-radius: 999px;
  background: #f3edf6;
  overflow: hidden;
}
.ms i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: linear-gradient(90deg, #ffd23f, #ffb020);
  border-radius: 999px;
  transition: width 0.25s;
}
.ms::after {
  content: attr(data-l);
  position: relative;
  display: block;
  font-size: 9px;
  font-weight: 800;
  line-height: 12px;
  padding-left: 6px;
  color: #6b4a00;
}
.buy {
  min-width: 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 7px 10px;
  border: 0;
  border-radius: 14px;
  background: #ece6f0;
  color: #a99bb6;
  cursor: not-allowed;
  font-size: 12px;
  font-weight: 700;
}
.buy b {
  font-size: 13px;
  white-space: nowrap;
}
.buy.can {
  background: linear-gradient(#2fd689, #14b86a);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 0 #0e8a4f;
}
.buy.can:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #0e8a4f;
}
.more {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  margin: 12px 4px;
}

/* ---------- sưu tập ---------- */
.album-note {
  margin: 2px 2px 10px;
  font-size: 13px;
  color: var(--muted);
}
.album {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 8px;
}
.card {
  --rc: #8b95a7;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 6px 10px;
  border-radius: 18px;
  border: 2px solid color-mix(in srgb, var(--rc) 45%, #fff);
  background: radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--rc) 20%, #fff), #fff 70%);
  cursor: pointer;
}
.card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
}
.card b {
  font-size: 12px;
  line-height: 1.2;
  text-align: center;
  min-height: 2.4em;
}
.card span {
  font-size: 10px;
  font-weight: 800;
  color: var(--rc);
  text-transform: uppercase;
}
.card.locked img {
  filter: brightness(0) opacity(0.3);
}
.card.locked {
  background: #f6f2f8;
  border-color: #ebe3ef;
}
.card.on {
  box-shadow: 0 0 0 3px var(--rc);
}
.card.mythic {
  border-color: transparent;
  background:
    radial-gradient(circle at 50% 35%, #fff3, #fff 70%) padding-box,
    linear-gradient(135deg, #14b86a, #ffb020, #ff4f8b, #7c5cff) border-box;
}
.mic {
  position: absolute;
  top: 6px;
  right: 8px;
  font-style: normal;
}

/* ---------- lớp phủ ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(43, 29, 58, 0.45);
  backdrop-filter: blur(4px);
}
.sheet {
  position: relative;
  width: min(400px, 100%);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  padding: 22px;
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 30px 60px rgba(43, 29, 58, 0.35);
  text-align: center;
  animation: pop 0.3s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes pop {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
}
.sheet h2 {
  margin: 4px 0;
  font-family: "Baloo 2", sans-serif;
  font-size: 28px;
  line-height: 1.1;
}
.sub {
  margin: 8px 0;
  color: var(--muted);
  font-size: 14px;
}
.small {
  font-size: 12px;
  color: var(--muted);
}
.btns {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 14px;
}
.btn {
  border: 0;
  border-radius: 16px;
  padding: 11px 18px;
  font-weight: 800;
  font-size: 15px;
  background: #f1ebf4;
  cursor: pointer;
}
.btn.primary {
  background: linear-gradient(#ff6fa2, #ff4f8b);
  color: #fff;
  box-shadow: 0 4px 0 #d23468;
}
.btn.big {
  width: 100%;
  padding: 14px;
  font-size: 17px;
}
.btn.danger {
  margin-top: 10px;
  background: #ffe8ec;
  color: #c62845;
  font-size: 13px;
}
.reveal {
  --rc: #8b95a7;
  overflow: hidden;
}
.reveal .burst {
  position: absolute;
  left: 50%;
  top: 38%;
  width: 640px;
  height: 640px;
  margin: -320px 0 0 -320px;
  background: repeating-conic-gradient(color-mix(in srgb, var(--rc) 30%, transparent) 0 8deg, transparent 8deg 20deg);
  animation: spin 12s linear infinite;
  pointer-events: none;
}
.reveal > *:not(.burst) {
  position: relative;
}
.kicker {
  margin: 0;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--pink);
}
.reveal img {
  width: 220px;
  height: 220px;
  object-fit: contain;
  filter: drop-shadow(0 14px 16px rgba(60, 20, 80, 0.3));
  animation: arrive 0.7s cubic-bezier(0.2, 1.5, 0.4, 1);
}
@keyframes arrive {
  from {
    transform: scale(0.2) rotate(-25deg);
    opacity: 0;
  }
}
.big-ico {
  font-size: 54px;
}
.away-coins {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 6px;
  padding: 8px 18px;
  border-radius: 999px;
  background: #fff4dc;
  font-family: "Baloo 2", sans-serif;
  font-size: 30px;
  font-weight: 800;
}
.help {
  text-align: left;
}
.help h2 {
  text-align: center;
}
.help ul {
  padding-left: 20px;
}
.help li {
  margin: 6px 0;
  font-size: 14px;
  line-height: 1.5;
}
.close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 12px;
  background: #f1ebf4;
  font-size: 22px;
  cursor: pointer;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 40;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 9px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  text-align: center;
  pointer-events: none;
}
.toast.show {
  animation: toast 2.4s ease both;
}
@keyframes toast {
  0% {
    opacity: 0;
    transform: translate(-50%, -10px);
  }
  10%,
  80% {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  100% {
    opacity: 0;
  }
}

/* ---------- điện thoại dọc: sân khấu trên, cửa hàng dưới ---------- */
@media (max-width: 820px) {
  .main {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 46fr) minmax(0, 54fr);
    gap: 10px;
    padding: 0 10px 10px;
  }
  .top {
    padding: 8px 10px;
  }
  .top h1 {
    font-size: 22px;
  }
  .stage {
    padding: 8px;
    border-radius: 24px;
  }
  .arena {
    min-height: 0;
  }
  .hero-name {
    margin: 0 0 6px;
  }
  .hero-name b {
    font-size: 18px;
  }
  .wallet {
    font-size: 36px;
  }
  .rates {
    font-size: 13px;
  }
  .shop {
    border-radius: 24px;
  }
  .album {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }
}
@media (max-width: 380px) {
  .row {
    grid-template-columns: 48px minmax(0, 1fr) auto;
    gap: 8px;
  }
  .thumb {
    width: 48px;
    height: 48px;
  }
  .buy {
    min-width: 84px;
  }
}
/* điện thoại xoay ngang: hai cột, gọn chiều cao */
@media (max-width: 920px) and (max-height: 500px) and (orientation: landscape) {
  .main {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
    grid-template-rows: minmax(0, 1fr);
  }
  .top {
    padding: 4px 10px;
  }
  .wallet {
    font-size: 28px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .rays,
  .hero,
  .reveal .burst {
    animation: none;
  }
}
