:root {
  --bg: #101722;
  --panel: rgba(17, 24, 39, 0.88);
  --line: rgba(255, 255, 255, 0.12);
  --text: #f8fafc;
  --muted: #94a3b8;
  --mint: #5eead4;
  --amber: #fbbf24;
  --rose: #fb7185;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 10%, rgba(94, 234, 212, 0.2), transparent 30%),
    radial-gradient(circle at 82% 18%, rgba(251, 191, 36, 0.18), transparent 26%),
    linear-gradient(145deg, #101722, #0f172a 55%, #111827);
  color: var(--text);
  font-family: 'Outfit', 'M PLUS Rounded 1c', sans-serif;
}

#app {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 18px;
}

.back-link {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 20;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.78);
  color: var(--mint);
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.6px;
}

.game-shell {
  width: min(560px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 42px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
}

.eyebrow {
  color: var(--mint);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 1.4px;
}

h1 {
  font-size: 2.25rem;
  font-weight: 900;
  letter-spacing: 0;
}

h1 span {
  color: var(--amber);
}

.wallet {
  min-width: 128px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  text-align: right;
}

.wallet span,
.score-row span {
  display: block;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 1px;
}

.wallet b,
.score-row b {
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 900;
}

.score-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.score-row div {
  min-width: 0;
  padding: 12px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.board-wrap {
  padding: 12px;
  border-radius: 22px;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(94, 234, 212, 0.26);
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.28);
}

.board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  aspect-ratio: 1;
}

.tile {
  min-width: 0;
  aspect-ratio: 1;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.tile span {
  font-size: clamp(1.35rem, 6vw, 2rem);
  line-height: 1;
}

.tile b {
  margin-top: 4px;
  color: #fff;
  font-size: clamp(0.86rem, 3.2vw, 1.1rem);
  font-weight: 900;
}

.tile small {
  max-width: 100%;
  padding: 0 3px;
  color: rgba(255, 255, 255, 0.76);
  font-size: clamp(0.48rem, 1.8vw, 0.58rem);
  font-weight: 900;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile-2 { background: linear-gradient(135deg, #334155, #475569); }
.tile-4 { background: linear-gradient(135deg, #0f766e, #14b8a6); }
.tile-8 { background: linear-gradient(135deg, #2563eb, #38bdf8); }
.tile-16 { background: linear-gradient(135deg, #7c3aed, #a78bfa); }
.tile-32 { background: linear-gradient(135deg, #be123c, #fb7185); }
.tile-64 { background: linear-gradient(135deg, #b45309, #fbbf24); }
.tile-128,
.tile-256,
.tile-512,
.tile-1024 {
  background: linear-gradient(135deg, #111827, #fbbf24);
  border-color: rgba(251, 191, 36, 0.65);
  box-shadow: inset 0 0 26px rgba(251, 191, 36, 0.18);
}

.controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.controls button,
.pad button {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

#btn-claim {
  background: linear-gradient(135deg, var(--mint), #22c55e);
  color: #052e2b;
}

#btn-daily {
  background: linear-gradient(135deg, var(--amber), var(--rose));
  color: #1f1300;
}

.controls button:disabled {
  opacity: 0.5;
  filter: grayscale(1);
  cursor: not-allowed;
}

.pad {
  display: none;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.message {
  min-height: 44px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.74);
  border: 1px solid var(--line);
  color: #cbd5e1;
  text-align: center;
  font-size: 0.88rem;
  font-weight: 800;
}

@media (max-width: 540px) {
  #app {
    padding: 12px;
  }

  .game-shell {
    padding-top: 44px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .wallet {
    width: 100%;
    text-align: left;
  }

  h1 {
    font-size: 2rem;
  }

  .score-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

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

  .pad {
    display: grid;
  }
}
