:root {
  --bg: #0b1220;
  --panel: rgba(15, 23, 42, 0.72);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #4ade80;
  --gold: #facc15;
}

* { box-sizing: border-box; }
html, body { touch-action: none; overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
input { -webkit-user-select: text; user-select: text; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.label { color: var(--muted); }
.title { font-weight: 600; margin-bottom: 4px; }

.panel { position: fixed; background: var(--panel); border-radius: 10px; padding: 8px 12px; backdrop-filter: blur(4px); pointer-events: none; }
#stats { top: 12px; left: 12px; }
#leaders { top: 12px; right: 12px; min-width: 180px; }
#leaders ol { margin: 0; padding-left: 22px; }
#leaders li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
#leaders li.me { color: var(--accent); font-weight: 600; }
#leaders li .s { float: right; margin-left: 10px; color: var(--muted); }
#quests { left: 12px; bottom: 12px; pointer-events: auto; max-width: 280px; opacity: 0.85; }
#quests ul { list-style: none; margin: 6px 0 0; padding: 0; font-size: 13px; }
#quests li { margin: 3px 0; }
#quests li.done { color: var(--accent); }
#quests li progress { width: 100%; height: 5px; display: block; accent-color: var(--accent); }
#quests.collapsed ul { display: none; }
button.link { background: none; border: 0; color: var(--text); font: inherit; font-weight: 600; padding: 0; cursor: pointer; }

#achBtn { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); }
.chip { background: var(--panel); color: var(--text); border: 0; border-radius: 999px; padding: 6px 12px; font: inherit; cursor: pointer; }
#minimap { position: fixed; right: 12px; bottom: 12px; width: 120px; height: 120px; opacity: 0.8; pointer-events: none; }
.boost { display: none; position: fixed; right: 20px; bottom: 150px; width: 64px; height: 64px; border-radius: 50%; border: 0; background: rgba(250, 204, 21, 0.8); font-size: 28px; touch-action: none; }
@media (pointer: coarse) { .boost { display: block; } #leaders { min-width: 140px; font-size: 13px; } }

#toasts { position: fixed; top: 60px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; z-index: 5; }
.toast { background: var(--panel); padding: 6px 14px; border-radius: 999px; animation: toast 3.2s forwards; white-space: nowrap; }
.toast.ach { border: 1px solid var(--gold); }
@keyframes toast { 0% { opacity: 0; transform: translateY(-6px); } 10%, 80% { opacity: 1; transform: none; } 100% { opacity: 0; } }

.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(2, 6, 23, 0.55); z-index: 10; padding: 16px; }
.card { background: #0f172a; border: 1px solid #1e293b; border-radius: 16px; padding: 24px; width: min(440px, 100%); max-height: 90vh; overflow: auto; text-align: center; }
.card h1 { margin: 0 0 8px; color: var(--accent); }
.card h2 { margin: 0 0 8px; }
.card ol, .card ul { text-align: left; }
#joinForm { display: flex; gap: 8px; margin: 16px 0 8px; }
input { flex: 1; min-width: 0; padding: 10px 12px; border-radius: 10px; border: 1px solid #334155; background: #020617; color: var(--text); font: inherit; }
button { padding: 10px 16px; border-radius: 10px; border: 1px solid #334155; background: #1e293b; color: var(--text); font: inherit; cursor: pointer; }
button.primary { background: var(--accent); color: #052e16; border-color: var(--accent); font-weight: 700; }
.hint { font-size: 13px; color: var(--muted); }
.cols { margin-top: 12px; }
ul.ach { list-style: none; padding: 0; }
ul.ach li { padding: 6px 0; border-bottom: 1px solid #1e293b; opacity: 0.45; }
ul.ach li.got { opacity: 1; }
ul.ach li b { display: block; }
#records li.muted { list-style: none; }

@media (max-width: 600px) {
  .panel { padding: 6px 10px; font-size: 12px; }
  #online { display: none; }
  #leaders { min-width: 0; max-width: 46%; }
  #leaders li:nth-child(n + 6):not(.me) { display: none; }
  #achBtn { left: 12px; top: 92px; transform: none; font-size: 12px; padding: 4px 10px; }
  #quests { max-width: calc(100% - 150px); }
  #quests ul { font-size: 12px; }
  #minimap { width: 100px; height: 100px; }
}
.card { touch-action: pan-y; }
