/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: 999px; font-weight: 700;
  background: var(--card-2); color: var(--ink); border: 1px solid var(--line);
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.danger { background: var(--bad); color: #fff; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: 0.85rem; }
.btn.big { min-height: 52px; font-size: 1.05rem; padding: 12px 28px; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--card-2); }
.icon-btn.recording { background: var(--bad); color: #fff; animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }

/* ---------- search ---------- */
.search { display: flex; align-items: center; gap: 10px; padding: 0 14px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; color: var(--ink-2); }
.search-input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; height: 46px; color: var(--ink); }

/* ---------- game cards ---------- */
.game-card { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.card-thumb { position: relative; aspect-ratio: 16 / 9; background: linear-gradient(135deg, var(--card-2), var(--bg-2)); overflow: hidden; }
.card-thumb img, .card-thumb video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.card-body { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 12px; padding: 12px 14px 14px; }
.card-icon { width: 44px; height: 44px; border-radius: 12px; }
.card-title { font-size: 1.02rem; font-family: var(--font-display); }
.card-desc { font-size: 0.82rem; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.fav-btn { position: absolute; top: 10px; right: 10px; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: rgba(20, 19, 28, 0.55); color: #fff; }
.fav-btn svg { fill: none; stroke: currentColor; stroke-width: 2; }
.fav-btn.on { color: var(--accent); background: #fff; }
.fav-btn.on svg { fill: currentColor; }

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-weight: 600; }
.resume-list { display: grid; gap: 10px; }
.resume-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); text-align: left; width: 100%; }
.resume-card img { border-radius: 10px; }
.resume-text { flex: 1; display: grid; }
.resume-text small { color: var(--ink-2); }

/* ---------- play hub ---------- */
.hub { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; margin-top: 12px; }
.hub-card { min-width: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 10px; }
.hub-card h3 { font-family: var(--font-display); font-size: 1.15rem; }
.hub-card p { color: var(--ink-2); font-size: 0.9rem; }
.hub-card.searching { justify-items: center; text-align: center; padding: 32px 16px; }
.join-row { display: flex; gap: 10px; }
.code-input { flex: 1; min-width: 0; height: 46px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--bg-2); padding: 0 14px; text-transform: uppercase; letter-spacing: 0.25em; font-weight: 700; font-size: 1.1rem; text-align: center; }
.option-controls { display: flex; gap: 12px; flex-wrap: wrap; }
.field { display: grid; gap: 4px; font-size: 0.8rem; color: var(--ink-2); }
.select { height: 44px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--bg-2); padding: 0 12px; }

