:root {
  --bg: #070b14;
  --bg-glow: radial-gradient(1200px 600px at 50% -10%, rgba(34, 211, 238, 0.14), transparent 60%),
             radial-gradient(800px 500px at 100% 100%, rgba(244, 114, 182, 0.10), transparent 60%);
  --surface: #111a2e;
  --surface-2: #182338;
  --surface-3: #1f2c45;
  --border: #243354;
  --text: #e8eef8;
  --muted: #8d9cba;
  --accent: #22d3ee;
  --accent-2: #f472b6;
  --lime: #a3e635;
  --amber: #fbbf24;
  --danger: #f87171;
  --ok: #34d399;
  --radius: 16px;
  --radius-sm: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --nav-h: 64px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  background-image: var(--bg-glow);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
a { color: var(--accent); }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { margin: 0 0 8px; line-height: 1.2; }
h1 { font-size: 26px; letter-spacing: -0.01em; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 640px) { .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid3 { gap: 8px; } .grid3 .tile .v { font-size: 22px; } }

.app { max-width: 720px; margin: 0 auto; padding: 16px 16px calc(var(--nav-h) + 24px); }
.app.wide { max-width: 1200px; padding-bottom: 40px; }

.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0)) , var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card.glow { border-color: rgba(34, 211, 238, 0.45); box-shadow: 0 0 0 1px rgba(34,211,238,0.15), 0 20px 50px rgba(34,211,238,0.10); }
.card + .card { margin-top: 12px; }
.card.compact { padding: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font-weight: 600; font-size: 15px;
  transition: transform 0.05s ease, background 0.15s ease, opacity 0.15s ease;
  text-decoration: none; min-height: 44px;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, var(--accent), #0ea5e9); color: #04121a; border-color: transparent; }
.btn.pink { background: linear-gradient(135deg, var(--accent-2), #c026d3); color: #fff; border-color: transparent; }
.btn.lime { background: linear-gradient(135deg, var(--lime), #65a30d); color: #0b1a02; border-color: transparent; }
.btn.danger { background: rgba(248,113,113,0.12); border-color: rgba(248,113,113,0.5); color: #fecaca; }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.sm { padding: 7px 12px; min-height: 34px; font-size: 13px; border-radius: 9px; }
.btn.xs { padding: 4px 9px; min-height: 28px; font-size: 12px; border-radius: 8px; }

.input, textarea.input, select.input {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border);
  background: #0b1322; color: var(--text); outline: none; min-height: 44px;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(34,211,238,0.18); }
textarea.input { min-height: 90px; resize: vertical; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase;
  background: rgba(255,255,255,0.06); border: 1px solid var(--border); color: var(--muted);
}
.chip.cat { color: var(--cat, var(--accent)); border-color: color-mix(in srgb, var(--cat, var(--accent)) 45%, transparent); background: color-mix(in srgb, var(--cat, var(--accent)) 12%, transparent); }
.pts { font-family: var(--mono); font-weight: 800; color: var(--amber); }
.pts.big { font-size: 22px; }
.badge { display: inline-flex; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent-2); color: #fff; font-size: 11px; font-weight: 800; align-items: center; justify-content: center; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.brand { font-family: var(--mono); font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; font-size: 13px; color: var(--accent); }
.brand small { display: block; color: var(--muted); font-weight: 500; letter-spacing: 0.02em; text-transform: none; font-family: var(--font); }
.avatar { width: 40px; height: 40px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; font-size: 22px; background: var(--surface-2); border: 1px solid var(--border); }
.avatar.lg { width: 64px; height: 64px; font-size: 36px; border-radius: 18px; }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--nav-h);
  background: rgba(9, 13, 24, 0.92); backdrop-filter: blur(14px); border-top: 1px solid var(--border);
  display: flex; justify-content: space-around; padding-bottom: env(safe-area-inset-bottom); z-index: 20;
}
.nav button {
  flex: 1; background: none; border: 0; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; font-weight: 600; position: relative;
}
.nav button .ico { font-size: 20px; line-height: 1; }
.nav button.active { color: var(--accent); }
.nav button .badge { position: absolute; top: 8px; right: calc(50% - 22px); }

.quest-hero { position: relative; overflow: hidden; }
.quest-hero::before { content: ''; position: absolute; inset: -40% -20% auto; height: 180px; background: radial-gradient(closest-side, color-mix(in srgb, var(--cat, var(--accent)) 30%, transparent), transparent); pointer-events: none; }
.quest-title { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; margin: 10px 0 8px; }
.quest-desc { font-size: 16px; color: #d5deee; }
.quest-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); border-left: 4px solid var(--cat, var(--border)); }
.item .thumb { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; flex: none; background: #0b1322; cursor: zoom-in; }
.item.me { outline: 2px solid var(--accent); }
.rank { font-family: var(--mono); font-weight: 800; width: 32px; text-align: center; color: var(--muted); }
.rank.r1 { color: var(--amber); font-size: 20px; }
.rank.r2 { color: #cbd5e1; font-size: 18px; }
.rank.r3 { color: #d97706; font-size: 17px; }

.tile { padding: 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.tile .v { font-family: var(--mono); font-size: 26px; font-weight: 800; color: var(--accent); }
.tile .l { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; }

.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) 40px; gap: 8px; align-items: center; margin: 6px 0; }
.bar-row .lbl { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .track { height: 10px; border-radius: 6px; background: rgba(255,255,255,0.06); overflow: hidden; }
.bar-row .fill { height: 100%; border-radius: 6px; background: var(--c, var(--accent)); }
.bar-row .num { font-family: var(--mono); font-size: 13px; text-align: right; color: var(--muted); }

.photo-wall { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.photo-wall img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; cursor: zoom-in; background: #0b1322; }
@media (min-width: 640px) { .photo-wall { grid-template-columns: repeat(5, 1fr); } }

.banner { background: linear-gradient(135deg, rgba(244,114,182,0.2), rgba(34,211,238,0.2)); border: 1px solid rgba(244,114,182,0.5); padding: 12px 14px; border-radius: 12px; margin-bottom: 12px; display: flex; gap: 10px; align-items: flex-start; }
.banner .x { background: none; border: 0; color: var(--muted); font-size: 18px; padding: 0 4px; }

.toast-wrap { position: fixed; top: 12px; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 50; pointer-events: none; }
.toast { pointer-events: auto; background: #0f1a30; border: 1px solid var(--accent); color: var(--text); padding: 10px 16px; border-radius: 12px; box-shadow: var(--shadow); font-weight: 600; max-width: 92vw; animation: pop 0.2s ease; }
.toast.err { border-color: var(--danger); }
.toast.ok { border-color: var(--ok); }
@keyframes pop { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }

.sheet-bg { position: fixed; inset: 0; background: rgba(2, 6, 14, 0.7); backdrop-filter: blur(4px); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 720px; max-height: 92dvh; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); animation: up 0.2s ease; }
@keyframes up { from { transform: translateY(30px); opacity: 0.5; } to { transform: none; opacity: 1; } }
@media (min-width: 720px) { .sheet-bg { align-items: center; } .sheet { border-radius: 20px; } }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,0.92); z-index: 60; display: flex; align-items: center; justify-content: center; cursor: zoom-out; }
.lightbox img { max-width: 96vw; max-height: 92vh; border-radius: 8px; }

.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.emoji-grid button { font-size: 22px; padding: 6px 0; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.emoji-grid button.sel { border-color: var(--accent); background: rgba(34,211,238,0.15); }
.name-list { max-height: 220px; overflow: auto; border: 1px solid var(--border); border-radius: 12px; background: #0b1322; }
.name-list button { display: flex; width: 100%; text-align: left; padding: 10px 12px; background: none; border: 0; border-bottom: 1px solid var(--border); gap: 8px; align-items: center; }
.name-list button:last-child { border-bottom: 0; }
.name-list button.sel { background: rgba(34,211,238,0.15); }
.name-list button:disabled { opacity: 0.45; }

.world { text-align: center; padding: 30px 12px; }
.world .big { font-size: 72px; line-height: 1; margin-bottom: 10px; animation: spin 12s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 45; overflow: hidden; }
.confetti span { position: absolute; top: -20px; font-size: 22px; animation: fall 1.8s ease-in forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); opacity: 0.2; } }

table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tbl th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; cursor: pointer; white-space: nowrap; user-select: none; }
.tbl tr:hover td { background: rgba(255,255,255,0.02); }
.tbl td.num, .tbl th.num { text-align: right; font-family: var(--mono); }
.tbl-wrap { overflow: auto; -webkit-overflow-scrolling: touch; }
.status { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.status.on { background: rgba(52,211,153,0.15); color: var(--ok); }
.status.paused { background: rgba(251,191,36,0.15); color: var(--amber); }
.status.off { background: rgba(248,113,113,0.15); color: var(--danger); }

.tabs { display: flex; gap: 6px; overflow: auto; padding-bottom: 6px; margin-bottom: 14px; }
.tabs button { white-space: nowrap; padding: 9px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); font-weight: 600; position: relative; }
.tabs button.active { background: rgba(34,211,238,0.15); color: var(--accent); border-color: rgba(34,211,238,0.5); }
.tabs button .badge { margin-left: 6px; }

.msg { max-width: 85%; padding: 10px 12px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); }
.msg.mine { align-self: flex-end; background: rgba(34,211,238,0.15); border-color: rgba(34,211,238,0.4); }
.msg .when { font-size: 11px; color: var(--muted); margin-top: 4px; }
.thread { display: flex; flex-direction: column; gap: 8px; }

.drawer-bg { position: fixed; inset: 0; background: rgba(2, 6, 14, 0.6); z-index: 40; display: flex; justify-content: flex-end; }
.drawer { width: min(560px, 100%); height: 100%; overflow: auto; background: var(--surface); border-left: 1px solid var(--border); padding: 18px; animation: slide 0.2s ease; }
@keyframes slide { from { transform: translateX(30px); opacity: 0.5; } to { transform: none; opacity: 1; } }
.qr-box { background: #fff; padding: 16px; border-radius: 16px; display: inline-block; }
.qr-box svg { width: min(70vw, 360px); height: auto; display: block; }
pre.code { background: #0b1322; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; overflow: auto; font-size: 12px; }
hr.sep { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.2); border-top-color: var(--accent); border-radius: 50%; animation: rot 0.8s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }
@media print { body { background: #fff; color: #000; } .no-print { display: none !important; } .app { padding: 0; } .card { box-shadow: none; border-color: #ccc; } }
