/* ═══════════════════════════════════════════════════════════════
   GameLobby — Dark Minimal Theme
   Font: Syne (display) + JetBrains Mono (mono/ui)
   ═══════════════════════════════════════════════════════════════ */

:root {
  --bg:        #0a0a0c;
  --bg-1:      #111116;
  --bg-2:      #18181f;
  --bg-3:      #1f1f28;
  --border:    #2a2a35;
  --border-hi: #3d3d50;

  --text:      #e8e8f0;
  --text-2:    #8888a0;
  --text-3:    #55556a;

  --accent:    #7c6af7;
  --accent-hi: #9d8fff;
  --accent-lo: #7c6af720;

  --green:     #3dd68c;
  --green-lo:  #3dd68c18;
  --red:       #f75a5a;
  --red-lo:    #f75a5a18;
  --yellow:    #f7c25a;
  --yellow-lo: #f7c25a18;

  --radius:    6px;
  --radius-lg: 10px;

  --font-display: 'Syne', sans-serif;
  --font-mono:    'JetBrains Mono', monospace;

  --header-h: 56px;
  --sidebar-w: 260px;
}

/* ─── RESET ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}

input, button, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

/* ─── PAGES ─────────────────────────────────────────────────── */
.page { display: none; height: 100vh; }
.page.active { display: flex; flex-direction: column; }
.page.hidden { display: none !important; }

/* ─── AUTH ──────────────────────────────────────────────────── */
#page-auth {
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, #7c6af715 0%, transparent 70%),
    var(--bg);
}

.auth-container {
  width: 100%;
  max-width: 380px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.auth-logo {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text);
  margin-bottom: 4px;
}
.logo-bracket { color: var(--text-3); }
.logo-accent  { color: var(--accent-hi); }

.auth-tagline {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 3px;
  text-transform: lowercase;
  margin-bottom: 24px;
}

.auth-card {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-card h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

/* ─── FORMS ─────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.form-group input {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}
.form-group input::placeholder { color: var(--text-3); }
.form-group input:focus { border-color: var(--accent); }

.form-error {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--red);
  min-height: 16px;
}

.form-success {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--green);
}

.form-switch {
  font-size: 12px;
  color: var(--text-2);
  text-align: center;
}
.form-switch a {
  color: var(--accent-hi);
  text-decoration: none;
  font-weight: 600;
}
.form-switch a:hover { text-decoration: underline; }

/* ─── BUTTONS ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}

.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hi);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--border-hi);
  background: var(--bg-3);
}

.btn-danger {
  background: var(--red-lo);
  color: var(--red);
  border: 1px solid #f75a5a30;
}
.btn-danger:hover:not(:disabled) {
  background: #f75a5a30;
}

.btn-full { width: 100%; }

.btn-sm  { padding: 6px 12px; font-size: 11px; }
.btn-xs  { padding: 4px 8px;  font-size: 10px; }

.btn-ready {
  background: var(--green-lo);
  color: var(--green);
  border: 1px solid #3dd68c30;
  font-size: 12px;
  padding: 10px 20px;
  width: 100%;
}
.btn-ready:hover:not(:disabled) { background: #3dd68c30; }
.btn-ready.is-ready {
  background: var(--green);
  color: #0a0a0c;
}

.btn-start {
  margin-top: 8px;
  width: 100%;
  background: var(--accent);
  color: #fff;
}
.btn-start:hover:not(:disabled) {
  background: var(--accent-hi);
  transform: translateY(-1px);
}

/* ─── HEADER ────────────────────────────────────────────────── */
.app-header {
  height: var(--header-h);
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  flex-shrink: 0;
}

.header-logo {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 1px;
}

.header-center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-user-pill {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 14px 4px 5px;
  cursor: pointer;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  transition: border-color 0.15s, background 0.15s;
}
.header-user-pill:hover {
  border-color: var(--accent);
  background: var(--accent-lo);
}

.header-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-lo);
  border: 1px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-hi);
  flex-shrink: 0;
  overflow: hidden;
  text-transform: uppercase;
}
.header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* ─── PROFILE AVATAR WRAP + UPLOAD OVERLAY ──────────────────── */
.profile-avatar-wrap {
  position: relative;
  flex-shrink: 0;
  width: 52px;
  height: 52px;
}

