:root {
  --bg: #0c0d16;
  --bg-2: #141626;
  --card: #1a1d31;
  --line: #2a2e4a;
  --text: #ecebf7;
  --muted: #9a9bb8;
  --common: #3ee0c8;
  --rare: #a98bff;
  --meant: #ff7ab0;
  --meant-2: #ffbe5c;
  --ok: #3ee08a;
  --bad: #ff6b6b;
  --tier: var(--common);
  --radius: 18px;
  --sans: 'Space Grotesk', system-ui, -apple-system, Segoe UI, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--sans);
  background:
    radial-gradient(1000px 600px at 85% -10%, rgba(169, 139, 255, 0.12), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(62, 224, 200, 0.08), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }

.tier-common { --tier: var(--common); }
.tier-rare { --tier: var(--rare); }
.tier-meant { --tier: var(--meant); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px max(16px, env(safe-area-inset-left));
  background: rgba(12, 13, 22, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  background: none; border: 0; padding: 0;
  font-weight: 700; font-size: 1.25rem; letter-spacing: -0.03em;
}
.brand img { display: block; filter: drop-shadow(0 0 6px rgba(176, 124, 255, 0.35)); }
.brand .word { color: #f3f2fb; }
.brand .word span {
  background: linear-gradient(90deg, #4ee8ee, #8fa8ff 40%, #b98cff 70%, #ff6fb8);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
@media (max-width: 380px) { .brand .word { display: none; } }

.hero-mark {
  display: block; width: clamp(96px, 18vw, 132px); height: auto; margin-bottom: 18px;
  filter: drop-shadow(0 0 18px rgba(176, 124, 255, 0.35));
}
.round-timer { display: flex; align-items: baseline; gap: 8px; font-size: 0.9rem; }
.round-timer .label { color: var(--muted); }
.round-timer .mono { font-size: 1.05rem; color: var(--text); }
@media (max-width: 420px) { .round-timer .label { display: none; } }

main { max-width: 980px; margin: 0 auto; padding: 24px 16px 48px; }

/* ---------- home ---------- */
.hero { margin: 20px 0 32px; }
.hero h1 { font-size: clamp(1.8rem, 5vw, 3rem); line-height: 1.1; letter-spacing: -0.03em; margin: 0 0 14px; }
.hero h1 em { font-style: normal; color: var(--muted); }
.hero p { max-width: 60ch; color: var(--muted); margin: 0; font-size: 1.05rem; }
.loading { color: var(--muted); }

.tiers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 760px) { .tiers { grid-template-columns: 1fr; } }

.tier-card {
  position: relative; overflow: hidden; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; min-height: 190px;
  display: flex; flex-direction: column; gap: 10px;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.tier-card::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(400px 200px at 100% 0%, color-mix(in srgb, var(--tier) 22%, transparent), transparent 70%);
  pointer-events: none;
}
.tier-card:hover, .tier-card:focus-visible {
  transform: translateY(-3px); border-color: var(--tier);
  box-shadow: 0 10px 40px -10px color-mix(in srgb, var(--tier) 50%, transparent);
  outline: none;
}
.tier-card .dots { display: flex; gap: 6px; }
.tier-card .dots i { width: 26px; height: 26px; border-radius: 7px; border: 2px solid var(--tier); opacity: 0.85; }
.tier-card h3 { margin: 6px 0 0; font-size: 1.5rem; letter-spacing: -0.02em; }
.tier-card .odds { color: var(--tier); font-weight: 500; font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.08em; }
.tier-card .stat { margin-top: auto; color: var(--muted); font-size: 0.92rem; }
.tier-meant { background-image: linear-gradient(135deg, rgba(255, 122, 176, 0.06), rgba(255, 190, 92, 0.06)); }
.tier-meant h3 {
  background: linear-gradient(90deg, var(--meant), var(--meant-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ---------- reveal ---------- */
.reveal { margin-top: 48px; }
.reveal h2 { margin: 0; letter-spacing: -0.02em; }
.reveal > p { margin: 4px 0 18px; }
.reveal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.reveal-card { background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.reveal-card header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.reveal-card .acr { font-family: var(--mono); font-weight: 800; color: var(--tier); letter-spacing: 0.12em; }
.reveal-card ol { margin: 0; padding-left: 20px; }
.reveal-card li { margin: 2px 0; }
.reveal-card li span { color: var(--muted); font-size: 0.85rem; }
.reveal-card .empty { color: var(--muted); font-size: 0.9rem; margin: 0; }

/* ---------- tier view ---------- */
.back {
  background: none; border: 0; color: var(--muted); padding: 6px 0; font-size: 0.95rem;
}
.back:hover { color: var(--text); }
.tier-head h2 { font-size: clamp(1.6rem, 4vw, 2.4rem); margin: 10px 0 4px; letter-spacing: -0.02em; color: var(--tier); }
.tier-head p { margin: 0 0 24px; }
.acronyms { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
@media (max-width: 520px) { .acronyms { grid-template-columns: 1fr 1fr; gap: 10px; } }
.acr-tile {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 12px 16px; text-align: center;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.acr-tile:hover, .acr-tile:focus-visible { transform: translateY(-3px); border-color: var(--tier); outline: none; }
.acr-tile .letters { display: flex; justify-content: center; gap: 4px; flex-wrap: nowrap; }
.acr-tile .letters span {
  font-family: var(--mono); font-weight: 800; font-size: clamp(1.05rem, 3.6vw, 1.9rem);
  width: 1.6em; height: 1.8em; display: grid; place-items: center;
  border-radius: 10px; background: color-mix(in srgb, var(--tier) 12%, var(--bg-2));
  color: var(--tier);
}
.acr-tile .meta { margin-top: 14px; color: var(--muted); font-size: 0.9rem; }
.acr-tile .cta { margin-top: 6px; font-weight: 500; }

/* ---------- dialog ---------- */
dialog {
  width: min(480px, calc(100vw - 32px));
  background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: 22px; padding: 24px;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.7);
}
dialog::backdrop { background: rgba(5, 6, 12, 0.7); backdrop-filter: blur(4px); }
.badge {
  display: inline-block; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--tier); border: 1px solid color-mix(in srgb, var(--tier) 50%, transparent);
  border-radius: 999px; padding: 3px 10px;
}
.chips { display: flex; gap: 8px; justify-content: center; margin: 18px 0 22px; flex-wrap: wrap; }
.chip { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 56px; }
.chip b {
  font-family: var(--mono); font-size: 1.8rem; font-weight: 800;
  width: 52px; height: 58px; display: grid; place-items: center; border-radius: 12px;
  background: var(--bg-2); border: 2px solid var(--line); color: var(--muted);
  transition: all 0.15s ease;
}
.chip small { font-size: 0.75rem; color: var(--muted); max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-height: 1.2em; }
.chip.ok b { border-color: var(--ok); color: var(--ok); background: rgba(62, 224, 138, 0.08); }
.chip.bad b { border-color: var(--bad); color: var(--bad); background: rgba(255, 107, 107, 0.08); }
.chip.next b { border-color: var(--tier); color: var(--tier); }
label { display: block; font-size: 0.9rem; color: var(--muted); margin-bottom: 14px; }
label input {
  display: block; width: 100%; margin-top: 6px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; font-size: 1.05rem; color: var(--text);
}
label input:focus, .composer input:focus { outline: 2px solid var(--tier); outline-offset: 1px; border-color: transparent; }
.error { color: var(--bad); min-height: 1.5em; margin: 0 0 10px; font-size: 0.92rem; }
.actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.fine { color: var(--muted); font-size: 0.8rem; margin: 14px 0 0; text-align: center; }

button[type='submit'], #closedBtn, .actions button:not(.ghost) {
  background: var(--tier); color: #0c0d16; border: 0; border-radius: 12px;
  padding: 11px 18px; font-weight: 700;
}
button[disabled] { opacity: 0.4; cursor: not-allowed; }
.ghost { background: transparent; border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; }
.ghost:hover { border-color: var(--muted); }

/* ---------- room ---------- */
.room { display: flex; flex-direction: column; height: calc(100dvh - 64px - 24px); min-height: 460px; }
.room-head { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; }
.room-title { text-align: center; }
.room-title .acr { margin: 6px 0 0; font-size: clamp(1.6rem, 5vw, 2.2rem); letter-spacing: 0.2em; color: var(--tier); }
.room-title .phrase { margin: 0; font-size: 1.1rem; font-weight: 500; }
.room-timer { color: var(--muted); font-size: 0.85rem; text-align: right; }
.room-timer .mono { display: block; color: var(--text); font-size: 1.05rem; }
.room-timer.urgent .mono { color: var(--bad); }

.members { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin: 14px 0 6px; }
.member {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 12px 4px 8px; font-size: 0.85rem;
}
.member::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.member.online::before { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.member.me { border-color: color-mix(in srgb, var(--tier) 50%, transparent); }

.waiting { text-align: center; margin: 24px auto 8px; max-width: 420px; }
.waiting p { margin: 4px 0; }
.pulse {
  width: 18px; height: 18px; margin: 0 auto 14px; border-radius: 50%; background: var(--tier);
  animation: pulse 1.8s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--tier) 70%, transparent); }
  100% { box-shadow: 0 0 0 26px transparent; }
}

.messages { list-style: none; margin: 8px 0; padding: 8px 4px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.msg { display: flex; flex-direction: column; max-width: 80%; align-self: flex-start; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg .who { display: flex; gap: 8px; align-items: baseline; font-size: 0.8rem; color: var(--muted); }
.msg .who button { background: none; border: 0; padding: 0; font-weight: 700; color: var(--c, var(--tier)); }
.msg .who button:hover { text-decoration: underline; }
.msg .bubble {
  background: var(--card); border: 1px solid var(--line); border-radius: 4px 16px 16px 16px;
  padding: 8px 12px; margin-top: 3px; white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg.mine .bubble { background: color-mix(in srgb, var(--tier) 18%, var(--card)); border-color: transparent; border-radius: 16px 4px 16px 16px; }
.sys { align-self: center; color: var(--muted); font-size: 0.85rem; text-align: center; }
.sys.hi { color: var(--tier); font-weight: 500; }

.composer { display: flex; gap: 8px; padding: 10px 0 max(4px, env(safe-area-inset-bottom)); }
.composer input {
  flex: 1; min-width: 0; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 14px; padding: 13px 16px; font-size: 1rem;
}

/* ---------- paid features ---------- */
.badge.lock { --tier: var(--meant-2); margin-left: 6px; }
.room-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 4px 0 6px; }
.pill {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 14px; font-size: 0.88rem; font-weight: 500;
}
.pill:hover { border-color: var(--tier); }
.pill.gold { border-color: color-mix(in srgb, var(--meant-2) 45%, transparent); color: var(--meant-2); }
.hold { text-align: center; margin: 16px auto 4px; max-width: 420px; }
.hold p { margin: 4px 0; }
.hold .pulse { background: var(--meant-2); }

.pay-title { margin: 0 0 14px; font-size: 1.3rem; letter-spacing: -0.02em; }
.pay-opt { background: var(--bg-2); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin-bottom: 12px; }
.pay-opt h4 { margin: 0 0 6px; font-size: 1.05rem; }
.pay-opt p { margin: 0 0 12px; font-size: 0.9rem; }
.pay-opt.buyout { border-color: color-mix(in srgb, var(--meant-2) 35%, var(--line)); }
.amounts { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.amounts button {
  flex: 1; min-width: 64px; background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 6px; display: flex; flex-direction: column; align-items: center; line-height: 1.2;
}
.amounts button b { font-size: 1.05rem; }
.amounts button small { color: var(--muted); font-size: 0.75rem; }
.amounts button.on { border-color: var(--tier); background: color-mix(in srgb, var(--tier) 12%, var(--card)); }
.pay-btn {
  width: 100%; background: var(--tier); color: #0c0d16; border: 0; border-radius: 12px;
  padding: 12px 16px; font-weight: 700;
}
.pay-btn.gold { background: linear-gradient(90deg, var(--meant), var(--meant-2)); }
.composer input:disabled { opacity: 0.5; }

/* ---------- menu / overlay / toast ---------- */
.menu {
  position: fixed; z-index: 30; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 4px; display: flex; flex-direction: column; min-width: 140px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.menu button { background: none; border: 0; text-align: left; padding: 9px 12px; border-radius: 8px; }
.menu button:hover { background: var(--bg-2); }
.menu button[data-act='report'] { color: var(--bad); }

.overlay { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgba(5, 6, 12, 0.8); backdrop-filter: blur(6px); }
.overlay-card { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 28px; max-width: 400px; text-align: center; }
.overlay-card h2 { margin: 0 0 8px; }
.overlay-card p { margin: 0 0 20px; }

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 50;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  font-weight: 500; max-width: calc(100vw - 32px); text-align: center;
  animation: toast-in 0.2s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ---------- celebration ---------- */
.burst { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.burst i {
  position: absolute; top: -20px; width: 10px; height: 14px; border-radius: 2px;
  animation: fall var(--d, 2.4s) cubic-bezier(0.2, 0.6, 0.4, 1) forwards;
}
@keyframes fall {
  to { transform: translate(var(--x, 0), 110vh) rotate(var(--r, 540deg)); opacity: 0.2; }
}
.burst .meant-banner {
  position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%);
  font-size: clamp(2rem, 8vw, 4.5rem); font-weight: 700; letter-spacing: -0.03em; white-space: nowrap;
  background: linear-gradient(90deg, var(--meant), var(--meant-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: banner 3s ease forwards;
}
@keyframes banner {
  0% { opacity: 0; transform: translate(-50%, -40%) scale(0.8); }
  15%, 75% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(1.05); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition: none !important; }
}
