/* ============================================================
   Arcade site-wide responsive shell
   Driven by js/viewport.js → html[data-bp], [data-short], --ui-scale
   ============================================================ */

:root {
    --vw: 100vw;
    --vh: 100vh;
    --svh: 100vh;
    --ui-scale: 1;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

html, body {
    max-width: 100%;
    overflow-x: clip;
}

/* Floating notices — always above docks / cams / chat */
.arcade-notice-layer {
    position: fixed;
    inset: 0;
    z-index: 90;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    padding:
        calc(12px + var(--safe-top))
        calc(12px + var(--safe-right))
        calc(12px + var(--safe-bottom))
        calc(12px + var(--safe-left));
}

.arcade-notice-layer > * {
    pointer-events: auto;
    max-width: min(540px, calc(100% - 16px));
}

/* Generic toast/notice helpers usable by any page */
.arcade-toast-fixed {
    position: fixed;
    left: 50%;
    bottom: calc(18px + var(--safe-bottom));
    transform: translateX(-50%);
    z-index: 95;
    max-width: min(420px, calc(100vw - 24px));
}

/* ---- Breakpoint utilities (set by viewport.js) ---- */
html[data-bp="xs"] body,
html[data-bp="sm"] body {
    font-size: 14px;
}

html[data-short="1"] .hide-when-short {
    display: none !important;
}

/* ---- Main arcade / Tetris (style.css consumers) ---- */
html[data-bp="xs"] .game-wrapper,
html[data-bp="sm"] .game-wrapper {
    grid-template-columns: 1fr;
    width: min(100%, 100vw - 16px);
    padding: 10px;
    gap: 10px;
    box-sizing: border-box;
}

html[data-bp="xs"] .game-wrapper .panel,
html[data-bp="sm"] .game-wrapper .panel {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

html[data-bp="xs"] .game-and-chat-row,
html[data-bp="sm"] .game-and-chat-row,
html[data-bp="md"] .game-and-chat-row {
    flex-direction: column;
    align-items: stretch;
    width: min(100%, 100vw - 12px);
    padding: 0 6px;
    box-sizing: border-box;
}

html[data-bp="xs"] .chat-wrapper,
html[data-bp="sm"] .chat-wrapper,
html[data-bp="md"] .chat-wrapper {
    position: relative !important;
    top: auto !important;
    width: 100% !important;
    max-width: none !important;
    max-height: none !important;
}

html[data-bp="xs"] .leaderboard-wrapper,
html[data-bp="sm"] .leaderboard-wrapper {
    font-size: 0.85em;
    padding: 10px 12px;
    overflow-x: auto;
}

html[data-bp="xs"] #leaderboard-table,
html[data-bp="sm"] #leaderboard-table {
    font-size: 0.85em;
}

html[data-short="1"] .game-over .controls,
html[data-short="1"] .arcade-replay-box {
    margin-top: 8px;
}

/* Scale tetris board shell on very small widths */
html[data-bp="xs"] #tetris-view .game-column,
html[data-bp="sm"] #tetris-view .game-column {
    transform: scale(var(--ui-scale));
    transform-origin: top center;
}

/* ---- UNO ---- */
html[data-bp="xs"] .uno-view,
html[data-bp="sm"] .uno-view {
    padding: 12px 10px 28px;
}

html[data-bp="xs"] .uno-logo {
    font-size: 2em;
    letter-spacing: 8px;
}

html[data-short="1"] .uno-view {
    min-height: var(--svh);
    padding-top: 10px;
    padding-bottom: 16px;
}

html[data-bp="xs"] .lobby-card,
html[data-bp="sm"] .lobby-card {
    width: 100%;
    max-width: 100%;
}

html[data-bp="xs"] .join-row--split,
html[data-bp="sm"] .join-row--split {
    flex-wrap: wrap;
}

html[data-bp="xs"] :root,
html[data-bp="sm"] :root {
    --card-w: 56px;
    --card-h: 82px;
}

html[data-bp="xs"][data-short="1"] :root {
    --card-w: 48px;
    --card-h: 70px;
}