.profile-avatar-wrap .profile-avatar {
  width: 52px;
  height: 52px;
  overflow: hidden;
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.avatar-upload-overlay {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  opacity: 0;
  transition: opacity 0.15s;
}
.profile-avatar-wrap:hover .avatar-upload-overlay:not(.hidden) {
  opacity: 1;
}


.lobby-id-display {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-2);
}
.lobby-id-display strong {
  color: var(--text);
  letter-spacing: 2px;
}

.header-actions { display: flex; gap: 8px; }

/* ─── LOBBIES PAGE ──────────────────────────────────────────── */
#page-lobbies {
  background: var(--bg);
}

.lobbies-main {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.lobbies-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.page-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
}

/* ─── LOBBY LIST ────────────────────────────────────────────── */
.lobbies-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lobby-empty {
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 40px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
}

.lobby-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: all 0.12s;
}
.lobby-card:hover {
  border-color: var(--border-hi);
  background: var(--bg-3);
  transform: translateX(2px);
}

.lobby-card-host {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  min-width: 120px;
}

.lobby-card-id {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 2px;
}

.lobby-card-game {
  font-size: 12px;
  color: var(--text-2);
  flex: 1;
}

.lobby-card-badges {
  display: flex;
  gap: 6px;
  align-items: center;
}

.badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.badge-public  { background: var(--green-lo); color: var(--green); }
.badge-private { background: var(--yellow-lo); color: var(--yellow); }
.badge-waiting { background: var(--accent-lo); color: var(--accent-hi); }
.badge-progress { background: var(--red-lo); color: var(--red); }
.badge-full    { background: var(--bg-3); color: var(--text-3); }

/* ─── MODALS ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}
.modal-overlay.hidden { display: none !important; }

.modal {
  background: var(--bg-2);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: modal-in 0.15s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
}

.modal-sub {
  font-size: 12px;
  color: var(--text-2);
  margin-top: -8px;
}

.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 4px;
}

.modal-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.choice-btn {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  color: var(--text);
  transition: all 0.12s;
}
.choice-btn:hover {
  border-color: var(--accent);
  background: var(--accent-lo);
}
.choice-btn.selected {
  border-color: var(--accent);
  background: var(--accent-lo);
}

.choice-icon { font-size: 22px; }
.choice-label { font-weight: 700; font-size: 14px; }
.choice-desc { font-size: 11px; color: var(--text-2); }

/* ─── LOBBY PAGE ────────────────────────────────────────────── */
#page-lobby {
  overflow: hidden;
}

.lobby-layout {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ─── SIDEBAR ───────────────────────────────────────────────── */
.lobby-sidebar {
  width: var(--sidebar-w);
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar-section {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.section-label {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--text-3);
  text-transform: uppercase;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.host-only-badge {
  background: var(--accent-lo);
  color: var(--accent-hi);
  font-size: 8px;
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: 0.5px;
}

.selected-game-name {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
}

/* ─── GAME LIST ─────────────────────────────────────────────── */
.game-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.game-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text-2);
  padding: 7px 10px;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.1s;
}
.game-btn:hover {
  background: var(--bg-3);
  color: var(--text);
  border-color: var(--border);
}
.game-btn.active {
  background: var(--accent-lo);
  color: var(--accent-hi);
  border-color: #7c6af730;
}

/* Guest: game buttons non-interactive */
.game-btn.guest-view {
  cursor: default;
  pointer-events: none;
  opacity: 0.7;
}
.game-btn.guest-view.active {
  opacity: 1;
}

/* ─── PLAYER LIST ───────────────────────────────────────────── */
.player-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.player-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  gap: 8px;
}

.player-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.player-role {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-3);
  letter-spacing: 0.5px;
}

.player-ready {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 3px;
}
.player-ready.ready    { background: var(--green-lo); color: var(--green); }
.player-ready.not-ready { background: var(--bg); color: var(--text-3); }

.player-kick {
  background: transparent;
  border: 1px solid #f75a5a25;
  color: var(--red);
  font-family: var(--font-mono);
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.1s;
}
.player-kick:hover { background: var(--red-lo); }

/* ─── PRIVACY CONTROLS ──────────────────────────────────────── */
.privacy-controls { display: flex; flex-direction: column; gap: 8px; }
.privacy-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
#privacy-label { font-size: 12px; color: var(--text-2); }

