/* Preserve the original game artwork; mobile chat uses restrained brown and gold tones. */
.mobile-only { display: none; }
html.mobile-layout { height: 100%; overflow: hidden; overscroll-behavior: none; }
html.mobile-layout body { position: fixed; inset: 0; width: 100%; height: 100%; padding: 0; overflow: hidden; overscroll-behavior: none; touch-action: pan-y; }
html.mobile-layout .game-wrapper {
    display: grid; grid-template-rows: var(--mobile-toolbar-height, 34px) var(--mobile-board-height, 208px) var(--mobile-summary-height, 70px) minmax(0, 1fr);
    width: 100%; height: var(--mobile-height, 100dvh); min-height: 0; margin: 0;
    padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); overflow: hidden;
}
html.mobile-layout .window-bar { grid-row: 1; min-width: 0; height: 100%; gap: 4px; padding-inline: 4px; }
html.mobile-layout .window-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
html.mobile-layout .window-logo { flex: none; }
html.mobile-layout .window-link { display: flex; align-items: center; justify-content: center; flex: none; min-height: 24px; padding: 1px 8px; }
html.mobile-layout .music-toggle { width: 27px; height: 24px; }
html.mobile-layout .mobile-only { display: flex; }
html.mobile-layout .mobile-board-row { grid-row: 2; position: relative; min-width: 0; min-height: 0; overflow: hidden; }
html.mobile-layout .mobile-board-canvas { position: absolute; inset: 0 auto auto 0; width: 794px; height: 428px; transform-origin: top left; }
html.mobile-layout .mobile-board-canvas .control-bar { top: 390px; }
html.mobile-layout .mobile-board-canvas #race-overlay { top: 0; width: 794px; height: 428px; }
html.mobile-layout #desktop-bottom-area { display: none; }
html.mobile-layout .mobile-summary-row { grid-row: 3; position: relative; min-width: 0; min-height: 0; overflow: hidden; }
html.mobile-layout .mobile-summary-canvas { position: absolute; inset: 0 auto auto 0; width: 794px; height: 144px; transform-origin: top left; }
html.mobile-layout .mobile-summary-canvas .box-left, html.mobile-layout .mobile-summary-canvas .box-rich { display: flex; flex: none; width: 284px; }
html.mobile-layout .mobile-summary-canvas .box-left { order: 0; }
html.mobile-layout .mobile-summary-canvas .box-middle { order: 1; }
html.mobile-layout .mobile-summary-canvas .box-rich { order: 2; }
html.mobile-layout .mobile-social-row { grid-row: 4; min-width: 0; min-height: 0; padding: 0 2px; overflow: hidden; }
html.mobile-layout .mobile-social-row .box-right {
    min-width: 0; min-height: 0; width: 100%; height: 100%; padding-right: 0;
    border: 1px solid #927a4c; border-radius: 4px; background: #29221d; color: #e6d8b8;
    /* Fifteen faint outlines stay staggered without bunching up when the keyboard opens. */
    --chat-dog-print: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20160%20160%22%3E%3Cg%20transform%3D%22rotate(-9%2080%2080)%22%20fill%3D%22none%22%20stroke%3D%22%23d7bd85%22%20stroke-width%3D%223.5%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%20opacity%3D%22.065%22%3E%3Cpath%20d%3D%22M40%2069%2035%2023Q55%2025%2068%2048Q80%2044%2093%2049Q108%2025%20124%2023L119%2072C128%2089%20129%20113%20111%20128C95%20141%2066%20142%2048%20127C31%20114%2030%2088%2040%2069Z%22%2F%3E%3Cpath%20d%3D%22m46%2040%204%2022%2011-9m41%200%2012%2010%202-23M54%2087q7-5%2013%200m25%200q7-5%2013%200M80%20112v5q-6%207-12%200m12%200q6%207%2012%200%22%2F%3E%3Cpath%20d%3D%22M74%20105q6-6%2012%200l-6%207Z%22%20fill%3D%22%23d7bd85%22%20stroke%3D%22none%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E");
    background-image: var(--chat-dog-print), var(--chat-dog-print), var(--chat-dog-print),
        var(--chat-dog-print), var(--chat-dog-print), var(--chat-dog-print),
        var(--chat-dog-print), var(--chat-dog-print), var(--chat-dog-print),
        var(--chat-dog-print), var(--chat-dog-print), var(--chat-dog-print),
        var(--chat-dog-print), var(--chat-dog-print), var(--chat-dog-print),
        linear-gradient(155deg, #2d251f, #29221d 55%, #27201b);
    background-size: 52px 52px, 42px 42px, 46px 46px, 48px 48px,
        44px 44px, 50px 50px, 42px 42px, 46px 46px,
        40px 40px, 44px 44px, 42px 42px, 46px 46px,
        40px 40px, 44px 44px, 40px 40px, 100% 100%;
    background-position: right 7% top 88px, left 12% top 150px, left 51% top 52px,
        right 24% top 236px, left 18% top 316px, right 4% top 380px,
        left 43% top 436px, left 5% top 410px, left 4% top 60px,
        right 28% top 136px, left 36% top 208px, right 6% top 280px,
        left 5% top 240px, right 36% top 358px, left 68% top 424px, center;
    background-repeat: no-repeat;
    font-family: -apple-system, BlinkMacSystemFont, 'Microsoft YaHei', sans-serif;
}
html.mobile-layout .mobile-social-row .box-right button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
html.mobile-layout .chat-heading {
    display: flex; flex: none; align-items: center; justify-content: center; gap: 10px;
    height: 26px; padding: 0 13px; color: #c9b17d; background: #29221d;
    font-size: 10px; line-height: 26px; letter-spacing: 2px;
}
html.mobile-layout .chat-heading-label {
    flex: none; padding-left: 3px; color: #d8b97c;
    font: 900 14px/20px 'Songti SC', 'STSong', 'Noto Serif SC', SimSun, serif;
    letter-spacing: 3px; white-space: nowrap;
    text-shadow: 0 -1px #f6dfaa55, 0 1px #160f08, 0 2px 1px #080604;
}
@supports ((background-clip: text) or (-webkit-background-clip: text)) {
    html.mobile-layout .chat-heading-label {
        background-image: linear-gradient(180deg, #fff0be 0%, #dbbd81 28%, #9b753e 48%, #efd69d 53%, #bc975d 78%, #ecd19a 100%);
        -webkit-background-clip: text; background-clip: text;
        -webkit-text-fill-color: transparent; color: transparent; text-shadow: none;
        filter: drop-shadow(0 -.5px 0 #eddbaf40) drop-shadow(0 1px 0 #160f08) drop-shadow(0 2px 1px #080604);
    }
}
html.mobile-layout .chat-heading::before, html.mobile-layout .chat-heading::after {
    content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, #8d75484d);
    box-shadow: 0 1px 0 #100c0855;
}
html.mobile-layout .chat-heading::after { transform: scaleX(-1); }
/* Keep the existing space for messages and the editor while a keyboard is open. */
html.mobile-layout .game-wrapper[data-chat-keyboard="true"] .chat-heading { display: none; }
html.mobile-layout .chat-sidebar { position: static; display: flex; flex-direction: row; justify-content: flex-start; flex: none; gap: 4px; width: auto; height: 33px; padding: 0 8px; border-bottom: 1px solid #66553a; background: #30271f; }
html.mobile-layout .chat-sidebar button { min-width: 56px; padding: 0 10px; border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; color: #b5a58a; writing-mode: horizontal-tb; letter-spacing: 1px; font-family: inherit; font-size: 11px; line-height: 30px; }
html.mobile-layout .chat-sidebar button[aria-selected="true"] { color: #e3c886; border-bottom-color: #ba9858; background: transparent; box-shadow: none; }
html.mobile-layout .chat-sidebar button:focus-visible { outline: 1px solid #d5ba7a; outline-offset: -3px; }
html.mobile-layout .chat-messages { padding: 9px 8px; color: #e6d8b8; font-family: inherit; scrollbar-color: #756245 transparent; }
html.mobile-layout .chat-msg { display: grid; grid-template-columns: 22px minmax(0,1fr); column-gap: 6px; row-gap: 2px; align-items: start; margin-bottom: 9px; }
html.mobile-layout .chat-avatar { grid-column: 1; grid-row: 1 / 3; width: 22px; height: 22px; margin: 1px 0 0; }
html.mobile-layout .chat-msg .chat-name { grid-column: 2; grid-row: 1; color: #b5a58a; font-size: 10px; line-height: 14px; font-weight: normal; }
html.mobile-layout .chat-msg .chat-text { grid-column: 2; grid-row: 2; justify-self: start; min-width: 0; max-width: 100%; padding: 4px 7px; border: 1px solid #544735; border-radius: 0 4px 4px 4px; background: #362d24; color: #e6d8b8; font-size: 12px; line-height: 18px; white-space: pre-wrap; overflow-wrap: anywhere; }
html.mobile-layout .chat-input-area { align-items: stretch; gap: 6px; height: 42px; padding: 5px 7px; border-top: 1px solid #66553a; background: #30271f; }
html.mobile-layout .chat-input { padding-inline: 7px; border-color: #756245; border-radius: 7px; background: #241e19; color: #e6d8b8; caret-color: #e3c886; }
html.mobile-layout .chat-input:focus { outline: 1px solid #ba9858; outline-offset: -1px; }
html.mobile-layout .chat-input::placeholder { color: #b0a088; }
html.mobile-layout .chat-btn { width: 43px; border-color: #c4a25e; border-radius: 6px; background: linear-gradient(#d3b97b, #b29559); color: #352817; font-size: 11px; }
html.mobile-layout .chat-btn:active { background: #a68a51; }
html.mobile-layout .online-heading { padding: 6px 9px; border-bottom-color: #66553a80; color: #b5a58a; font: 11px/16px -apple-system, BlinkMacSystemFont, 'Microsoft YaHei', sans-serif; }
html.mobile-layout .online-players { padding: 0 9px; scrollbar-color: #756245 transparent; }
html.mobile-layout .online-player { gap: 6px; padding: 6px 1px; border-bottom-color: #66553a70; font: 11px/16px -apple-system, BlinkMacSystemFont, 'Microsoft YaHei', sans-serif; }
html.mobile-layout .online-player-avatar { width: 22px; height: 22px; }
html.mobile-layout .online-self { border-color: #756245; color: #d5ba7a; font-size: 10px; }
html.mobile-layout .online-note { color: #b5a58a; font: 11px/16px -apple-system, BlinkMacSystemFont, 'Microsoft YaHei', sans-serif; }
html.mobile-layout .btm-content, html.mobile-layout .bet-records, html.mobile-layout .chat-messages, html.mobile-layout .online-players { overscroll-behavior: contain; }
/* Keep the computed input font large enough to avoid focus zoom on iOS. */
html.mobile-layout .chat-input { font-size: 16px; }
html.mobile-layout .chat-input::placeholder { font-size: 12px; }
html.mobile-layout .settings-dialog, html.mobile-layout .vault-dialog { max-width: calc(100vw - 22px); }
@media (max-height: 480px) {
    html.mobile-layout .chat-heading { display: none; }
}
@media (max-width: 350px) {
    html.mobile-layout .window-logo { display: none; }
    html.mobile-layout .window-title { font-size: 10px; }
    html.mobile-layout .window-link { padding-inline: 6px; }
}
