:root {
  --bg: #1b120c;
  --bg-2: #2a1b10;
  --card: rgba(255, 255, 255, .06);
  --line: rgba(255, 255, 255, .1);
  --text: #fff6ea;
  --muted: #c9b39b;
  --accent: #f59e0b;
  --accent-2: #fb923c;
  --good: #34d399;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(120% 70% at 50% 0%, #4a2c14 0%, var(--bg-2) 45%, var(--bg) 100%);
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
#app { height: 100%; display: flex; flex-direction: column; padding: 14px 16px 84px; }
h2 { margin: 6px 0 12px; font-size: 1.3rem; }
.muted { color: var(--muted); }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.score { display: flex; align-items: center; gap: 8px; font-size: 2rem; font-weight: 800; letter-spacing: -.02em; }
.score .coin { font-size: 1.7rem; }
.rank { padding: 6px 12px; border-radius: 999px; background: var(--card); color: var(--muted); font-weight: 600; font-size: .85rem; }

.view { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow-y: auto; }
#view-play { align-items: center; justify-content: space-evenly; overflow: visible; }

.boost { padding: 6px 14px; border-radius: 999px; background: linear-gradient(135deg, #7c3aed, #db2777); font-weight: 700; font-size: .9rem; }

.potato {
  width: min(72vw, 300px);
  aspect-ratio: 1;
  border: 0;
  padding: 0;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(245, 158, 11, .35), transparent 70%);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .06s;
}
.potato:active { transform: scale(.93); }
.potato img { width: 100%; height: 100%; pointer-events: none; filter: drop-shadow(0 18px 30px rgba(0, 0, 0, .45)); }
.potato.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-8px); } 50% { transform: translateX(8px); } 75% { transform: translateX(-4px); } }

.energy { width: 100%; max-width: 420px; }
.energy-label { display: flex; justify-content: center; gap: 4px; margin-bottom: 6px; font-weight: 700; }
.bar { height: 12px; border-radius: 999px; background: var(--card); overflow: hidden; border: 1px solid var(--line); }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), #fde047); transition: width .25s; }

.actions { width: 100%; max-width: 420px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.act {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 4px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--card); color: var(--text); font: inherit; font-weight: 700; font-size: .82rem;
}
.act small { color: var(--muted); font-weight: 600; font-size: .7rem; }
.act.hot { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.act:active, .btn:active, .upg:active { transform: scale(.97); }

.list { display: flex; flex-direction: column; gap: 10px; }
.upg {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; text-align: left;
  padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); color: var(--text); font: inherit;
}
.upg-t { font-weight: 700; }
.upg-t em { font-style: normal; color: var(--muted); font-weight: 600; font-size: .85rem; }
.upg-d { color: var(--muted); font-size: .85rem; }
.upg-c { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-weight: 800; color: var(--accent); }
.upg.off { opacity: .5; }

.card { padding: 16px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); margin: 6px 0 14px; }
.big { font-size: 2rem; font-weight: 800; }
.btn {
  width: 100%; margin-top: 10px; padding: 14px; border: 0; border-radius: 14px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent)); color: #1b120c; font: inherit; font-weight: 800;
}
.btn.ghost { background: var(--card); color: var(--text); border: 1px solid var(--line); }

.top-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.top-list li { display: grid; grid-template-columns: 30px 1fr auto; gap: 8px; align-items: center; padding: 10px 12px; border-radius: 12px; background: var(--card); }
.top-list .n { color: var(--muted); font-weight: 700; }
.top-list .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-list .pts { font-weight: 700; }
.top-list li:nth-child(-n+3) .n { color: var(--accent); }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: rgba(20, 13, 8, .92); border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.tabs button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border: 0; border-radius: 12px; background: none; color: var(--muted); font: inherit; font-size: 1.2rem; }
.tabs button span { font-size: .72rem; font-weight: 600; }
.tabs button.on { color: var(--text); background: var(--card); }

.float {
  position: fixed; z-index: 10; pointer-events: none; transform: translate(-50%, -50%);
  font-weight: 800; font-size: 1.4rem; color: #fde047; text-shadow: 0 2px 6px rgba(0, 0, 0, .5);
  animation: float .8s ease-out forwards;
}
@keyframes float { to { transform: translate(-50%, -140%); opacity: 0; } }

#toast {
  position: fixed; left: 50%; bottom: 96px; z-index: 20; transform: translate(-50%, 20px);
  max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 12px;
  background: rgba(0, 0, 0, .85); color: #fff; font-weight: 600; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.gate { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; }
.gate img { width: 160px; }
.gate p { color: var(--muted); }
