/* Fun Chat - visual design */
:root {
  --bg: #f5f4fb;
  --panel: #ffffff;
  --panel-2: #f6f5fc;
  --line: #e7e5f2;
  --text: #1d1b2f;
  --muted: #6e6a88;
  --brand-1: #6a4cff;
  --brand-2: #b44cf0;
  --brand-3: #ff4f8b;
  --grad: linear-gradient(135deg, var(--brand-1) 0%, var(--brand-2) 55%, var(--brand-3) 100%);
  --accent: #6a4cff;
  --accent-2: #5536f0;
  --accent-soft: #efebff;
  --theirs: #ffffff;
  --danger: #e5484d;
  --ok: #19a463;
  --warn: #e39b1b;
  --male-g: linear-gradient(135deg, #3b82f6, #22c3ee);
  --female-g: linear-gradient(135deg, #ff4f8b, #ff9a5a);
  --other-g: linear-gradient(135deg, #8b5cf6, #6366f1);
  --bot-g: linear-gradient(135deg, #10b981, #3b82f6);
  --male: #2f74e6;
  --female: #e8457f;
  --other: #7c4ff0;
  --p0: #f5b40b;
  --p1: #ef4462;
  --shadow-s: 0 1px 2px rgba(30, 20, 80, 0.06), 0 2px 8px rgba(30, 20, 80, 0.05);
  --shadow: 0 10px 30px rgba(40, 20, 120, 0.12);
  --radius: 18px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0d18;
    --panel: #171528;
    --panel-2: #1f1d35;
    --line: #2b2847;
    --text: #eeecfa;
    --muted: #a09cbf;
    --accent: #8b74ff;
    --accent-2: #a594ff;
    --accent-soft: #2a2552;
    --theirs: #221f3a;
    --shadow-s: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, "SF Pro Text", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.hidden { display: none !important; }
::selection { background: rgba(106, 76, 255, 0.25); }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 12px;
  padding: 9px 16px;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.08s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--grad); border: 0; color: #fff; box-shadow: 0 6px 18px rgba(106, 76, 255, 0.3); }
.btn.primary:hover { box-shadow: 0 8px 24px rgba(106, 76, 255, 0.42); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.big { width: 100%; padding: 13px; font-size: 16px; border-radius: 14px; }
.btn:disabled { opacity: 0.55; cursor: default; transform: none; }
.btn.small { padding: 6px 12px; font-size: 13px; border-radius: 10px; }

.icon-btn {
  width: 40px; height: 40px; flex: 0 0 40px;
  border: 0; border-radius: 12px; background: transparent; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted);
  transition: background 0.15s ease, color 0.15s ease;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--accent); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.send { background: var(--grad); color: #fff; border-radius: 50%; box-shadow: 0 4px 14px rgba(106, 76, 255, 0.35); }
.icon-btn.send:hover { color: #fff; filter: brightness(1.08); }
.icon-btn.on-brand { color: rgba(255, 255, 255, 0.85); }
.icon-btn.on-brand:hover { background: rgba(255, 255, 255, 0.18); color: #fff; }

/* ---------- landing ---------- */
.screen { height: 100%; }
#landing {
  position: relative; overflow-x: hidden; overflow-y: auto;
  min-height: 100%;
  display: flex; flex-direction: column;
  background: linear-gradient(140deg, #2a1b8f 0%, #5b2fd1 40%, #a83ce0 70%, #ff4f8b 100%);
  color: #fff;
}
.blobs span {
  position: absolute; border-radius: 50%; filter: blur(60px); opacity: 0.55; pointer-events: none;
  animation: drift 18s ease-in-out infinite alternate;
}
.blobs span:nth-child(1) { width: 420px; height: 420px; background: #ff7ab6; top: -120px; right: -80px; }
.blobs span:nth-child(2) { width: 360px; height: 360px; background: #4cc9ff; bottom: -140px; left: -100px; animation-delay: -6s; }
.blobs span:nth-child(3) { width: 260px; height: 260px; background: #ffd166; top: 40%; left: 45%; opacity: 0.25; animation-delay: -12s; }
@keyframes drift { from { transform: translate(0, 0) scale(1); } to { transform: translate(40px, 30px) scale(1.12); } }

.land-top { position: relative; display: flex; align-items: center; justify-content: space-between; padding: 18px 28px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 22px; letter-spacing: -0.3px; }
.brand-mark { width: 38px; height: 38px; }
.brand.small { font-size: 18px; flex: 1; color: #fff; }
.brand.small .brand-mark { width: 30px; height: 30px; }
.top-link { color: rgba(255, 255, 255, 0.85); text-decoration: none; font-weight: 600; }
.top-link:hover { color: #fff; }

.landing-wrap {
  position: relative; flex: 1;
  display: flex; gap: 56px; align-items: center; justify-content: center;
  max-width: 1080px; width: 100%; margin: 0 auto; padding: 20px 28px 32px;
}
.landing-intro { flex: 1; min-width: 0; }
.landing-intro h1 { font-size: 56px; line-height: 1.04; margin: 18px 0 14px; letter-spacing: -1.5px; font-weight: 800; }
.landing-intro .hl {
  background: linear-gradient(90deg, #ffe08a, #ffb3d1);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tagline { font-size: 18px; color: rgba(255, 255, 255, 0.86); margin: 0 0 20px; max-width: 520px; }
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(255, 255, 255, 0.16); border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 6px 14px; border-radius: 999px; font-size: 14px; backdrop-filter: blur(8px);
}
.pulse { width: 9px; height: 9px; border-radius: 50%; background: #3df5a0; margin-right: 6px; animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(61, 245, 160, 0.6); } 70% { box-shadow: 0 0 0 9px rgba(61, 245, 160, 0); } 100% { box-shadow: 0 0 0 0 rgba(61, 245, 160, 0); } }
.chips { list-style: none; padding: 0; margin: 0 0 22px; display: flex; flex-wrap: wrap; gap: 8px; }
.chips li { background: rgba(255, 255, 255, 0.14); border-radius: 999px; padding: 6px 13px; font-size: 14px; font-weight: 600; }
.game-strip { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; max-width: 520px; }
.game-tile {
  background: rgba(255, 255, 255, 0.12); border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 16px; padding: 12px 4px 9px; text-align: center; font-size: 11px; font-weight: 700;
  display: flex; flex-direction: column; align-items: center; gap: 6px; backdrop-filter: blur(6px);
  transition: transform 0.2s ease, background 0.2s ease;
}
.game-tile:hover { transform: translateY(-3px); background: rgba(255, 255, 255, 0.2); }
.game-tile svg { width: 28px; height: 28px; }
.land-foot { position: relative; text-align: center; font-size: 13px; color: rgba(255, 255, 255, 0.7); padding: 0 16px 18px; }

.join-card {
  width: 390px; max-width: 100%; flex: 0 0 auto;
  background: var(--panel); color: var(--text);
  border-radius: 24px; padding: 28px;
  box-shadow: 0 30px 80px rgba(20, 0, 80, 0.35);
  display: flex; flex-direction: column; gap: 14px;
}
.join-card h2 { margin: 0; font-size: 26px; letter-spacing: -0.5px; }
.join-sub { margin: -10px 0 0; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.field input, .field select, .filters input, .filters select, .modal-card select, .modal-card textarea, .modal-card input[type=text] {
  border: 1.5px solid var(--line); background: var(--panel-2); border-radius: 12px; padding: 11px 13px;
  font-size: 15px; color: var(--text); width: 100%; min-width: 0; transition: border-color 0.15s ease, background 0.15s ease;
}
.field input:focus, .field select:focus, textarea:focus, .filters input:focus, .filters select:focus {
  outline: none; border-color: var(--accent); background: var(--panel);
}
.row2 { display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.seg button {
  border: 1.5px solid var(--line); background: var(--panel-2); border-radius: 12px; padding: 10px 4px;
  cursor: pointer; font-weight: 700; color: var(--text); transition: all 0.15s ease;
}
.seg button:hover { border-color: var(--accent); }
.seg button.on { color: #fff; border-color: transparent; box-shadow: 0 6px 16px rgba(60, 40, 160, 0.25); }
.seg button.on[data-v=m] { background: var(--male-g); }
.seg button.on[data-v=f] { background: var(--female-g); }
.seg button.on[data-v=o] { background: var(--other-g); }
.check { display: flex; gap: 9px; align-items: flex-start; font-size: 14px; }
.check input { margin-top: 2px; width: 17px; height: 17px; accent-color: var(--accent); }
.form-error { color: var(--danger); margin: 0; min-height: 1.2em; font-size: 14px; font-weight: 600; }
.notice { background: var(--accent-soft); color: var(--text); border-radius: 12px; padding: 10px 12px; margin: 0; font-size: 14px; }

/* ---------- main layout ---------- */
#main { display: flex; height: 100%; height: 100dvh; }
#sidebar {
  width: 350px; flex: 0 0 350px; background: var(--panel);
  border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0;
}
#convo {
  flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0;
  background:
    radial-gradient(circle at 15% 10%, rgba(106, 76, 255, 0.06), transparent 40%),
    radial-gradient(circle at 85% 90%, rgba(255, 79, 139, 0.06), transparent 40%),
    var(--bg);
}

.side-brand { display: flex; align-items: center; gap: 4px; padding: 12px 10px 12px 16px; background: var(--grad); }
.me { display: flex; align-items: center; gap: 11px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.me .nick { font-weight: 700; }
.me .sub { font-size: 12px; color: var(--muted); }

.tabs { display: grid; grid-template-columns: repeat(3, 1fr); padding: 8px 10px 0; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs button {
  border: 0; background: none; padding: 10px 4px 11px; cursor: pointer; color: var(--muted); font-weight: 700;
  border-bottom: 3px solid transparent; border-radius: 10px 10px 0 0; transition: color 0.15s ease;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.count { font-weight: 600; font-size: 12px; color: var(--muted); background: var(--panel-2); padding: 1px 7px; border-radius: 99px; }
.badge {
  display: inline-block; min-width: 19px; padding: 0 6px; border-radius: 10px;
  background: var(--brand-3); color: #fff; font-size: 11px; line-height: 19px; text-align: center; font-weight: 700;
}
.badge:empty { display: none; }

.pane { flex: 1; overflow: auto; min-height: 0; }
.filters { padding: 12px; display: flex; flex-direction: column; gap: 8px; position: sticky; top: 0; background: var(--panel); z-index: 1; border-bottom: 1px solid var(--line); }
.filters input, .filters select { padding: 8px 10px; font-size: 13px; border-radius: 10px; }
.filter-row { display: grid; grid-template-columns: 1fr 1fr 1.2fr; gap: 6px; }

.list { list-style: none; margin: 0; padding: 6px; }
.list li {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; cursor: pointer; border-radius: 14px;
  transition: background 0.12s ease;
}
.list li:hover { background: var(--panel-2); }
.list li.active { background: var(--accent-soft); }
.list li.away { opacity: 0.55; }
.list .info { flex: 1; min-width: 0; }
.list .name { font-weight: 650; display: flex; align-items: center; gap: 6px; }
.list .name .nick { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 11px; color: var(--muted); }
.tag { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; padding: 2px 7px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); font-weight: 800; white-space: nowrap; }
.tag.turn { background: var(--ok); color: #fff; }
.tag.bot { background: var(--bot-g); color: #fff; }
.empty-note { color: var(--muted); text-align: center; padding: 26px 16px; font-size: 14px; list-style: none; }
.empty-note:hover { background: none !important; cursor: default; }
.list li.botrow { background: linear-gradient(90deg, rgba(16, 185, 129, 0.09), rgba(59, 130, 246, 0.07)); margin-bottom: 4px; }

.avatar {
  width: 40px; height: 40px; flex: 0 0 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 16px; position: relative; text-transform: uppercase;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.12);
}
.avatar.m { background: var(--male-g); }
.avatar.f { background: var(--female-g); }
.avatar.o { background: var(--other-g); }
.avatar.bot { background: var(--bot-g); }
.avatar.room { background: var(--grad); border-radius: 13px; }
.avatar .st { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%; background: var(--ok); border: 2.5px solid var(--panel); }
.avatar .st.away { background: var(--warn); }
.avatar .st.gone { background: var(--muted); }

/* ---------- conversation ---------- */
.empty-convo { flex: 1; display: flex; align-items: center; justify-content: center; text-align: center; color: var(--muted); padding: 24px; }
.empty-inner h2 { color: var(--text); margin: 18px 0 6px; }
.empty-art {
  width: 120px; height: 120px; margin: 0 auto; border-radius: 36px; background: var(--grad);
  box-shadow: 0 20px 50px rgba(106, 76, 255, 0.35); position: relative; transform: rotate(-6deg);
}
.empty-art::before, .empty-art::after { content: ""; position: absolute; background: #fff; border-radius: 14px; }
.empty-art::before { left: 22px; top: 30px; width: 60px; height: 34px; }
.empty-art::after { right: 18px; bottom: 26px; width: 48px; height: 26px; opacity: 0.7; }

#convoView { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.convo-head {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px;
  background: color-mix(in srgb, var(--panel) 88%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line); position: relative; z-index: 2;
}
#backBtn { display: none; }
.convo-title { flex: 1; display: flex; align-items: center; gap: 11px; min-width: 0; }
.convo-title .t { font-weight: 750; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.convo-title .s { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.convo-actions { display: flex; gap: 2px; }

.messages { flex: 1; overflow-y: auto; padding: 18px 16px 8px; display: flex; flex-direction: column; gap: 3px; min-height: 0; }
.msg { display: flex; flex-direction: column; align-items: flex-start; max-width: 76%; animation: pop 0.18s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg .who { font-size: 12px; font-weight: 750; margin: 8px 0 2px 12px; cursor: pointer; }
.msg .who.m { color: var(--male); }
.msg .who.f { color: var(--female); }
.msg .who.o { color: var(--other); }
.msg .who:hover { text-decoration: underline; }
.bubble {
  background: var(--theirs); padding: 8px 13px; border-radius: 20px; border-top-left-radius: 6px;
  white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; box-shadow: var(--shadow-s);
}
.msg.mine .bubble { background: var(--grad); color: #fff; border-radius: 20px; border-top-right-radius: 6px; box-shadow: 0 4px 14px rgba(106, 76, 255, 0.22); }
.msg.mine .bubble a { color: #fff; }
.msg .time { font-size: 10px; color: var(--muted); margin: 2px 10px 3px; }
.msg.system { align-self: center; max-width: 90%; color: var(--muted); font-size: 12px; text-align: center; padding: 6px 12px; background: var(--panel-2); border-radius: 99px; margin: 6px 0; }
.day-sep { align-self: center; font-size: 11px; color: var(--muted); padding: 10px 0; font-weight: 600; }

.audio { display: flex; align-items: center; gap: 10px; min-width: 210px; }
.audio .play {
  width: 36px; height: 36px; border-radius: 50%; border: 0; cursor: pointer; flex: 0 0 36px;
  display: inline-flex; align-items: center; justify-content: center; background: var(--grad); color: #fff;
}
.msg.mine .audio .play { background: #fff; color: var(--brand-1); }
.audio .play svg { width: 16px; height: 16px; }
.audio .abar { flex: 1; height: 5px; border-radius: 3px; background: rgba(127, 127, 160, 0.3); overflow: hidden; }
.audio .afill { height: 100%; width: 0; background: currentColor; transition: width 0.1s linear; }
.audio .atime { font-size: 12px; font-variant-numeric: tabular-nums; min-width: 34px; }

.invite { display: flex; flex-direction: column; gap: 8px; min-width: 230px; }
.invite .ttl { font-weight: 750; display: flex; align-items: center; gap: 8px; }
.invite .ttl svg { width: 26px; height: 26px; flex: 0 0 26px; }
.invite .st { font-size: 13px; opacity: 0.9; }
.invite .acts { display: flex; gap: 6px; }
.msg.mine .invite .btn { color: var(--text); }

.typing { height: 20px; padding: 0 18px; font-size: 12px; color: var(--muted); font-style: italic; }

.composer { background: var(--panel); border-top: 1px solid var(--line); padding: 10px 12px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
.compose-row { display: flex; align-items: flex-end; gap: 6px; }
.compose-row textarea {
  flex: 1; resize: none; border: 1.5px solid var(--line); background: var(--panel-2); border-radius: 22px;
  padding: 9px 15px; max-height: 120px; min-height: 42px; line-height: 1.4; font-size: 15px;
}
.compose-disabled { text-align: center; color: var(--muted); padding: 10px; font-size: 14px; }
.rec-bar { display: flex; align-items: center; gap: 10px; padding: 2px 4px; }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.25; } }
#recTime { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 76px; }
.rec-meter { flex: 1; height: 8px; background: var(--panel-2); border-radius: 4px; overflow: hidden; }
#recLevel { height: 100%; width: 0; background: var(--grad); transition: width 0.08s linear; }

/* ---------- games ---------- */
/* Conversation body: chat column + game panel.
   Narrow screens: the board sits above the chat. Wide screens: side by side. */
.convo-body { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-col { flex: 1; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.game-panel {
  margin: 12px 12px 0; background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px 16px 16px; display: flex; flex-direction: column; align-items: center; gap: 10px;
  overflow-y: auto; flex: 0 0 auto; max-height: 100%;
  container-type: inline-size;
  /* board edge: fits the panel width and leaves room for the chat below */
  --bs: max(220px, min(calc(100cqi - 8px), calc(100dvh - 400px), 440px));
}
@media (min-width: 1000px) {
  .convo-body.with-game { flex-direction: row-reverse; }
  .convo-body.with-game .game-panel {
    width: clamp(380px, 48%, 620px); margin: 12px 12px 12px 0; max-height: none; justify-content: flex-start;
    --bs: max(240px, min(calc(100cqi - 8px), calc(100dvh - 300px), 580px));
  }
}
.game-panel.min { padding-bottom: 12px; }
.game-head { width: 100%; display: flex; align-items: center; gap: 8px; }
.game-head .gicon { width: 30px; height: 30px; color: var(--accent); }
.game-head .gicon svg { width: 30px; height: 30px; }
.game-head .gname { font-weight: 750; flex: 1; min-width: 0; }
.game-head .gname small { display: block; font-weight: 600; color: var(--muted); font-size: 12px; }
.game-status { font-weight: 700; text-align: center; padding: 4px 14px; border-radius: 99px; background: var(--panel-2); }
.game-status.win { color: #fff; background: var(--ok); }
.game-status.lose { color: #fff; background: var(--danger); }
.game-status.turn { color: #fff; background: var(--grad); }
.game-acts { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

.game-panel > * { flex-shrink: 0; }
.ttt { display: grid; grid-template-columns: repeat(3, 70px); grid-template-rows: repeat(3, 70px); gap: 7px; }
.ttt button { border: 0; background: var(--panel-2); border-radius: 14px; font-size: 34px; font-weight: 900; cursor: pointer; color: var(--text); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.06); }
.ttt button:not(:disabled):hover { background: var(--accent-soft); }
.ttt button.p0 { color: var(--p0); }
.ttt button.p1 { color: var(--p1); }
.ttt button.win { background: var(--accent-soft); outline: 2px solid var(--accent); }
.ttt button:disabled { cursor: default; }

.c4 { display: grid; grid-template-columns: repeat(7, 40px); gap: 5px; background: linear-gradient(160deg, #5a3cf0, #7b4cf5); padding: 8px; border-radius: 16px; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.2); }
.c4 button { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--panel); cursor: pointer; padding: 0; box-shadow: inset 0 3px 4px rgba(0, 0, 0, 0.18); }
.c4 button.p0 { background: radial-gradient(circle at 35% 30%, #ffe27a, var(--p0)); }
.c4 button.p1 { background: radial-gradient(circle at 35% 30%, #ff8fa3, var(--p1)); }
.c4 button.win { box-shadow: 0 0 0 3px #fff inset; }
.c4 button.last { outline: 2px solid #fff; outline-offset: -7px; }
.c4 button:disabled { cursor: default; }
.c4.myturn button:not(.p0):not(.p1):hover { background: var(--accent-soft); }

.rps { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.rps .score { font-size: 24px; font-weight: 900; font-variant-numeric: tabular-nums; }
.rps .picks { display: flex; gap: 10px; }
.rps .picks button {
  width: 96px; padding: 12px 6px; border-radius: 16px; border: 1.5px solid var(--line); background: var(--panel-2);
  cursor: pointer; font-weight: 750; display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--text);
  transition: transform 0.1s ease;
}
.rps .picks button:not(:disabled):hover { transform: translateY(-2px); border-color: var(--accent); }
.rps .picks button svg { width: 34px; height: 34px; }
.rps .picks button.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.rps .picks button:disabled { cursor: default; opacity: 0.75; }
.rps .last { font-size: 13px; color: var(--muted); text-align: center; }
.legend { font-size: 12px; color: var(--muted); display: flex; gap: 14px; align-items: center; flex-wrap: wrap; justify-content: center; }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.legend i.c-p0 { background: var(--p0); }
.legend i.c-p1 { background: var(--p1); }
.legend i.c-dark { background: #2b2b33; }
.legend i.c-light { background: #f2f2f2; border: 1px solid #999; }

/* 8x8 boards: chess, checkers, reversi */
.board {
  display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr);
  width: var(--bs); height: var(--bs); flex: 0 0 auto;
  border-radius: 10px; overflow: hidden; box-shadow: 0 8px 24px rgba(30, 20, 60, 0.25);
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.sq { position: relative; border: 0; padding: 0; margin: 0; cursor: pointer; display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 0; overflow: hidden; }
.sq:disabled { cursor: default; }
.sq.light { background: #f0d9b5; }
.sq.dark { background: #b58863; }
.sq.last.light { background: #f6eb72; }
.sq.last.dark { background: #dcc34b; }
.sq.sel { box-shadow: inset 0 0 0 4px rgba(106, 76, 255, 0.85); }
.sq.check { background: radial-gradient(circle, #ff5a5a 0%, #e5484d 45%, transparent 75%) !important; }
.sq.dot::after { content: ""; width: 28%; height: 28%; border-radius: 50%; background: rgba(40, 20, 120, 0.35); }
.sq.cap::after { content: ""; position: absolute; inset: 4%; border-radius: 50%; border: 4px solid rgba(40, 20, 120, 0.35); }
.sq .coord { position: absolute; font-size: 10px; font-weight: 700; opacity: 0.7; pointer-events: none; }
.sq .coord.rank { top: 2px; left: 3px; }
.sq .coord.file { bottom: 1px; right: 3px; }
.sq.light .coord { color: #b58863; }
.sq.dark .coord { color: #f0d9b5; }
.pc { font-size: calc(var(--bs) * 0.098); line-height: 1; pointer-events: none; font-family: "Segoe UI Symbol", "DejaVu Sans", "Noto Sans Symbols 2", "Apple Symbols", serif; }
.pc.w { color: #fff; -webkit-text-stroke: 1.2px #2a2a2a; text-shadow: 0 2px 2px rgba(0, 0, 0, 0.35); }
.pc.b { color: #1d1d22; text-shadow: 0 1px 1px rgba(255, 255, 255, 0.25), 0 2px 3px rgba(0, 0, 0, 0.35); }
.captured { display: flex; flex-wrap: wrap; gap: 0 1px; min-height: 22px; font-size: 18px; align-items: center; justify-content: center; max-width: var(--bs); flex: 0 0 auto; }
.captured .pc { font-size: 18px; }
.captured.empty { visibility: hidden; }

.board.checkers .sq.light { background: #f3e3c3; }
.board.checkers .sq.dark { background: #6b4a33; }
.board.checkers .sq.last.dark { background: #8a6a3a; }
.man {
  width: 76%; height: 76%; border-radius: 50%; pointer-events: none; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35), inset 0 0 0 4px rgba(255, 255, 255, 0.12), inset 0 0 0 7px rgba(0, 0, 0, 0.12);
}
.man.s0 { background: radial-gradient(circle at 35% 30%, #ff8a8a, #c62835); }
.man.s1 { background: radial-gradient(circle at 35% 30%, #5d5d6a, #17171c); }
.man.king::after { content: "K"; color: #ffd84a; font-weight: 900; font-size: calc(var(--bs) * 0.045); text-shadow: 0 1px 1px rgba(0, 0, 0, 0.6); }

.board.reversi { background: #0f7a4a; gap: 2px; padding: 2px; }
.board.reversi .sq { background: #179457; border-radius: 3px; }
.board.reversi .sq.last { background: #1fb36b; }
.board.reversi .sq.dot::after { background: rgba(0, 0, 0, 0.28); width: 24%; height: 24%; }
.disc { width: 82%; height: 82%; border-radius: 50%; pointer-events: none; box-shadow: 0 2px 3px rgba(0, 0, 0, 0.4); transition: background 0.25s ease; }
.disc.s0 { background: radial-gradient(circle at 35% 30%, #55555f, #121216); }
.disc.s1 { background: radial-gradient(circle at 35% 30%, #ffffff, #d6d6dc); }
.score-row { display: flex; gap: 18px; font-weight: 800; font-size: 18px; align-items: center; }
.score-row span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- modal / toasts ---------- */
.modal { position: fixed; inset: 0; background: rgba(14, 8, 40, 0.55); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; animation: fade 0.15s ease-out; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  background: var(--panel); border-radius: 22px; box-shadow: var(--shadow); width: 440px; max-width: 100%;
  max-height: 90vh; overflow: auto; padding: 22px; display: flex; flex-direction: column; gap: 12px;
  animation: pop 0.18s ease-out;
}
.modal-card h3 { margin: 0; font-size: 20px; }
.modal-card p { margin: 0; }
.modal-card .sub { color: var(--muted); font-size: 14px; }
.modal-card .acts { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.modal-card ol { margin: 0; padding-left: 20px; }
.modal-card ol li { margin-bottom: 6px; }
.game-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.game-pick button {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left;
  border: 1.5px solid var(--line); background: var(--panel-2); border-radius: 16px; padding: 14px; cursor: pointer; color: var(--text);
  transition: transform 0.1s ease, border-color 0.15s ease;
}
.game-pick button:hover { border-color: var(--accent); transform: translateY(-2px); }
.game-pick b { display: block; }
.game-pick span.d { font-size: 12px; color: var(--muted); }
.game-pick svg { width: 34px; height: 34px; color: var(--accent); }
.promo { display: flex; gap: 10px; justify-content: center; }
.promo button { width: 64px; height: 64px; border-radius: 14px; border: 1.5px solid var(--line); background: #f0d9b5; cursor: pointer; }
.promo button .pc { font-size: 40px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; }
.switch input { width: 18px; height: 18px; accent-color: var(--accent); }
.profile-head { display: flex; align-items: center; gap: 14px; }
.profile-head .avatar { width: 56px; height: 56px; flex-basis: 56px; font-size: 24px; }
.share-box { display: flex; gap: 8px; }
.share-box input { flex: 1; }

.toasts { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 60; width: min(420px, calc(100% - 32px)); pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: 11px 15px; border-radius: 14px; box-shadow: var(--shadow); font-size: 14px; pointer-events: auto; cursor: pointer; animation: tin 0.2s ease-out; font-weight: 600; }
.toast.error { background: var(--danger); color: #fff; }
.toast.info { background: var(--grad); color: #fff; }
@keyframes tin { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.conn { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--warn); color: #fff; padding: 9px 16px; border-radius: 12px; font-weight: 700; font-size: 14px; z-index: 55; box-shadow: var(--shadow); }

/* ---------- mobile ---------- */
@media (max-width: 860px) {
  .landing-wrap { flex-direction: column; gap: 26px; padding-top: 4px; }
  .landing-intro { text-align: center; }
  .landing-intro h1 { font-size: 40px; }
  .tagline { margin-left: auto; margin-right: auto; font-size: 16px; }
  .chips { justify-content: center; }
  .game-strip { margin: 0 auto; grid-template-columns: repeat(3, 1fr); max-width: 360px; }
  .land-top { padding: 14px 16px; }
}
@media (max-width: 760px) {
  #sidebar { width: 100%; flex: 1 1 auto; border-right: 0; }
  #convo { display: none; }
  body.in-convo #sidebar { display: none; }
  body.in-convo #convo { display: flex; }
  #backBtn { display: inline-flex; }
  .msg { max-width: 88%; }
  .game-panel { margin: 8px 8px 0; padding: 8px 10px 10px; gap: 8px; --bs: max(200px, min(calc(100cqi - 4px), calc(100dvh - 330px), 440px)); }
  /* on phones the header line already shows the status: keep the board and the chat */
  .game-panel .legend, .game-panel .captured, .game-panel .game-status { display: none; }
  .ttt { grid-template-columns: repeat(3, 62px); grid-template-rows: repeat(3, 62px); }
  .c4 { grid-template-columns: repeat(7, 36px); gap: 4px; }
  .c4 button { width: 36px; height: 36px; }
  .rps .picks button { width: 86px; }
  .game-pick { grid-template-columns: 1fr 1fr; }
  .join-card { padding: 22px; }
}
