:root {
  color-scheme: light;
  --ink: #e8e5de;
  --panel: #f5f2eb;
  --edge: #d2cec4;
  --text: #292a2c;
  --muted: #77766f;
  --accent: #a6503d;
  font-family: "Segoe UI", Arial, sans-serif;
}
* { box-sizing: border-box; }
body { min-width: 320px; min-height: 100vh; margin: 0; color: var(--text); background-color: var(--ink); background-image: radial-gradient(ellipse at 15% 15%, #758a7133, transparent 34%), radial-gradient(ellipse at 90% 70%, #a6503d1f, transparent 38%), repeating-linear-gradient(45deg, transparent 0 42px, #61594d12 43px 44px); }
button, input, textarea, select { font: inherit; }
.lobby-shell { width: min(920px, calc(100% - 40px)); margin: 0 auto; }
.lobby-header { height: 76px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--edge); }
.brand { display: flex; gap: 10px; align-items: center; color: inherit; text-decoration: none; }
.brand-mark { width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid #393b40; border-radius: 8px; color: #f5f2eb; background: #303237; font-size: 23px; }
.brand-copy { display: grid; gap: 2px; letter-spacing: .14em; }
.brand-copy b { font-size: 12px; }
.brand-copy small, .eyebrow { color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .16em; }
.brand-copy small a { color: inherit; text-decoration: none; }
.account-panel { display: grid; grid-template-columns: 1fr 300px; gap: 40px; align-items: center; padding: 45px 0 35px; border-bottom: 1px solid var(--edge); }
.intro h1 { max-width: 480px; margin: 8px 0; font-size: clamp(30px, 5vw, 48px); letter-spacing: -.04em; }
.intro p, .hint { color: var(--muted); line-height: 1.6; }
.account-card, .list-card, .play-panel { border: 1px solid var(--edge); border-radius: 12px; background: linear-gradient(145deg, #fffefa, var(--panel)); box-shadow: 0 14px 32px #080a0d18; }
.account-card { padding: 20px; }
h2, h3, p { margin-top: 0; }
.account-card h2, .section-title h2, .welcome-row h2 { margin: 5px 0 15px; font-size: 19px; }
form { display: grid; gap: 12px; }
label { display: grid; gap: 6px; color: #5e5d58; font-size: 11px; font-weight: 700; }
input, select { width: 100%; min-width: 0; border: 1px solid var(--edge); border-radius: 6px; padding: 10px; color: var(--text); background: #fffefa; }
input:focus, select:focus { outline: 2px solid #a6503d66; border-color: var(--accent); }
.button { border: 1px solid var(--edge); border-radius: 6px; padding: 10px 14px; color: var(--text); background: #fffefa; cursor: pointer; font-weight: 700; }
.button.primary { border-color: #303237; color: #fffefa; background: #303237; }
.button:hover { filter: brightness(.96); }
.button:disabled { opacity: .55; cursor: wait; }
.quiet { padding: 8px 12px; }
.text-button { display: block; margin: 13px auto 0; border: 0; padding: 4px; color: var(--accent); background: transparent; cursor: pointer; font-size: 12px; }
.play-panel { margin: 24px 0; padding: 20px; }
.invite-share, .invite-share * { min-width: 0; }
.invite-share { display: grid; gap: 8px; width: min(100%, 560px); margin: 0 auto 18px; padding: 16px; border: 1px solid var(--edge); border-radius: 10px; background: var(--panel); }
.invite-share .join-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(84px, auto); width: 100%; max-width: 100%; gap: 8px; }
.invite-share textarea { display: block; width: 100%; min-width: 0; max-width: 100%; height: 48px; margin: 0; border: 1px solid var(--edge); border-radius: 6px; padding: 8px; resize: none; overflow: hidden; overflow-wrap: anywhere; word-break: break-all; color: var(--text); background: #fffefa; font-size: clamp(8px, 1.8vw, 10px); line-height: 1.35; }
.invite-share .button { min-width: 0; padding: 8px 10px; white-space: normal; font-size: 11px; }
.invite-share .hint { margin: 0; }
.quick-play { display: grid; grid-template-columns: minmax(160px, .8fr) minmax(160px, 1fr) minmax(230px, 1.3fr); gap: 16px; align-items: end; }
.join-row { display: flex; gap: 8px; }
.join-row input { flex: 1; }
.hint { margin: 12px 0 0; font-size: 12px; }
.friends-panel { padding: 6px 0 28px; }
.welcome-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.welcome-row h2 { margin-bottom: 0; }
.friend-form { max-width: 440px; margin-bottom: 20px; }
.dashboard-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.list-card { min-height: 112px; padding: 15px; }
.list-card h3 { margin-bottom: 11px; font-size: 14px; }
.item-list { display: grid; gap: 8px; }
.community-panel { margin: 24px 0; padding: 14px 20px 20px; border: 1px solid var(--edge); border-radius: 12px; background: linear-gradient(145deg,#fffefa,var(--panel)); box-shadow: 0 14px 32px #080a0d18; }
.community-tabs { display: flex; gap: 6px; margin-bottom: 16px; border-bottom: 1px solid var(--edge); }
.community-tab { position: relative; border: 0; padding: 10px 13px; color: var(--muted); background: transparent; cursor: pointer; font-size: 12px; font-weight: 800; }
.community-tab.selected { color: var(--text); }
.community-tab.selected::after { position: absolute; right: 10px; bottom: -1px; left: 10px; height: 3px; border-radius: 3px 3px 0 0; background: var(--accent); content: ""; }
.community-tab-panel .section-title { display: flex; justify-content: space-between; align-items: end; gap: 12px; margin-bottom: 12px; }
.community-tab-panel h2 { margin: 5px 0 0; font-size: 19px; }
.leaderboard-list { display: grid; gap: 6px; }
.live-matches-list { display: grid; gap: 7px; }
.live-match-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 4px; border-top: 1px solid var(--edge); }
.live-match-detail { display: grid; gap: 4px; min-width: 0; }
.live-match-detail strong { overflow-wrap: anywhere; font-size: 13px; }
.live-match-detail span { color: var(--muted); font-size: 10px; }
.live-match-item .button { flex: 0 0 auto; padding: 7px 12px; font-size: 11px; }
.leaderboard-entry { min-width: 0; border-top: 1px solid var(--edge); }
.leaderboard-summary { display: grid; grid-template-columns: 34px minmax(0,1fr) auto; align-items: center; width: 100%; gap: 10px; padding: 9px 4px; border: 0; color: var(--text); background: transparent; cursor: pointer; text-align: left; }
.leaderboard-summary:hover { background: #a6503d0c; }
.leaderboard-rank { color: var(--accent); font: 700 12px "DM Mono",monospace; }
.leaderboard-identity { display: grid; gap: 2px; min-width: 0; }
.leaderboard-identity strong { overflow: hidden; text-overflow: ellipsis; }
.leaderboard-identity small { color: var(--muted); font-size: 10px; }
.leaderboard-rating { white-space: nowrap; font: 700 11px "DM Mono",monospace; }
.leaderboard-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 4px 10px 48px; }
.leaderboard-actions .button { padding: 7px 10px; font-size: 11px; }
.profile-modal { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 20px; background: #17161480; }
.profile-card { position: relative; width: min(520px,100%); max-height: min(760px,90vh); overflow: auto; padding: 25px; border: 1px solid var(--edge); border-radius: 14px; background: linear-gradient(145deg,#fffefa,var(--panel)); box-shadow: 0 20px 60px #080a0d55; }
.profile-close { position: absolute; top: 12px; right: 14px; width: 34px; height: 34px; border: 1px solid var(--edge); border-radius: 50%; color: var(--muted); background: transparent; cursor: pointer; font-size: 22px; }
.profile-card h2 { margin: 6px 44px 3px 0; font-size: 25px; }
.profile-card h3 { margin: 20px 0 8px; font-size: 14px; }
.profile-stats { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 8px; margin: 18px 0; }
.profile-stats>div { display: grid; gap: 4px; padding: 11px 8px; border: 1px solid var(--edge); border-radius: 8px; background: #ffffff8c; text-align: center; }
.profile-stats strong { font: 700 17px "DM Mono",monospace; }
.profile-games { display: grid; gap: 6px; }
.profile-game { display: grid; grid-template-columns: 52px minmax(0,1fr) 40px; align-items: center; gap: 9px; padding: 9px; border: 1px solid var(--edge); border-radius: 7px; background: #ffffff8c; }
.profile-outcome { font: 800 10px "DM Mono",monospace; }
.profile-game.win .profile-outcome,.profile-rating-change.positive { color: #527a4c; }
.profile-game.draw .profile-outcome { color: #77766f; }
.profile-game.loss .profile-outcome,.profile-rating-change.negative { color: #a6503d; }
.profile-game-detail { display: grid; gap: 3px; min-width: 0; }
.profile-game-detail strong,.profile-game-detail small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-game-detail small { color: var(--muted); font-size: 10px; }
.profile-rating-change { text-align: right; font: 700 11px "DM Mono",monospace; }
.invite-time-modal { position: fixed; z-index: 30; inset: 0; display: grid; place-items: center; padding: 18px; background: #17161480; }
.invite-time-card { position: relative; width: min(480px,100%); max-height: min(760px,92vh); overflow: auto; padding: 24px; border: 1px solid var(--edge); border-radius: 14px; background: linear-gradient(145deg,#fffefa,var(--panel)); box-shadow: 0 20px 60px #080a0d55; }
.invite-time-card h2 { margin: 6px 42px 4px 0; font-size: 22px; }
.invite-time-card>p { margin-bottom: 15px; }
.invite-time-options { display: grid; gap: 13px; }
.invite-time-group { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; min-width: 0; margin: 0; border: 0; padding: 0; }
.invite-time-group legend { grid-column: 1 / -1; margin-bottom: 2px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.invite-time-option { display: flex; align-items: center; gap: 9px; min-width: 0; padding: 10px; border: 1px solid var(--edge); border-radius: 8px; background: #ffffffb8; cursor: pointer; font-size: 12px; }
.invite-time-option:has(input:checked) { border-color: var(--accent); background: #a6503d12; box-shadow: 0 0 0 1px #a6503d33; }
.invite-time-option input { width: 16px; height: 16px; flex: 0 0 auto; margin: 0; accent-color: var(--accent); }
.invite-time-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 18px; }
.join-prompt-modal { position: fixed; z-index: 35; inset: 0; display: grid; place-items: center; padding: 18px; background: #17161480; }
.join-prompt-card { width: min(420px,100%); padding: 28px; border: 1px solid var(--edge); border-radius: 14px; background: linear-gradient(145deg,#fffefa,var(--panel)); box-shadow: 0 20px 60px #080a0d55; animation: joinPromptIn .22s ease-out; }
.join-prompt-card h2 { margin: 7px 0; font-size: 23px; }
.join-prompt-card p { margin-bottom: 21px; line-height: 1.5; }
.join-prompt-actions { display: flex; justify-content: flex-end; gap: 9px; }
.game-list-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; border-top: 1px solid #e6e2d9; padding-top: 10px; }
.game-list-details { display: grid; gap: 4px; min-width: 0; }
.game-list-details strong { overflow-wrap: anywhere; font-size: 12px; }
.game-list-details span { color: var(--muted); font-size: 10px; line-height: 1.4; }
.game-list-item .button { flex: 0 0 auto; padding: 7px 10px; font-size: 10px; }
.game-list-item .button.danger { border-color: #d9b9b0; color: #913b36; background: #f3e5df; }
.time-control-picker { min-width: 0; }
.time-control-picker select { display: block; margin-top: 2px; }
.list-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; border-top: 1px solid #e6e2d9; padding-top: 8px; font-size: 12px; }
.list-item > span { min-width: 0; overflow-wrap: anywhere; }
.list-item .button { padding: 6px 9px; font-size: 11px; white-space: nowrap; }
.muted { color: var(--muted); font-size: 12px; }
.message { min-height: 22px; max-width: 100%; color: var(--accent); font-size: 13px; overflow-wrap: anywhere; }
footer { padding: 12px 0 25px; color: var(--muted); font-size: 11px; text-align: center; }
.hidden { display: none !important; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 650px) {
  .lobby-shell { width: calc(100% - 28px); }
  .account-panel { grid-template-columns: 1fr; gap: 20px; padding: 30px 0 24px; }
  .account-card { max-width: none; }
  .quick-play, .dashboard-grid { grid-template-columns: 1fr; }
  .invite-share .join-row { grid-template-columns: minmax(0, 1fr); }
  .community-panel { padding: 12px 15px 15px; }
  .profile-card { padding: 20px 15px; }
  .invite-time-card { padding: 21px 15px; }
  .join-prompt-card { padding: 23px 18px; }
  .game-list-item { align-items: flex-start; flex-wrap: wrap; }
  .game-list-item .button { white-space: normal; }
}
@keyframes joinPromptIn { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