html[data-short="1"] .house-rules-panel {
    max-height: 28vh;
    overflow: auto;
}

/* ---- Poker notice + layout adaptations ---- */
.poker-notice-layer {
    position: fixed;
    inset: 0;
    z-index: 90;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding:
        calc(16px + var(--safe-top))
        calc(14px + var(--safe-right))
        calc(16px + var(--safe-bottom))
        calc(14px + var(--safe-left));
}

.poker-notice-layer .poker-announce,
.poker-notice-layer .poker-result-overlay {
    pointer-events: auto;
    position: relative;
    left: auto;
    top: auto;
    margin: 0;
    transform: none;
    max-width: min(540px, 100%);
    width: min(540px, 100%);
}

html[data-bp="xs"] .poker-notice-layer .poker-result-headline,
html[data-bp="sm"] .poker-notice-layer .poker-result-headline {
    font-size: clamp(1.05rem, 5vw, 1.35rem);
}

html[data-bp="xs"] .poker-view,
html[data-bp="sm"] .poker-view {
    padding: 12px 10px 100px;
    gap: 10px;
}

html[data-short="1"] .poker-table-view {
    padding-bottom: 88px;
}

html[data-short="1"] .poker-felt {
    height: clamp(240px, 38vh, 380px);
}

html[data-bp="xs"] .poker-felt,
html[data-bp="sm"] .poker-felt {
    border-radius: 24px;
    height: clamp(260px, 40vh, 400px);
}

html[data-bp="xs"] .poker-seat,
html[data-bp="sm"] .poker-seat {
    min-width: 88px;
    max-width: 112px;
    padding: 5px 7px;
    font-size: 0.82em;
}

html[data-bp="xs"] .poker-seat-cam,
html[data-bp="sm"] .poker-seat-cam {
    width: 28px;
    height: 28px;
}

html[data-bp="xs"] .poker-cam-tile,
html[data-bp="sm"] .poker-cam-tile {
    width: 84px;
    height: 64px;
}

html[data-short="1"] .poker-cam-tile {
    width: 72px;
    height: 54px;
}

html[data-bp="xs"] .poker-last-hand-detail,
html[data-short="1"] .poker-hotkeys,
html[data-bp="xs"] .poker-hotkeys {
    display: none !important;
}

html[data-bp="xs"] .poker-action-feed,
html[data-bp="sm"] .poker-action-feed {
    max-height: 3.6em;
}

html[data-bp="xs"] .poker-lb-box,
html[data-bp="sm"] .poker-lb-box {
    width: 100%;
}

html[data-bp="xs"] .poker-wallet-box,
html[data-bp="sm"] .poker-wallet-box,
html[data-bp="xs"] .poker-friends,
html[data-bp="sm"] .poker-friends {
    width: 100%;
}

html[data-bp="xs"] .poker-join-row,
html[data-bp="sm"] .poker-join-row {
    flex-wrap: wrap;
}

html[data-bp="xs"] .poker-chat-dock,
html[data-bp="sm"] .poker-chat-dock {
    top: calc(8px + var(--safe-top));
    right: calc(8px + var(--safe-right));
    width: min(280px, calc(100vw - 16px));
}

html[data-bp="xs"] .poker-cam-dock,
html[data-bp="sm"] .poker-cam-dock {
    left: calc(8px + var(--safe-left));
    bottom: calc(8px + var(--safe-bottom));
    max-width: calc(100vw - 16px);
}

html[data-short="1"] .poker-chat-log {
    height: 110px;
}

/* Landscape phones: keep felt shorter, free vertical space for actions */
html[data-landscape="1"][data-short="1"] .poker-felt {
    height: clamp(180px, 46vh, 300px);
}

html[data-landscape="1"][data-short="1"] .poker-hero {
    margin-top: 6px;
    gap: 6px;
}

/* Mod page */
html[data-bp="xs"] .mod-drawer,
html[data-bp="sm"] .mod-drawer {
    width: min(100vw, 100%);
}
