.screen-chat-button {
  position: fixed; z-index: 18; width: 48px; height: 48px; box-sizing: border-box;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 6px; font: 20px/1.2 Arial,sans-serif; color: #fff;
  background: #343332f5; border: 1px solid #aaa; border-radius: 8px;
  box-shadow: 0 2px 8px #0005; cursor: pointer; touch-action: none;
  transform: scale(var(--menu-inverse-scale, 1)); transform-origin: 0 0;
}
.screen-chat-button::before { content: '💬'; font-size: 22px; flex: 0 0 auto; }
.screen-chat-button:focus-visible { outline: 3px solid #81ceff; outline-offset: 2px; }
.screen-chat-button.selection-obscured { visibility: hidden; pointer-events: none; }
.screen-chat-unread {
  position: absolute; right: -6px; top: -8px; min-width: 23px; height: 23px;
  box-sizing: border-box; padding: 2px 5px; border: 1px solid #ffd6d6;
  border-radius: 14px; background: #b52c32; color: #fff; font: bold 14px/17px Arial,sans-serif;
}
.screen-chat-unread[hidden] { display: none; }
body > .dialog.screen-chat-popup {
  position: fixed !important; left: 50% !important;
  top: calc(var(--chat-center-y, var(--menu-screen-height, 100vh) / 2) * var(--menu-inverse-scale, 1)) !important;
  width: min(440px, calc(var(--menu-screen-width, 100vw) - 24px)) !important;
  height: min(640px, calc(var(--chat-visible-height, var(--menu-screen-height, 100vh)) - 24px)) !important;
  max-height: calc(var(--chat-visible-height, var(--menu-screen-height, 100vh)) - 24px);
  box-sizing: border-box; display: flex !important; flex-direction: column;
  transform: translate(-50%, -50%) scale(var(--menu-inverse-scale, 1)) !important;
  transform-origin: center; margin: 0 !important; overflow: hidden;
  z-index: 36 !important; background: #30302efc; color: white;
  border: 1px solid #999; border-radius: 12px; font: 20px/1.5 Arial,sans-serif;
}
.screen-chat-header {
  position: relative; flex: 0 0 auto; display: flex; justify-content: space-between; align-items: center;
  min-height: 56px; padding: 6px 10px 6px 16px; box-sizing: border-box; border-bottom: 1px solid #777;
}
.screen-chat-header > * { position: static; }
.screen-chat-header button { width: 44px; height: 44px; font: 28px/1 Arial,sans-serif; background: #4b4a48; color: white; border: 0; border-radius: 6px; cursor: pointer; }
body > .dialog.screen-chat-popup > .bar { display: none; }
body > .dialog.screen-chat-popup > .content-container {
  position: relative !important; top: auto !important; left: 0; width: 100%; height: auto !important;
  flex: 1 1 auto; min-height: 0; max-height: calc(var(--chat-visible-height, var(--menu-screen-height, 100vh)) - 92px);
  overflow: auto !important; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
}
body > .dialog.screen-chat-popup .content { position: relative; width: 100% !important; height: auto; }
body > .dialog.screen-chat-popup :is(.text, .caption) { font: 20px/1.5 Arial,sans-serif; }
body > .dialog.screen-chat-popup input { box-sizing: border-box; min-height: 44px; padding: 8px; font: 20px/1.4 Arial,sans-serif; }
.chat-gif-toolbar { position: relative; display: flex; align-items: center; gap: 12px; padding: 0 12px 12px; box-sizing: border-box; width: 100%; }
.chat-gif-toolbar > * { position: static; }
.chat-gif-toolbar button { min-height: 44px; min-width: 64px; border: 1px solid #aaa; border-radius: 6px; background: #454442; color: white; font: bold 18px Arial,sans-serif; cursor: pointer; }
.chat-gif-toolbar span { font: 16px/1.4 Arial,sans-serif; }
.chat-gif-picker { position: relative; display: block; padding: 0 12px 12px; box-sizing: border-box; width: 100%; text-align: left; }
.chat-gif-picker[hidden] { display: none !important; }
.chat-gif-picker > input, .chat-gif-picker > select { position: static; display: block; width: 100%; margin: 0 0 8px; }
.chat-gif-picker > select { min-height: 44px; padding: 6px; font: 18px Arial,sans-serif; color: white; background: #454442; }
.chat-gif-grid { position: relative; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; max-height: 270px; overflow: auto; overscroll-behavior: contain; }
.chat-gif-grid .chat-gif-choice { position: relative; display: flex; align-items: center; justify-content: center; width: 100%; height: 88px; padding: 4px; box-sizing: border-box; border: 1px solid #777; border-radius: 6px; background: #454442; cursor: pointer; }
.chat-gif-choice:hover, .chat-gif-choice:focus-visible { outline: 2px solid #81ceff; outline-offset: -2px; }
.chat-gif-choice img { position: static; display: block; max-width: 100%; max-height: 100%; object-fit: contain; }
.chat-gif-tile { position: relative; min-width: 0; }
.chat-gif-star { position: absolute; right: 1px; top: 1px; z-index: 1; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 0 8px 0 12px; background: #1c2028e8; color: #fff; font: 27px/44px Arial,sans-serif; cursor: pointer; touch-action: manipulation; }
.chat-gif-star[aria-pressed="true"] { color: #ffda70; background: #493c20ed; }
.chat-gif-star:hover, .chat-gif-star:focus-visible { outline: 2px solid #9acbff; outline-offset: -2px; }
.chat-gif-shelves { position: relative; flex: 0 0 auto; display: flex; gap: 5px; }
.chat-gif-shelves button { position: static; flex: 1 1 0; min-width: 0; min-height: 44px; padding: 6px 4px; border: 1px solid transparent; border-radius: 8px; background: #30353e; color: #bec7d4; font: bold 14px/1.3 Arial,sans-serif; cursor: pointer; }
.chat-gif-shelves button[aria-pressed="true"] { background: #3c5069; border-color: #769cc6; color: #fff; }
.chat-gif-empty { position: relative; grid-column: 1 / -1; margin: 0; padding: 22px 8px; color: #c0c9d8; text-align: center; font: 14px/1.6 Arial,sans-serif; }
.chat-gif-picker small { display: block; margin-top: 8px; font: 15px/1.4 Arial,sans-serif; }
.chat-gif-refresh { position: static; min-height: 44px; width: 100%; margin-bottom: 8px; font: 18px Arial,sans-serif; color: white; background: #454442; border: 1px solid #999; border-radius: 6px; cursor: pointer; }
.chat-gif-refresh:disabled { opacity: .6; }
.chat-gif-credit { display: block; margin-top: 8px; font: 14px Arial,sans-serif; color: #aadaff; }
.chat-gif-credit[hidden] { display: none; }
/* Room chat: one message stream, one composer, and dedicated media tabs. */
body > .dialog.screen-chat-modern {
  width: min(420px, calc(var(--menu-screen-width, 100vw) - 24px)) !important;
  height: min(520px, calc(var(--chat-visible-height, var(--menu-screen-height, 100vh)) - 24px)) !important;
  background: #25282dfc; border: 1px solid #626872; border-radius: 18px;
  box-shadow: 0 16px 48px #0009; font: 17px/1.45 Arial,sans-serif; text-align: left;
}
body > .dialog.screen-chat-modern.chat-media-active {
  height: min(640px, calc(var(--chat-visible-height, var(--menu-screen-height, 100vh)) - 24px)) !important;
}
body > .dialog.screen-chat-modern > .content-container {
  flex: 1 1 0; min-height: 0; max-height: none; overflow: hidden !important;
}
body > .dialog.screen-chat-modern .content {
  position: relative !important; inset: auto; display: flex; flex-direction: column;
  height: 100% !important; min-height: 0; padding: 0; overflow: hidden; box-sizing: border-box;
}
.screen-chat-modern .content > * { margin: 0; width: 100%; box-sizing: border-box; }
.screen-chat-modern .screen-chat-header {
  min-height: 64px; padding: 10px 12px 10px 16px; border-bottom: 1px solid #3d424a;
}
.screen-chat-modern .chat-heading { display: flex; flex-direction: column; gap: 1px; }
.screen-chat-modern .chat-heading strong { font: bold 19px/1.3 Arial,sans-serif; }
.screen-chat-modern .chat-heading span { color: #b9bfc9; font: 12px/1.4 Arial,sans-serif; }
.screen-chat-modern .screen-chat-header button { width: 44px; height: 44px; background: #ffffff09; border-radius: 12px; }
.screen-chat-modern .chat-tabs {
  position: relative; flex: 0 0 54px; display: flex; gap: 4px; padding: 5px 12px;
  border-bottom: 1px solid #3d424a; background: #202328;
}
.screen-chat-modern .chat-tab {
  position: relative; flex: 1; min-width: 0; min-height: 44px; padding: 6px;
  border: 0; border-radius: 8px; background: transparent; color: #bbc2cd; font: bold 15px/1.3 Arial,sans-serif; cursor: pointer;
}
.screen-chat-modern .chat-tab[aria-selected="true"] { background: #414754; color: white; }
.screen-chat-modern .chat-tab-unread { position: static; display: inline-block; margin-left: 5px; padding: 1px 5px; min-width: 18px; border-radius: 12px; background: #b12c32; color: white; font: 12px Arial,sans-serif; }
.screen-chat-modern .chat-stream, .screen-chat-modern .chat-media { position: relative; flex: 1 1 0; min-height: 0; overflow: hidden; }
.screen-chat-modern .chat-messages {
  position: relative; display: block; box-sizing: border-box; width: 100%; height: 100%; min-height: 0; overflow: auto;
  padding: 16px 14px 24px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
}
.screen-chat-modern .chat-empty { position: relative; height: 100%; min-height: 90px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; color: #aeb6c3; text-align: center; }
.screen-chat-modern .chat-empty > * { position: static; }
.screen-chat-modern .chat-empty-icon { font-size: 32px; opacity: .75; }
.screen-chat-modern .chat-empty strong { font: bold 17px/1.4 Arial,sans-serif; color: #e4e7ec; }
.screen-chat-modern .chat-empty > span:last-child { font: 13px/1.5 Arial,sans-serif; }
.screen-chat-modern .chat-message { position: relative; width: fit-content; max-width: 92%; margin-bottom: 12px; padding: 9px 12px; border-radius: 4px 12px 12px; background: #353a43; box-sizing: border-box; }
.screen-chat-modern .chat-message.is-own { margin-left: auto; border-radius: 12px 4px 12px 12px; background: #354b62; }
.screen-chat-modern .chat-message-author { position: static; display: block; margin-bottom: 3px; color: #b8d0ec; font: bold 13px/1.4 Arial,sans-serif; overflow-wrap: anywhere; }
.screen-chat-modern .chat-message-body { position: relative; color: #f0f2f6; font: 17px/1.5 Arial,sans-serif; white-space: pre-wrap; overflow-wrap: anywhere; }
.screen-chat-modern .chat-message-body img { position: static; max-width: 100%; width: 68px; height: 68px; object-fit: contain; }
.screen-chat-modern .chat-new-messages { position: absolute; right: 12px; bottom: 8px; padding: 7px 12px; border: 1px solid #92b7e6; border-radius: 18px; background: #344d6c; color: white; font: 13px Arial,sans-serif; cursor: pointer; }
.screen-chat-modern .chat-composer { position: relative; flex: 0 0 auto; padding: 10px 12px 9px; border-top: 1px solid #3d424a; background: #202328; }
.screen-chat-modern .chat-compose-form { position: relative; display: flex; gap: 8px; width: 100%; }
body > .dialog.screen-chat-modern .chat-message-input {
  position: static; display: block; flex: 1 1 0; min-width: 0; width: 0; min-height: 46px; height: 46px;
  box-sizing: border-box; padding: 10px 12px; border: 1px solid #586170; border-radius: 12px;
  background: #353a43; color: white; font: 16px/1.4 Arial,sans-serif;
}
.screen-chat-modern input::placeholder { color: #a9b1bf; opacity: 1; }
.screen-chat-modern .chat-send { position: static; flex: 0 0 46px; width: 46px; height: 46px; border: 0; border-radius: 12px; background: #477eaf; color: white; font: 23px Arial,sans-serif; cursor: pointer; }
.screen-chat-modern .chat-send:disabled { color: #858c98; background: #353a43; cursor: default; }
.screen-chat-modern .chat-compose-note { position: relative; margin-top: 6px; color: #aeb6c3; font: 11px/1.4 Arial,sans-serif; }
.screen-chat-modern .chat-gif-picker { position: relative; display: flex; flex-direction: column; height: 100%; min-height: 0; padding: 12px; gap: 10px; }
.screen-chat-modern .chat-gif-search-row { position: relative; display: flex; gap: 8px; flex: 0 0 auto; }
body > .dialog.screen-chat-modern .chat-gif-search-row input { position: static; flex: 1 1 0; width: 0; min-width: 0; height: 44px; padding: 8px 10px; border: 1px solid #586170; border-radius: 10px; background: #353a43; color: white; font: 16px Arial,sans-serif; }
.screen-chat-modern .chat-gif-submit { position: static; flex: 0 0 auto; padding: 8px 12px; border: 1px solid #586170; border-radius: 10px; background: #414b5c; color: white; font: 14px Arial,sans-serif; cursor: pointer; }
.screen-chat-modern .chat-gif-filters { position: relative; display: flex; flex: 0 0 44px; align-items: center; gap: 8px; min-width: 0; }
.screen-chat-modern .chat-gif-filters select { position: static; max-width: 50%; min-width: 0; height: 44px; padding: 5px 7px; border: 1px solid #586170; border-radius: 8px; background: #353a43; color: #e7ebf1; font: 14px Arial,sans-serif; }
.screen-chat-modern .chat-gif-filters [role="status"] { position: static; flex: 1; min-width: 0; color: #b9c2d0; font: 12px/1.4 Arial,sans-serif; }
.screen-chat-modern .chat-gif-refresh { position: static; flex: 0 0 auto; width: auto; min-height: 44px; margin: 0; padding: 5px 10px; border: 1px solid #586170; border-radius: 8px; background: #353a43; color: #e7ebf1; font: 14px Arial,sans-serif; }
.screen-chat-modern .chat-gif-grid { position: relative; flex: 1 1 0; min-height: 0; max-height: none; grid-auto-rows: 100px; align-content: start; padding: 2px; gap: 7px; }
.screen-chat-modern .chat-gif-grid .chat-gif-choice { height: 100px; border-radius: 9px; border: 1px solid #4e5663; background: #31363e; }
.screen-chat-modern .chat-gif-footer { position: relative; flex: 0 0 auto; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 10px; align-items: center; }
.screen-chat-modern .chat-gif-footer small { position: static; margin: 0; color: #b9c2d0; font: 11px/1.4 Arial,sans-serif; }
.screen-chat-modern .chat-gif-credit { position: static; margin: 0; font: 11px/1.4 Arial,sans-serif; }
.screen-chat-modern :is(button,input,select):focus-visible { outline: 2px solid #9acbff; outline-offset: 2px; }
.screen-chat-modern [hidden] { display: none !important; }
@media (max-height: 500px) {
  .screen-chat-modern .screen-chat-header { min-height: 50px; padding: 3px 12px; }
  .screen-chat-modern .chat-heading span { display: none; }
  .screen-chat-modern .chat-tabs { flex-basis: 50px; padding-top: 3px; padding-bottom: 3px; }
  .screen-chat-modern .chat-gif-picker { padding: 8px 12px; gap: 6px; }
  .screen-chat-modern .chat-gif-grid { grid-auto-rows: 82px; }
  .screen-chat-modern .chat-gif-grid .chat-gif-choice { height: 82px; }
}
.game-gif-reaction {
  position: fixed; z-index: 24; width: var(--game-gif-size, 140px); pointer-events: none;
  transform: scale(var(--menu-inverse-scale, 1)); transform-origin: 0 0;
  user-select: none; -webkit-user-select: none;
}
.game-gif-reaction img { position: static; display: block; width: 100%; height: var(--game-gif-size, 140px); object-fit: contain; background: #181818a6; border-radius: 8px; box-shadow: 0 2px 12px #0009; }
.game-gif-reaction span { position: static; display: block; width: 100%; padding: 4px 0; color: #fff; background: #202020db; font: 15px/20px Arial,sans-serif; text-align: center; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.experience-backdrop { position: fixed; left: 50%; top: 50%; width: var(--menu-screen-width, 100vw); height: var(--menu-screen-height, 100vh); transform: translate(-50%, -50%) scale(var(--menu-inverse-scale, 1)); transform-origin: center; z-index: 1000003; display: flex; justify-content: center; align-items: center; padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)); box-sizing: border-box; background: #0009; }
.experience-panel { position: relative; display: flex; flex-direction: column; width: min(100%, 760px); height: min(860px, calc(var(--menu-screen-height, 100vh) - 24px)); max-height: 100%; overflow: hidden; background: #30302e; color: #fff; border: 1px solid #888; border-radius: 14px; font: 20px/1.6 Arial,sans-serif; box-sizing: border-box; }
.experience-panel * { position: static; box-sizing: border-box; }
.experience-panel header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid #777; }
.experience-panel h2 { margin: 0; font-size: 24px; }
.experience-panel header button { min-width: 48px; flex: 0 0 48px; }
.experience-panel h3, .experience-panel h4 { margin: 18px 0 8px; }
.experience-content { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 16px; -webkit-overflow-scrolling: touch; }
.experience-panel button, .experience-panel input, .experience-panel select { min-height: 48px; font: inherit; border: 1px solid #999; border-radius: 8px; padding: 8px 12px; }
.experience-panel button { background: #315f80; color: #fff; cursor: pointer; margin: 4px; touch-action: manipulation; }
.experience-panel input { display: block; width: 100%; color: #fff; background: #454543; }
.experience-panel label { display: block; }
.experience-panel :focus-visible { outline: 3px solid #81ceff; outline-offset: 2px; }
.experience-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 0; border-bottom: 1px solid #666; }
.experience-row strong { flex: 1 1 100%; }
.experience-panel summary { padding: 12px 0; cursor: pointer; border-bottom: 1px solid #777; }
.experience-panel li { padding: 4px 0; overflow-wrap: anywhere; }
#window .online-lobby .lobby-room[hidden] { display: none !important; }
#window .online-lobby .lobby-room-hint { padding: 8px 12px; background: #315f80; border-radius: 8px; min-height: 44px; box-sizing: border-box; }
#window .online-lobby > .home-profile, #splash > .home-profile { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; }
#window .online-lobby .home-profile-tools, #splash .home-profile-tools { grid-column: 1 / -1; position: static; display: flex; gap: 12px; }
#window .online-lobby .home-profile-extra, #splash .home-profile-extra { flex: 1 1 40%; }
#window > .room-tools { position: absolute; left: 50%; top: auto; bottom: calc(100px * var(--menu-inverse-scale, 1)); transform: translateX(-50%) scale(var(--menu-inverse-scale, 1)); transform-origin: bottom center; z-index: 22; display: flex; gap: 10px; }
#window .room-tools button { position: static; min-height: 48px; padding: 10px 16px; font: 20px/1.4 Arial,sans-serif; color: #fff; background: #315f80; border: 1px solid #999; border-radius: 10px; white-space: nowrap; }
#window .room-tools button[hidden] { display: none; }
#window .room-ready-badge { display: block !important; position: absolute; z-index: 30; top: calc(100% + 4px * var(--menu-inverse-scale, 1)); bottom: auto; left: 50%; right: auto; width: max-content; padding: 4px 8px; font: 18px/1.2 Arial,sans-serif; color: #fff; background: #793434; border-radius: 6px; text-align: center; pointer-events: none; transform: translateX(-50%) scale(var(--menu-inverse-scale, 1)); transform-origin: center top; }
#window .room-ready-status { position: static; display: flex; align-items: center; color: white; padding: 8px; font: 20px/1.4 Arial,sans-serif; background: #252525e8; border-radius: 8px; white-space: nowrap; }
#window .room-ready-badge.is-ready { background: #24582c; }
.connection-countdown { display: block; font-weight: bold; margin-top: 6px; }
#noname-connection-status { width: min(640px, calc(var(--menu-screen-width, 100vw) - 24px)); max-width: none; top: calc(20px * var(--menu-inverse-scale, 1)); transform: translateX(-50%) scale(var(--menu-inverse-scale, 1)); transform-origin: center top; }
#target-reason, #selection-summary { position: fixed; z-index: 25; left: 50%; transform: translateX(-50%) scale(var(--menu-inverse-scale, 1)); transform-origin: center bottom; width: max-content; max-width: calc(var(--menu-screen-width, 100vw) - 24px); box-sizing: border-box; color: #fff; padding: 8px 12px; border-radius: 8px; background: #222e; font: 18px/1.4 Arial,sans-serif; text-align: center; pointer-events: none; }
#target-reason { top: 35%; }
#selection-summary { bottom: 22%; }
#selection-summary[hidden] { display: none; }
#window #arena .player.selected { outline: 4px solid #ffe681; outline-offset: 2px; }
#window #arena .card.selected { outline: 3px solid #ffe681; outline-offset: -2px; }
@media (pointer: coarse) and (orientation: portrait) {
  #window .room-ready-badge { font-size: 18px; }
}
@media (orientation: portrait) {
  .mobile-menu-ui #window #arena { height: calc(100% - max(44px, env(safe-area-inset-bottom)) * var(--menu-inverse-scale, 1)) !important; }
  .mobile-menu-ui #window > .connectbutton { top: auto !important; bottom: calc(max(44px, env(safe-area-inset-bottom)) * var(--menu-inverse-scale, 1)); transform-origin: bottom center; }
  .mobile-menu-ui #window > .room-tools { bottom: calc((max(44px, env(safe-area-inset-bottom)) + 72px) * var(--menu-inverse-scale, 1)); }
}
@media (max-height: 500px) { .experience-panel { max-height: 100%; } #selection-summary { bottom: 26%; font-size: 16px; } }
#window #roundmenu.draggable-roundmenu {
  touch-action: none; user-select: none; -webkit-user-select: none;
  cursor: grab; transition: none;
  transform: scale(var(--menu-inverse-scale, 1)) !important; transform-origin: 0 0;
}
#window #roundmenu.draggable-roundmenu:active { cursor: grabbing; }
.cloud-lobby-connection {
  position: absolute; left: calc(50% - 160px * var(--menu-inverse-scale, 1));
  top: 40%; width: 320px; text-align: center; font: 20px/1.5 Arial,sans-serif;
  color: white; text-shadow: 0 1px 3px black;
  transform: scale(var(--menu-inverse-scale, 1)); transform-origin: 0 0;
}
.cloud-lobby-connection button { min-height: 52px; padding: 10px 24px; font: 20px Arial,sans-serif; }
