:root {
  --bg: #14102a; --bg2: #1f1840; --panel: #2a2150; --ink: #f4f0ff; --muted: #a99fd0; --line: #000;
  --red: #ff5a5f; --blue: #3cc8ff; --yellow: #ffd23c; --green: #5ad84a; --pink: #f53cd1;
  --px: "Press Start 2P", "Mitr", monospace; --th: "Mitr", "Sarabun", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--th); font-size: 18px; line-height: 1.55;
  background-image: linear-gradient(var(--bg2) 2px, transparent 2px), linear-gradient(90deg, var(--bg2) 2px, transparent 2px);
  background-size: 32px 32px;
}
/* เส้นจอ CRT จาง ๆ */
body::after { content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 40;
  background: repeating-linear-gradient(0deg, #0000 0 3px, #0000001a 3px 4px); }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; font-weight: 600; line-height: 1.35; }
.pxf { font-family: var(--px); letter-spacing: .02em; line-height: 1.5; }
.muted { color: var(--muted); }
.box { background: var(--panel); border: 4px solid var(--line); box-shadow: 6px 6px 0 #000, inset -4px -4px 0 #0004, inset 4px 4px 0 #fff2; padding: 16px; }
.btn {
  font: 600 1rem var(--th); color: #14102a; background: var(--yellow); border: 4px solid #000; padding: .55em 1em; cursor: pointer;
  box-shadow: 4px 4px 0 #000, inset -4px -4px 0 #0003; transition: transform .05s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 #000, inset -4px -4px 0 #0003; }
.btn.ghost { background: var(--panel); color: var(--ink); }
.btn.green { background: var(--green); }
.btn:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 4px solid var(--pink); outline-offset: 3px; }
.av { display: inline-grid; place-items: center; width: 1.9em; height: 1.9em; background: var(--bg2); border: 3px solid #000; font-size: 1.1em; flex: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--bg2); border: 3px solid #000; padding: 2px 8px 2px 2px; font-size: .9rem; }
.chip .av { width: 1.6em; height: 1.6em; border: 0; font-size: .95em; }
.badge2 { display: inline-block; background: var(--pink); color: #fff; font: .8rem var(--px); padding: 6px 8px; border: 3px solid #000; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { filter: brightness(1.5); } }
@keyframes pop { 0% { transform: scale(.4); } 70% { transform: scale(1.1); } 100% { transform: scale(1); } }
@keyframes flip { 0% { transform: perspective(900px) rotateY(90deg); } 100% { transform: perspective(900px) rotateY(0); } }
.pop { animation: pop .35s steps(6) both; }
.flip { animation: flip .4s steps(8) both; }
.offline-bar { display: none; }
body.offline .offline-bar { display: block; position: fixed; top: 0; inset-inline: 0; z-index: 60; background: var(--red); color: #fff; text-align: center; padding: 4px; font-size: .9rem; }
@media (prefers-reduced-motion: reduce) { .pop, .flip, .badge2 { animation: none; } }