/* ─── READY AREA ────────────────────────────────────────────── */
.ready-area {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ─── CHAT ───────────────────────────────────────────────────── */
.lobby-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.game-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10,10,12,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  backdrop-filter: blur(8px);
}
.game-overlay.hidden { display: none !important; }

.game-overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  text-align: center;
}

.game-status-text {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  animation: pulse 1s ease-in-out infinite alternate;
}
@keyframes pulse {
  from { opacity: 0.8; }
  to   { opacity: 1; }
}

.countdown-display {
  font-family: var(--font-mono);
  font-size: 72px;
  font-weight: 700;
  color: var(--accent-hi);
  line-height: 1;
  transition: all 0.3s;
}

.game-over-display {
  font-size: 22px;
  font-weight: 700;
  color: var(--yellow);
  text-align: center;
}

.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  padding: 14px 20px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.chat-msg {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.chat-msg-meta {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.chat-msg-user {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--accent-hi);
}

.chat-msg-time {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-3);
}

.chat-msg-text {
  font-size: 13px;
  color: var(--text);
  line-height: 1.4;
  word-break: break-word;
}

.chat-msg.is-system .chat-msg-text {
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 11px;
  font-style: italic;
}
.chat-msg.is-system .chat-msg-user { color: var(--text-3); }

.chat-input-row {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.chat-input-row input {
  flex: 1;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 9px 12px;
  font-family: var(--font-mono);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}
.chat-input-row input::placeholder { color: var(--text-3); }
.chat-input-row input:focus { border-color: var(--accent); }

/* ─── UTIL ───────────────────────────────────────────────────── */
.hidden    { display: none !important; }
.mt-sm     { margin-top: 8px; }
.mt-xs     { margin-top: 4px; }

/* ─── SCROLLBAR ─────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ─── RESPONSIVE ADJUST ─────────────────────────────────────── */
@media (max-width: 640px) {
  :root { --sidebar-w: 200px; }
  .auth-container { padding: 16px; }
}

/* ─── COMMAND FEEDBACK MESSAGES (local only) ────────────────── */
.chat-msg-cmd .chat-msg-text { font-family: var(--font-mono); font-size: 11px; }

.cmd-ok       { color: var(--green) !important; }
.cmd-err      { color: var(--red)   !important; }
.cmd-ok-text  { color: var(--green); }
.cmd-err-text { color: var(--red);   }

/* ─── PLAYER ITEM — CLICKABLE ───────────────────────────────── */
.player-item {
  cursor: pointer;
}
.player-item:hover {
  border-color: var(--accent);
  background: var(--accent-lo);
}

/* ─── PROFILE MODAL ─────────────────────────────────────────── */
.modal-profile {
  max-width: 440px;
  padding: 0;
  overflow: hidden;
  gap: 0;
  position: relative;
}

.modal-close-x {
  position: absolute;
  top: 12px;
  right: 14px;
  background: transparent;
  border: none;
  color: var(--text-3);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  z-index: 10;
  transition: color 0.1s, background 0.1s;
}
.modal-close-x:hover { color: var(--text); background: var(--bg-3); }

/* Header band */
.profile-header {
  background: linear-gradient(135deg, #1a1a2e 0%, #16162a 60%, var(--accent-lo) 100%);
  border-bottom: 1px solid var(--border);
  padding: 28px 24px 22px;
  display: flex;
  align-items: center;
  gap: 18px;
}

.profile-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent-lo);
  border: 2px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
  color: var(--accent-hi);
  flex-shrink: 0;
  text-transform: uppercase;
}

.profile-header-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.profile-username {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-since {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
  letter-spacing: 0.5px;
}

/* Overall totals row */
.profile-totals {
  display: flex;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  gap: 0;
}

.profile-total-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.profile-total-num {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
}
.profile-total-num.green  { color: var(--green); }
.profile-total-num.red    { color: var(--red); }
.profile-total-num.accent { color: var(--accent-hi); }

.profile-total-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 1.5px;
  color: var(--text-3);
  text-transform: uppercase;
}

.profile-total-divider {
  width: 1px;
  height: 40px;
  background: var(--border);
  flex-shrink: 0;
}

/* Per-game breakdown */
.profile-games-label {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--text-3);
  text-transform: uppercase;
  padding: 14px 24px 8px;
  background: var(--bg-2);
}

