/* R06 mantém a lógica do jogo intacta e amplia o palco visual. */
body {
    align-items: stretch;
    overflow: auto;
}

#game-container {
    max-width: none;
    min-height: 100vh;
    height: 100vh;
    border-radius: 0;
}

.game-header {
    min-height: 74px;
    height: auto;
    display: grid;
    grid-template-columns: minmax(280px, 360px) minmax(430px, 1fr) minmax(290px, auto);
    gap: 12px;
    padding: 6px 14px;
}

.header-leaderboard {
    display: grid;
    min-width: 0;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 8px;
}

.header-add-players {
    min-height: 36px;
    padding: 6px 10px;
    border: 1px solid #c8943f;
    border-radius: 9px;
    background: linear-gradient(180deg, #e9c068, #9b6528);
    color: #fff8da;
    font-size: .68rem;
    font-weight: 800;
    cursor: pointer;
}

.header-player-strip.players-container {
    display: flex;
    max-height: none;
    flex-direction: row;
    gap: 4px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
}

.header-player-strip .player-card {
    min-width: 72px;
    padding: 4px 5px;
    flex: 1 0 72px;
    background: rgba(5, 25, 15, .5);
}

.header-player-strip .player-avatar {
    width: 27px;
    height: 27px;
    flex: 0 0 27px;
}

.header-player-strip .p-name {
    font-size: .6rem;
}

.header-player-strip .p-pos {
    font-size: .5rem;
}

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
}

.game-main {
    grid-template-columns: minmax(0, 1fr) 286px;
    gap: 0;
    padding: 0;
}

.board-wrapper {
    min-width: 0;
}

.board-37 {
    width: 100%;
    height: 100%;
    max-height: 100%;
    aspect-ratio: auto;
}

.control-dock {
    min-width: 0;
    padding: 10px;
    gap: 9px;
    overflow-y: auto;
    border-left: 2px solid rgba(32, 69, 48, .92);
    border-radius: 0;
}

.control-dock.is-collapsed {
    width: 56px;
    min-width: 56px;
    overflow: hidden;
    padding: 8px;
}

.control-dock.is-collapsed > :not(.dock-collapse-control) {
    display: none;
}

.dock-collapse-control {
    display: grid;
    place-items: center;
    min-height: 42px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: #203c32;
    color: #fff6cf;
    cursor: pointer;
}

.game-title-card {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 360px;
    padding: 5px 13px;
    border: 2px solid #b68142;
    border-radius: 12px;
    background: linear-gradient(180deg, #e9c485, #a96f35);
    box-shadow: inset 0 0 0 2px rgba(255, 240, 185, 0.35), 0 4px 12px rgba(0,0,0,.25);
    color: #fff6cf;
    text-shadow: 1px 2px 0 #4d2c15;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(.7rem, 1.4vw, 1.25rem);
    font-weight: 800;
    letter-spacing: .02em;
    line-height: 1.05;
}

.session-meta-label {
    display: block;
    max-width: 34vw;
    margin-left: 6px;
    overflow: hidden;
    color: #c7e7bb;
    font-size: .62rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.game-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 28px;
    padding: 4px 12px;
    color: var(--text-muted);
    font-size: .68rem;
    background: linear-gradient(rgba(48,27,10,.18), rgba(48,27,10,.18)), url("../assets/final-v2/footer.png") center / 100% 100% no-repeat;
    color: #fff1bd;
    border-top: 2px solid rgba(224, 174, 76, .55);
}

.footer-legend {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border: 1px solid rgba(239, 194, 89, .48);
    border-radius: 14px;
    background: rgba(28, 54, 30, .66);
    font-weight: 800;
    color: inherit;
    cursor: pointer;
    font: inherit;
}
.footer-legend small { opacity: .82; font-weight: 500; }
.footer-challenge { background: rgba(101, 39, 25, .68); }
.footer-decision { background: rgba(18, 81, 77, .68); }
.footer-back { padding: 4px 12px; border-radius: 12px; background: #356c35; border: 1px solid #d7bd67; }

.footer-story {
    padding: 4px 10px;
    border-radius: 12px;
    color: #fff5c9;
    background: rgba(20, 68, 43, .8);
    border: 1px solid rgba(255, 230, 151, .38);
    font-weight: 800;
    white-space: nowrap;
}

.game-footer a {
    color: #c9ebad;
    text-decoration: none;
}

.game-footer a:hover { text-decoration: underline; }

.footer-brand-logo {
    width: clamp(150px, 13vw, 220px);
    max-height: 46px;
    object-fit: contain;
    flex: 0 0 auto;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .72));
}

