:root {
  --bg: #000;
  --ink: #e6ede0;
  --muted: #7d8a74;
  --green: #5ad22a;
  --green-dim: #2d6a16;
  --green-glow: rgba(90, 210, 42, .35);
  --panel: #070a05;
  --line: #16200f;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 var(--mono); text-transform: lowercase;
  padding: 0 16px calc(24px + env(safe-area-inset-bottom));
  max-width: 620px; margin-inline: auto;
}
code, input, textarea, .keep { text-transform: none; }
a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 8px; color: var(--ink); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
section { margin-top: 36px; }
button, .button {
  font: inherit; text-transform: lowercase; cursor: pointer;
  background: var(--green); color: #000; border: 0; border-radius: 6px; padding: 10px 16px; font-weight: 600;
}
button:disabled { background: var(--green-dim); color: #0a1206; cursor: default; }
.ghost, button.ghost { background: transparent; color: var(--green); border: 1px solid var(--green-dim); }
.button { display: inline-block; }

/* top bar */
.top { display: flex; align-items: center; gap: 10px; padding: 14px 0 0; }
.top-avatar { width: 36px; height: 36px; border-radius: 50%; border: 1px solid rgba(90, 210, 42, .3); }
.top-name { display: flex; flex-direction: column; line-height: 1.25; flex: 1; min-width: 0; }
.top-name strong { font-size: 15px; }
.top-name .muted { font-size: 12px; }
.worth { text-align: right; display: flex; flex-direction: column; line-height: 1.25; }
.worth .muted { font-size: 11px; }
.worth strong { color: var(--green); font-size: 15px; font-variant-numeric: tabular-nums; }

/* hero */
.hero { margin-top: 28px; display: grid; gap: 22px; justify-items: center; text-align: center; }
.goblin-wrap { position: relative; width: min(260px, 70vw); }
.goblin {
  display: block; width: 100%; height: auto; border-radius: 18px;
  border: 2px solid rgba(90, 210, 42, .3); box-shadow: 0 0 60px var(--green-glow);
  transition: filter .8s ease, box-shadow .8s ease, opacity .8s ease;
}
.off-badge {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  background: rgba(0,0,0,.8); color: var(--muted); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 12px; font-size: 12px; display: none;
}
body.off .goblin { filter: grayscale(1) brightness(.35) contrast(.9); box-shadow: none; opacity: .85; border-color: var(--line); }
body.off .off-badge { display: block; }
body.off .top-name #status { color: var(--muted); }
#status { color: var(--green); }

.battery-block { width: 100%; }
.battery {
  position: relative; height: 56px; border: 2px solid var(--ink); border-radius: 12px; padding: 5px;
  background: var(--panel);
}
.battery::after { /* the nub */
  content: ""; position: absolute; right: -12px; top: 50%; transform: translateY(-50%);
  width: 8px; height: 22px; background: var(--ink); border-radius: 0 4px 4px 0;
}
.battery-fill {
  height: 100%; width: 0%; border-radius: 7px; background: var(--green);
  box-shadow: 0 0 24px var(--green-glow);
  transition: width .9s cubic-bezier(.2,.8,.2,1), background .6s;
  min-width: 0;
}
body.low .battery-fill { animation: pulse 1.6s ease-in-out infinite; }
body.off .battery-fill { background: var(--green-dim); box-shadow: none; animation: none; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .45 } }
.battery-ticks { position: absolute; inset: 5px; display: flex; pointer-events: none; }
.battery-ticks i { flex: 1; border-right: 1px solid rgba(255,255,255,.08); }
.battery-ticks i:last-child { border: 0; }

.pct-row { display: flex; align-items: baseline; justify-content: center; gap: 12px; margin-top: 16px; }
.pct { font-size: 64px; font-weight: 700; line-height: 1; letter-spacing: -2px; font-variant-numeric: tabular-nums; color: var(--green); }
body.off .pct { color: var(--muted); }
.caption { margin: 10px 0 4px; font-size: 17px; }
.rules { margin: 0; font-size: 12px; }

/* chat */
.wall {
  list-style: none; margin: 0; padding: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  max-height: 46vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth;
}
.wall:empty::before { content: "nobody has said anything. the battery is draining."; color: var(--muted); }
.wall li { display: grid; gap: 2px; font-size: 14px; }
.wall .q { color: var(--muted); overflow-wrap: anywhere; }
.wall .q::before { content: "anon  "; color: var(--green-dim); white-space: pre; }
.wall .a { color: var(--ink); overflow-wrap: anywhere; }
.wall .a::before { content: "goblin  "; color: var(--green); white-space: pre; }
.wall li.mine .q::before { content: "you  "; }
.say { margin-top: 10px; display: grid; gap: 8px; }
.say textarea {
  width: 100%; resize: none; font: inherit; color: var(--ink); background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; padding: 12px; min-height: 48px; line-height: 1.4;
}
.say textarea:focus { outline: none; border-color: var(--green-dim); }
.say-row { display: flex; align-items: center; gap: 10px; }
.say-row #count { font-size: 12px; }
.say-row #note { flex: 1; font-size: 12px; text-align: right; }
.say-row #note.err { color: #d8a24a; }
.chat .small { margin: 8px 0 0; }

/* card */
#canvas { width: 100%; height: auto; display: block; border-radius: 10px; border: 1px solid var(--line); background: #000; }
.card-controls { display: grid; gap: 14px; margin-top: 14px; }
.card-controls label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.card-controls output { color: var(--green); }
.card-controls input[type=text] {
  font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
}
.card-controls input[type=range] { width: 100%; accent-color: var(--green); }
.card-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.card-actions .button { padding: 10px 16px; }
.card-controls .small { margin: 0; }

/* coin */
.ca { display: flex; gap: 8px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 8px 8px 12px; }
.ca code { flex: 1; font-size: 12px; overflow-wrap: anywhere; color: var(--ink); }
.ca button { padding: 8px 12px; font-size: 13px; }
.links { display: flex; gap: 18px; margin-top: 12px; }

footer { margin-top: 48px; font-size: 12px; text-align: center; }

@media (min-width: 560px) {
  .hero { grid-template-columns: 220px 1fr; text-align: left; align-items: center; }
  .goblin-wrap { width: 220px; }
  .pct-row { justify-content: flex-start; }
}
