:root {
  --bg: #121110;
  --panel: #1a1816;
  --line: #2c2925;
  --text: #ece6dc;
  --muted: #a59d90;
  --gold: #d9b45a;
  --gold-hi: #f0d48a;
  --green: #4cc26a;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { -webkit-tap-highlight-color: transparent; overscroll-behavior: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
input, .sheet-body p { user-select: text; -webkit-user-select: text; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.gold { color: var(--gold); }

#app {
  max-width: 440px; margin: 0 auto; min-height: 100%;
  padding: max(14px, env(safe-area-inset-top)) 18px max(10px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; text-align: center;
}
.rule { height: 1px; background: var(--line); margin: 10px 0; }

.top h1 { margin: 4px 0 0; font-size: clamp(30px, 9vw, 40px); letter-spacing: .02em; font-weight: 800; color: var(--gold); }
.tag { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.label { font-size: 12.5px; letter-spacing: .06em; color: var(--muted); margin-top: 4px; }
.big { font-size: clamp(36px, 11vw, 48px); font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.15; }
.online { color: var(--muted); font-size: 13.5px; display: flex; justify-content: center; align-items: center; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-right: 7px; box-shadow: 0 0 8px var(--green); animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .45; } }

.announce { margin: 8px 0 0; padding: 8px 12px; border: 1px solid #5b4a22; border-radius: 10px; background: #241e12; color: var(--gold-hi); font-size: 13.5px; }

/* ---------------- potato */
.stage { margin-top: 10px; }
.potato-card {
  position: relative; width: 100%; aspect-ratio: 4 / 3; border-radius: 16px; overflow: hidden;
  background: radial-gradient(ellipse at 50% 30%, #2a2540 0%, #15131c 55%, #0d0c10 100%);
  border: 1px solid #24212c; touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.spot { position: absolute; inset: 0; background: radial-gradient(ellipse 55% 45% at 50% 52%, rgba(255, 214, 150, .16), transparent 70%); pointer-events: none; }
.potato-img, .potato-pending {
  position: absolute; left: 50%; top: 50%; width: 124%; height: 124%; translate: -50% -50%;
  object-fit: contain; pointer-events: none; transition: transform .09s ease-out;
  filter: drop-shadow(0 18px 18px rgba(0, 0, 0, .55));
}
/* Clearly temporary stand-in until the GPT art lands in art-handoff/deliver. */
.potato-pending { display: grid; place-items: center; }
.potato-pending::before {
  content: ""; position: absolute; width: 70%; height: 52%; border-radius: 48% 52% 45% 55% / 55% 48% 52% 45%;
  background: radial-gradient(ellipse at 38% 32%, #f0cf95, #b9844a 55%, #6e4521);
}
.potato-pending span { position: relative; font-size: 11px; letter-spacing: .2em; color: rgba(40, 24, 8, .7); font-weight: 700; }
.potato-pending[hidden] { display: none; }

.fx { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.plus {
  position: absolute; font-weight: 800; font-size: 22px; color: var(--gold-hi); text-shadow: 0 2px 6px #000;
  animation: rise .8s ease-out forwards; pointer-events: none;
}
@keyframes rise { to { transform: translateY(-70px) scale(1.15); opacity: 0; } }
.speech {
  position: absolute; left: 50%; top: 10px; translate: -50% 0; max-width: 85%;
  background: #f4eddf; color: #2a1d10; font-size: 14px; font-style: italic; padding: 7px 12px; border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .5); animation: pop .25s ease-out; pointer-events: none;
}
@keyframes pop { from { transform: scale(.7); opacity: 0; } }

.evo { margin: 12px 0 2px; font-size: 24px; font-weight: 800; }
.status { margin: 0; color: var(--muted); font-style: italic; font-size: 15px; min-height: 1.4em; }

/* ---------------- progress */
.progress { margin-top: 14px; text-align: left; }
.row { display: flex; justify-content: space-between; font-size: 14px; color: var(--text); }
.bar { height: 9px; border-radius: 9px; background: #2c2925; margin: 6px 0; overflow: hidden; }
.fill { height: 100%; width: 0; border-radius: 9px; background: linear-gradient(90deg, #b8913c, var(--gold-hi)); transition: width .4s ease; }
.sub { color: var(--muted); font-size: 14px; text-align: center; }
.mine .big { color: var(--text); }

/* ---------------- nav */
.nav { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: auto; padding-top: 4px; }
.nav button { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 0; font-size: 13px; color: var(--muted); border-radius: 10px; }
.nav button:hover, .nav button:focus-visible { color: var(--text); background: #1c1a17; outline: none; }
.nav svg { width: 22px; height: 22px; fill: none; stroke: var(--gold); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.brand { margin-top: 6px; font-size: 10.5px; letter-spacing: .14em; color: #5f584e; }

/* ---------------- toasts */
.toasts { position: fixed; left: 0; right: 0; top: max(12px, env(safe-area-inset-top)); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; z-index: 30; }
.toast {
  max-width: min(92vw, 400px); background: #211d17; border: 1px solid #5b4a22; border-radius: 12px; padding: 9px 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5); font-size: 14px; text-align: left; animation: slide .3s ease-out;
}
.toast b { color: var(--gold); display: block; font-size: 12px; letter-spacing: .08em; }
.toast.out { opacity: 0; transform: translateY(-10px); transition: .4s; }
@keyframes slide { from { transform: translateY(-16px); opacity: 0; } }

/* ---------------- sheets */
.sheet { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.sheet[hidden] { display: none; }
.sheet-card {
  width: 100%; max-width: 460px; max-height: 82vh; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-bottom: 0; border-radius: 18px 18px 0 0;
  padding: 14px 16px max(16px, env(safe-area-inset-bottom)); animation: up .22s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-head h3 { margin: 0; color: var(--gold); font-size: 19px; }
.sheet-head button { font-size: 18px; color: var(--muted); padding: 4px 8px; }
.sheet-body { overflow-y: auto; margin-top: 10px; text-align: left; }

.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tabs button { flex: 1; padding: 8px; border-radius: 10px; background: #221f1b; color: var(--muted); }
.tabs button.on { background: #3a301a; color: var(--gold-hi); }
.board { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.board td { padding: 7px 4px; border-bottom: 1px solid #25221e; }
.board td:first-child { width: 36px; color: var(--muted); }
.board td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.board tr.you td { color: var(--gold-hi); }
.youline { margin-top: 10px; padding: 9px 10px; border-radius: 10px; background: #221f1b; font-size: 14px; }

.timeline { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 2px solid #3a301a; }
.timeline li { position: relative; padding: 0 0 14px 6px; }
.timeline li::before { content: ""; position: absolute; left: -23px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.timeline li.evolution::before { background: var(--gold); box-shadow: 0 0 8px var(--gold); }
.timeline .when { font-size: 12px; color: var(--muted); }
.timeline .what { font-size: 15px; }
.timeline li.evolution .what { color: var(--gold-hi); font-weight: 700; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field input[type=text] { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: #110f0e; color: var(--text); font: inherit; }
.inline { display: flex; gap: 8px; }
.toggle { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid #25221e; }
.toggle input { width: 20px; height: 20px; accent-color: var(--gold); }
.err { color: #e08a7a; font-size: 13px; min-height: 1.2em; margin-top: 4px; }
.small { font-size: 12px; color: var(--muted); }
.btn { padding: 10px 16px; border-radius: 10px; background: linear-gradient(180deg, #e2c06a, #b48e3a); color: #1a1408; font-weight: 800; }
.btn.ghost { background: #221f1b; color: var(--text); font-weight: 600; }
.ach { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px; color: #5f584e; border-bottom: 1px solid #221f1b; }
.ach.got { color: var(--text); }
.ach.got span:first-child::before { content: "★ "; color: var(--gold); }
.share-preview { width: 100%; border-radius: 12px; border: 1px solid var(--line); display: block; margin-bottom: 10px; }
.share-actions { display: flex; gap: 8px; }
.share-actions .btn { flex: 1; }

/* ---------------- store & supporter perks */
.supporter { margin-top: 3px; font-size: 13px; color: var(--gold); letter-spacing: .02em; }
.supporter[hidden] { display: none; }
.store-link { font-size: inherit; letter-spacing: inherit; color: var(--gold); text-decoration: underline; text-underline-offset: 2px; padding: 0; }
.board .badge { color: var(--gold); margin-left: 5px; }
.item { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; background: #1e1b18; }
.item.owned { border-color: #5b4a22; background: #241f15; }
.item-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.item-name { font-weight: 800; color: var(--text); }
.item-name .b { color: var(--gold); margin-right: 6px; }
.item p { margin: 6px 0 10px; font-size: 13.5px; color: var(--muted); }
.item .btn { width: 100%; }
.item .btn[disabled] { opacity: .55; cursor: default; }
.store-note { font-size: 12.5px; color: var(--muted); margin: 4px 0 12px; }
.fxp { position: absolute; pointer-events: none; color: var(--gold-hi); text-shadow: 0 0 8px rgba(240, 212, 138, .8); animation: burst .9s ease-out forwards; font-size: 16px; }
.fxp.coin { width: 12px; height: 12px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff2b8, #d9a531 60%, #8a6414); box-shadow: 0 0 6px rgba(240, 200, 90, .7); }
@keyframes burst { to { transform: translate(var(--dx), var(--dy)) rotate(var(--r)); opacity: 0; } }

/* ---------------- potato power */
.power { margin: 10px auto 0; display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px;
  border: 1px solid #5b4a22; background: #211c12; color: var(--gold-hi); font-size: 13.5px; font-weight: 700; }
.power[hidden] { display: none; }
.power:disabled { opacity: .6; cursor: default; }
.power.on { background: linear-gradient(90deg, #6a4c12, #b8913c, #6a4c12); background-size: 200% 100%; color: #1a1408;
  border-color: #f0d48a; animation: shimmer 2.2s linear infinite; cursor: default; }
@keyframes shimmer { to { background-position: -200% 0; } }
.power-line { margin-top: 2px; font-size: 12.5px; color: var(--muted); }
.power-line[hidden] { display: none; }
.potato-card.boosted { box-shadow: 0 0 0 1px #b8913c, 0 0 34px rgba(240, 212, 138, .28); }
.plus.x2 { color: #fff3c4; font-size: 26px; }
.ad-sim { position: fixed; inset: 0; z-index: 60; background: #000; color: #fff; display: grid; place-items: center; text-align: center; font-size: 15px; }

/* ---------------- celebration */
.celebrate { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: radial-gradient(circle at 50% 45%, #3a2c10 0%, #0b0a09 70%); overflow: hidden; animation: fadein .5s; }
.celebrate[hidden] { display: none; }
@keyframes fadein { from { opacity: 0; } }
.rays { position: absolute; width: 220vmax; height: 220vmax; background: repeating-conic-gradient(rgba(240, 212, 138, .09) 0 6deg, transparent 6deg 18deg); animation: spin 30s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.cele-inner { position: relative; text-align: center; padding: 24px; max-width: 420px; }
.cele-kicker { letter-spacing: .3em; font-size: 12px; color: var(--muted); animation: fadein 1s .2s both; }
.cele-img { width: min(70vw, 300px); margin: 16px auto 0; display: block; filter: drop-shadow(0 0 40px rgba(240, 212, 138, .5)); animation: ascend 1.6s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes ascend { from { transform: translateY(60px) scale(.6); opacity: 0; filter: brightness(4) drop-shadow(0 0 80px #fff); } }
.cele-pending { position: relative; width: min(60vw, 260px); height: min(42vw, 180px); margin: 22px auto 0; transform: none; translate: none; left: auto; top: auto; animation: ascend 1.6s cubic-bezier(.2, .8, .2, 1) both; }
.cele-pending::before { width: 100%; height: 100%; box-shadow: 0 0 60px rgba(240, 212, 138, .45); }
.cele-sub { margin-top: 18px; color: var(--muted); animation: fadein 1s .8s both; }
.cele-name { font-size: clamp(30px, 9vw, 44px); font-weight: 900; line-height: 1.1; margin-top: 6px; text-shadow: 0 0 30px rgba(217, 180, 90, .6); animation: slam .7s 1.1s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes slam { from { transform: scale(3); opacity: 0; } }
.cele-line { margin: 12px 0 22px; font-style: italic; color: var(--text); animation: fadein 1s 1.8s both; }
.celebrate .btn { animation: fadein 1s 2.4s both; }

@media (max-height: 700px) {
  .potato-card { aspect-ratio: 16 / 10; }
  .tag { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .rays, .dot { animation: none; }
}
