:root {
  --bg: #f4f1ea; --card: #ffffff; --ink: #1f1d1a; --muted: #6b665e; --line: #d9d4c8;
  --accent: #b4472e; --accent-ink: #ffffff; --ok: #2f6f3a; --soft: #ebe6da;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #191817; --card: #232120; --ink: #ece8e0; --muted: #a39d92; --line: #3a3733; --accent: #d4664b; --accent-ink: #1a1210; --ok: #7cc089; --soft: #2d2a28; }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
h1 { font-size: 18px; margin: 0; }
h2 { font-size: 16px; margin: 20px 0 8px; }
p { margin: 0 0 12px; }
button { font: inherit; color: inherit; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--card); }
.account { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.notice { margin: 10px 16px 0; padding: 10px 12px; border: 1px solid var(--line); background: var(--soft); border-radius: 6px; font-size: 14px; }

.layout { display: grid; grid-template-columns: minmax(300px, 5fr) minmax(360px, 6fr); gap: 16px; padding: 16px; max-width: 1280px; margin: 0 auto; align-items: start; }
.play { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 20px 16px; text-align: center; position: sticky; top: 16px; }
.balance { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.rates { color: var(--muted); font-size: 14px; margin-top: 4px; }

.scene { position: relative; aspect-ratio: 4 / 3; margin-top: 14px; border-radius: 8px; overflow: hidden; background: var(--soft); user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.sceneart, .sceneart svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.sceneart .s2, .sceneart .s3 { transition: opacity 900ms ease; }
.scene.st0 .s2, .scene.st0 .s3, .scene.st1 .s3 { opacity: 0; }

.rays { position: absolute; left: 50%; top: 47%; width: 74%; aspect-ratio: 1; transform: translate(-50%, -50%); pointer-events: none; opacity: 0; transition: opacity 900ms ease; }
.rays svg { width: 100%; height: 100%; animation: spin 40s linear infinite; }
.rays .ray { opacity: 0; transition: opacity 900ms ease; }
.scene.g1 .rays, .scene.g2 .rays, .scene.g3 .rays { opacity: 1; }
.scene.g2 .rays .ray, .scene.g3 .rays .ray { opacity: 1; }
.scene.g3 .rays svg { animation-duration: 14s; }

.orbit { position: absolute; left: 50%; top: 47%; width: 68%; aspect-ratio: 1; margin: -34% 0 0 -34%; pointer-events: none; animation: spin 50s linear infinite; }
.helper { position: absolute; width: 11%; aspect-ratio: 1; }
.helper svg { width: 100%; height: 100%; display: block; animation: peck 1.1s ease-in-out infinite; }
@keyframes peck { 0%, 70%, 100% { transform: translate(0, 0); } 82% { transform: translate(-22%, 22%); } }
@keyframes spin { to { transform: rotate(360deg); } }
.rays svg { transform-origin: 50% 50%; }

.clicker { position: absolute; left: 50%; top: 47%; width: 40%; aspect-ratio: 1; transform: translate(-50%, -50%); padding: 0; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
.clicker svg { width: 100%; height: 100%; display: block; transition: transform 70ms ease-out; pointer-events: none; }
.clicker.down svg { transform: scale(0.9) rotate(-3deg); }
.clicker:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; border-radius: 12px; }

.tool { position: absolute; width: 15%; aspect-ratio: 1; pointer-events: none; transform-origin: 85% 15%; z-index: 3; }
.tool svg { width: 100%; height: 100%; display: block; }
.tool.hit { animation: swing 150ms ease-out; }
@keyframes swing { 0% { transform: rotate(38deg); } 55% { transform: rotate(-12deg); } 100% { transform: rotate(0deg); } }

.pop { position: absolute; pointer-events: none; font-weight: 800; font-size: 15px; color: #1f1d1a; text-shadow: 0 1px 0 #fff, 0 -1px 0 #fff, 1px 0 0 #fff, -1px 0 0 #fff; white-space: nowrap; animation: rise 750ms ease-out forwards; z-index: 4; }
.scene.dark .pop { color: #fff; text-shadow: 0 1px 0 #000, 0 -1px 0 #000, 1px 0 0 #000, -1px 0 0 #000; }
@keyframes rise { from { opacity: 1; transform: translate(-50%, -50%); } to { opacity: 0; transform: translate(-50%, -330%); } }
.bit { position: absolute; width: 9px; height: 9px; border-radius: 2px; pointer-events: none; animation: fly 600ms ease-out forwards; z-index: 2; }
@keyframes fly { from { opacity: 1; transform: translate(-50%, -50%) rotate(0deg); } to { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(220deg); } }

.place { position: absolute; left: 10px; bottom: 8px; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.82); color: #1f1d1a; pointer-events: none; }
.toast { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); padding: 7px 14px; border-radius: 6px; background: #1f1d1a; color: #fff; font-weight: 700; font-size: 14px; white-space: nowrap; max-width: 94%; overflow: hidden; text-overflow: ellipsis; pointer-events: none; z-index: 5; animation: drop 300ms ease-out; }
@keyframes drop { from { transform: translate(-50%, -160%); } to { transform: translate(-50%, 0); } }
.scene.flash::after { content: ""; position: absolute; inset: 0; background: #fff; animation: flash 900ms ease-out forwards; pointer-events: none; z-index: 6; }
@keyframes flash { from { opacity: 0.95; } to { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .rays svg, .orbit, .helper svg { animation: none; }
  .pop, .bit { animation-duration: 1ms; }
  .clicker svg { transition: none; }
}

.worlds { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; margin-top: 10px; }
.hint { color: var(--muted); font-size: 13px; margin-top: 12px; }
.hint.warn { color: var(--ink); font-size: 14px; font-weight: 600; background: var(--soft); border: 1px solid var(--accent); border-radius: 6px; padding: 9px 12px; cursor: pointer; }
.hint.warn::after { content: " Sign up 92"; color: var(--accent); white-space: nowrap; }
.why { font-weight: 600; background: var(--soft); border-left: 3px solid var(--accent); padding: 8px 10px; margin: 6px 0 10px; font-size: 14px; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: 8px; min-width: 0; }
.tabs { display: flex; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { flex: 1 0 auto; padding: 12px 10px; border: 0; background: none; cursor: pointer; border-bottom: 3px solid transparent; color: var(--muted); font-weight: 600; font-size: 14px; }
.tab.on { color: var(--ink); border-bottom-color: var(--accent); }
.tabbody { padding: 14px 16px 18px; }
.lead { color: var(--muted); font-size: 14px; }
.sub { color: var(--muted); font-size: 13px; font-weight: 400; }

.btn { border: 1px solid var(--line); background: var(--card); border-radius: 6px; padding: 9px 14px; cursor: pointer; font-weight: 600; font-size: 14px; }
.btn:hover:not(:disabled) { background: var(--soft); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.08); }
.btn.ghost { border-color: transparent; }
.btn.on { background: var(--ink); border-color: var(--ink); color: var(--card); }

.buyrow, .subtabs { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; font-size: 14px; color: var(--muted); flex-wrap: wrap; }
.list { display: flex; flex-direction: column; }
.row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row .name { font-weight: 600; }
.row .lv { color: var(--muted); font-weight: 400; font-size: 13px; margin-left: 6px; }
.row .info { color: var(--muted); font-size: 13px; }
.row .btn { min-width: 132px; text-align: center; line-height: 1.2; }
.row .btn small { display: block; font-weight: 400; font-size: 12px; opacity: 0.85; }
.row.locked { opacity: 0.55; }

.box { border: 1px solid var(--line); border-radius: 6px; padding: 12px; margin: 10px 0; background: var(--bg); }
.bar { height: 8px; background: var(--soft); border-radius: 4px; overflow: hidden; margin: 10px 0 12px; border: 1px solid var(--line); }
.fill { height: 100%; width: 0; background: var(--ok); }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 6px 6px; border-bottom: 1px solid var(--line); }
.table td { padding: 7px 6px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tr.me td { background: var(--soft); font-weight: 600; }
.table .tag { color: var(--muted); font-size: 12px; margin-left: 6px; }

.formrow { display: flex; gap: 8px; margin: 8px 0 14px; flex-wrap: wrap; }
input { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 9px 10px; min-width: 0; flex: 1; }
input:focus-visible, .btn:focus-visible, .tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.err { color: var(--accent); font-size: 14px; margin: 6px 0; }

.statgrid { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; font-size: 14px; }
.statgrid div:nth-child(odd) { color: var(--muted); }
.statgrid div:nth-child(even) { text-align: right; font-variant-numeric: tabular-nums; }
.ach { display: flex; flex-wrap: wrap; gap: 6px; }
.ach span { border: 1px solid var(--line); border-radius: 4px; padding: 3px 7px; font-size: 12px; color: var(--muted); }
.ach span.got { color: var(--ink); background: var(--soft); border-color: var(--ok); }

dialog { border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink); padding: 18px; width: min(380px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
dialog h2 { margin: 0 0 6px; }
dialog label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 0; }
dialog label input { display: block; width: 100%; margin-top: 4px; }
.dlgrow { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; padding: 10px; gap: 10px; }
  .play { position: static; padding: 14px 12px; }
  .balance { font-size: 22px; }
  .tabbody { padding: 12px; }
  .row .btn { min-width: 116px; }
}

/* account dialog */
.dlghead { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.dlghead h2 { margin: 0; }
dialog .subtabs { margin: 4px 0; }
.btn.wide { width: 100%; margin-top: 14px; padding: 11px 14px; }
.dform .sub { margin: 10px 0 0; }
.dform details { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 10px; }
.dform summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.dform .box { font-size: 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.linkbtn { display: block; margin: 10px auto 0; border: 0; background: none; color: var(--accent); font-size: 14px; cursor: pointer; text-decoration: underline; }
.hp { position: absolute !important; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.field-hint { font-size: 13px; margin: 6px 0 0; }
.field-hint:empty { display: none; }
.field-hint.bad { color: var(--accent); }
.field-hint.good { color: var(--ok); }
.ok { color: var(--ok); font-size: 14px; margin: 6px 0; }
.verified { color: var(--ok); font-weight: 600; }
.unverified { color: var(--accent); font-weight: 600; }
dialog { max-height: calc(100dvh - 32px); overflow-y: auto; }