/* ---------- history / profile / settings ---------- */
.history-list { display: grid; gap: 10px; margin-bottom: 14px; }
.history-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); border-left-width: 5px; }
.history-row.win { border-left-color: var(--good); }
.history-row.loss { border-left-color: var(--bad); }
.history-row.draw { border-left-color: var(--gold); }
.history-icon { border-radius: 10px; }
.history-main { flex: 1; display: grid; min-width: 0; }
.history-main small, .history-opp { color: var(--ink-2); font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { padding: 4px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 700; background: var(--card-2); }
.badge.win { background: var(--good); color: #fff; }
.badge.loss { background: var(--bad); color: #fff; }
.badge.draw { background: var(--gold); color: #3a2a00; }

.profile-card { text-align: center; display: grid; justify-items: center; gap: 4px; padding: 20px 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.avatar { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; border: 4px solid var(--accent); }
.avatar.fallback { display: grid; place-items: center; font-size: 2rem; font-weight: 800; background: var(--teal); color: #fff; }
.profile-name { font-family: var(--font-display); font-size: 1.4rem; margin-top: 8px; }
.profile-username, .profile-id { color: var(--ink-2); }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 8px; text-align: center; display: grid; gap: 2px; }
.stat strong { font-size: 1.4rem; font-family: var(--font-display); }
.stat span { font-size: 0.75rem; color: var(--ink-2); }
.stat.good strong { color: var(--good); }
.stat.bad strong { color: var(--bad); }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; display: grid; gap: 12px; }
.panel h3 { font-family: var(--font-display); }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.setting-text { display: grid; gap: 2px; min-width: 0; }
.setting-text small { color: var(--ink-2); }
.segmented { display: inline-flex; background: var(--bg-2); border-radius: 999px; padding: 3px; }
.segmented button { padding: 7px 14px; border-radius: 999px; font-weight: 700; color: var(--ink-2); }
.segmented button.on { background: var(--accent); color: #fff; }
.switch { position: relative; width: 52px; height: 30px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.slider { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background 0.15s; pointer-events: none; }
.slider::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch input:checked + .slider { background: var(--teal); }
.switch input:checked + .slider::after { transform: translateX(22px); }

/* ---------- modal + toast ---------- */
.modal-overlay { position: fixed; inset: 0; z-index: 100; background: rgba(10, 9, 16, 0.6); display: grid; place-items: center; padding: 20px; }
.modal-card { width: 100%; max-width: 420px; background: var(--card); border-radius: var(--radius); padding: 20px; display: grid; gap: 14px; box-shadow: var(--shadow); max-height: 85vh; overflow: auto; }
.modal-title { font-size: 1.3rem; }
.modal-body { color: var(--ink-2); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 22px + env(safe-area-inset-bottom, 0px)); z-index: 120; background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 600; max-width: 90vw; text-align: center; box-shadow: var(--shadow); }

/* ---------- room: players, lobby, result ---------- */
.conn-chip { font-size: 0.72rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--card-2); white-space: nowrap; }
.conn-chip.open { background: var(--good); color: #fff; }
.conn-chip.reconnecting, .conn-chip.connecting { background: var(--gold); color: #3a2a00; }
.conn-chip.closed { background: var(--bad); color: #fff; }
.player-pill { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 8px; border-radius: 999px; background: var(--card); border: 2px solid var(--line); flex: none; font-size: 0.85rem; }
.player-pill.turn { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(228, 87, 46, 0.18); }
.player-pill.out { opacity: 0.45; }
.player-pill small { color: var(--ink-2); }
.turn-tag { color: var(--accent); font-weight: 700; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ink-2); }
.dot.on { background: var(--good); }
.dot.off { background: var(--bad); }
.pill-avatar { width: 28px; height: 28px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; background: var(--teal); color: #fff; font-size: 0.72rem; font-weight: 800; }
.pill-avatar img { width: 100%; height: 100%; object-fit: cover; }
.pill-name { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }

.lobby { display: grid; gap: 14px; justify-items: center; text-align: center; padding: 26px 8px; }
.lobby-code { display: grid; gap: 6px; justify-items: center; background: var(--card); border: 1px dashed var(--accent); border-radius: var(--radius); padding: 16px 22px; }
.lobby-code strong { font-size: 2.2rem; letter-spacing: 0.3em; font-family: ui-monospace, Menlo, monospace; padding-left: 0.3em; }
.lobby-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.result-card { position: relative; margin-top: 12px; z-index: 15; background: var(--card); border: 2px solid var(--accent); border-radius: var(--radius); padding: 16px; display: grid; gap: 8px; text-align: center; box-shadow: var(--shadow); }
.result-card h3 { font-family: var(--font-display); font-size: 1.5rem; }
.result-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 4px; }

/* ---------- chat / voice / reactions ---------- */
.chat-box { position: sticky; bottom: 0; z-index: 25; background: var(--bg); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); }
.reaction-row { display: flex; gap: 2px; overflow-x: auto; padding: 6px 8px; scrollbar-width: none; }
.reaction-btn { flex: none; font-size: 1.5rem; width: 44px; height: 44px; border-radius: 12px; }
.reaction-btn:active { background: var(--card-2); transform: scale(1.15); }
.chat-toggle { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 8px; font-weight: 700; color: var(--ink-2); }
.chat-badge { background: var(--accent); color: #fff; border-radius: 999px; font-size: 0.72rem; padding: 1px 8px; }
.chat-sheet { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 0 12px 10px; }
.chat-notice { font-size: 0.75rem; color: var(--ink-2); text-align: center; }
.chat-list { height: 38vh; max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 6px 2px; overscroll-behavior: contain; }
.chat-empty { margin: auto; color: var(--ink-2); font-size: 0.9rem; }
.msg { max-width: 82%; padding: 8px 12px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); word-break: break-word; }
.msg.mine { align-self: flex-end; background: var(--accent); color: #fff; border-color: transparent; border-bottom-right-radius: 4px; }
.msg.theirs { align-self: flex-start; border-bottom-left-radius: 4px; }
.msg-name { font-size: 0.72rem; font-weight: 700; color: var(--teal); }
.msg-meta { display: flex; gap: 8px; justify-content: flex-end; font-size: 0.66rem; opacity: 0.75; margin-top: 2px; }
.chat-composer { display: flex; gap: 8px; align-items: center; }
.chat-input { flex: 1; min-width: 0; height: 44px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); padding: 0 16px; }
.send-btn { padding: 8px 16px; }
.rec-bar { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--bad); border-radius: 999px; padding: 6px 8px 6px 14px; font-size: 0.85rem; }
.rec-bar .btn { margin-left: auto; min-height: 32px; padding: 4px 12px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--bad); animation: pulse 1s infinite; }
.voice-bubble { display: flex; align-items: center; gap: 10px; min-width: 160px; }
.voice-play { width: 34px; height: 34px; border-radius: 50%; background: rgba(0, 0, 0, 0.18); color: inherit; font-size: 0.85rem; }
.voice-wave { flex: 1; height: 14px; border-radius: 7px; background: repeating-linear-gradient(90deg, currentColor 0 2px, transparent 2px 5px); opacity: 0.45; }
.voice-dur { font-size: 0.8rem; }
.reaction-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 12; }
.floating-reaction { position: absolute; bottom: 0; display: grid; justify-items: center; animation: floatUp 2.4s ease-out forwards; }
.fr-emoji { font-size: 2.6rem; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3)); }
.fr-name { font-size: 0.66rem; background: var(--card); padding: 1px 8px; border-radius: 999px; }
@keyframes floatUp { from { transform: translateY(0) scale(0.6); opacity: 0; } 15% { opacity: 1; transform: translateY(-30px) scale(1.1); } to { transform: translateY(-260px) scale(1); opacity: 0; } }
