:root {
  color-scheme: light;
  --font-text: Tahoma, "Noto Sans Georgian", "BPG Arial", Sylfaen, "DejaVu Sans", Arial, sans-serif;
  --font-emoji: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Android Emoji", "Twemoji Mozilla", emoji;
  --blue: #285aa9;
  --blue-dark: #1f4787;
  --blue-deep: #173767;
  --orange: #ff9933;
  --pale-blue: #d9e6f5;
  --cream: #fff9ec;
  --ink: #343434;
  --page: #edf2f7;
  --surface: #ffffff;
  --surface-alt: #f6f8fb;
  --surface-warm: #fff9ec;
  --line: #9dadc1;
  --line-soft: #c8d3df;
  --text: #343434;
  --text-soft: #4f5965;
  --muted: #6f7b89;
  --muted-soft: #8994a0;
  --link: #285aa9;
  --input: #ffffff;
  --incoming: #fff9ec;
  --outgoing: #d9e6f5;
  --incoming-text: #343434;
  --outgoing-text: #26384f;
  --focus: #ff9933;
  --success: #39834d;
  --danger: #a13232;
  --shadow: rgba(41, 63, 91, .13);
  --overlay: rgba(16, 25, 37, .82);
  font-family: var(--font-text);
  background: var(--page);
  color: var(--text);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --blue: #3e70ba;
  --blue-dark: #28548f;
  --blue-deep: #173767;
  --orange: #ffad5c;
  --pale-blue: #263b52;
  --cream: #302b23;
  --ink: #edf3fa;
  --page: #111821;
  --surface: #1c2632;
  --surface-alt: #222f3d;
  --surface-warm: #302b23;
  --line: #526479;
  --line-soft: #394b5e;
  --text: #edf3fa;
  --text-soft: #d0dae5;
  --muted: #a5b1bf;
  --muted-soft: #8492a2;
  --link: #8eb8ef;
  --input: #151e28;
  --incoming: #302b23;
  --outgoing: #263b52;
  --incoming-text: #f2eee7;
  --outgoing-text: #edf4fc;
  --focus: #ffad5c;
  --success: #75c58a;
  --danger: #ffaaaa;
  --shadow: rgba(0, 0, 0, .3);
  --overlay: rgba(5, 9, 14, .9);
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body { min-height: 100vh; min-height: 100svh; margin: 0; background: var(--page); color: var(--text); font-family: var(--font-text); font-size: 13px; line-height: 1.45; }
button, input, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
a { color: var(--link); }
h1, h2, h3, p { margin: 0; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, .file-button:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.emoji-glyph { display: inline-flex; min-width: 1em; align-items: center; justify-content: center; font-family: var(--font-emoji), sans-serif; font-size: 1em; font-style: normal; font-weight: 400; font-variant-emoji: emoji; line-height: 1; vertical-align: -.08em; white-space: nowrap; }

/* Shared 2007-era chrome */
.classic-panel, .sidebar-module { border: 1px solid var(--line); border-radius: 2px; background: var(--surface); box-shadow: 0 1px 2px var(--shadow); }
.panel-header { min-height: 25px; margin: 0; padding: 5px 8px; border-bottom: 1px solid var(--blue-deep); background: linear-gradient(#3c70bc, #285aa9); color: #fff; font-size: 11px; font-weight: 700; line-height: 1.3; letter-spacing: .01em; }
.panel-body { padding: 9px; }
.classic-button, .room-details button, .game-choice, .game-controls button, .game-reset, .header-action, #send {
  border: 1px solid var(--blue-dark);
  border-radius: 2px;
  background: linear-gradient(#4d7dc1, #285aa9);
  color: #fff;
  box-shadow: inset 0 1px rgba(255,255,255,.2);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.classic-button:hover, .room-details button:hover, .game-choice:hover, .game-controls button:hover, .game-reset:hover, .header-action:hover, #send:hover { background: linear-gradient(#5b8bcd, #3065b5); }
button:disabled, input:disabled, textarea:disabled { opacity: .48; cursor: not-allowed; }
.eyebrow { color: var(--orange); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
html[lang="ka"] .eyebrow { letter-spacing: .02em; text-transform: none; }
.module-copy { color: var(--muted); font-size: 11px; line-height: 1.5; }

/* Masthead and shared switches */
.site-masthead { min-height: 56px; border-bottom: 1px solid #163666; background: linear-gradient(#3569b4, #285aa9 65%, #234f95); box-shadow: 0 1px 3px rgba(0,0,0,.22); color: #fff; }
.masthead-inner { width: min(1180px, calc(100% - 24px)); min-height: 56px; display: flex; align-items: center; gap: 20px; margin: 0 auto; }
.wordmark { flex: 0 0 auto; color: #fff; font-size: 23px; font-weight: 700; letter-spacing: -1.5px; line-height: 1; text-decoration: none; text-shadow: 0 1px rgba(0,0,0,.28); }
.wordmark span { color: #ffb15e; }
.masthead-tools { display: flex; align-items: center; gap: 7px; margin-left: auto; }
.language-switcher, .theme-switcher { display: inline-flex; width: max-content; align-items: center; gap: 1px; padding: 2px; border: 1px solid rgba(255,255,255,.42); border-radius: 2px; background: rgba(18,48,91,.62); }
.language-switcher button, .language-switcher a, .theme-switcher button { min-height: 20px; display: inline-flex; align-items: center; border: 0; border-radius: 1px; padding: 2px 6px; background: transparent; color: #eaf2fc; font-size: 10px; font-weight: 700; line-height: 1; text-decoration: none; cursor: pointer; }
.language-switcher button:hover, .language-switcher a:hover, .theme-switcher button:hover { background: rgba(255,255,255,.13); }
.language-switcher button.selected, .language-switcher a.selected, .theme-switcher button.selected { background: #fff; color: #234f95; }

/* Homepage portal */
.welcome-page { min-height: 100vh; min-height: 100svh; display: flex; flex-direction: column; background: linear-gradient(var(--pale-blue), var(--page) 140px); }
.portal-shell { width: min(1180px, calc(100% - 24px)); display: grid; grid-template-columns: minmax(230px, 250px) minmax(0, 1fr) minmax(220px, 240px); grid-template-areas: "left main right"; align-items: start; gap: 12px; flex: 1; margin: 12px auto 18px; }
.portal-left { grid-area: left; }
.portal-main { grid-area: main; display: grid; gap: 12px; }
.portal-right { grid-area: right; }
.portal-column { display: grid; gap: 10px; min-width: 0; }
.room-entry .panel-body { display: grid; gap: 6px; }
.field-label { margin-top: 3px; color: var(--text-soft); font-size: 10px; font-weight: 700; }
.room-input { width: 100%; min-height: 30px; border: 1px solid var(--line); border-radius: 1px; padding: 6px 7px; background: var(--input); color: var(--text); font-family: Consolas, "Courier New", monospace; font-size: 12px; font-weight: 700; letter-spacing: .08em; }
.room-input:focus { border-color: var(--blue); box-shadow: inset 0 0 0 1px var(--pale-blue); outline: 1px solid var(--orange); outline-offset: 1px; }
.room-input::placeholder { color: var(--muted-soft); font-family: var(--font-text); font-size: 10px; font-weight: 400; letter-spacing: 0; text-transform: none; }
.field-help { color: var(--muted); font-size: 9px; line-height: 1.4; }
.room-entry-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.classic-button { min-height: 28px; padding: 5px 7px; }
.room-create { border-color: #b66418; background: linear-gradient(#ffae5d, #ed841d); color: #3c240f; text-shadow: 0 1px rgba(255,255,255,.35); }
.room-create:hover { background: linear-gradient(#ffbc78, #f3902c); }
.room-error { color: var(--danger); font-size: 10px; line-height: 1.35; }
.room-error:empty { display: none; }
.welcome-card-body { padding: clamp(18px, 4vw, 34px); }
.welcome-card h1 { max-width: 650px; margin-top: 4px; color: var(--blue-deep); font-size: clamp(28px, 5vw, 48px); line-height: 1.04; letter-spacing: -1.7px; }
:root[data-theme="dark"] .welcome-card h1 { color: #dbe9fb; }
html[lang="ka"] .welcome-card h1 { letter-spacing: -.8px; }
.welcome-copy { max-width: 680px; margin-top: 12px; color: var(--text-soft); font-size: 14px; line-height: 1.6; }
.welcome-alert { margin-top: 12px; padding: 9px 10px; border: 1px solid #c67823; border-radius: 2px; background: var(--cream); color: var(--text); font-size: 11px; font-weight: 700; line-height: 1.45; }
.random-entry { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 20px; padding: 14px; border: 1px solid #c67823; border-radius: 2px; background: linear-gradient(var(--cream), color-mix(in srgb, var(--cream) 88%, var(--orange))); }
.random-entry h2 { color: var(--text); font-size: 14px; }
.random-entry p { max-width: 520px; margin-top: 3px; color: var(--text-soft); font-size: 11px; }
.start-button { min-height: 34px; display: inline-flex; flex: 0 0 auto; align-items: center; gap: 9px; border: 1px solid #b66418; border-radius: 2px; padding: 7px 12px; background: linear-gradient(#ffb563, #ff9022); color: #3b250f; box-shadow: inset 0 1px rgba(255,255,255,.45); font-weight: 700; cursor: pointer; }
.start-button:hover { background: linear-gradient(#ffc17c, #ff9d37); }
.start-button span:last-child { font-size: 18px; line-height: .8; }
.welcome-note { margin-top: 12px; color: var(--muted); font-size: 10px; }
.privacy-grid { display: grid; grid-template-columns: repeat(3, 1fr); }
.privacy-grid > div { min-width: 0; padding: 12px; border-right: 1px solid var(--line-soft); }
.privacy-grid > div:last-child { border-right: 0; }
.privacy-grid strong, .privacy-grid span { display: block; }
.privacy-grid strong { color: var(--blue-dark); font-size: 11px; text-transform: capitalize; }
:root[data-theme="dark"] .privacy-grid strong { color: var(--link); }
.privacy-grid span { margin-top: 3px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.online-status { display: flex; align-items: center; gap: 6px; color: var(--success); font-size: 11px; font-weight: 700; }
.online-dot, .connection-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 1px rgba(0,0,0,.12); }
.status-module .online-count { margin-top: 5px; color: var(--text); font-size: 11px; font-weight: 700; }
.status-module .module-copy { margin-top: 6px; }
.rules-list { display: grid; gap: 6px; margin: 7px 0 0; padding-left: 18px; color: var(--text-soft); font-size: 10px; line-height: 1.45; }
.rules-list li::marker { color: var(--orange); }
.sidebar-note { margin-top: 9px; padding-top: 8px; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: 10px; line-height: 1.45; }
.site-footer { width: min(1180px, calc(100% - 24px)); display: flex; justify-content: space-between; gap: 12px; margin: 0 auto; padding: 10px 2px 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.footer-brand { color: var(--blue); font-weight: 700; text-decoration: none; }
.public-nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 10px; }
.public-nav a { text-underline-offset: 2px; }
.public-nav a[aria-current="page"] { color: var(--text); font-weight: 700; text-decoration: none; }

/* Public information pages */
.public-shell { width: min(860px, calc(100% - 24px)); flex: 1; margin: 12px auto 18px; }
.public-card { overflow: hidden; }
.public-card-header { padding: clamp(20px, 5vw, 38px); border-bottom: 1px solid var(--line-soft); background: linear-gradient(135deg, var(--surface), var(--surface-alt)); }
.public-card h1 { max-width: 720px; margin-top: 6px; color: var(--blue-deep); font-size: clamp(27px, 5vw, 42px); line-height: 1.08; letter-spacing: -1.2px; }
:root[data-theme="dark"] .public-card h1 { color: #dbe9fb; }
html[lang="ka"] .public-card h1 { letter-spacing: -.5px; }
.public-intro { max-width: 720px; margin-top: 12px; color: var(--text-soft); font-size: 14px; line-height: 1.65; }
.public-sections, .faq-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.public-section { min-width: 0; padding: 18px 20px; border-right: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }
.public-section:nth-child(2n) { border-right: 0; }
.public-section h2 { color: var(--blue-dark); font-size: 14px; line-height: 1.35; }
:root[data-theme="dark"] .public-section h2 { color: var(--link); }
.public-section p { margin-top: 7px; color: var(--text-soft); font-size: 12px; line-height: 1.65; }
.public-cta { padding: 20px; text-align: center; }
.public-cta .start-button { text-decoration: none; }

/* Three-column chat portal */
.chat-page { height: 100vh; height: 100dvh; display: grid; grid-template-columns: minmax(180px, 220px) minmax(0, 1fr) minmax(230px, 270px); background: var(--page); }
.side-panel { min-width: 0; min-height: 0; overflow-x: hidden; overflow-y: auto; background: var(--pale-blue); color: var(--text); }
.rules-panel { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-right: 1px solid var(--line); }
.chat-wordmark { display: block; margin: -12px -12px 0; padding: 15px 12px; border-bottom: 1px solid var(--blue-deep); background: linear-gradient(#3569b4, #285aa9); }
.chat-side-nav { display: flex; gap: 6px; padding: 6px 8px; border: 1px solid var(--line); background: var(--surface); font-size: 10px; }
.chat-side-nav a, .chat-side-nav span { padding-right: 6px; border-right: 1px solid var(--line-soft); }
.chat-side-nav span { color: var(--muted); }
.rules-copy .panel-body { padding-bottom: 10px; }
[data-participant-color="blue"] { --participant-color: #1d4ed8; }
[data-participant-color="orange"] { --participant-color: #a84b08; }
[data-participant-color="green"] { --participant-color: #16713a; }
[data-participant-color="purple"] { --participant-color: #7e22ce; }
[data-participant-color="red"] { --participant-color: #b42323; }
[data-participant-color="teal"] { --participant-color: #0f766e; }
[data-participant-color="magenta"] { --participant-color: #b9185b; }
[data-participant-color="olive"] { --participant-color: #64720d; }
[data-participant-color="indigo"] { --participant-color: #4338ca; }
[data-participant-color="brown"] { --participant-color: #83451c; }
:root[data-theme="dark"] [data-participant-color="blue"] { --participant-color: #93c5fd; }
:root[data-theme="dark"] [data-participant-color="orange"] { --participant-color: #fdba74; }
:root[data-theme="dark"] [data-participant-color="green"] { --participant-color: #86efac; }
:root[data-theme="dark"] [data-participant-color="purple"] { --participant-color: #d8b4fe; }
:root[data-theme="dark"] [data-participant-color="red"] { --participant-color: #fca5a5; }
:root[data-theme="dark"] [data-participant-color="teal"] { --participant-color: #5eead4; }
:root[data-theme="dark"] [data-participant-color="magenta"] { --participant-color: #f9a8d4; }
:root[data-theme="dark"] [data-participant-color="olive"] { --participant-color: #d9f99d; }
:root[data-theme="dark"] [data-participant-color="indigo"] { --participant-color: #a5b4fc; }
:root[data-theme="dark"] [data-participant-color="brown"] { --participant-color: #e7b98b; }
.room-presence-panel .panel-body { display: grid; gap: 8px; }
.room-presence-id { color: var(--muted); font-size: 10px; }
.room-presence-id code, .mobile-room-summary code { color: var(--blue-dark); font-family: Consolas, "Courier New", monospace; font-size: 10px; font-weight: 700; overflow-wrap: anywhere; }
:root[data-theme="dark"] .room-presence-id code, :root[data-theme="dark"] .mobile-room-summary code { color: var(--link); }
.room-presence-panel .copy-room-link { width: 100%; }
.room-presence-count { color: var(--text-soft); font-size: 10px; font-weight: 700; }
.room-participant-list { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.room-participant-list li { display: flex; min-width: 0; align-items: center; gap: 6px; color: var(--participant-color, var(--text-soft)); font-size: 10px; font-weight: 700; }
.room-participant-list li::before { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: var(--participant-color, var(--success)); box-shadow: 0 0 0 1px rgba(0,0,0,.2); content: ""; }
.mobile-room-panel { display: none; gap: 6px; padding: 7px 10px; border-bottom: 1px solid var(--line); background: var(--pale-blue); }
.mobile-room-summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mobile-room-summary p { min-width: 0; color: var(--text-soft); font-size: 10px; }
.mobile-room-summary .copy-room-link { min-height: 24px; flex: 0 0 auto; padding: 3px 7px; }
.mobile-room-panel .room-participant-list { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.conversation { min-width: 0; min-height: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--surface); }
.chat-header { min-height: 63px; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "banner language theme" "banner actions actions"; align-items: center; gap: 5px 7px; padding: 7px 10px; border-bottom: 1px solid var(--blue-deep); background: linear-gradient(#3c70bc, #285aa9); color: #fff; }
.chat-banner { grid-area: banner; min-width: 0; }
.chat-language { grid-area: language; }
.chat-theme { grid-area: theme; }
.header-actions { grid-area: actions; display: flex; justify-content: flex-end; gap: 5px; }
.chat-peer, .chat-peer-copy { min-width: 0; }
.status-line { display: flex; align-items: center; gap: 6px; min-width: 0; }
.connection-status { display: inline-flex; align-items: center; gap: 5px; min-width: 0; max-width: 45%; overflow: hidden; color: #e9f8eb; font-size: 10px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.connection-status[data-state="connected"] .connection-dot { background: #39ff64; box-shadow: 0 0 0 1px rgba(0, 45, 12, .55), 0 0 5px rgba(57, 255, 100, .8); }
.connection-status[data-state="connecting"], .connection-status[data-state="reconnecting"] { color: #ffe0a8; }
.connection-status[data-state="issue"] { color: #ffd0d0; }
.status-separator { color: rgba(255,255,255,.55); }
.status { min-width: 0; overflow: hidden; color: #e7effa; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.search-indicator { width: 11px; height: 11px; flex: 0 0 auto; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: searching .75s linear infinite; }
.room-details { display: flex; min-width: 0; align-items: center; gap: 5px; margin-top: 5px; color: #e3ecf8; font-size: 10px; }
.room-details code { overflow: hidden; color: #fff2d8; font-family: Consolas, "Courier New", monospace; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-overflow: ellipsis; white-space: nowrap; }
.room-details button { min-height: 20px; padding: 2px 6px; border-color: rgba(255,255,255,.55); background: rgba(12,43,86,.55); }
.room-detail-separator { color: rgba(255,255,255,.55); }
.header-action { min-height: 25px; padding: 4px 8px; border-color: rgba(255,255,255,.58); background: rgba(20,52,96,.6); white-space: nowrap; }
.header-actions a.header-action { display: none; align-items: center; text-decoration: none; }
.header-action:hover { background: rgba(12,39,79,.8); }
.header-action.danger { border-color: #f1b4a9; background: #8c3732; }
.header-action.next-action { border-color: #ffd19a; background: #d97516; color: #fff; }

/* Conversation and classic message rows */
.message-viewport { position: relative; flex: 1; min-height: 0; background-color: var(--surface); background-image: linear-gradient(rgba(40,90,169,.035) 1px, transparent 1px); background-size: 100% 24px; }
.messages { position: relative; z-index: 1; height: 100%; min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 2px; padding: 12px clamp(10px, 2.2vw, 24px) 16px; scroll-behavior: smooth; scrollbar-gutter: stable; }
.conversation-empty { position: absolute; z-index: 2; inset: 0; display: grid; align-content: center; justify-items: center; gap: 5px; padding: 24px; color: var(--muted); text-align: center; }
.empty-mark { display: grid; width: 32px; height: 32px; place-items: center; margin-bottom: 4px; border: 1px solid var(--line); border-radius: 2px; background: var(--pale-blue); color: var(--blue); }
.conversation-empty strong { color: var(--blue-dark); font-size: 12px; }
:root[data-theme="dark"] .conversation-empty strong { color: var(--link); }
.conversation-empty p { max-width: 360px; font-size: 10px; }
.find-new-stranger { min-height: 36px; margin-top: 7px; padding: 8px 14px; border-color: #b66418; background: linear-gradient(#ffae5d, #ed841d); color: #3c240f; box-shadow: inset 0 1px rgba(255,255,255,.35), 0 1px 2px var(--shadow); }
.find-new-stranger:hover { background: linear-gradient(#ffbc78, #f3902c); }
.bubble { position: relative; align-self: flex-start; max-width: min(76%, 620px); margin-top: 7px; padding: 7px 8px 5px; border: 1px solid var(--line); border-radius: 3px; overflow-wrap: anywhere; background: var(--incoming); color: var(--incoming-text); box-shadow: 0 1px 1px var(--shadow); line-height: 1.4; user-select: text; }
.bubble.mine { align-self: flex-end; border-color: color-mix(in srgb, var(--blue) 45%, var(--line)); background: var(--outgoing); color: var(--outgoing-text); }
.bubble[data-participant-color] { border-left: 3px solid var(--participant-color); }
.bubble.mine[data-participant-color] { border-right: 3px solid var(--participant-color); border-left-width: 1px; }
.message-sender { display: block; margin-bottom: 3px; color: var(--participant-color, var(--muted)); font-size: 9px; font-weight: 700; line-height: 1.2; }
.bubble.mine .message-sender { text-align: right; }
.bubble.grouped { margin-top: 2px; }
.bubble.has-following { border-bottom-color: var(--line-soft); }
.system { align-self: center; max-width: 90%; margin: 9px 0 3px; padding: 3px 8px; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); background: var(--surface-alt); color: var(--muted); font-size: 10px; text-align: center; }
.room-system { display: inline-flex; align-items: center; gap: 5px; border-color: var(--participant-color, var(--line-soft)); }
.participant-color-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: var(--participant-color, var(--muted)); box-shadow: 0 0 0 1px rgba(0,0,0,.2); }
.room-typing { color: var(--participant-color, var(--muted)); font-weight: 700; }
.message-body { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; column-gap: 8px; min-width: 0; }
.message-body .reply-quote { grid-column: 1 / -1; }
.message-text { grid-column: 1; min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.message-text, .reply-quote, textarea[name="message"] { font-family: var(--font-text), var(--font-emoji); font-variant-emoji: emoji; }
.reply-quote { margin: 0 0 5px; padding: 4px 6px; border-left: 3px solid var(--orange); background: color-mix(in srgb, var(--surface) 68%, transparent); color: var(--text-soft); font-size: 10px; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-meta { display: flex; align-items: center; justify-content: flex-end; gap: 4px; color: var(--muted); font-size: 9px; line-height: 1; white-space: nowrap; }
.message-body .message-meta { grid-column: 2; justify-self: end; }
.delivery-seen { color: var(--blue); }
.deleted-message { color: var(--muted); font-style: italic; }
.deleted-label { grid-column: 1; }

/* Message actions intentionally stay inline, like early social-network posts. */
.message-actions { position: relative; display: flex; align-items: center; flex-wrap: wrap; gap: 0; min-height: 18px; margin: 3px -2px -2px; color: var(--link); font-size: 10px; line-height: 1.2; }
.mine .message-actions { justify-content: flex-end; }
.message-action { width: auto; height: auto; min-height: 18px; border: 0; border-radius: 0; padding: 1px 4px; background: transparent; color: var(--link); box-shadow: none; font-size: 10px; font-weight: 400; line-height: 1.2; text-decoration: none; cursor: pointer; }
.message-action + .message-action::before, .quick-reaction-picker + .message-action::before { content: "·"; margin-right: 7px; color: var(--muted-soft); pointer-events: none; }
.message-action:hover, .message-action:focus-visible { background: transparent; color: var(--link); text-decoration: underline; }
.message-action:disabled { text-decoration: none; }
.reaction-trigger .emoji-glyph { display: none; }
.quick-reaction-picker { position: absolute; z-index: 15; top: calc(100% + 3px); left: 0; display: flex; align-items: center; gap: 2px; padding: 4px; border: 1px solid var(--line); border-radius: 2px; background: var(--surface); box-shadow: 0 3px 9px var(--shadow); }
.mine .quick-reaction-picker { right: 0; left: auto; }
.quick-reaction-picker button { display: grid; width: 27px; height: 25px; place-items: center; border: 1px solid transparent; border-radius: 2px; padding: 0; background: transparent; color: var(--text); cursor: pointer; font-size: 15px; }
.quick-reaction-picker button:hover, .quick-reaction-picker button:focus-visible { border-color: var(--line); background: var(--pale-blue); }
.quick-reaction-picker .quick-reaction.selected { border-color: var(--blue); background: var(--pale-blue); }
.quick-reaction-picker .reaction-more { color: var(--link); font-size: 16px; }
.reaction-list { display: flex; flex-wrap: wrap; gap: 3px; margin: 4px 0 0; }
.reaction-badge { display: inline-flex; min-width: 26px; min-height: 20px; align-items: center; justify-content: center; gap: 3px; border: 1px solid var(--line); border-radius: 9px; padding: 1px 6px; background: var(--surface); color: var(--text); cursor: pointer; font-size: 10px; }
.reaction-badge .emoji-glyph { font-size: 12px; }
.reaction-badge:hover, .reaction-badge:focus-visible { border-color: var(--blue); background: var(--pale-blue); }
.reaction-badge-static { cursor: default; }
.message-more-menu { position: absolute; z-index: 18; top: calc(100% + 3px); right: 0; display: grid; min-width: 118px; padding: 3px; border: 1px solid var(--line); border-radius: 2px; background: var(--surface); box-shadow: 0 3px 9px var(--shadow); }
.message-more-menu.menu-above { top: auto; bottom: calc(100% + 3px); }
.message-more-menu.menu-align-left { right: auto; left: 0; }
.message-menu-item { width: 100%; min-height: 25px; border: 0; padding: 5px 7px; background: transparent; color: var(--text); cursor: pointer; font-size: 10px; text-align: left; }
.message-menu-item:hover, .message-menu-item:focus-visible { background: var(--pale-blue); color: var(--link); outline: 0; }
.delete-trigger { color: var(--danger); }

/* Emoji picker */
.emoji-picker-full { position: absolute; z-index: 22; left: 0; bottom: calc(100% + 6px); display: grid; grid-template-rows: auto auto minmax(0, 1fr); width: min(360px, calc(100vw - 20px)); max-height: min(440px, calc(100vh - 20px)); overflow: hidden; border: 1px solid var(--line); border-radius: 2px; background: var(--surface); box-shadow: 0 6px 18px var(--shadow); color: var(--text); }
.emoji-picker-full[data-align="right"] { right: 0; left: auto; }
.emoji-picker-full[data-placement="below"] { top: calc(100% + 6px); bottom: auto; }
.emoji-picker-full[data-fit="compact"] { max-height: min(340px, 52vh); }
.emoji-picker-header { display: flex; align-items: center; gap: 5px; padding: 6px; border-bottom: 1px solid var(--line-soft); background: var(--pale-blue); }
.emoji-search { min-width: 0; flex: 1; height: 28px; border: 1px solid var(--line); border-radius: 1px; padding: 5px 7px; background: var(--input); color: var(--text); font-size: 11px; }
.emoji-picker-close { display: grid; width: 28px; height: 28px; place-items: center; border: 1px solid var(--line); border-radius: 1px; background: var(--surface); color: var(--text); cursor: pointer; font-size: 17px; }
.emoji-picker-categories { display: flex; gap: 1px; overflow-x: auto; padding: 3px 5px; border-bottom: 1px solid var(--line-soft); background: var(--surface-alt); }
.emoji-category { display: grid; width: 29px; height: 27px; flex: 0 0 auto; place-items: center; border: 1px solid transparent; border-radius: 1px; background: transparent; color: var(--muted); cursor: pointer; }
.emoji-category:hover, .emoji-category:focus-visible, .emoji-category.selected { border-color: var(--line); background: var(--pale-blue); outline: 0; }
.emoji-picker-content { min-height: 0; overflow-y: auto; padding: 3px 6px 8px; }
.emoji-section-title { position: sticky; z-index: 1; top: 0; margin: 0; padding: 5px 2px 3px; background: color-mix(in srgb, var(--surface) 94%, transparent); color: var(--muted); font-size: 9px; font-weight: 700; text-transform: uppercase; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 1px; }
.emoji-cell { display: grid; min-width: 0; min-height: 34px; place-items: center; border: 1px solid transparent; border-radius: 2px; padding: 0; background: transparent; cursor: pointer; font-size: 18px; }
.emoji-cell .emoji-glyph { font-size: 18px; }
.emoji-cell:hover, .emoji-cell:focus-visible, .emoji-cell.selected { border-color: var(--blue); background: var(--pale-blue); outline: 0; }
.emoji-picker-empty { display: grid; min-height: 90px; place-items: center; color: var(--muted); font-size: 11px; text-align: center; }

/* Images, viewer and unread marker */
.image-card { display: block; max-width: min(76%, 460px); padding: 4px; }
.image-message-body { grid-template-columns: minmax(0, 1fr); row-gap: 4px; }
.image-message-body .image-body, .image-message-body .message-meta { grid-column: 1; }
.image-body { position: relative; display: grid; gap: 4px; min-width: 0; overflow: hidden; border: 1px solid var(--line-soft); background: var(--surface-alt); }
.image-card img { display: block; width: auto; max-width: 100%; max-height: min(52vh, 430px); object-fit: contain; }
.image-card img[role="button"] { cursor: zoom-in; }
.image-card .message-meta { padding: 1px 3px 2px; }
.view-once-preview { filter: blur(18px); transform: scale(1.06); }
.view-once-reveal { position: absolute; top: 50%; left: 50%; z-index: 1; min-height: 30px; transform: translate(-50%, -50%); border: 1px solid #fff; border-radius: 2px; padding: 5px 8px; background: rgba(24,43,68,.92) !important; color: #fff; cursor: pointer; font-size: 10px; font-weight: 700; white-space: nowrap; }
.image-status { color: var(--muted); font-size: 9px; }
.new-messages { position: absolute; z-index: 6; right: 50%; bottom: 10px; display: inline-flex; align-items: center; gap: 5px; transform: translateX(50%); border: 1px solid var(--blue-dark); border-radius: 2px; padding: 5px 8px; background: var(--blue); color: #fff; box-shadow: 0 2px 6px var(--shadow); cursor: pointer; font-size: 10px; font-weight: 700; }
.image-viewer { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); background: var(--overlay); }
.image-viewer-frame { position: relative; display: grid; max-width: 96vw; max-height: 92dvh; place-items: center; }
.image-viewer-image { display: block; max-width: 96vw; max-height: 90dvh; border: 4px solid var(--surface); object-fit: contain; box-shadow: 0 8px 28px rgba(0,0,0,.5); }
.image-viewer-close { position: absolute; z-index: 1; top: -10px; right: -10px; display: grid; width: 30px; height: 30px; place-items: center; border: 1px solid #fff; border-radius: 2px; background: var(--blue-deep); color: #fff; cursor: pointer; font-size: 18px; }

/* Composer */
.composer-area { padding: 7px clamp(8px, 2vw, 18px) max(8px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--pale-blue); }
.reply-composer { display: flex; align-items: center; justify-content: space-between; gap: 6px; max-width: 760px; margin: 0 auto 5px; padding: 5px 7px; border: 1px solid var(--line); border-left: 3px solid var(--orange); background: var(--surface-warm); color: var(--text-soft); font-size: 10px; }
.reply-composer-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-cancel { width: 22px; height: 22px; border: 0; background: transparent; color: var(--danger); cursor: pointer; }
.typing, .error { max-width: 760px; margin: 0 auto; font-size: 10px; }
.typing { margin-bottom: 4px; color: var(--blue-dark); font-style: italic; }
.typing::before { content: "•"; margin-right: 4px; color: var(--orange); }
.error { margin-top: 4px; color: var(--danger); }
.error:empty { display: none; }
#composer { display: flex; align-items: flex-end; gap: 4px; max-width: 760px; margin: 0 auto; padding: 4px; border: 1px solid var(--line); border-radius: 2px; background: var(--surface); box-shadow: inset 0 1px 2px var(--shadow); }
#composer:focus-within { border-color: var(--blue); outline: 1px solid color-mix(in srgb, var(--orange) 65%, transparent); }
textarea[name="message"] { flex: 1; min-width: 0; min-height: 31px; max-height: 110px; field-sizing: content; resize: none; border: 0; outline: 0; padding: 7px 5px; background: transparent; color: var(--text); font-size: 12px; line-height: 1.35; overflow-y: auto; }
textarea[name="message"]::placeholder { color: var(--muted-soft); }
.file-button, .view-once-option, #send { display: grid; width: 31px; height: 31px; flex: 0 0 auto; place-items: center; border-radius: 2px; cursor: pointer; }
.file-button { border: 1px solid var(--line); background: var(--surface-alt); color: var(--blue); font-size: 18px; }
.file-button:hover { background: var(--pale-blue); }
.file-button.disabled { opacity: .48; cursor: not-allowed; }
.file-button input { display: none; }
.view-once-option { position: relative; }
.view-once-option input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.view-once-option span[aria-hidden="true"] { display: grid; width: 100%; height: 100%; place-items: center; border: 1px solid transparent; border-radius: 2px; color: var(--muted); }
.view-once-option:hover span[aria-hidden="true"], .view-once-option input:checked + span { border-color: var(--blue); background: var(--pale-blue); color: var(--blue); }
#send { padding: 0; }
.send-text { display: none; }
.send-arrow { font-size: 15px; }

/* Games */
.game-panel { display: flex; flex-direction: column; gap: 10px; padding: 12px; background: var(--pale-blue); }
.game-panel-heading, .game-view { border: 1px solid var(--line); border-radius: 2px; background: var(--surface); box-shadow: 0 1px 2px var(--shadow); }
.game-panel-heading .panel-header { margin: -1px -1px 0; }
.mobile-chat-link { display: none; padding: 6px 8px 0; font-size: 10px; }
.game-selector { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 7px; }
.game-choice { min-height: 27px; padding: 4px; border-color: var(--line); background: linear-gradient(var(--surface), var(--surface-alt)); color: var(--text-soft); }
.game-choice.selected { border-color: #b66418; background: linear-gradient(#ffb563, #ee871f); color: #3d260f; }
.game-view { display: flex; flex: 1; flex-direction: column; gap: 8px; padding: 9px; }
.game-view h2 { padding-bottom: 5px; border-bottom: 1px solid var(--line-soft); color: var(--blue-dark); font-size: 14px; }
:root[data-theme="dark"] .game-view h2 { color: var(--link); }
.game-copy { color: var(--muted); font-size: 10px; }
.game-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; padding: 4px; border: 1px solid var(--line); background: var(--surface-warm); }
.game-tile { display: grid; aspect-ratio: 1; place-items: center; border: 1px solid var(--line-soft); border-radius: 1px; background: var(--pale-blue); color: var(--text); font-size: clamp(11px, 1.4vw, 16px); font-weight: 700; }
.value-2 { background: #d9e6f5; }.value-4 { background: #bdd2eb; }.value-8 { background: #ffcd99; }.value-16 { background: #ffb66c; }.value-32, .value-64 { background: #ee8d54; color: #fff; }.value-128, .value-256 { background: #4f79b7; color: #fff; }.value-512, .value-1024, .value-2048 { background: #285aa9; color: #fff; }
.game-meta { display: flex; justify-content: space-between; min-height: 18px; color: var(--muted); font-size: 10px; }
.game-meta strong { color: var(--text); }
.game-controls { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: auto; }
.game-controls button, .game-reset { min-height: 27px; }
.game-controls .game-reset { grid-column: 1 / -1; }
.blocky-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; padding: 4px; border: 1px solid var(--line); background: var(--surface-warm); }
.blocky-block { aspect-ratio: 1; border: 0; border-radius: 1px; background: var(--line-soft); cursor: pointer; transition: filter .1s ease, transform .1s ease; }
.blocky-block:hover { filter: brightness(1.12); transform: scale(1.06); }
.blocky-block.drop-target { box-shadow: inset 0 0 0 2px var(--blue); filter: brightness(1.15); }
.blocky-block.drop-invalid { box-shadow: inset 0 0 0 2px #c33; filter: saturate(.6); }
.blocky-drag-layer { position: fixed; z-index: 50; inset: 0; width: 100vw; height: 100vh; pointer-events: none; }
.blocky-1 { background: #285aa9; }.blocky-2 { background: #ff9933; }.blocky-3 { background: #5da36d; }.blocky-4 { background: #935eb1; }
.blocky-pieces { --blocky-preview-cell: clamp(10px, 3.2vw, 15px); display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.blocky-piece { min-width: 0; min-height: 52px; display: grid; place-items: center; overflow: hidden; padding: 3px; border: 1px solid var(--line); border-radius: 1px; background: var(--surface-alt); cursor: grab; touch-action: none; user-select: none; }
.blocky-piece.dragging, .blocky-piece.selected { border-color: var(--orange); box-shadow: inset 0 0 0 1px var(--orange); }
.blocky-piece:disabled { opacity: .35; cursor: default; }
.blocky-piece-preview { display: grid; flex: 0 0 auto; place-items: stretch; }
.blocky-piece-preview[data-rows="1"] { grid-template-rows: repeat(1, var(--blocky-preview-cell)); }
.blocky-piece-preview[data-rows="2"] { grid-template-rows: repeat(2, var(--blocky-preview-cell)); }
.blocky-piece-preview[data-rows="3"] { grid-template-rows: repeat(3, var(--blocky-preview-cell)); }
.blocky-piece-preview[data-columns="1"] { grid-template-columns: repeat(1, var(--blocky-preview-cell)); }
.blocky-piece-preview[data-columns="2"] { grid-template-columns: repeat(2, var(--blocky-preview-cell)); }
.blocky-piece-preview[data-columns="3"] { grid-template-columns: repeat(3, var(--blocky-preview-cell)); }
.blocky-piece-cell { width: var(--blocky-preview-cell); height: var(--blocky-preview-cell); border-radius: 1px; }
.blocky-piece-cell[data-preview-row="0"] { grid-row: 1; }.blocky-piece-cell[data-preview-row="1"] { grid-row: 2; }.blocky-piece-cell[data-preview-row="2"] { grid-row: 3; }
.blocky-piece-cell[data-preview-column="0"] { grid-column: 1; }.blocky-piece-cell[data-preview-column="1"] { grid-column: 2; }.blocky-piece-cell[data-preview-column="2"] { grid-column: 3; }
.blocky-reset { margin-top: auto; }

/* Multi-tab notice */
.tab-lock { position: fixed; z-index: 200; inset: 0; display: grid; place-items: center; padding: 18px; background: var(--overlay); }
.tab-lock-card { width: min(430px, 100%); border: 3px solid var(--surface); outline: 1px solid var(--line); padding: 0 18px 18px; background: var(--surface); box-shadow: 0 10px 32px rgba(0,0,0,.45); text-align: center; }
.tab-language, .tab-theme { margin-top: 10px; border-color: var(--line); background: var(--pale-blue); }
.tab-language button, .tab-theme button { color: var(--text-soft); }
.tab-language button.selected, .tab-theme button.selected { background: var(--blue); color: #fff; }
.tab-lock-card .eyebrow { margin-top: 15px; }
.tab-lock-card h2 { margin: 5px 0 8px; color: var(--blue-dark); font-size: 18px; }
.tab-lock-card p:not(.eyebrow) { color: var(--muted); font-size: 11px; }
.tab-lock-card .start-button { margin-top: 14px; }

@media (max-width: 1020px) {
  .portal-shell { grid-template-columns: 215px minmax(0, 1fr); grid-template-areas: "left main" "right main"; }
  .portal-right { align-self: start; }
  .chat-page { grid-template-columns: minmax(0, 1fr) minmax(230px, 270px); }
  .rules-panel { display: none; }
  .mobile-room-panel { display: grid; }
}

@media (max-width: 760px) {
  .masthead-inner { width: calc(100% - 16px); min-height: 52px; flex-wrap: wrap; gap: 5px 10px; padding: 6px 0; }
  .wordmark { font-size: 20px; }
  .masthead-tools { gap: 4px; }
  .theme-switcher button, .language-switcher button, .language-switcher a { padding-inline: 4px; font-size: 9px; }
  .portal-shell { width: calc(100% - 16px); grid-template-columns: 1fr; grid-template-areas: "main" "left" "right"; gap: 9px; margin-top: 8px; }
  .portal-column { gap: 9px; }
  .privacy-grid { grid-template-columns: 1fr; }
  .privacy-grid > div { border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .privacy-grid > div:last-child { border-bottom: 0; }
  .random-entry { align-items: stretch; flex-direction: column; }
  .start-button { justify-content: center; }
  .site-footer { width: calc(100% - 16px); flex-direction: column; gap: 3px; }
  .public-shell { width: calc(100% - 16px); margin-top: 8px; }
  .public-sections, .faq-list { grid-template-columns: 1fr; }
  .public-section, .public-section:nth-child(2n) { border-right: 0; }
  .public-nav { justify-content: flex-start; }

  .chat-page { height: auto; min-height: 100dvh; display: flex; flex-direction: column; overflow: visible; }
  .conversation { height: 100dvh; min-height: 560px; flex: 0 0 auto; border-right: 0; }
  .game-panel { min-height: 100dvh; flex: 0 0 auto; border-top: 4px solid var(--blue); scroll-margin-top: 0; }
  .chat-header { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "banner language" "theme actions"; }
  .chat-theme { justify-self: start; }
  .header-actions a.header-action { display: inline-flex; }
  .mobile-chat-link { display: block; }
  .header-actions { flex-wrap: wrap; }
  .bubble, .image-card { max-width: 89%; }
  .messages { padding-inline: 9px; }
  .emoji-picker-full { position: fixed; right: 7px !important; bottom: max(7px, env(safe-area-inset-bottom)) !important; left: 7px !important; top: auto !important; width: auto; max-height: min(70vh, 430px); }
}

@media (max-width: 430px) {
  body { font-size: 12px; }
  .masthead-tools { margin-left: auto; }
  .language-switcher button, .language-switcher a, .theme-switcher button { min-height: 19px; padding: 2px 3px; font-size: 8px; }
  .welcome-card-body { padding: 16px; }
  .welcome-card h1 { font-size: 29px; }
  .chat-header { padding-inline: 7px; }
  .connection-status { width: 8px; max-width: 8px; gap: 0; font-size: 0; }
  .status-separator { display: none; }
  .header-action { padding-inline: 6px; font-size: 10px; }
  .emoji-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .message-body { column-gap: 5px; }
  .message-meta { font-size: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

@keyframes searching { to { transform: rotate(360deg); } }