.profile-games {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--bg-2);
  padding: 0 24px 16px;
}

.profile-game-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.profile-game-row:last-child { border-bottom: none; }

.profile-game-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.profile-game-stats {
  display: flex;
  gap: 10px;
  align-items: center;
}

.profile-stat-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  min-width: 48px;
  text-align: center;
}
.profile-stat-pill.w { background: var(--green-lo); color: var(--green); }
.profile-stat-pill.l { background: var(--red-lo);   color: var(--red);   }

.profile-game-bar-wrap {
  width: 80px;
  height: 4px;
  background: var(--bg-3);
  border-radius: 2px;
  overflow: hidden;
}
.profile-game-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* Kick section */
.profile-kick-section {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-2);
}

.profile-loading {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-3);
  text-align: center;
  padding: 24px;
  background: var(--bg-2);
}


/* ═══════════════════════════════════════════════════════════════
   GAME BUTTON — COMING SOON / DISABLED
   ═══════════════════════════════════════════════════════════════ */
.game-btn-disabled {
  opacity: 0.35 !important;
  cursor: not-allowed !important;
  pointer-events: none;
}
.coming-soon-tag {
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 1px;
  background: var(--bg-3);
  color: var(--text-3);
  padding: 1px 4px;
  border-radius: 3px;
  margin-left: 4px;
  vertical-align: middle;
}

/* ═══════════════════════════════════════════════════════════════
   YAHTZEE PAGE
   ═══════════════════════════════════════════════════════════════ */
#page-yahtzee {
  position: fixed;
  inset: 0;
  background: var(--bg-0);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 100;
}

/* ── Countdown screen ─────────────────────────────────────────── */
.yahtzee-countdown-screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-0);
  z-index: 10;
}
.yahtzee-countdown-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.yahtzee-countdown-label {
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: 3px;
  color: var(--text-3);
  text-transform: uppercase;
}
.yahtzee-countdown-number {
  font-family: var(--font-display);
  font-size: 96px;
  font-weight: 800;
  color: var(--accent-hi);
  line-height: 1;
  transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1);
}

/* ── Game screen overall layout ──────────────────────────────────
   Opp row (top, ~80px)
   Center layout (flex, fill, overflow hidden)
   Me row (bottom, ~80px)
   ──────────────────────────────────────────────────────────────── */
.yahtzee-game-screen {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* ── Player rows (top = opp, bottom = me) ────────────────────────*/
.ytz-player-row {
  height: 80px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 14px;
  background: var(--bg-1);
  position: relative;
  z-index: 2;
}
.ytz-player-row-top    { border-bottom: 1px solid var(--border); justify-content: flex-start; }
.ytz-player-row-bottom { border-top: 1px solid var(--border);    justify-content: flex-start; }

.ytz-pr-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.ytz-pr-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ytz-round-badge-wrap {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: baseline;
  gap: 4px;
  pointer-events: none;
}

/* ── Avatar ──────────────────────────────────────────────────────*/
.ytz-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent-lo);
  border: 2px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--accent-hi);
  overflow: hidden;
  flex-shrink: 0;
  text-transform: uppercase;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s;
}
.ytz-avatar:hover {
  box-shadow: 0 0 0 2px var(--accent-hi);
  transform: scale(1.07);
}
.ytz-avatar img { width: 100%; height: 100%; object-fit: cover; }

.ytz-player-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.ytz-turn-badge {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 1.5px;
  color: var(--accent-hi);
  background: var(--accent-lo);
  padding: 2px 6px;
  border-radius: 3px;
  text-transform: uppercase;
  width: fit-content;
}

.ytz-round-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--text-3);
  text-transform: uppercase;
}
.ytz-round-num {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  color: var(--accent-hi);
}

/* ── Chat bubbles ─────────────────────────────────────────────── */
.ytz-bubble {
  position: absolute;
  left: 54px;
  top: 50%;
  transform: translateY(-50%);
  max-width: 220px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 11px;
  font-size: 12px;
  color: var(--text);
  z-index: 50;
  word-break: break-word;
  box-shadow: 0 3px 10px rgba(0,0,0,0.4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.6s ease;
}
.ytz-bubble.fade-out { opacity: 0; }

/* ── Center layout: play area left, scorecard right ──────────── */
.ytz-center-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ── Play area (dice table + controls + chat) ────────────────── */
.ytz-play-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 16px 20px;
  gap: 14px;
  overflow: hidden;
}

