/* App shell and top bar. This file loads after ui.css, so its rules can place the shared components. */
/* ---------- Khung ứng dụng ---------- */
.app-shell { display: flex; flex-direction: column; height: 100vh; }

.topbar {
    height: 60px; flex-shrink: 0;
    display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: var(--sp-8);
    padding: 0 var(--sp-12);
    background: var(--table-deep); color: var(--table-text);
}
.topbar .tb-left { justify-self: start; min-width: 0; }
.topbar .tb-center { justify-self: center; display: flex; }
.topbar .tb-right { justify-self: end; }
.logo { display: flex; align-items: center; gap: var(--sp-5); font: var(--fw-heavy) var(--fs-2xl) var(--f-display); color: var(--plaster); white-space: nowrap; }
.logo .mark { width: 30px; height: 30px; border-radius: var(--r-sm); background: var(--son); color: var(--white); display: grid; place-items: center; box-shadow: var(--bevel-sm); flex-shrink: 0; }
.logo .mark svg { width: 18px; height: 18px; }
.topbar .group { display: flex; align-items: center; gap: var(--sp-4); flex-wrap: nowrap; }
.room-pill, .round-chip {
    display: inline-flex; align-items: center; gap: var(--sp-4); height: 34px; padding: 0 var(--sp-8);
    border-radius: var(--r-pill); background: color-mix(in srgb, var(--white) 7%, transparent);
    font: var(--fw-regular) var(--fs-md) var(--f-ui); color: var(--table-soft); white-space: nowrap;
}
.room-pill { padding-right: var(--sp-2); }
.room-pill .dot { width: 8px; height: 8px; border-radius: var(--r-round); background: var(--table-dim); }
.room-pill .dot.on { background: var(--online); }
.room-copy { height: 26px; min-width: 26px; padding: 0 var(--sp-3); }
.room-copy .copied { color: var(--online); }
.topbar .ico { width: 16px; height: 16px; display: inline-flex; flex-shrink: 0; }
.topbar .ico svg { width: 100%; height: 100%; }
.topbar .tb-icon { width: 34px; padding: 0; justify-content: center; }
.topbar button:focus-visible { outline: var(--ring-focus); outline-offset: 2px; }
.tb-more { position: relative; display: none; }
.tb-scrim { position: fixed; inset: 0; z-index: 44; }
.tb-menu {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 45; min-width: 220px;
    display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-4);
    border-radius: var(--r-md); background: var(--table-deep); box-shadow: var(--shadow-pop);
}
.tb-item {
    display: flex; align-items: center; min-height: 44px; padding: 0 var(--sp-6);
    border: 0; border-radius: var(--r-sm); background: transparent; cursor: pointer; text-align: left;
    font: var(--fw-regular) var(--fs-md) var(--f-ui); color: var(--table-text);
}
.lang-toggle {
    display: inline-flex; gap: var(--sp-1); padding: var(--sp-2);
    border-radius: var(--r-pill); background: color-mix(in srgb, var(--white) 7%, transparent);
}
.lang-toggle > button { height: 26px; padding: 0 var(--sp-5); }
.tb-menu .lang-toggle { align-self: flex-start; }
.mobile-only { display: none; }
.tb-item:hover { background: color-mix(in srgb, var(--white) 8%, transparent); }


.tile:focus-visible { outline: var(--ring-focus); outline-offset: 2px; }

/* ---------- RichText: styled text of the rule book, the deck viewer and the log ---------- */
.rt-btn {
    display: inline-block; padding: 0 var(--sp-4); border-radius: var(--r-xs); white-space: nowrap;
    background: var(--plaster-2); box-shadow: 0 -2px 0 var(--plaster-edge) inset;
    font: var(--fw-bold) 0.95em/1.5 var(--f-display); color: var(--ink);
}
.rt-money { font-weight: var(--fw-bold); white-space: nowrap; }
.rt-money.lost { color: var(--son); }
.rt-money.gained { color: var(--good); }
.rt-term { font-weight: var(--fw-bold); color: var(--ink); }
.rt-tile {
    font-weight: var(--fw-semibold); color: var(--ink); white-space: nowrap;
    padding: 0 var(--sp-2); border-radius: var(--r-xs);
    background: color-mix(in srgb, var(--tc, var(--khaki)) 14%, transparent);
    border-bottom: 2px solid var(--tc, var(--khaki));
}
.rt-tip {
    padding: var(--sp-4) var(--sp-5); border-radius: var(--r-sm);
    background: var(--warn-bg); border-left: 3px solid var(--gold);
    font: var(--fw-regular) var(--fs-sm)/1.5 var(--f-ui); color: var(--ink-2);
}
.rt-tip > b:first-child { margin-right: 6px; color: var(--warn); }