.footer-brand-wrap { position: relative; display: inline-flex; align-items: center; outline: none; }
.footer-brand-tooltip { position: absolute; left: 0; bottom: calc(100% + 9px); width: min(340px, 72vw); padding: 10px 12px; border-radius: 12px; background: rgba(8,34,22,.96); color: #fff5c9; border: 1px solid #d7bd67; box-shadow: 0 8px 22px rgba(0,0,0,.35); line-height: 1.3; opacity: 0; pointer-events: none; transform: translateY(6px); transition: opacity .2s ease, transform .2s ease; z-index: 200; }
.footer-brand-wrap:hover .footer-brand-tooltip, .footer-brand-wrap:focus .footer-brand-tooltip, .footer-brand-wrap:focus-visible .footer-brand-tooltip { opacity: 1; transform: translateY(0); }
.footer-detail-popover { position: fixed; left: 50%; bottom: 44px; z-index: 210; transform: translateX(-50%); width: min(460px, 90vw); padding: 14px 18px; border-radius: 16px; background: rgba(7,37,24,.96); color: #fff5c9; border: 1px solid #d7bd67; box-shadow: 0 12px 30px rgba(0,0,0,.4); line-height: 1.4; }
.footer-detail-popover[hidden] { display:none; }
.reopen-question { width:100%; padding:8px 10px; border:1px solid #d7bd67; border-radius:10px; background:#1d6949; color:#fff8cf; font-weight:800; cursor:pointer; }
.reopen-question[hidden] { display:none; }

.mobile-experience-note {
    display: none;
}

/*
 * Notebook, monitor 4:3 e janelas quase quadradas: o dock deixa de comprimir
 * o tabuleiro. A arte mantém a proporção canônica e os controles passam para
 * uma grade abaixo, permanecendo grandes e legíveis.
 */
@media (max-width: 1360px), (max-aspect-ratio: 4 / 3) {
    #game-container {
        height: auto;
        min-height: 100vh;
    }

    .game-header {
        grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
        align-items: center;
    }

    .header-leaderboard {
        min-width: 0;
    }

    .room-status {
        grid-column: 1 / -1;
        min-width: 0;
        justify-content: center;
    }

    .game-main {
        display: flex;
        flex-direction: column;
        width: 100%;
        overflow: visible;
    }

    .board-wrapper {
        order: 1;
        width: 100%;
        min-width: 0;
        min-height: 0;
        overflow: hidden;
    }

    .board-37 {
        width: 100%;
        min-width: 0;
        min-height: 0;
        height: auto;
        aspect-ratio: 1407 / 1012;
    }

    /* Em telas quase quadradas a arte canônica fica pequena dentro do gramado.
       Ampliamos apenas a camada do jogo, mantendo o container e o dock estáveis. */
    .trail-stage { inset: -6% -7%; width: 114%; height: 112%; }
    .board-final-geysiara { left: 1.5%; }

    .control-dock,
    .control-dock.is-collapsed {
        order: 2;
        display: grid;
        width: 100%;
        min-width: 0;
        max-height: none;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        align-items: start;
        overflow: visible;
        border-top: 2px solid rgba(32, 69, 48, .92);
        border-left: 0;
    }

    .dock-collapse-control {
        grid-column: 1 / -1;
    }

    .quick-actions,
    .game-log {
        grid-column: span 2;
    }

    .game-footer {
        position: sticky;
        bottom: 0;
        z-index: 40;
        flex-wrap: wrap;
        justify-content: center;
    }
}

@media (max-aspect-ratio: 1.15/1) and (min-width: 769px) {
    .trail-stage { inset: -10% -11%; width: 122%; height: 120%; }
    .board-final-title { transform: translate(-50%, -50%) scale(1.06); }
    .board-final-geysiara { transform: scale(.86); transform-origin: 0 100%; }
}

@media (max-width: 768px) {
    .game-footer {
        position: sticky;
        bottom: 0;
        z-index: 40;
        flex-wrap: wrap;
        justify-content: center;
        min-height: 52px;
        padding: 5px 8px;
    }

    .footer-brand-logo {
        width: 142px;
        max-height: 42px;
    }

    .footer-legend small {
        display: none;
    }

    .mobile-experience-note {
        display: block;
        position: fixed;
        left: 50%;
        bottom: 58px;
        z-index: 90;
        width: min(92vw, 430px);
        transform: translateX(-50%);
        padding: 7px 10px;
        border-radius: 11px;
        background: rgba(10, 43, 26, .92);
        color: #fff4c6;
        text-align: center;
        font-size: .72rem;
        box-shadow: 0 6px 18px rgba(0, 0, 0, .32);
        pointer-events: none;
        animation: mobile-note-hide 9s forwards;
    }
}

@keyframes mobile-note-hide {
    0%, 78% { opacity: 1; }
    100% { opacity: 0; visibility: hidden; }
}

.turn-card {
    padding: 8px;
}

.active-player-info .avatar-head img {
    width: 72px !important;
    height: 72px !important;
}

.active-player-info {
    align-items: center;
}

.house-spotlight {
    padding: 10px 12px;
    border-radius: 10px;
    color: #183325;
    background: linear-gradient(145deg, #fff9df, #f3e3b2);
    border: 1px solid #d9bd70;
    box-shadow: 0 5px 16px rgba(0, 0, 0, 0.2);
}

.house-spotlight-kicker {
    display: block;
    color: #6c5a2b;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.house-spotlight strong {
    display: block;
    margin-top: 2px;
    font-size: 0.95rem;
}

.house-spotlight p {
    margin-top: 3px;
    font-size: 0.78rem;
    line-height: 1.25;
}

.house-learning {
    color: #1e6040;
    font-weight: 700;
}

.timer-console {
    display: grid;
    gap: 7px;
    padding: 9px;
    border: 1px solid var(--border-color);
    border-radius: 9px;
    background: rgba(0, 0, 0, 0.18);
}

.timer-console-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.76rem;
}

.timer-console-heading span,
.timer-console small {
    color: var(--text-muted);
    font-size: 0.64rem;
}

.timer-buttons {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
}

.timer-buttons .btn {
    min-width: 0;
    padding: 6px 4px;
    font-size: 0.68rem;
}

.timer-buttons .btn:last-child {
    grid-column: span 2;
}

.dice-box {
    gap: 5px;
}

.dice-action-row {
    display: grid;
    width: 100%;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.dice-action-row .btn {
    width: 100%;
    min-width: 0;
    padding: 9px 5px;
    font-size: .72rem;
}

.participant-stepper {
    display: grid;
    width: 100%;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.participant-stepper .btn {
    min-width: 0;
    padding: 7px 4px;
    font-size: .68rem;
}

.audio-mixer {
    display: grid;
    width: 100%;
    grid-template-columns: auto minmax(70px, 1fr);
    align-items: center;
    gap: 3px 7px;
    padding: 6px 7px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: rgba(0, 0, 0, .16);
}

.audio-mixer label {
    display: flex;
    min-width: 94px;
    justify-content: space-between;
    gap: 5px;
    color: #fff6cf;
    font-size: .62rem;
    font-weight: 700;
}

.audio-mixer output {
    color: #bfe79e;
}

.audio-mixer input[type="range"] {
    width: 100%;
    accent-color: #2ecc71;
}

@media (max-width: 1050px) {
    .game-header {
        grid-template-columns: minmax(210px, auto) 1fr;
    }
    .room-status {
        grid-column: 1 / -1;
        justify-content: flex-end;
    }
}

.manual-dice-controls {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
    margin-top: 5px;
}

.manual-dice-controls[hidden] { display: none; }

.manual-dice-controls button {
    min-width: 46px;
    min-height: 46px;
    font-size: 1.15rem;
    border: 1px solid #d8b45c;
    border-radius: 6px;
    background: #f6e6a4;
    color: #233d2c;
    font-weight: 800;
    cursor: pointer;
}

.dice-action-row { align-items: stretch; }
.dice-action-card {
    min-height: 68px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 7px;
    text-align: center;
}
.dice-action-card img { width: 34px; height: 34px; object-fit: contain; }
.dice-action-card span { display:flex; flex-direction:column; }
.dice-action-card small { opacity:.85; font-size:.63rem; font-weight:600; }
.dice-action-physical { background: #c87e22; color: #fff7e4; border-color:#efbd5d; }
.dice-action-physical img { filter: hue-rotate(168deg) saturate(.25) brightness(1.45); }

.quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
}

.quick-action {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 3px;
}

.quick-action .btn {
    width: 100%;
    padding: 7px 6px;
    font-size: 0.78rem;
}

.quick-action small {
    min-height: 2.2em;
    color: var(--text-muted);
    font-size: 0.64rem;
    line-height: 1.1;
}

.consent-check {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    margin-top: 7px;
    font-size: 0.78rem;
    line-height: 1.25;
}

.dock-drawer {
    border: 1px solid var(--border-color);
    border-radius: 9px;
    background: rgba(0, 0, 0, 0.16);
}

.dock-drawer summary {
    padding: 8px 10px;
    color: var(--accent-gold);
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 700;
}

.sidebar-players {
    border: 0;
    border-radius: 0;
    padding: 6px;
    background: transparent;
}

.players-container {
    max-height: 178px;
    gap: 6px;
}

.player-card {
    position: relative;
    padding: 6px;
}

.btn-remove-photo {
    align-self: center;
    border: 0;
    border-radius: 7px;
    padding: 5px;
    background: rgba(231, 76, 60, 0.18);
    color: #fff;
    cursor: pointer;
}

.btn-remove-photo:hover:not(:disabled) {
    background: rgba(231, 76, 60, 0.42);
}

.photo-source-actions,
.history-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.photo-ready-label,
.camera-status {
    color: var(--text-muted);
    font-size: 0.78rem;
}

.modal-wide {
    width: min(760px, calc(100vw - 28px));
    max-height: calc(100vh - 36px);
    overflow-y: auto;
}

.modal-camera-card video {
    display: block;
    width: min(100%, 560px);
    min-height: 260px;
    margin: 12px auto;
    border-radius: 12px;
    background: #101b17;
    object-fit: cover;
}

.session-history-list {
    display: grid;
    gap: 8px;
    max-height: 430px;
    margin: 12px 0;
    overflow-y: auto;
}

.history-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 9px;
    background: rgba(0, 0, 0, 0.18);
}

.history-card strong,
.history-card small {
    display: block;
}

.history-card small {
    margin-top: 2px;
    color: var(--text-muted);
}

.house-editor-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 14px 0;
}

.house-editor-grid label {
    display: grid;
    gap: 5px;
    font-size: 0.78rem;
    font-weight: 700;
}

.house-editor-grid .span-2 {
    grid-column: 1 / -1;
}

.house-editor-grid textarea {
    resize: vertical;
}

.protected-rule {
    padding: 10px;
    border: 1px solid rgba(244, 185, 66, 0.55);
    border-radius: 8px;
    background: rgba(244, 185, 66, 0.11);
    font-size: 0.78rem;
}

.teacher-steps {
    display: grid;
    gap: 10px;
    margin: 14px 0 18px 22px;
    line-height: 1.35;
}

.player-avatar {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
}

.player-details .p-name {
    font-size: 0.8rem;
}

.player-details .p-pos {
    font-size: 0.68rem;
}

.game-log-box {
    min-height: 0;
    max-height: 155px;
    border: 0;
    border-radius: 0 0 9px 9px;
}

@media (max-width: 900px) {
    #game-container {
        height: auto;
        min-height: 100vh;
    }

    .game-main {
        display: flex;
        flex-direction: column;
        overflow: visible;
    }

    .board-wrapper {
        order: 1;
        justify-content: flex-start;
        overflow-x: auto;
        overflow-y: hidden;
        aspect-ratio: auto;
        min-height: 590px;
    }

    .board-37 {
        min-width: 980px;
        min-height: 590px;
    }

    .control-dock {
        order: 2;
        min-height: 0;
        overflow: visible;
    }

    .room-status {
        flex: 1 1 100%;
    }

    .house-editor-grid {
        grid-template-columns: 1fr;
    }

    .house-editor-grid .span-2 {
        grid-column: auto;
    }

    .game-header {
        grid-template-columns: 1fr;
        padding: 6px 8px;
    }

    .game-main {
        width: 100%;
    }

    .board-wrapper {
        width: 100%;
        min-height: 0;
        overflow: hidden;
    }

    .board-37 {
        width: 100%;
        min-width: 0;
        min-height: 0;
        height: auto;
        aspect-ratio: 1407 / 1012;
    }

    .control-dock,
    .control-dock.is-collapsed {
        width: 100%;
        min-width: 0;
        max-height: none;
        border-top: 2px solid rgba(32, 69, 48, .92);
        border-left: 0;
    }
}

@media (max-width: 600px) and (orientation: portrait) {
    .header-title {
        font-size: clamp(.78rem, 4.8vw, 1.1rem);
    }

    .header-player-strip.players-container {
        max-width: 100%;
    }

    .game-footer {
        gap: 4px;
    }

    .footer-brand-logo {
        width: 118px;
        max-height: 34px;
    }

    .footer-legend {
        display: none;
    }

    .mobile-experience-note {
        bottom: 55px;
        font-size: .78rem;
        font-weight: 800;
    }

    .tour-bubble {
        position: fixed !important;
        left: 12px !important;
        right: 12px !important;
        top: auto !important;
        bottom: 64px !important;
        width: auto !important;
        max-height: 42vh;
        overflow-y: auto;
    }
}