/* ── Dice table (absolute-positioned dice inside) ────────────── */
.ytz-dice-table {
  flex: 1;
  min-height: 0;
  position: relative;
  background: #0d0d1a;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: inset 0 4px 20px rgba(0,0,0,0.6);
  overflow: hidden;
}

/* ── Die wrapper — absolutely positioned within table ────────── */
.ytz-die-wrap {
  position: absolute;
  width: 56px;
  height: 56px;
  cursor: default;
  perspective: 300px;
  transition: left 0.35s ease, top 0.35s ease;
}
.ytz-die-wrap.clickable { cursor: pointer; }
.ytz-die-wrap.clickable:hover .ytz-die3d {
  filter: drop-shadow(0 0 8px rgba(99,102,241,0.7));
}
.ytz-die-wrap.held .ytz-die3d {
  filter: drop-shadow(0 0 10px rgba(74,222,128,0.75));
}

/* ── 3D die cube ─────────────────────────────────────────────── */
.ytz-die3d {
  width: 56px;
  height: 56px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.2s ease;
}

.ytz-face {
  position: absolute;
  width: 56px;
  height: 56px;
  border-radius: 10px;
  backface-visibility: hidden;
  display: grid;
  align-items: center;
  justify-items: center;
  /* Inset border trick for the die face border */
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.12);
}