/* ---------- Timer ring around the avatar ---------- */
.timer-ring { position: relative; flex-shrink: 0; }
.timer-ring svg.ring { position: absolute; inset: -6px; width: calc(100% + 12px); height: calc(100% + 12px); transform: rotate(-90deg); }
.timer-ring svg.ring circle { transition: stroke-dashoffset 900ms linear, stroke 200ms; }

@media (max-width: 900px) {
    body { overflow-x: hidden; overflow-y: auto; }
    .app-shell { height: auto; min-height: 100vh; }
    .topbar { padding: 0 var(--sp-4); gap: var(--sp-2); height: 56px; grid-template-columns: auto auto minmax(0, 1fr); }
    .topbar.in-game .tb-wide { display: none; }
    .topbar.in-game .tb-more { display: inline-flex; }
    .logo { font-size: 0; gap: 0; }
    .topbar .group { gap: var(--sp-2); min-width: 0; }
    .topbar-toast { position: fixed; top: 62px; left: var(--sp-5); right: var(--sp-5); z-index: 50; justify-content: space-between; }
    .room-pill, .round-chip { height: 44px; min-height: 44px; padding: 0 var(--sp-4); font-size: var(--fs-xs); }
    .hide-mobile { display: none !important; }
    .mobile-only { display: inline-flex; }
}

/* ---------- Mobile in-game landscape prompt (hidden in lobby and on desktop) ---------- */
.landscape-guard { display: none; }
@media (max-width: 900px) and (orientation: portrait) and (pointer: coarse) {
    .landscape-guard {
        position: fixed; inset: 0; z-index: 90;
        display: flex; align-items: center; justify-content: center;
        padding: var(--sp-8);
        background: color-mix(in srgb, var(--table-deep) 92%, transparent);
        backdrop-filter: blur(6px);
    }
    .landscape-guard-card {
        width: min(360px, 100%);
        display: flex; flex-direction: column; align-items: center; gap: var(--sp-5);
        padding: var(--sp-10) var(--sp-8);
        border-radius: var(--r-lg);
        background: var(--plaster); color: var(--ink);
        box-shadow: var(--shadow-pop);
        text-align: center;
    }
    .landscape-guard-ico {
        width: 52px; height: 52px; color: var(--table);
        animation: landscape-tilt 2.2s var(--ease-out) infinite;
    }
    .landscape-guard-ico svg { width: 100%; height: 100%; }
    .landscape-guard-title { margin: 0; font: var(--fw-bold) var(--fs-xl)/1.25 var(--f-display); }
    .landscape-guard-body { margin: 0; font: var(--fw-regular) var(--fs-md)/1.5 var(--f-ui); color: var(--ink-2); }
    .landscape-guard-hint {
        margin: 0; width: 100%; box-sizing: border-box;
        padding: var(--sp-4) var(--sp-5); border-radius: var(--r-sm);
        background: var(--warn-bg); border-left: 3px solid var(--gold);
        font: var(--fw-regular) var(--fs-sm)/1.5 var(--f-ui); color: var(--ink);
        text-align: left;
    }
    .landscape-guard-actions {
        width: 100%; display: flex; flex-direction: column; gap: var(--sp-3); margin-top: var(--sp-2);
    }
}
@keyframes landscape-tilt {
    0%, 20% { transform: rotate(0deg); }
    50%, 75% { transform: rotate(-90deg); }
    100% { transform: rotate(0deg); }
}
