/* «Голосование за игру» (game-vote.ts): host button in the room and the full-screen vote.
   Reads only the room tokens of room-themes.css, so the vote wears the selected game's palette. */

.btn-vote {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; min-height: 48px; margin: -6px 0 18px; padding: 10px 16px;
    background: var(--room-surface); color: var(--room-text);
    border: 1.5px solid var(--room-line); border-radius: var(--room-radius-action);
    font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn-vote[hidden] { display: none; }
.btn-vote .rp-icon { font-size: 20px; color: var(--room-accent-text); }
.btn-vote:disabled { opacity: 0.5; cursor: progress; }
.btn-vote:focus-visible { outline: 2px solid var(--room-text); outline-offset: 2px; }

.gv-open, .gv-open body { overflow: hidden; }
.gv {
    position: fixed; inset: 0; z-index: 60;
    width: 100%; max-width: 420px; margin: 0 auto;
    display: flex; flex-direction: column;
    background: linear-gradient(180deg, var(--room-bg) 0%, var(--room-bg-deep) 100%);
    color: var(--room-text);
}
.gv-back {
    position: absolute; top: 16px; left: 16px; z-index: 2;
    width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
    background: none; border: 0; color: var(--room-text); font-size: 20px; cursor: pointer;
}
.gv-back:focus-visible { outline: 2px solid var(--room-text); outline-offset: 2px; border-radius: var(--room-radius-chip); }

.gv-head { padding: 14px 56px 8px; text-align: center; }
.gv-head h2 { font-size: 20px; font-weight: 700; line-height: 1.2; }
.gv-hint { margin-top: 2px; font-size: 13px; line-height: 1.3; color: var(--room-muted); }
.gv-left {
    display: inline-flex; align-items: center; gap: 8px;
    margin-top: 8px; padding: 4px 12px;
    background: var(--room-accent-soft); border-radius: 999px;
    font-size: 13px; font-weight: 600; color: var(--room-accent-text);
}
.gv-pips { display: inline-flex; gap: 4px; }
.gv-pips i {
    width: 10px; height: 10px; border-radius: 50%;
    border: 2px solid var(--room-accent-text); transition: background-color 160ms ease, transform 160ms ease;
}
.gv-pips i.on { background: var(--room-accent-text); }
.gv.is-result .gv-head .gv-hint, .gv.is-result .gv-left, .gv.is-spinning .gv-left { display: none; }

/* Compact rows: most of the room's games are visible at once, the rest scroll. */
.gv-grid {
    flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
    display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: 68px; gap: 8px; align-content: start;
    padding: 10px 12px 8px;
}
.gv.is-result .gv-grid { display: none; }
/* Shade over the grid's lower edge: tells there are more games below. */
.gv-fade {
    position: relative; z-index: 2; height: 56px; margin-top: -56px; pointer-events: none;
    background: linear-gradient(180deg, transparent, var(--room-bg-deep));
    opacity: 0; transition: opacity 200ms ease;
}
.gv.can-scroll .gv-fade { opacity: 1; }
.gv.is-result .gv-fade { display: none; }
.gv-cell { position: relative; min-width: 0; }
.gv-tile {
    position: relative; width: 100%; height: 100%;
    display: flex; align-items: center; gap: 8px;
    padding: 4px 6px 4px 5px; text-align: left;
    background: var(--room-surface); color: var(--room-text);
    border: 2px solid transparent; border-radius: var(--room-radius-card);
    font: inherit; cursor: pointer;
    transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
}
.gv-tile:focus-visible { outline: 2px solid var(--room-text); outline-offset: 2px; }
.gv-cell.is-mine .gv-tile { border-color: var(--room-accent); background: var(--room-accent-soft); }
.gv-icon, .gv-tile .game-dropdown-item-icon-emoji {
    width: 44px; height: 44px; border-radius: 8px; object-fit: cover; flex-shrink: 0;
    font-size: 30px; display: flex; align-items: center; justify-content: center;
}
.gv-text { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 3px; }
.gv-name {
    font-size: 13.5px; font-weight: 600; line-height: 1.2; letter-spacing: -0.005em;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    overflow-wrap: break-word; hyphens: auto;
}
/* Under the name: faces of everyone who voted for it (mine first, ringed), then the total. */
.gv-row { display: flex; align-items: center; gap: 6px; min-height: 0; }
.gv-cell:not(.has-votes) .gv-row { display: none; }
/* Too few people in the room for this game: dimmed, «Нужно от N игроков» instead of votes. */
.gv-need { display: none; font-size: 12px; line-height: 1.2; color: var(--room-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gv-cell.is-locked:not(.has-votes) .gv-need { display: block; }
/* A guest suggested this game from its preview: «Предложили: Аня» in the game's accent. */
.gv-suggested { display: none; font-size: 12px; line-height: 1.2; font-weight: 600; color: var(--room-accent-text, var(--room-accent)); overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.gv-cell.is-suggested .gv-suggested { display: -webkit-box; }
/* The vote already shows suggestions on the tiles; the host's suggestion toast would cover its buttons. */
html.gv-open .rc-suggest { display: none; }
.gv-cell.is-locked .gv-icon, .gv-cell.is-locked .gv-name { opacity: .45; }
.gv-cell.is-locked .gv-name { -webkit-line-clamp: 1; padding-right: 14px; }
.gv-cell.is-long .gv-name::before { content: ""; float: right; width: 12px; height: 1em; }
.gv-foot { flex-shrink: 0; display: flex; align-items: center; margin-left: auto; }
.gv-voters { display: flex; }
.gv-voters:empty { display: none; }
.gv-face {
    position: relative; width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--room-menu); color: var(--room-text); font-size: 10px; font-weight: 700;
    border: 1.5px solid var(--room-bg);
}
.gv-face + .gv-face { margin-left: -6px; }
.gv-face img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.gv-face.is-me { border: 2px solid var(--room-accent); z-index: 1; }
.gv-times {
    position: absolute; right: -7px; bottom: -4px; z-index: 2;
    padding: 0 3px; border-radius: 999px; line-height: 11px;
    background: var(--room-accent); color: var(--room-on-accent); font-size: 9px; font-weight: 800;
}
.gv-face:has(.gv-times) + .gv-face { margin-left: 6px; }
.gv-more { font-size: 9px; }
.gv-count {
    display: inline-flex; align-items: center; justify-content: center; gap: 3px;
    min-width: 24px; height: 20px; padding: 0 7px; border-radius: 999px;
    background: var(--room-menu); color: var(--room-muted); font-size: 12px;
}
.gv-count b { font-weight: 700; }
.gv-count .rp-icon { display: none; font-size: 11px; }
.gv-cell:not(.has-votes) .gv-foot { display: none; }
.gv-cell.has-votes .gv-count { color: var(--room-text); }
.gv-cell.is-leading .gv-count { background: var(--room-accent); color: var(--room-on-accent); }
.gv-cell.is-leading .gv-count .rp-icon { display: inline-block; }
/* «−» (icon corner) and «?» (tile corner) sit inside the tile, so the grid's scroll edge never cuts them; their invisible targets are bigger than the drawn circles. */
.gv-minus {
    position: absolute; top: 2px; left: 2px; z-index: 1;
    width: 22px; height: 22px; border-radius: 50%;
    display: none; align-items: center; justify-content: center;
    background: var(--room-menu); border: 1.5px solid var(--room-accent); cursor: pointer; padding: 0;
}
.gv-minus::before { content: ''; width: 9px; height: 2px; border-radius: 2px; background: var(--room-text); }
.gv-minus::after { content: ''; position: absolute; inset: -6px; }
.gv-cell.is-mine .gv-minus { display: flex; }
.gv-minus:focus-visible { outline: 2px solid var(--room-text); outline-offset: 2px; }
/* «?» in the tile's top-right corner opens «Об игре»; two-line titles (`is-long`) leave room for it. */
.gv-info {
    position: absolute; top: 3px; right: 3px; z-index: 1;
    width: 20px; height: 20px; border-radius: 50%; padding: 0;
    display: flex; align-items: center; justify-content: center;
    background: none; color: var(--room-muted); border: 0;
    font-size: 16px; cursor: pointer;
}
.gv-info::after { content: ''; position: absolute; inset: -6px; }
.gv-info:focus-visible { outline: 2px solid var(--room-text); outline-offset: 2px; }
.gv.is-spinning .gv-minus, .gv.is-spinning .gv-tile, .gv.is-spinning .gv-info { pointer-events: none; }

.gv-sheet {
    position: absolute; inset: 0; z-index: 5;
    display: flex; align-items: flex-end;
    background: color-mix(in srgb, var(--room-bg-deep) 70%, transparent);
}
.gv-sheet-panel {
    width: 100%; max-height: 85%; overflow-y: auto;
    display: flex; flex-direction: column; align-items: center; text-align: center;
    padding: 22px 20px calc(16px + env(safe-area-inset-bottom, 0px));
    background: var(--room-menu); border-top: 1px solid var(--room-line);
    border-radius: var(--room-radius-field) var(--room-radius-field) 0 0;
}
.gv-sheet-icon, .gv-sheet-panel .game-dropdown-item-icon-emoji { width: 72px; height: 72px; border-radius: 16px; object-fit: cover; font-size: 48px; display: flex; align-items: center; justify-content: center; }
.gv-sheet-panel h3 { margin-top: 12px; font-size: 20px; font-weight: 700; line-height: 1.2; }
.gv-sheet-players { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; padding: 4px 12px; border-radius: 999px; background: var(--room-surface); font-size: 14px; color: var(--room-muted); }
.gv-sheet-players[hidden], .gv-sheet-text[hidden] { display: none; }
.gv-sheet-players .rp-icon { font-size: 16px; color: var(--room-accent-text); }
.gv-sheet-text { margin: 12px 0 18px; font-size: 16px; line-height: 1.4; color: var(--room-text); }
.gv-sheet-panel .btn-play { margin-top: 4px; }
.gv-cell.is-spin .gv-tile { border-color: var(--room-accent); background: var(--room-accent-soft); transform: scale(1.04); }

.gv-result[hidden] { display: none; }
.gv-result { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; align-items: center; padding: 8px 24px 16px; text-align: center; }
.gv-result-label { font-size: 15px; color: var(--room-muted); margin-top: 12px; }
.gv-winner { display: flex; flex-direction: column; align-items: center; margin-top: 18px; }
.gv-winner-icon { width: 112px; height: 112px; border-radius: 24px; object-fit: cover; box-shadow: 0 0 0 6px var(--room-accent-soft); }
.gv-winner .game-dropdown-item-icon-emoji { width: 112px; height: 112px; font-size: 72px; display: flex; align-items: center; justify-content: center; }
.gv-winner-name { margin-top: 18px; font-size: 26px; font-weight: 800; line-height: 1.15; overflow-wrap: break-word; hyphens: auto; }
.gv-winner-votes { margin-top: 6px; font-size: 15px; font-weight: 600; color: var(--room-accent-text); }
.gv-tie { margin-top: 6px; font-size: 14px; color: var(--room-muted); }
.gv-runners { list-style: none; width: 100%; max-width: 300px; margin-top: 26px; display: flex; flex-direction: column; gap: 6px; }
.gv-runners li {
    display: flex; justify-content: space-between; gap: 12px; align-items: center;
    padding: 10px 14px; border-radius: var(--room-radius-card);
    background: var(--room-surface); font-size: 14px; text-align: left;
}
.gv-runners li b { color: var(--room-muted); }

.gv-bottom { padding: 6px 16px calc(10px + env(safe-area-inset-bottom, 0px)); }
.gv-bottom .btn-play { padding: 14px; }
.gv-status { text-align: center; font-size: 13px; color: var(--room-muted); margin-bottom: 6px; }
.gv-status:empty { display: none; }
.gv-bottom .btn-play[hidden], .gv-alt[hidden] { display: none; }
.gv-alt {
    display: block; min-height: 40px; margin: 2px auto 0; padding: 8px 16px;
    background: none; border: 0; border-radius: var(--room-radius-chip);
    color: var(--room-muted); font: inherit; font-size: 14px;
    text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.gv-alt:focus-visible { outline: 2px solid var(--room-text); outline-offset: 2px; }

@media (max-width: 360px) {
    .gv-head { padding: 12px 52px 6px; }
    .gv-grid { padding: 6px 10px 8px; }
}

@media (prefers-reduced-motion: no-preference) {
    .gv { animation: gv-in 260ms cubic-bezier(.2, .9, .3, 1.25) both; }
    .gv-tile:active { transform: scale(.96) translateY(2px); transition-duration: 100ms; }
    .gv-cell.is-bump .gv-tile { animation: gv-bump 320ms cubic-bezier(.2, .9, .3, 1.25); }
    .gv-cell.is-bump .gv-count { animation: gv-pop 320ms cubic-bezier(.2, .9, .3, 1.25); }
    .gv-left.is-empty-shake { animation: gv-shake 360ms ease-out; }
    .gv-cell.is-need-shake .gv-tile { animation: gv-shake 360ms ease-out; }
    .gv-sheet { animation: gv-fade 180ms ease-out both; }
    .gv-sheet-panel { animation: gv-sheet-up 260ms cubic-bezier(.2, .9, .3, 1.1) both; }
    .gv.is-result .gv-winner-icon { animation: gv-win 620ms cubic-bezier(.2, .9, .3, 1.25) both; }
    .gv.is-result .gv-winner-name, .gv.is-result .gv-winner-votes { animation: gv-rise 320ms cubic-bezier(.2, .9, .3, 1.25) 180ms both; }
    .gv.is-result .gv-runners li { animation: gv-rise 280ms ease-out 320ms both; }
}
@keyframes gv-in { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@keyframes gv-bump { 0% { transform: none; } 40% { transform: scale(1.05, .94); } 70% { transform: scale(.98, 1.03); } 100% { transform: none; } }
@keyframes gv-pop { 0% { transform: scale(.4); } 60% { transform: scale(1.3); } 100% { transform: none; } }
@keyframes gv-shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-3px); } }
@keyframes gv-win {
    0% { opacity: 0; transform: scale(.3) rotate(-12deg); }
    55% { opacity: 1; transform: scale(1.12, .9) rotate(4deg); }
    80% { transform: scale(.96, 1.05) rotate(-1deg); }
    100% { transform: none; }
}
@keyframes gv-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes gv-sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes gv-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