/* Face positions */
.ytz-face-1 { transform: rotateY(0deg)    translateZ(28px); background: radial-gradient(ellipse at 30% 30%, #2a2a45 0%, #13131f 100%); }
.ytz-face-2 { transform: rotateY(180deg)  translateZ(28px); background: radial-gradient(ellipse at 30% 30%, #2a2a45 0%, #13131f 100%); }
.ytz-face-3 { transform: rotateY(90deg)   translateZ(28px); background: radial-gradient(ellipse at 30% 30%, #2a2a45 0%, #13131f 100%); }
.ytz-face-4 { transform: rotateY(-90deg)  translateZ(28px); background: radial-gradient(ellipse at 30% 30%, #2a2a45 0%, #13131f 100%); }
.ytz-face-5 { transform: rotateX(90deg)   translateZ(28px); background: radial-gradient(ellipse at 30% 30%, #2a2a45 0%, #13131f 100%); }
.ytz-face-6 { transform: rotateX(-90deg)  translateZ(28px); background: radial-gradient(ellipse at 30% 30%, #2a2a45 0%, #13131f 100%); }

/* Dots on each face using CSS grid + pseudo elements */
/* Each face gets a dot layout via a custom property grid pattern.
   We use the ::before trick: each face has a 3x3 sub-grid of dot slots. */
.ytz-face::before {
  content: '';
  display: none; /* overridden per face */
}

/* Shared dot style via data-dots divs injected by JS */
.ytz-dot {
  width: 9px;
  height: 9px;
  background: #e0e0ff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

/* Face-specific dot colors for held state (green tint) */
.ytz-die-wrap.held .ytz-dot {
  background: #4ade80;
  box-shadow: 0 0 4px rgba(74,222,128,0.4);
}

/* ── Roll controls row ───────────────────────────────────────── */
.ytz-roll-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}
.ytz-roll-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 48px;
}
.ytz-roll-label {
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 1.5px;
  color: var(--text-3);
  text-transform: uppercase;
}
.ytz-roll-count {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  color: var(--accent-hi);
  line-height: 1;
}
.ytz-roll-btn {
  font-size: 14px;
  padding: 10px 20px;
  font-weight: 700;
  white-space: nowrap;
}

/* Timer inline with controls */
.ytz-timer-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}
.ytz-timer-bar-bg {
  flex: 1;
  height: 4px;
  background: var(--bg-3);
  border-radius: 2px;
  overflow: hidden;
}
.ytz-timer-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 1s linear, background 0.3s;
}
.ytz-timer-text {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
  min-width: 28px;
  text-align: right;
}

/* ── Chat row ────────────────────────────────────────────────── */
.ytz-chat-row {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.ytz-chat-row input {
  flex: 1;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 7px 10px;
  font-size: 12px;
  font-family: var(--font-mono);
  outline: none;
  transition: border-color 0.15s;
}
.ytz-chat-row input:focus { border-color: var(--accent); }

/* ── Scorecard panel (right side, narrower) ──────────────────── */
.ytz-scorecard-panel {
  width: 260px;
  flex-shrink: 0;
  overflow-y: auto;
  border-left: 1px solid var(--border);
  background: var(--bg-0);
  padding: 12px 10px;
}

.ytz-scorecard {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.ytz-sc-header {
  display: grid;
  grid-template-columns: 1fr 44px 44px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  padding: 8px 8px;
}
.ytz-sc-col-header {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--accent-hi);
  text-align: center;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ytz-sc-cat-label { /* spacer */ }

.ytz-sc-section-label {
  font-family: var(--font-mono);
  font-size: 7px;
  letter-spacing: 2.5px;
  color: var(--text-3);
  text-transform: uppercase;
  padding: 4px 8px 3px;
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.ytz-sc-row {
  display: grid;
  grid-template-columns: 1fr 44px 44px;
  border-bottom: 1px solid var(--border);
}
.ytz-sc-row:last-child { border-bottom: none; }
.ytz-sc-row:hover { background: rgba(255,255,255,0.03); }
.ytz-sc-row.ytz-sc-bonus    { background: var(--bg-2); opacity: 0.8; }
.ytz-sc-row.ytz-sc-subtotal { background: var(--bg-2); font-weight: 700; }
.ytz-sc-row.ytz-sc-total    { background: var(--bg-2); border-top: 2px solid var(--accent); }

.ytz-sc-cat {
  padding: 6px 8px;
  font-size: 11px;
  color: var(--text-2);
}

.ytz-sc-cell {
  padding: 6px 2px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  border-left: 1px solid var(--border);
  min-height: 30px;
}
.ytz-sc-cell.filled  { color: var(--text); }
.ytz-sc-cell.empty   { color: var(--text-3); font-size: 9px; }
.ytz-sc-cell.preview {
  color: var(--accent-hi);
  background: var(--accent-lo);
  cursor: pointer;
  font-weight: 700;
  transition: background 0.1s;
}
.ytz-sc-cell.preview:hover { background: rgba(99,102,241,0.28); }
.ytz-sc-row.ytz-sc-total .ytz-sc-cell {
  font-size: 13px;
  font-weight: 800;
  color: var(--accent-hi);
}

/* ── Game Over screen ────────────────────────────────────────── */
.yahtzee-gameover-screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10,10,20,0.92);
  z-index: 20;
}
.yahtzee-gameover-inner {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  min-width: 300px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.yahtzee-gameover-title {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 800;
  text-align: center;
}
.yahtzee-gameover-scores {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}
.ytz-go-score-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg-2);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.ytz-go-name    { font-size: 14px; font-weight: 600; color: var(--text); }
.ytz-go-pts     { font-family: var(--font-mono); font-size: 18px; font-weight: 700; color: var(--text-2); }
.ytz-go-pts.winner { color: var(--green); }
.ytz-go-subtitle { font-size: 13px; color: var(--text-2); text-align: center; }
.ytz-return-btn  { min-width: 200px; }

/* ── View Chat Modal ─────────────────────────────────────────── */
.modal-ytz-chat {
  max-width: 380px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  gap: 0;
  overflow: hidden;
}
.modal-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.ytz-chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ytz-chat-log-entry {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-size: 12px;
}
.ytz-log-user {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}
.ytz-log-user.me  { color: var(--accent-hi); }
.ytz-log-user.opp { color: var(--text-3); }
.ytz-log-msg { color: var(--text-2); word-break: break-word; }

/* ── Coming-soon game buttons ────────────────────────────────── */
.game-btn-disabled {
  opacity: 0.35 !important;
  cursor: not-allowed !important;
  pointer-events: none;
}
.coming-soon-tag {
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 1px;
  background: var(--bg-3);
  color: var(--text-3);
  padding: 1px 4px;
  border-radius: 3px;
  margin-left: 4px;
  vertical-align: middle;
}

/* ── Lobby header pill (sm variant) ─────────────────────────── */
.header-user-pill-sm {
  padding: 3px 10px 3px 4px;
  font-size: 12px;
}
