/* Network identity, scene selection and result reading. Loaded last so each
   layout has one owner, independent of the older generic card/target panels. */
#game[data-stage="reveal"] .game-actions { inset:0; padding:0; width:auto; max-width:none; max-height:none; transform:none; }
#game[data-stage="reveal"] .identity-pane.identity-layout,
.game-document.identity-review .identity-layout {
 position:absolute;inset:0;display:block;width:100%;height:100%;max-width:none;max-height:none;
 padding:0;margin:0;border:0;background:none;box-shadow:none;overflow:auto;overscroll-behavior:contain;
}
#game[data-stage="reveal"] .identity-layout .identity-card,
.identity-review .identity-layout .identity-card {
 position:absolute;left:var(--identity-layout-left);top:var(--identity-layout-top);
 width:var(--identity-layout-width);height:var(--identity-layout-height);min-height:0;min-width:0;padding:0;margin:0;
}
.identity-layout .identity-card .court-card {width:100%;height:100%!important;}
#game[data-stage="reveal"] .identity-layout .identity-confirm,
.identity-review .identity-layout .identity-confirm {
 position:absolute;left:var(--identity-layout-left);top:calc(var(--identity-layout-top) + var(--identity-layout-height) + var(--identity-layout-gap));
 width:var(--identity-layout-width);min-width:0;height:var(--identity-layout-button-height);min-height:var(--identity-layout-button-height)!important;
 margin:0;padding:6px 8px;font-size:clamp(16px,calc(12px * var(--identity-unit)),28px)!important;white-space:nowrap;
}
#game[data-stage="reveal"] .identity-layout .identity-clues,
.identity-review .identity-layout .identity-clues {
 position:absolute;left:var(--identity-layout-clue-left);top:var(--identity-layout-clue-top);
 width:var(--identity-layout-clue-width);height:var(--identity-layout-clue-height);max-height:none;min-height:0;
 display:flex;flex-direction:column;gap:clamp(6px,calc(6px * var(--identity-unit)),12px);
 padding:clamp(8px,calc(12px * var(--identity-unit)),24px);margin:0 0 16px;
 overflow:auto;overscroll-behavior:contain;
}
.identity-layout .identity-clues::before,.identity-layout .identity-clues::after {content:none!important;}
.identity-layout .identity-clues[hidden] {display:none!important;}
.identity-layout .identity-clue-title {flex:none;font-size:clamp(24px,calc(24px * var(--identity-unit)),48px);line-height:1.25;margin:0;padding:0 0 8px;border-bottom:1px solid #79694d5c;font-weight:400;text-align:center;}
.identity-layout .identity-clues p {color:#42392f;margin:0;font-size:clamp(12px,calc(12px * var(--identity-unit)),24px);line-height:1.4;text-shadow:none;}
.identity-layout .identity-clue-kind {white-space:pre-line;text-align:center;flex:none;}
.identity-layout .identity-clue-empty {flex:1;display:grid;place-items:center;text-align:center;}
.identity-clue-people {flex:1;min-height:0;display:grid;grid-template-columns:repeat(var(--clue-count),minmax(74px,1fr));gap:6px;overflow:auto;}
.identity-clue-person {min-height:0;display:grid;grid-template-rows:auto minmax(72px,1fr) auto;gap:4px;align-items:center;text-align:center;}
.identity-layout .identity-clue-name {overflow-wrap:anywhere;min-height:2.8em;display:grid;place-items:center;}
.identity-clue-person > .original-portrait {display:block;width:100%;height:100%;min-height:0;max-height:calc(116px * var(--identity-unit));align-self:center;}
.identity-clue-person > .player-token {min-width:0;padding:0;background:none;border:0;}
.identity-layout .identity-clue-scroll {display:none;font-size:12px;line-height:16px;text-align:center;flex:none;}
@media(max-width:800px) and (max-height:620px) {
 .identity-layout .identity-clue-scroll {display:block;}
 .identity-clue-person {grid-template-rows:auto minmax(36px,1fr) auto;}
}
.game-document.identity-review {position:fixed;inset:0;width:100vw!important;max-width:none!important;height:100dvh;max-height:none;padding:0!important;background:none;border:0;box-shadow:none;overflow:hidden;}
.identity-review > .document-title {position:absolute;left:16px;top:16px;border:0;color:#e2decb;font-size:20px;padding:0;margin:0;}
.identity-review > .document-close {z-index:2;}

/* Scene characters are the primary target. This single-row keyboard/touch
   fallback stays below the court instead of covering it with portrait cards. */
#game:is([data-stage="team_selection"],[data-stage="assassination"],[data-stage="lady_selection"],[data-stage="sword_decision"],[data-stage="recruitment"]) .game-actions:has(.selection-dock) {
 position:absolute;inset:auto 16px max(12px,env(safe-area-inset-bottom));width:auto;max-width:none;max-height:160px;
 padding:0;transform:none;background:none;border:0;box-shadow:none;overflow:visible;display:flex;flex-direction:column;gap:6px;pointer-events:none;
}
.selection-dock {display:grid;grid-template-columns:minmax(0,1fr) auto;grid-template-rows:auto 48px;gap:6px 16px;width:min(1080px,100%);padding:8px 12px;background:#171c21d9;border:1px solid #8e969366;pointer-events:auto;}
.selection-dock > .waiting-note {grid-column:1;grid-row:1;width:auto;margin:0;padding:0;font-size:16px;line-height:22px;text-align:left;background:none;}
.selection-dock > .selection-roster {grid-column:1;grid-row:2;display:flex;flex-wrap:nowrap;gap:8px;overflow-x:auto;overflow-y:hidden;max-width:100%;min-width:0;overscroll-behavior:contain;scrollbar-width:thin;}
.selection-dock .selection-player {flex:0 0 88px;min-width:88px;min-height:44px;height:44px;padding:4px 6px;font-size:14px;line-height:18px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.selection-dock > .avalon-button {grid-column:2;grid-row:1/3;align-self:center;min-height:44px;width:172px;min-width:0;font-size:20px;}
#game[data-stage="assassination"] .game-actions:has(.selection-dock) > .assassination-target {font-size:16px;line-height:22px;padding:0;margin:0;text-shadow:1px 1px #000;}
#game .game-actions:has(.selection-dock) > .submission-status {pointer-events:auto;width:min(1080px,100%);font-size:14px;margin:0;padding:4px 8px;}
@media(max-width:800px),(max-height:620px) {
 .selection-dock {gap:4px 8px;padding:6px 8px;grid-template-rows:20px 48px;}
 .selection-dock > .waiting-note {font-size:13px;line-height:20px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
 .selection-dock > .avalon-button {width:120px;font-size:16px;}
 .selection-dock .selection-player {flex-basis:82px;min-width:82px;font-size:13px;}
 #game:is([data-stage="team_selection"],[data-stage="assassination"],[data-stage="lady_selection"],[data-stage="sword_decision"],[data-stage="recruitment"]) .game-actions:has(.selection-dock) {left:8px;right:8px;bottom:max(8px,env(safe-area-inset-bottom));}
}

/* Result names are live text, not tiny letters baked into a thumbnail. The
   scrolling list cannot push return/wait status off the first screen. */
#game[data-stage="game_result"] .game-actions:has(.result-readable) {display:block;inset:0;transform:none;width:auto;padding:0;overflow:hidden;}
#game[data-stage="game_result"]:has(.result-readable) .game-hud {display:none;}
#game[data-stage="game_result"] .result-readable.result-pane {
 position:absolute;left:24px;right:24px;top:150px;bottom:20px;width:auto;max-width:none;max-height:none;height:auto;
 display:grid;grid-template-rows:auto auto minmax(0,1fr) auto;gap:8px;padding:16px 24px;overflow:hidden;
}
.result-readable > h2 {font-size:28px;line-height:34px;margin:0;}
.result-readable > .result-summary {margin:0;font-size:18px;line-height:24px;}
.result-readable > .result-roles {display:grid;grid-template-columns:repeat(var(--result-columns),minmax(0,1fr));gap:16px;align-content:start;min-height:0;overflow:auto;overscroll-behavior:contain;padding:4px;}
.result-readable .result-role {width:auto;min-width:0;display:flex;flex-direction:column;align-items:center;gap:8px;}
.result-readable .result-role > .court-card {width:min(100%,calc((100vw - 220px) / var(--result-columns)),calc((100dvh - 470px) / var(--result-rows) * 180 / 276));}
.result-readable .result-role-copy {min-width:0;width:100%;text-align:center;}
.result-readable .result-player-name {font-size:16px;line-height:22px;white-space:normal;overflow-wrap:anywhere;margin:0 0 4px;}
.result-readable .result-role-name {font-size:20px;line-height:26px;margin:0;}
.result-readable .result-faction {font-size:14px;line-height:20px;margin:2px 0 6px;}
.result-readable .result-role-details {min-width:0;width:100%;max-width:172px;min-height:44px;font-size:16px;padding:4px 8px;}
.result-readable > .result-footer {min-height:44px;display:flex;align-items:center;justify-content:center;flex:none;padding:4px 0 0;}
.result-footer .result-waiting {font-size:18px;line-height:24px;margin:0;}
.result-footer > .avalon-button {min-height:44px;}
.game-document.result-role-document {overflow:hidden;}
/* Override the shared mobile document's non-shrinking ordinary children. */
.game-modal-layer .game-document.result-role-document > .result-detail-body {flex:1 1 auto;min-height:0;overflow:auto;overscroll-behavior:contain;}
.result-detail-body > .court-card {float:left;width:180px;margin:0 20px 16px 0;}
.result-role-document > .avalon-button {flex:none;min-height:44px;align-self:center;}
.result-detail-body > h3 {font-size:20px;line-height:28px;margin:12px 0 6px;}
@media(max-width:800px),(max-height:620px) {
 #game[data-stage="game_result"]:has(.result-readable) .game-hud {display:none;}
 #game[data-stage="game_result"] .result-readable.result-pane {left:12px;right:12px;top:68px;bottom:max(8px,env(safe-area-inset-bottom));padding:10px 12px;gap:4px;background:#c7b99a;color:#42392f;border:3px solid #51483b;box-shadow:inset 0 0 0 2px #b2a484;}
 .result-readable > h2 {font-size:22px;line-height:26px;color:#42392f;}
 .result-readable > .result-summary {font-size:14px;line-height:20px;color:#42392f;}
 .result-readable > .result-roles {grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;}
 .result-readable .result-role {display:grid;grid-template-columns:64px minmax(0,1fr);gap:10px;align-items:center;padding:6px;border:1px solid #79694d59;}
 .result-readable .result-role > .court-card {width:64px;}
 .result-readable .result-role-copy {text-align:left;}
 .result-readable .result-player-name {font-size:14px;line-height:18px;margin:0;}
 .result-readable .result-role-name {font-size:18px;line-height:24px;}
 .result-readable .result-faction {font-size:12px;line-height:16px;margin:0;}
 .result-readable .result-role-details {font-size:14px;min-height:44px;max-width:172px;margin-top:4px;}
 .result-footer .result-waiting {font-size:16px;line-height:22px;}
 .result-detail-body > .court-card {width:120px;margin-right:12px;}
 .result-role-document .account-copy {font-size:16px;line-height:1.5;}
}
@media(max-width:479px) {
 .result-readable > .result-roles {grid-template-columns:minmax(0,1fr);}
 .selection-dock {grid-template-columns:minmax(0,1fr) 104px;}
 .selection-dock > .avalon-button {width:104px;font-size:14px;}
}

/* Match the end-game cards laid out over the royal court. */
#game[data-stage="game_result"] .result-native.result-pane{
 --result-card-width:min(180px,calc((100vw - 180px) / var(--result-columns)),calc((100dvh - 255px - 40px * var(--result-rows)) / var(--result-rows) * 180 / 276));
 inset:clamp(68px,13vh,118px) 16px clamp(12px,7vh,64px);
 grid-template-rows:auto auto minmax(0,1fr) auto;
 gap:4px;padding:0;background:none;border:0;box-shadow:none;color:#e9dec5;text-shadow:1px 2px #18140f;
}
.result-native.result-pane>h2{color:inherit;font-size:clamp(24px,3.4vw,48px);line-height:1.1}
.result-native.result-pane>.result-summary{color:inherit;font-size:clamp(12px,1.3vw,18px)}
.result-native.result-pane>.result-roles{display:flex;flex-direction:column;gap:10px;padding:4px}
.result-native .result-card-row{display:flex;flex:none;justify-content:center;gap:clamp(8px,1.6vw,24px)}
.result-native .result-card-row>.result-role{display:flex;width:var(--result-card-width);flex:none;gap:4px;padding:0;border:0}
.result-native .result-card-caption{display:flex;align-items:center;justify-content:center;gap:4px;width:100%;min-width:0;height:32px}
.result-native .result-card-caption .original-portrait{flex:none;width:22px;height:30px}
.result-native .result-card-caption .result-player-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin:0;font-size:clamp(12px,1.3vw,18px)}
.result-native .result-card-row .result-role-details{width:100%;max-width:none;padding:0;margin:0;border:0;background:transparent;box-shadow:none}
.result-native .result-role-details .court-card{width:100%;margin:0;aspect-ratio:180/276;height:auto}
@media (hover: hover) and (pointer: fine) {
.result-native .result-role-details:is(:hover,:focus-visible){outline:0;filter:brightness(1.12)} }
.result-native .result-role-details:is(:focus-visible){outline:0;filter:brightness(1.12)}
@media(max-height:620px),(max-width:800px){
 #game[data-stage="game_result"] .result-native.result-pane{--result-card-width:clamp(64px,calc((100dvh - 208px) * 180 / 276),150px);inset:62px 12px max(8px,env(safe-area-inset-bottom))}
 .result-native .result-card-row{min-width:max-content;margin-inline:auto;justify-content:flex-start}
 .result-native .result-card-caption{height:25px}
 .result-native .result-card-caption .original-portrait{width:16px;height:23px}
}

.result-native.result-pane>.result-roles{flex-wrap:nowrap}
@media(min-width:801px) and (min-height:621px){
 #game[data-stage="game_result"] .result-native.result-pane:has(.result-card-row:nth-child(2)){
  --result-card-width:min(calc((100vw - 180px) / var(--result-columns)),calc((100dvh - 410px) / var(--result-rows) * 180 / 276));
  bottom:clamp(12px,2vh,28px);
 }
}

/* Use the complete original back and face, with the native 640ms half-turn. */
.identity-card.identity-flipping{perspective:900px}
.identity-card-turn{position:relative;width:100%;height:100%;transform-style:preserve-3d;animation:match-card-flip 640ms ease-in-out both}
.identity-layout .identity-card-turn>.court-card{position:absolute;inset:0;width:100%;height:100%!important;backface-visibility:hidden;-webkit-backface-visibility:hidden}
.identity-card-turn>.reveal-front{transform:rotateY(180deg)}
@media(prefers-reduced-motion:reduce){.identity-card-turn{animation-duration:1ms}}

/* Reveal artwork and outcome copy share the viewport axis. */
#game:is([data-stage=vote_reveal],[data-stage=mission_reveal]) .game-actions{inset:0;transform:none;width:auto;max-width:none;max-height:none;display:block;overflow:visible;pointer-events:none}
#game:is([data-stage=vote_reveal],[data-stage=mission_reveal]) .native-reveal{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:calc(100vw - 96px);margin:0;justify-content:center}
#game:is([data-stage=vote_reveal],[data-stage=mission_reveal]) .game-actions>.waiting-note{position:absolute;bottom:24px;left:50%;transform:translateX(-50%);width:max-content;max-width:calc(100vw - 32px);font-size:16px;padding:4px 8px;background:none;border:0;box-shadow:none}
#game[data-stage=mission_reveal] .game-actions>.stage-announcement{position:absolute;inset:0;display:grid;place-items:center}
@media(min-width:480px) and (max-height:620px) and (orientation:landscape){#game:is([data-stage=vote_reveal],[data-stage=mission_reveal]) .game-actions>.waiting-note{bottom:8px;font-size:12px}}
/* Decision layout: a local card choice and the single native action below. */
#game:is([data-stage=team_voting],[data-stage=mission_execution],[data-stage=inspection]) .game-actions.game-actions:has(.card-choice[data-kind]){
 --vote-card-width:min(var(--vote-native-width,180px),calc((100vw - 300px) / 2),calc((100dvh - 240px) * 180 / 276));
 display:block;position:absolute;inset:0;width:auto;max-width:none;max-height:none;transform:none;overflow:visible;pointer-events:none;
}
#game:is([data-stage=team_voting],[data-stage=mission_execution],[data-stage=inspection]) .game-actions.game-actions:has(.card-choice[data-kind])>.card-choice{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);display:flex;flex-wrap:nowrap;width:auto;margin:0;gap:var(--vote-native-gap,14px);pointer-events:auto}
#game:is([data-stage=team_voting],[data-stage=mission_execution],[data-stage=inspection]) .game-actions.game-actions:has(.card-choice[data-kind]) .court-card.court-card{width:var(--vote-card-width);height:auto!important;aspect-ratio:180/276}
#game:is([data-stage=team_voting],[data-stage=mission_execution],[data-stage=inspection]) .game-actions.game-actions:has(.card-choice[data-kind])>.card-submit{position:absolute;left:50%;right:auto;top:calc(50% + var(--vote-card-width) * 276 / 360 + 12px);bottom:auto;transform:translateX(-50%);width:calc(380 * var(--ui-unit));max-width:calc(100vw - 48px);min-width:0;height:calc(64 * var(--ui-unit));min-height:44px;padding:6px 12px;margin:0;font-size:clamp(16px,calc(24 * var(--ui-unit)),24px);pointer-events:auto}
#game:is([data-stage=team_voting],[data-stage=mission_execution],[data-stage=inspection]) .game-actions.game-actions:has(.card-choice[data-kind])>.waiting-note{position:absolute;left:50%;right:auto;top:calc(50% - var(--vote-card-width) * 276 / 360 - 32px);bottom:auto;transform:translateX(-50%);width:max-content;max-width:calc(100vw - 32px);font-size:16px;line-height:22px;margin:0;padding:0 8px;background:none;border:0;box-shadow:none}
/* Original content target: dim the unchosen artwork, no extra frame or skin. */
.card-choice[data-kind] .choice-card[aria-pressed]{outline:0;border:0;box-shadow:none}
.card-choice[data-kind]:has([aria-pressed=true]) .choice-card[aria-pressed=false]{filter:brightness(.55)}
.card-choice[data-kind] .choice-card[aria-pressed=true]{filter:none}
@media(max-height:620px) and (orientation:landscape){
 #game:is([data-stage=team_voting],[data-stage=mission_execution],[data-stage=inspection]) .game-actions.game-actions:has(.card-choice[data-kind]){--vote-card-width:min(var(--vote-native-width,180px),calc((100vw - 280px) / 2),calc((100dvh - 196px) * 180 / 276))}
 #game:is([data-stage=team_voting],[data-stage=mission_execution],[data-stage=inspection]) .game-actions.game-actions:has(.card-choice[data-kind])>.waiting-note{left:auto;right:12px;top:50%;transform:translateY(-50%);width:112px;font-size:13px;line-height:20px;padding:0}
}
/* 008: one status after sealing, without the editable choices or another panel. */
#game:is([data-stage=team_voting],[data-stage=mission_execution],[data-stage=inspection]) .game-actions:has(>.card-waiting){position:absolute;inset:0;width:auto;max-width:none;max-height:none;transform:none;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;padding:24px;overflow:auto;pointer-events:none}
#game:is([data-stage=team_voting],[data-stage=mission_execution],[data-stage=inspection]) .game-actions>.card-waiting{position:static;transform:none;width:auto;max-width:min(600px,100%);font-size:clamp(16px,2vw,24px);line-height:1.5;padding:8px 16px;margin:0;white-space:normal;background:none;border:0;box-shadow:none}
#game:is([data-stage=team_voting],[data-stage=mission_execution],[data-stage=inspection]) .game-actions>.card-waiting-sync{position:static;transform:none;width:calc(172 * var(--ui-unit));min-width:172px;min-height:44px;pointer-events:auto}
/* 009 native match hierarchy: world markers remain primary; supplementary lists
   are reached through the existing S button and parchment, not a second HUD bar. */
/* Native nomination is a clear court and centered M action. Keep the accessible
   S-button roster as a transparent, horizontally scrollable fallback. */
#game:is([data-stage=team_selection],[data-stage=assassination],[data-stage=lady_selection],[data-stage=sword_decision],[data-stage=recruitment]) .selection-dock{display:flex;flex-direction:column;align-items:center;gap:8px;width:min(1080px,100%);padding:0;background:none;border:0;box-shadow:none;pointer-events:none}
#game:is([data-stage=team_selection],[data-stage=assassination],[data-stage=lady_selection],[data-stage=sword_decision],[data-stage=recruitment]) .selection-dock>.waiting-note{width:100%;font-size:clamp(14px,calc(24 * var(--ui-unit)),24px);line-height:1.35;text-align:center;padding:0;background:none}
#game:is([data-stage=team_selection],[data-stage=assassination],[data-stage=lady_selection],[data-stage=sword_decision],[data-stage=recruitment]) .selection-dock>.selection-roster{display:flex;justify-content:safe center;align-items:center;width:100%;max-width:100%;min-height:48px;gap:8px;padding:2px 4px;overflow-x:auto;overflow-y:hidden;pointer-events:auto}
#game:is([data-stage=team_selection],[data-stage=assassination],[data-stage=lady_selection],[data-stage=sword_decision],[data-stage=recruitment]) .selection-dock .selection-player{flex:0 0 calc(172 * var(--ui-unit));width:calc(172 * var(--ui-unit));min-width:0;height:calc(42 * var(--ui-unit));min-height:44px;padding:6px 10px;font-size:clamp(13px,calc(20 * var(--ui-unit)),20px);line-height:1.25;background:var(--control-fill);border-color:var(--control-edge);color:var(--control-ink)}
#game:is([data-stage=team_selection],[data-stage=assassination],[data-stage=lady_selection],[data-stage=sword_decision],[data-stage=recruitment]) .selection-dock>.avalon-button{width:calc(380 * var(--ui-unit));min-width:0;max-width:100%;height:calc(64 * var(--ui-unit));min-height:44px;margin:0;padding:6px 12px;font-size:clamp(16px,calc(24 * var(--ui-unit)),24px);pointer-events:auto}
/* The name, not the combined portrait/name group, shares the card centerline. */
.result-native .result-card-caption{display:grid;grid-template-columns:22px minmax(0,1fr) 22px;gap:4px}
.result-native .result-card-caption>.original-portrait{grid-column:1;grid-row:1}
.result-native .result-card-caption>.result-player-name{grid-column:2;grid-row:1;display:block;width:100%;min-width:0;text-align:center;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.result-native.result-pane>h2{font-size:clamp(24px,calc(48 * var(--ui-unit)),48px)}
.result-native .result-footer>.avalon-button{width:calc(380 * var(--ui-unit));max-width:100%;min-width:0;height:calc(64 * var(--ui-unit));min-height:44px;font-size:clamp(16px,calc(24 * var(--ui-unit)),24px)}
@media(max-height:620px) and (orientation:landscape){
 #game:is([data-stage=team_selection],[data-stage=assassination],[data-stage=lady_selection],[data-stage=sword_decision],[data-stage=recruitment]) .selection-dock{gap:4px}
 #game:is([data-stage=team_selection],[data-stage=assassination],[data-stage=lady_selection],[data-stage=sword_decision],[data-stage=recruitment]) .selection-dock>.waiting-note{font-size:13px;line-height:18px}
 .result-native .result-card-caption{grid-template-columns:16px minmax(0,1fr) 16px;gap:2px}
}

.result-native .result-role-details::before,.result-native .result-role-details::after{content:none!important}
.card-choice[data-kind] .choice-card:focus-visible{outline:0;filter:brightness(1.12)}

@media(max-height:620px) and (orientation:landscape){#game:is([data-stage=team_selection],[data-stage=assassination],[data-stage=lady_selection],[data-stage=sword_decision],[data-stage=recruitment]) .selection-dock .selection-player{flex-basis:88px;width:88px;min-width:88px;height:40px;min-height:44px;font-size:14px}}

.identity-layout .identity-clues,.game-document.public-team-document {
 background-color:#c7b99a;background-image:radial-gradient(#79694d24 .6px,transparent .8px);background-size:5px 5px;
 border:3px solid #51483b;box-shadow:inset 0 0 0 2px #b2a484;border-radius:0;color:#42392f;text-shadow:none; }

/* Team and fullscreen share the existing toolbar action sizing. */
#game .game-toolbar .toolbar-left{position:absolute;left:0;top:0;display:flex;align-items:center;pointer-events:none}
#game .game-toolbar .toolbar-team[hidden]{display:none!important}
#game .game-toolbar .toolbar-team.preset-toolbar-action{width:calc(172 * var(--ui-unit));min-width:calc(172 * var(--ui-unit));height:var(--toolbar-control-size);min-height:var(--toolbar-control-size);padding:calc(4 * var(--ui-unit)) calc(12 * var(--ui-unit));white-space:nowrap;pointer-events:auto;box-shadow:0 0 0 max(1px,calc(2 * var(--ui-unit))) #131412}
.game-document.public-team-document{--identity-unit:1;display:flex;flex-direction:column;max-height:calc(100dvh - 32px);overflow:hidden}
.public-team-document>.public-team-content{flex:1 1 auto;min-height:0;overflow:auto;overscroll-behavior:contain;padding:0 4px}
.public-team-document>.avalon-button{align-self:center;flex:none}
.public-team-content .identity-clue-title{font-size:24px;line-height:1.3;text-align:center;margin:12px 0 8px;font-weight:400}
.public-team-content .identity-clue-people{min-height:160px;grid-template-columns:repeat(var(--clue-count),minmax(88px,1fr));overflow-x:auto;padding:4px}
.public-team-content .identity-clue-name,.public-team-content .identity-clue-seat,.public-team-content .identity-clue-empty{color:inherit;font-size:16px;line-height:1.4;text-align:center;margin:0;overflow-wrap:anywhere}
.public-team-document.identity-clues::before,.public-team-document.identity-clues::after{content:none!important}
@media(min-width:480px) and (max-height:620px) and (orientation:landscape){
 #game .game-toolbar :is(.toolbar-team,.toolbar-fullscreen).preset-toolbar-action{width:88px;min-width:88px;height:var(--toolbar-control-size);min-height:var(--toolbar-control-size);font-size:14px}
 #game:not([data-stage=menu]):not([data-stage=waiting]) .game-toolbar .toolbar-right{display:grid;width:140px;grid-template-columns:44px 88px;grid-template-rows:44px 44px;gap:8px;margin-left:auto;pointer-events:none}
 #game:not([data-stage=menu]):not([data-stage=waiting]) .game-toolbar .toolbar-fullscreen{grid-column:2;grid-row:1;justify-self:end}
 #game:not([data-stage=menu]):not([data-stage=waiting]) .game-toolbar .toolbar-menu{grid-column:1;grid-row:1}
 #game:not([data-stage=menu]):not([data-stage=waiting]) .game-toolbar .match-identity-shortcut{grid-column:2;grid-row:2;justify-self:end}
 #game:not([data-stage=menu]):not([data-stage=waiting]) .game-toolbar .toolbar-roster{grid-column:1;grid-row:2}
 #game:not([data-stage=menu]):not([data-stage=waiting]) .game-hud{left:50%;right:auto;top:max(8px,env(safe-area-inset-top));transform:translateX(-50%);width:calc(100vw - 312px);max-width:none;padding:0}
 .public-team-content .identity-clue-title{font-size:20px;margin:8px 0}
 .public-team-content .identity-clue-people{min-height:136px}
}
@media(pointer:coarse){#game .game-toolbar .toolbar-team.preset-toolbar-action{height:max(44px,var(--toolbar-control-size));min-height:max(44px,var(--toolbar-control-size))}}

/* 011: preserve the waiting-room badge surface; only add native interaction. */
#game[data-stage=waiting] .game-hud .room-code[role=button]{pointer-events:auto;cursor:pointer}
#game[data-stage=waiting] .game-hud .room-code[role=button]:focus-visible{border-color:#e5e9e3;background:#45443f;outline:0}
.room-nameplate-placeholder{height:24px;width:100%;background:none;border:0;box-shadow:none;pointer-events:none}
.public-team-content .identity-clue-people{display:grid;grid-auto-flow:column;grid-template-rows:auto;max-width:100%;min-width:0;overscroll-behavior-x:contain}
.public-team-content .identity-clue-person{min-width:0}
.public-team-content .identity-clue-name{white-space:normal;overflow:visible;text-overflow:clip}
.public-team-content .team-captain-icon{position:static;display:inline-block;transform:none;vertical-align:middle;margin-right:4px;background:currentColor}

/* Room membership is a read-only portrait list, separate from the wardrobe. */
.public-room-document .room-copy-action{width:172px;min-width:172px;height:42px;min-height:44px;font-size:20px;flex:none}
@media(max-height:620px) and (orientation:landscape){.public-room-document .room-copy-action{width:88px;min-width:88px;height:40px;min-height:44px;font-size:14px}}
#game .game-toolbar { --match-unit:min(var(--ui-unit),calc(100vw / 2000)); --match-button-height: max(44px, calc(72 * var(--match-unit))); --match-button-width:max(88px,calc(216 * var(--match-unit))); }
#game .game-toolbar .avalon-button.match-toolbar-action {
 height:var(--match-button-height); min-height:var(--match-button-height);
 width:var(--match-button-width); min-width:var(--match-button-width); flex:0 0 var(--match-button-width); padding:0 8px; white-space:nowrap;
 font-size:clamp(12px,calc(24 * var(--match-unit)),24px);
}
#game .game-toolbar .toolbar-fullscreen.match-toolbar-action .fullscreen-label{display:inline}
#game .game-toolbar .toolbar-fullscreen.match-toolbar-action .fullscreen-symbol{display:none}
#game .game-toolbar :is(.toolbar-left,.toolbar-right){gap:clamp(5px,0.9vw,14px);align-items:center}
#game .game-toolbar .match-toolbar-action[hidden]{display:none}
.game-document.native-role-deck {text-align:center;--deck-unit:clamp(.6px,var(--ui-unit),1px);width:min(1120px,calc(1120 * var(--deck-unit)),calc(100vw - 40px));padding:16px 22px;gap:14px;overflow:hidden;display:flex;flex-direction:column}
.native-role-deck>.document-title {font-size:clamp(24px,calc(36 * var(--deck-unit)),36px);margin:0;padding:0 54px 12px;min-height:50px}
.native-role-deck>.role-deck-summary{font-size:clamp(14px,calc(24 * var(--deck-unit)),24px);line-height:1.4}
#modals .game-document.native-role-deck>.role-deck-scroll{flex:1 1 auto;overflow-y:auto;min-height:0;padding:0 8px 8px;scrollbar-width:thin}
.native-role-deck .role-deck-faction{font-size:clamp(17px,calc(24 * var(--deck-unit)),24px);font-weight:400;margin:10px 0;color:#49636a}
.native-role-deck .role-deck-faction[data-faction=evil]{color:#883e3c}
.native-role-deck .role-deck-row {
 display:flex;flex-wrap:wrap;justify-content:center;gap:calc(18 * var(--deck-unit)) calc(32 * var(--deck-unit));
 width:calc(712 * var(--deck-unit));max-width:100%;margin:auto;padding:6px 0 14px;
}
.native-role-deck .role-deck-card {
 flex:0 0 calc(216 * var(--deck-unit));min-width:0;display:flex;flex-direction:column;gap:calc(10 * var(--deck-unit));
}
.native-role-deck .role-deck-card .court-card{display:block;width:100%;max-width:none;margin:0;height:auto!important;aspect-ratio:216/332}
.native-role-deck .role-deck-card img {display:block;width:100%;height:100%;object-fit:contain}
.native-role-deck .role-deck-card button {width:100%;min-width:0;min-height:max(36px,calc(52 * var(--deck-unit)));padding:4px;font-size:clamp(16px,calc(24 * var(--deck-unit)),24px)}
.native-role-deck .role-deck-link {display:flex;justify-content:center;align-items:center;gap:8px;min-height:44px;cursor:pointer;background:none;border:0}
.native-role-deck .role-deck-link input{appearance:none;width:20px;height:20px;border:2px solid #79694d;background:transparent;margin:0;display:grid;place-content:center;flex:none}
.native-role-deck .role-deck-link input:checked::after{content:'✓';font:20px AvalonPixel;color:#554632}
@media (hover: hover) and (pointer: fine) {
.native-role-deck .role-deck-link:hover input{border-color:#554632;outline:none} }
.native-role-deck .role-deck-link input:focus-visible{border-color:#554632;outline:none}
.native-role-deck .role-deck-linked-detail{color:#79694d}
.game-document.native-role-deck>.avalon-button.role-deck-reset:not(.document-close):not(.player-token){position:absolute;top:20px;right:84px;width:calc(172 * var(--deck-unit));min-width:0;min-height:32px;font-size:clamp(13px,calc(20 * var(--deck-unit)),20px);padding:2px 6px}
.role-deck-overview>.document-title{padding-left:calc(172 * var(--deck-unit));padding-right:calc(172 * var(--deck-unit))}
.native-role-deck .role-deck-feedback{font-size:clamp(14px,calc(22 * var(--deck-unit)),22px);color:#883e3c;min-height:24px;flex-shrink:0}
.native-role-deck .role-deck-feedback:empty {display:none}
.game-document.native-role-deck.role-deck-candidates{width:min(calc(var(--candidate-width,992) * var(--deck-unit)),calc(100vw - 40px));overflow-y:auto}
.role-deck-candidates .role-deck-row{width:auto;flex-wrap:nowrap;justify-content:safe center;overflow-x:auto}
.role-deck-candidates .role-deck-card{flex-basis:calc(198 * var(--deck-unit))}
.game-document.native-role-deck.role-deck-adjust{width:min(calc(800 * var(--deck-unit)),calc(100vw - 40px));min-height:min(calc(490 * var(--deck-unit)),calc(100dvh - 36px));overflow-y:auto}
.role-deck-adjust .role-deck-change{margin-top:8px}
.game-document.role-deck-adjust p,.game-document.role-deck-adjust label{font-size:clamp(16px,calc(24 * var(--deck-unit)),24px)}
.native-role-deck .document-close svg{width:75%;height:75%;max-width:none}
.role-deck-adjust .role-deck-explanation{margin:14px 0;min-height:40px}
.role-deck-adjust>.avalon-paired{margin-top:auto;padding-top:18px;gap:clamp(24px,calc(112 * var(--deck-unit)),112px)}
.role-deck-adjust>.avalon-paired>.avalon-button{min-height:max(40px,calc(64 * var(--deck-unit)));font-size:clamp(16px,calc(24 * var(--deck-unit)),24px)}
@media(max-width:600px){.game-document.native-role-deck>.avalon-button.role-deck-reset:not(.document-close):not(.player-token){position:static;order:5;align-self:center}.role-deck-overview>.document-title{padding-left:48px;padding-right:48px}}
#game:is([data-stage=team_selection],[data-stage=assassination],[data-stage=lady_selection],[data-stage=sword_decision],[data-stage=recruitment]) .selection-dock>.selection-roster {gap:12px;padding:4px 8px}
#game:is([data-stage=team_selection],[data-stage=assassination],[data-stage=lady_selection],[data-stage=sword_decision],[data-stage=recruitment]) .selection-dock .selection-player {
 display:flex;align-items:center;gap:8px; flex:0 0 clamp(108px,14vw,172px); padding:6px 9px;
}
.selection-player .original-portrait {flex:0 0 25px;width:25px;height:28px;object-fit:contain}
.selection-player-name {min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#game:not([data-stage=menu]):not([data-stage=waiting]) .game-toolbar .toolbar-right {
 display:flex; width:auto; margin-left:auto; gap:clamp(5px,0.7vw,12px);
}
#game:not([data-stage=menu]):not([data-stage=waiting]) .game-toolbar .toolbar-right>.original-icon {
 width:var(--match-button-height); min-width:var(--match-button-height); height:var(--match-button-height); min-height:var(--match-button-height);
}
#game:not([data-stage=menu]):not([data-stage=waiting]) .game-toolbar .toolbar-fullscreen {order:2}
#game:not([data-stage=menu]):not([data-stage=waiting]) .game-toolbar .toolbar-menu {order:3}

/* 015: registered icon control, same square and state system as its neighbours. */
#game .game-toolbar .toolbar-fullscreen.original-icon {
 width:var(--toolbar-control-size);min-width:var(--toolbar-control-size);flex:0 0 var(--toolbar-control-size);
 height:var(--toolbar-control-size);min-height:var(--toolbar-control-size);padding:0;
}
#game:not([data-stage=menu]):not([data-stage=waiting]) .game-toolbar .toolbar-fullscreen.original-icon {
 width:var(--match-button-height);min-width:var(--match-button-height);flex-basis:var(--match-button-height);
 height:var(--match-button-height);min-height:var(--match-button-height);
}
#game .toolbar-fullscreen.original-icon .fullscreen-label {display:none}
#game .toolbar-fullscreen.original-icon .fullscreen-symbol {display:block;width:32px;height:32px;fill:currentColor;stroke:none}
#game .toolbar-fullscreen.original-icon::before,#game .toolbar-fullscreen.original-icon::after {content:none}

/* Informational notices share the secret-clue paper material and one anchor.
   A notice in a modal is appended inside its top layer, never behind it. */
body #game-notice,body .connection-note,body #notice:not(:empty) {
 position:fixed;left:50%;right:auto;top:42%;bottom:auto!important;transform:translate(-50%,-50%);
 width:max-content;max-width:min(620px,calc(100vw - 40px));max-height:60dvh;overflow:auto;
 padding:18px 28px;margin:0;text-align:center;font-family:AvalonPixel,monospace;font-weight:400;font-size:clamp(16px,calc(24 * var(--ui-unit,0.75px)),24px);line-height:1.5;
 background-color:#c7b99a;background-image:radial-gradient(#79694d24 .6px,transparent .8px);background-size:5px 5px;
 color:#42392f;border:3px solid #51483b;border-radius:0;box-shadow:inset 0 0 0 2px #b2a484;text-shadow:none;z-index:220;
}
body #game-notice:empty {display:none}
.game-modal-layer:has(>.prompt-document) {display:flex;align-items:center;justify-content:center;padding-bottom:max(18px,16dvh)}
.game-document.prompt-document {background-color:#c7b99a;background-image:radial-gradient(#79694d24 .6px,transparent .8px);background-size:5px 5px;border:3px solid #51483b;box-shadow:inset 0 0 0 2px #b2a484;max-height:76dvh}

/* Restore recommendation and X share the very same header box. */
#modals .native-role-deck {--deck-header-control:max(44px,calc(48 * var(--deck-unit)))}
#modals .native-role-deck>.document-close,
#modals .native-role-deck>.avalon-button.role-deck-reset:not(.document-close):not(.player-token) {
 position:absolute;top:14px;height:var(--deck-header-control);min-height:var(--deck-header-control);max-height:var(--deck-header-control);margin:0;padding:0 8px;
}
#modals .native-role-deck>.document-close {right:18px;width:var(--deck-header-control);min-width:var(--deck-header-control);padding:0}
#modals .native-role-deck>.avalon-button.role-deck-reset:not(.document-close):not(.player-token) {right:calc(30px + var(--deck-header-control));width:max(96px,calc(172 * var(--deck-unit)))}
#modals .role-deck-overview>.document-title {min-height:calc(var(--deck-header-control) + 12px);padding:0 max(150px,calc(210 * var(--deck-unit))) 12px;margin:0}
@media(max-width:600px){#modals .role-deck-overview>.document-title{padding:calc(var(--deck-header-control) + 6px) 0 10px}}

/* hall_gameplay.gd: main action y = viewport - 99, height = 64 => 35px margin.
   Keep a usable minimum and safe-area inset, shared with the seat action. */
body {--court-action-bottom:max(28px,calc(35 * var(--ui-unit)),calc(env(safe-area-inset-bottom) + 16px))}
body #game[data-stage=waiting] .game-actions:has(.native-lobby-status),
body:has(#touch-movement:not([hidden]) #joystick:not([hidden])) #game[data-stage=waiting] .game-actions:has(.native-lobby-status),
body #game[data-stage=waiting] .game-actions {bottom:var(--court-action-bottom)}
body #touch-interact {bottom:var(--court-action-bottom);height:max(44px,calc(64 * var(--ui-unit)));min-height:max(44px,calc(64 * var(--ui-unit)))}
body #game:is([data-stage=team_selection],[data-stage=assassination],[data-stage=lady_selection],[data-stage=sword_decision],[data-stage=recruitment]) .game-actions:has(.selection-dock) {bottom:var(--court-action-bottom)}

/* 016: keep the unavailable mission card in the same two-card geometry. */
.card-choice[data-kind] .choice-card:disabled{filter:grayscale(1) brightness(.55)!important;opacity:1;cursor:not-allowed}
body #game-notice{pointer-events:auto;cursor:pointer;touch-action:manipulation}

#game:is([data-stage=team_voting],[data-stage=mission_execution],[data-stage=inspection]) .game-actions.game-actions:has(.card-choice[data-kind])>.card-submit{width:calc(2 * var(--vote-card-width) + var(--vote-native-gap,14px))}

/* Rules candidate only: existing parchment/card/button primitives. Artwork deliberately absent. */
.rules-editor .role-deck-scroll{max-height:62vh;overflow:auto}.rules-options{display:flex;gap:12px;flex-wrap:wrap;justify-content:center;margin:16px 0}.rules-pending,.rules-private-record{font-size:16px;line-height:1.5}.missing-role-art{display:flex!important;flex-direction:column;justify-content:flex-end;align-items:center;background:#25251f;color:#e6e0c9;padding:12px;box-sizing:border-box;text-align:center}.missing-art-space{flex:1;min-height:60px}.missing-role-art strong{font-size:20px}.missing-role-art p{font-size:14px;line-height:1.5;white-space:normal}.rules-editor .role-deck-feedback{white-space:pre-line}.rules-editor .document-actions{flex-shrink:0}

/* Missing new illustrations stay blank; preserve readable card silhouette. */
.original-card.court-card.missing-role-art{background:#25251f!important;border:1px solid #b9ae98!important;color:#e6e0c9!important;box-shadow:none!important;padding:12px!important}.result-current-faction{font-size:12px;color:var(--ivory);white-space:nowrap}.rules-public-history{font-size:16px;line-height:1.55}

#game:is([data-stage=lady_selection],[data-stage=sword_decision],[data-stage=recruitment]) .game-actions{left:16px;right:16px;top:auto;bottom:var(--court-action-bottom);width:auto;max-width:none;transform:none;justify-content:center;align-items:center}.rules-no-use{justify-content:center!important}

/* One native card editor: candidates replace the paper, never append below the deck. */
.unified-identity .identity-candidate-reason{font-size:14px;line-height:1.4;margin:0;color:#795248;white-space:normal}
.unified-identity .identity-unavailable .court-card{filter:grayscale(.75);opacity:.58}
.unified-identity .identity-option-reason{align-self:center;font-size:14px;max-width:28em}
.unified-identity .identity-linked-plans{display:flex;flex-direction:column;gap:12px}
.unified-identity .identity-linked-plans .role-deck-link{text-align:left;line-height:1.5}
.unified-identity>.avalon-paired{flex-shrink:0;margin:0;gap:18px}
.unified-identity.role-deck-candidates .role-deck-row{flex:1 1 auto;min-height:0;align-items:start;overflow:auto;padding:8px 4px 14px;scrollbar-width:thin}
.unified-identity.role-deck-adjust{min-height:0!important;max-height:calc(100dvh - 28px)}
@media(max-height:500px){
 .game-document.unified-identity{max-height:calc(100dvh - 16px);gap:6px;padding:8px 14px}
 .unified-identity>.document-title{min-height:34px;padding-bottom:4px;font-size:24px}
 .unified-identity>.role-deck-summary{margin:0}
 .unified-identity.role-deck-candidates .role-deck-card{flex-basis:110px}
 .unified-identity.role-deck-candidates .role-deck-card button{min-height:36px}
 .unified-identity .role-deck-feedback{font-size:14px;margin:2px 0}
 .unified-identity>.avalon-paired>.avalon-button{min-height:40px;font-size:18px}
}
#modals .game-document.unified-identity.role-deck-candidates{height:min(640px,calc(100dvh - 20px));max-height:calc(100dvh - 20px);overflow:hidden}
#modals .unified-identity.role-deck-candidates>.document-title,#modals .unified-identity.role-deck-candidates>.role-deck-summary,#modals .unified-identity.role-deck-candidates>.avalon-button{flex-shrink:0}
@media(max-height:500px){
 #modals .game-document.unified-identity.role-deck-candidates{padding:8px 14px;gap:4px}
 #modals .unified-identity.role-deck-candidates>.document-title{min-height:36px;padding-bottom:4px}
 #modals .unified-identity.role-deck-candidates>.role-deck-summary{margin:2px 0}
 #modals .unified-identity.role-deck-candidates>.avalon-button:not(.document-close){min-height:38px;padding:3px 12px;font-size:18px}
}
#modals .game-document.unified-identity.role-deck-candidates>.role-deck-row{flex:1 1 0;min-height:0;overflow:auto;margin:0;align-self:stretch}
/* Fixed, shared rules area: clear state without extra selected decorations. */
#modals .unified-identity .identity-local-rules{flex:0 0 auto;width:100%;padding:0 0 16px;margin-bottom:12px;border-bottom:1px solid #9d93836b}
#modals .identity-local-rules>.role-deck-faction{margin:0 0 8px;color:var(--ink);font-size:20px}
#modals .identity-rule-options{display:grid;grid-template-columns:1fr 1fr;gap:16px;width:min(100%,640px);margin:0 auto}
#modals .identity-rule-options>.identity-rule-toggle{display:flex;align-items:center;justify-content:center;gap:16px;width:100%;min-width:0;min-height:60px;padding:10px 16px;font-size:24px}
#modals .identity-rule-state{font-size:18px;white-space:nowrap}
#modals .identity-rule-name{white-space:nowrap}
#modals .identity-rule-options>.identity-option-reason{grid-column:1/-1;max-width:none;line-height:1.35}
@media(max-height:500px){
 #modals .unified-identity .identity-local-rules{padding:0 0 8px;margin-bottom:6px}
 #modals .identity-local-rules>.role-deck-faction{font-size:16px;margin-bottom:4px}
 #modals .identity-rule-options{gap:10px}
 #modals .identity-rule-options>.identity-rule-toggle{min-height:48px;padding:6px 10px;font-size:20px;gap:12px}
 #modals .identity-rule-state{font-size:16px}
}
/* Native pixel checkbox; state remains on the same shared button. */
.identity-rule-check{display:grid;place-items:center;width:22px;height:22px;box-sizing:border-box;border:2px solid currentColor;flex:0 0 22px}
.identity-rule-toggle[aria-pressed=true] .identity-rule-check::after{content:'';width:3px;height:3px;background:currentColor;box-shadow:3px 3px currentColor,6px 0 currentColor,9px -3px currentColor,12px -6px currentColor;transform:translate(-6px,0)}
#modals .game-document.unified-identity.role-deck-candidates{width:min(1320px,calc(100vw - 32px));height:min(800px,calc(100dvh - 20px))}
#modals .game-document.unified-identity.role-deck-candidates>.role-deck-row{overflow-x:auto;overflow-y:hidden;justify-content:flex-start;overscroll-behavior:contain;touch-action:pan-x;padding:6px 4px 14px;box-sizing:border-box}
#modals .unified-identity.role-deck-candidates .role-deck-card{flex:0 0 var(--identity-fit-card,110px);gap:6px}
#modals .unified-identity.role-deck-candidates .role-deck-card button{height:40px;min-height:40px;max-height:40px;flex:0 0 40px;font-size:18px;padding:2px}
#modals .unified-identity.role-deck-candidates .identity-candidate-reason{font-size:13px;line-height:18px;margin:0;max-height:36px;overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}
#modals .game-modal-layer:has(>.role-deck-candidates){padding:10px 16px;overflow:hidden;box-sizing:border-box}
#modals .game-document.unified-identity.role-deck-candidates{box-sizing:border-box;max-width:100%;max-height:100%;margin:0}
@media(max-height:500px){#modals .unified-identity.role-deck-candidates>.role-deck-summary{display:none}}

/* Plain paper feedback; not an error-colored instruction. */
.unified-identity .role-deck-feedback{color:#302b22;}
