/* «Башня» — online game layout. Loaded after tw-theme.css (Game Theme tokens). */
.tw-online *, .tw-online *::before, .tw-online *::after { box-sizing: border-box; }
html:has(body.tw-online) { background: #f2782a; }
body.tw-online { min-height: 100dvh; background-attachment: fixed; overscroll-behavior: none; }
.tw-online .app { max-width: 520px; }

/* Top bar: back, title, room code. */

.tw-avatar { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 32px; height: 32px; border-radius: 50%; overflow: hidden; background: var(--tw-ink); color: #fff; font-size: 14px; font-weight: 800; }
.tw-avatar.has-photo { background: var(--tw-cream); }
.tw-avatar img { width: 100%; height: 100%; object-fit: cover; }
.tw-avatar--lg { width: 40px; height: 40px; font-size: 17px; }

/* ---------- Lobby ---------- */
#lobby-screen { padding-left: 16px; padding-right: 16px; }
.tw-lobby { display: flex; flex-direction: column; flex: 1; min-height: 0; gap: 12px; }
.tw-lobby .title { margin-bottom: 0; color: var(--tw-ink); }
.tw-lobby-sub { margin-bottom: 0; color: #3d2a1c; }
.tw-players { list-style: none; margin: 0; padding: 8px; display: flex; flex-direction: column; gap: 4px; border-radius: 18px; background: var(--tw-cream); overflow-y: auto; min-height: 0; }
.tw-player { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 6px 8px; border-radius: 12px; color: var(--tw-ink); }
.tw-player.self { background: rgba(29, 27, 26, .07); }
.tw-player.offline { opacity: .45; }
.tw-player-name { flex: 1; min-width: 0; font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tw-badge { flex-shrink: 0; padding: 2px 8px; border-radius: 999px; background: var(--tw-ink); color: #fff; font-size: 11px; font-weight: 800; letter-spacing: .03em; text-transform: uppercase; }
.tw-lobby-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.tw-status { margin: 0; text-align: center; color: var(--tw-ink); font-size: 15px; }

/* ---------- Game ---------- */
/* The 3D stage runs to the top edge; the back arrow floats over it and the rest of the top bar lets touches through to the tower. */
#game-screen { position: relative; padding: 0 0 calc(8px + env(safe-area-inset-bottom, 0px)); }
.tw-playing .topbar { pointer-events: none; }
.tw-playing .topbar .btn-back { pointer-events: auto; }
.tw-turn-line { display: flex; align-items: baseline; justify-content: center; gap: 8px; margin: 0; color: var(--tw-ink); font-size: 16px; }
.tw-turn-line strong { min-width: 0; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tw-timer { flex-shrink: 0; min-width: 24px; font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; }
.tw-timer.warning { color: #8e1f17; }
.tw-stage { position: relative; flex: 1; min-height: 0; }
.tw-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
.tw-panel { display: flex; flex-direction: column; gap: 8px; padding: 0 16px; }
.tw-hint { margin: 0; min-height: 2.6em; text-align: center; font-size: 15px; font-weight: 600; line-height: 1.3; color: var(--tw-ink); }
.tw-order { list-style: none; margin: 0; padding: 2px 0; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.tw-order::-webkit-scrollbar { display: none; }
.tw-order-item { display: flex; align-items: center; gap: 6px; flex-shrink: 0; max-width: 150px; padding: 4px 10px 4px 4px; border-radius: 999px; background: rgba(255, 244, 226, .55); color: var(--tw-ink); border: 2px solid transparent; }
.tw-order-item.active { background: var(--tw-cream); border-color: var(--tw-ink); }
.tw-order-item.offline { opacity: .45; }
.tw-order-item.loser { background: #fff; border-color: #8e1f17; }
.tw-order-name { min-width: 0; font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tw-order-count { flex-shrink: 0; min-width: 22px; padding: 1px 6px; border-radius: 999px; background: var(--tw-wood); color: #fff; font-size: 12px; font-weight: 800; text-align: center; }
.tw-order-item .tw-avatar { width: 28px; height: 28px; font-size: 12px; }

/* ---------- Question or dare of the block just put on top ---------- */
.tw-task { position: absolute; left: 0; right: 0; bottom: 0; z-index: 19; padding: 0 12px calc(12px + env(safe-area-inset-bottom, 0px)); animation: tw-rise .35s ease both; }
.tw-task-card { display: flex; flex-direction: column; gap: 12px; padding: 16px; border-radius: 24px; background: var(--tw-cream); color: var(--tw-ink); box-shadow: 0 -6px 30px rgba(61, 42, 28, .25); }
.tw-task-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tw-task-kind { flex-shrink: 0; padding: 4px 12px; border-radius: 999px; background: var(--tw-ink); color: #fff; font-size: 13px; font-weight: 800; letter-spacing: .03em; text-transform: uppercase; }
.tw-task.dare .tw-task-kind { background: var(--tw-wood); }
.tw-task-who { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 14px; font-weight: 700; }
.tw-task-who span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tw-task-who .tw-avatar { width: 28px; height: 28px; font-size: 12px; }
.tw-task-text { margin: 0; font-size: 20px; font-weight: 700; line-height: 1.3; }
.tw-task-wait { margin: 0; text-align: center; font-size: 14px; color: #3d2a1c; }

/* ---------- Result (over the fallen tower) ---------- */
.tw-result { position: absolute; left: 0; right: 0; bottom: 0; z-index: 20; padding: 0 12px calc(12px + env(safe-area-inset-bottom, 0px)); animation: tw-rise .35s ease both; }
@keyframes tw-rise { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
.tw-result-card { display: flex; flex-direction: column; gap: 10px; max-height: 70vh; overflow-y: auto; padding: 18px 16px 16px; border-radius: 24px; background: var(--tw-cream); color: var(--tw-ink); box-shadow: 0 -6px 30px rgba(61, 42, 28, .25); }
.tw-result .result-title { margin: 0; font-size: 26px; text-align: center; color: var(--tw-ink); }
.tw-result-text { margin: 0; text-align: center; font-size: 16px; color: #3d2a1c; }
.tw-result-label { margin: 4px 0 0; font-size: 12px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--tw-ink-muted); }
.tw-result-board { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.tw-result-row { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px 10px 4px 4px; border-radius: 12px; background: rgba(29, 27, 26, .05); }
.tw-result-row.loser { background: rgba(142, 31, 23, .1); }
.tw-result-value { flex-shrink: 0; font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; }
.tw-result-row.loser .tw-result-value { color: #8e1f17; font-size: 14px; }
.tw-result-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.tw-result-note { margin: 0; text-align: center; font-size: 14px; color: #3d2a1c; }

@media (prefers-reduced-motion: reduce) { .tw-result, .tw-task { animation: none; } }
