/* New API adapters only. Layout, panels, cards and all phase colors come from css/game_app.css. */
[hidden]{display:none!important}
html[data-game-phase="beforegame"],body[data-game-phase="beforegame"]{background:seashell;color:#111827}
html[data-game-phase="day"],body[data-game-phase="day"]{background:floralwhite;color:#111827}
html[data-game-phase="night"],body[data-game-phase="night"]{background:#000030;color:snow}
html[data-game-phase="aftergame"],body[data-game-phase="aftergame"]{background:aliceblue;color:#111827}
.game-container{margin:0;width:100%}
#gameApp{overflow-anchor:none}
.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
.skip-link{position:fixed;left:8px;top:-100px;z-index:1000;background:white;color:#111827;padding:8px}
.skip-link:focus{top:8px}
:focus-visible{outline:3px solid #f6b74b;outline-offset:2px}
.notice{position:fixed;top:4px;left:50%;transform:translateX(-50%);z-index:1000;max-width:calc(100% - 24px);padding:8px 14px;border:1px solid #aed0b8;background:#e7f3ec;color:#21543a;border-radius:8px;white-space:pre-wrap}
.notice.error{background:#fff0ec;color:#8c2c22;border-color:#eab6ab}
dialog>.notice{position:static;transform:none;max-width:none;margin:0 0 12px;display:flex;flex-wrap:wrap;gap:8px;align-items:center;white-space:normal;overflow-wrap:anywhere}
dialog>.notice>span{flex-basis:100%}
.notice.is-collapsed>span,.notice.is-collapsed>button:not(.notice-toggle){display:none}
#gameApp:not(.desktop-horizontal) #talkInputBar{position:fixed;left:var(--higu-viewport-left,0px);right:auto;top:var(--higu-compose-top,auto);bottom:auto;width:var(--higu-viewport-width,100%);max-height:var(--higu-compose-max-height,100dvh);overflow-y:auto}
#gameApp.desktop-horizontal{height:var(--higu-viewport-height,100dvh)}
#gameApp.desktop-horizontal .desktop-talk-column{overflow:hidden}
#gameApp.desktop-horizontal #talkInputBar{max-height:55%;overflow-y:auto}
#gameApp.desktop-horizontal .talk-panel{min-height:0}
/* Reserve heaven independently; main talk scrolls inside the remaining space. */
#gameApp.desktop-horizontal .heaven-panel{flex-shrink:0}
#gameApp:not(.desktop-horizontal) .heaven-body{max-height:var(--higu-heaven-body-height,220px)}
/* While the mobile keyboard is open, spend the visual viewport on conversation. */
html.higu-reading-active,body.higu-reading-active{overflow:hidden}
/* A locked document changes sticky's scroll container; retain the header's flow space. */
.reading-topbar-space{flex:0 0 auto}
#gameApp.talk-reading .game-topbar{position:fixed;top:var(--higu-viewport-top,0px);left:var(--higu-viewport-left,0px);width:var(--higu-viewport-width,100%);z-index:40}
#gameApp.talk-reading #abilityPanel{visibility:hidden;pointer-events:none}
#gameApp.talk-reading:not(.keyboard-composing) :is(#statusPanel,#playerPanel.is-pinned){position:fixed;left:var(--higu-reading-left);width:var(--higu-reading-width);margin:0;box-sizing:border-box;z-index:32;overflow:auto}
#gameApp.talk-reading:not(.keyboard-composing) #playerPanel.is-pinned{top:var(--higu-reading-head-top);max-height:var(--higu-reading-player-max)}
#gameApp.talk-reading:not(.keyboard-composing) #statusPanel{top:var(--higu-reading-status-top);max-height:var(--higu-reading-status-max)}
#gameApp.talk-reading:not(.keyboard-composing) :is(.talk-panel,#heavenPanel){position:fixed;left:var(--higu-reading-left);width:var(--higu-reading-width);margin:0;z-index:30;display:flex;flex-direction:column;overflow:hidden;box-sizing:border-box}
#gameApp.talk-reading:not(.keyboard-composing) :is(.talk-panel,#heavenPanel){background:#fff}
#gameApp[data-phase=night].talk-reading:not(.keyboard-composing) :is(.talk-panel,#heavenPanel){background:#0f172a}
#gameApp.talk-reading:not(.keyboard-composing) .talk-panel{top:var(--higu-reading-top);height:var(--higu-reading-height)}
#gameApp.talk-newest-top:not(.desktop-horizontal):not(.keyboard-composing) #latestButton{top:54px;bottom:auto}
#gameApp.talk-reading:not(.keyboard-composing) #heavenPanel{top:var(--higu-reading-heaven-top);height:var(--higu-reading-heaven-height)}
#gameApp.talk-reading:not(.keyboard-composing) :is(.section-head,.heaven-panel-head){flex-shrink:0}
#gameApp.talk-reading:not(.keyboard-composing) #talkLog{flex:1 1 auto;height:auto!important;min-height:0!important;max-height:none!important}
#gameApp.talk-reading:not(.keyboard-composing) #heavenLog{flex:1 1 auto;min-height:0;max-height:none}
/* Geometry changes preserve reading positions immediately, without smooth-scroll feedback. */
#gameApp:not(.desktop-horizontal) :is(#talkLog,#heavenLog){scroll-behavior:auto}
#gameApp.keyboard-composing .game-topbar,
#gameApp.keyboard-composing :is(#statusPanel,#abilityPanel,#playerPanel,#loginBox,#villageOptionsPanel,#mobileMoreHud,#mobilePlayerFab){visibility:hidden!important;pointer-events:none}
#gameApp.keyboard-composing .talk-panel,
#gameApp.keyboard-composing #heavenPanel{position:fixed;left:calc(var(--higu-viewport-left) + 6px);width:calc(var(--higu-viewport-width) - 12px);margin:0;z-index:30;display:flex;flex-direction:column;overflow:hidden;box-sizing:border-box}
#gameApp.keyboard-composing .talk-panel{top:var(--higu-keyboard-talk-top);height:var(--higu-keyboard-talk-height);padding:4px}
#gameApp.keyboard-composing .talk-panel>.section-head{display:none}
#gameApp.keyboard-composing #talkLog{flex:1 1 auto;height:auto!important;min-height:0!important;max-height:none!important;scroll-behavior:auto}
#gameApp.keyboard-composing #heavenPanel{top:var(--higu-keyboard-heaven-top);height:var(--higu-keyboard-heaven-height)}
#gameApp.keyboard-composing .heaven-panel-head{flex-shrink:0}
#gameApp.keyboard-composing #heavenLog{flex:1 1 auto;min-height:0;max-height:none;scroll-behavior:auto}
#gameApp.keyboard-composing #talkInputBar{z-index:35}
/* Keep the conversation close to the adjacent edge of the composer. */
#gameApp{--talk-input-clearance:2px}
#gameApp:not(.desktop-horizontal):not(.talk-newest-top) .game-main{padding-bottom:calc(var(--talk-input-offset) + var(--talk-input-clearance) + var(--higu-scroll-room,0px))}
#gameApp:not(.desktop-horizontal):not(.talk-newest-top) .talk-panel{padding-bottom:2px}
#gameApp:not(.desktop-horizontal):not(.talk-newest-top) #talkInputBar{padding-top:2px}
#gameApp:not(.desktop-horizontal).talk-newest-top #talkInputBar{padding-bottom:2px}
#gameApp #smilePickerPanel.higu-smile-float,#gameApp #aronaAssistantPanel.higu-smile-float{position:fixed;left:var(--higu-picker-left,10px);top:var(--higu-picker-top,0);bottom:auto;right:auto;width:var(--higu-picker-width,calc(100% - 20px));max-height:var(--higu-picker-height,260px);margin:0;z-index:50}
.speech-hint{font-size:11px;opacity:.7;margin:0;line-height:1.4}
.talk-tools{flex-wrap:wrap}
.talk-tools select{width:auto;max-width:100%;height:30px;border-radius:999px;border:1px solid rgba(15,23,42,.16);padding:0 10px;font-weight:900;background:rgba(255,255,255,.92);color:#111827}
.game-app[data-phase=night] .talk-tools select{background:rgba(15,23,42,.92);color:snow;border-color:rgba(255,255,255,.16)}
.talk-tools #talkTarget{max-width:100%}
#talkScopeLabel{white-space:nowrap}
#connectionState{max-width:130px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#connectionState.is-selection-paused{color:#dc2626;font-weight:700}
.game-app[data-phase=night] #connectionState.is-selection-paused{color:#f87171}
.message-body{white-space:pre-wrap;overflow-wrap:anywhere}
.message-body img.talk-smile{display:inline-block;max-width:100%;height:auto;vertical-align:middle}
.message.is-dead-speaker .talk-avatar{opacity:.68}
.talk-channel-label{font-size:11px;margin-left:5px}
.message.is-private .talk-bubble{border-left:3px solid #b194db}
.message.is-system .message-body{white-space:pre-wrap}
#summaryEvents:empty{display:none}
#summaryEvents .message{padding:5px 8px;font-size:13px}
#summaryEvents .message-head{font-size:11px;opacity:.7}
#victoryPanel .victory-main{display:flex;flex-direction:column;gap:4px}
/* Traditional faction gradients, softened for the modern card layout. */
#victoryPanel{border-radius:12px;box-shadow:inset 0 1px 0 rgba(255,255,255,.18),0 2px 6px rgba(15,23,42,.1)}
#victoryPanel.victory-human{background:linear-gradient(135deg,#fff,#e0f2fe,#f8fafc);color:#111827}
#victoryPanel.victory-wolf{background:linear-gradient(135deg,#7f0000,#b91c1c,#4c1010)}
#victoryPanel.victory-fox{background:linear-gradient(135deg,#5a1f5a,#7e228c,#70409a)}
#victoryPanel:is(.victory-lover,.victory-lovers){background:linear-gradient(135deg,#9d174d,#be185d,#a33165)}
#victoryPanel:is(.victory-draw,.victory-abort){background:linear-gradient(135deg,#111827,#080d18,#374151)}
#victoryPanel.victory-custo{background:linear-gradient(135deg,#14532d,#246449,#064e3b)}
#victoryPanel.victory-night{background:linear-gradient(135deg,#000030,#111827,#020617)}
#victoryPanel.personal-win .victory-personal{background:rgba(255,255,255,.12)}
#heavenMessages .talk-row{font-size:12px;margin-bottom:4px}
#heavenMessages .talk-avatar-wrap{width:28px;min-width:28px;flex-basis:28px}
#heavenMessages .talk-avatar{max-width:26px;max-height:26px}
#heavenMessages .talk-bubble{padding:4px 7px}
#heavenMessages .talk-body{font-size:12px}
#heavenOlderMessages{margin-bottom:5px}
dialog{width:min(780px,calc(100% - 24px));max-height:88dvh;overflow:auto;border:1px solid rgba(148,163,184,.5);border-radius:18px;padding:18px;background:#fff;color:#111827;box-shadow:0 20px 80px #0005}
dialog::backdrop{background:rgba(15,23,42,.56)}
dialog .modal-head{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-bottom:12px}
dialog .stack-form,dialog .inline-form{display:grid;gap:12px}
dialog label{display:flex;flex-direction:column;gap:5px;font-size:13px}
dialog input,dialog textarea,dialog select{min-width:0;max-width:100%;border:1px solid #cbd5e1;border-radius:8px;padding:7px 9px;font:inherit}
dialog .primary{border:0;border-radius:10px;padding:9px 14px;background:#2563eb;color:white;font-weight:800}
dialog .form-actions{display:flex;gap:8px;flex-wrap:wrap;justify-content:flex-end}
dialog .muted{font-size:12px;opacity:.7}
dialog .legacy-options{width:100%;border-collapse:collapse;font-size:12px}
dialog .legacy-options th{text-align:right;width:13em;font-weight:normal}
dialog .legacy-options td,dialog .legacy-options th{padding:4px;vertical-align:top}
dialog .legacy-options small{opacity:.8}
dialog .legacy-options input[type=number]{width:64px}
dialog fieldset{border:1px solid #cbd5e1;border-radius:8px;padding:10px;min-width:0}
dialog [type=checkbox]{width:auto}
body[data-game-phase=night] dialog{background:#0f172a;color:snow}
body[data-game-phase=night] dialog input,body[data-game-phase=night] dialog textarea,body[data-game-phase=night] dialog select{background:#1e293b;color:snow;border-color:#475569}
@media(max-width:760px){#connectionState{display:none}.talk-section-actions{gap:3px}.speech-hint{font-size:10px}.talk-tools{padding-right:0}.village-options-body{font-size:12px}}
@media(max-width:620px){#talkScopeLabel{font-size:10px}#olderMessages{font-size:10px;padding:3px 5px}dialog{padding:12px}.legacy-options th{width:8em!important}}
@media(max-width:900px){#gameApp .player-panel:not(.is-collapsed){top:var(--higu-viewport-top,0px);max-height:calc(var(--higu-viewport-height,100dvh) - 8px - env(safe-area-inset-bottom,0px));padding-top:max(7px,env(safe-area-inset-top,0px))}}
/* Keep native Safari text/password/autofill colors paired with the field background. */
#gameApp .login-form input{color-scheme:light;color:#111827;-webkit-text-fill-color:#111827;caret-color:#111827;background:#fff;opacity:1}
#gameApp .login-form input::placeholder{color:#64748b;-webkit-text-fill-color:#64748b;opacity:1}
#gameApp .login-form input:is(:autofill,:-webkit-autofill){-webkit-text-fill-color:#111827;caret-color:#111827;box-shadow:0 0 0 1000px #fff inset}
#gameApp[data-phase=night] .login-form input{color-scheme:dark;color:#f8fafc;-webkit-text-fill-color:#f8fafc;caret-color:#f8fafc;background:#1e293b}
#gameApp[data-phase=night] .login-form input:is(:autofill,:-webkit-autofill){-webkit-text-fill-color:#f8fafc;caret-color:#f8fafc;box-shadow:0 0 0 1000px #1e293b inset}
@media(min-width:901px){
  #gameApp .game-main{padding-top:2px}
  #gameApp.talk-newest-top:not(.desktop-horizontal) .game-main{padding-top:calc(var(--talk-input-offset,96px) + 2px)}
  #gameApp #statusPanel{padding:3px;gap:4px;margin-bottom:3px}
  #gameApp #statusPanel .action-area{gap:4px}
  #gameApp #statusPanel .action-btn{min-height:26px;padding:0 10px}
  #gameApp #statusPanel .time-status{padding:2px 7px;min-width:160px}
  #gameApp #statusPanel .time-status-main strong{font-size:15px}
  #gameApp.talk-newest-top:not(.desktop-horizontal) #statusPanel{top:calc(var(--mobile-overlay-top,72px) + var(--talk-input-offset,96px) + 2px)}
}
#gameApp.desktop-horizontal .desktop-info-column{gap:4px}
#gameApp.desktop-horizontal #playerPanel{padding:5px}
#gameApp.desktop-horizontal .player-card{min-height:0;padding:3px 2px;gap:1px}
#gameApp.desktop-horizontal .player-name{font-size:11px;line-height:1.2}
#gameApp.desktop-horizontal:not(.player-details-open) :is(.player-trip,.player-meta){display:none}
#gameApp:not(.desktop-horizontal) #playerDetailsBtn{display:none}
/* Options float above both layouts; personal information now occupies their old column slot. */
#gameApp.desktop-horizontal :is(#villageOptionsBtn,#villageOptionsCloseBtn){display:inline-flex!important}
#gameApp.desktop-horizontal #villageOptionsPanel{position:fixed;top:var(--higu-options-top,80px)!important;left:8px;z-index:62;width:min(560px,calc(100% - 16px));max-height:min(60vh,var(--village-options-max-height,calc(100vh - 96px)));box-shadow:0 16px 40px #0f172a38}
#gameApp.desktop-horizontal .village-options-body{max-height:none}

#gameApp #aronaToggleBtn[hidden],#gameApp #aronaAssistantPanel[hidden]{display:none!important}
#gameApp #aronaAssistantPanel input,#gameApp #aronaAssistantPanel select{font-size:16px}

#gameApp #talkInputBar[hidden]{display:none!important}

/* Preserve stored line breaks in the original last-word block. */
#summaryPanel .lastword-body{white-space:pre-wrap}
#summaryEvents{display:grid;gap:inherit}
#heavenMessages .heaven-text{white-space:pre-wrap}

/* Dawn is already daytime: keep results visible while speech waits. */
body.is-dawn,body.is-dawn #gameApp{background:linear-gradient(155deg,#f4edf9 0%,#ffe7d7 45%,#fff6d7 100%)}
body.is-dawn #timeStatus{position:relative;overflow:hidden;background:linear-gradient(100deg,#fff6df,#ffdfc4);color:#783c16;border-color:#eab581;padding-bottom:6px}
body.is-dawn #timeStatus::after{content:'';position:absolute;bottom:0;left:0;height:3px;width:var(--dawn-progress,100%);background:#d98838;transition:width .3s linear}
body.is-dawn #sendButton:disabled{background:#f4d6b5;color:#71451f;border-color:#d9aa78;opacity:1;font-size:12px;white-space:pre-line;padding:0 4px}

.game-app .submission-recovery{padding:4px 10px;background:#fff3df;color:#81310d;font-size:13px;max-height:120px;overflow:auto}.submission-recovery button{margin:3px 6px 0 0}.submission-recovery[hidden]{display:none}

/* Reading positions are restored against visible message anchors by the client. */
#talkLog,#heavenLog{overflow-anchor:none}
.game-app .deadline-warning .system-pill{border:2px solid #c52222;background:#fff0e8;color:#a31313;font-size:18px;font-weight:900;line-height:1.6;padding:10px 18px;border-radius:8px;box-shadow:0 2px 10px #a3131322}
.game-app .deadline-warning .system-text{color:inherit;font:inherit}
.game-app[data-phase=night] .deadline-warning .system-pill{background:#601b24;color:#fff2d9;border-color:#ff8a80}
@media(max-width:900px){
  #gameApp #selfLastWordsFloat{top:var(--higu-will-top,4px);bottom:auto;left:calc(var(--higu-viewport-left,0px) + 4px);width:calc(var(--higu-viewport-width,100vw) - 8px);transform:none;height:var(--higu-will-height,50dvh);max-height:var(--higu-will-height,50dvh);z-index:65}
  #gameApp #selfLastWordsFloat .self-lastwords-head{flex:none;padding:4px 8px}
  #gameApp #willForm{display:flex;flex-direction:column;gap:4px;padding:4px 8px;min-height:0;overflow:auto}
  #gameApp #willForm[hidden]{display:none}
  #gameApp #willForm label{display:flex;flex:1;flex-direction:column;min-height:64px;gap:2px}
  #gameApp #willForm textarea{flex:1;height:0;min-height:44px;resize:none;font-size:16px;line-height:20px;padding:2px 4px;box-sizing:border-box}
  #gameApp #willForm .form-actions{flex:none;margin:0}
  #gameApp.mobile-will-open #talkInputBar{min-height:62px}
  #gameApp.mobile-will-open #sayInput{min-height:42px;max-height:44px;overflow-y:auto!important}
}
