/* Hanabi — table view (TV / iPad) */
html, body.tv { height: 100%; overflow: hidden; }
body.tv { font-size: 18px; }
.tv-app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
.tv-loading { display: flex; align-items: center; justify-content: center; height: 100%; font-size: 1.4rem; }
.logo { filter: drop-shadow(0 0 12px rgba(255,179,71,0.6)); }

/* ── picker ── */
body.tv.mode-picker { overflow: auto; }
.picker { max-width: 760px; margin: 0 auto; padding: 6vh 20px 40px; display: flex; flex-direction: column; gap: 14px; }
.picker-title { font-size: 2.6rem; font-weight: 800; text-align: center; letter-spacing: 0.5px; }
.picker-sub { text-align: center; font-size: 1.1rem; margin-bottom: 10px; }
.picker-panel h3 { margin-bottom: 10px; }
.picker-table { gap: 16px; padding: 14px 16px; }
.picker-code { font-size: 2rem; font-weight: 800; letter-spacing: 4px; font-variant-numeric: tabular-nums; min-width: 110px; color: var(--accent); }
.picker-meta { flex: 1; min-width: 0; }
.picker-name { font-size: 1.2rem; font-weight: 700; }
.picker-seats { display: flex; gap: -4px; }
.picker-seats .avatar + .avatar { margin-left: -8px; }
.picker-empty { padding: 20px 0; }
.picker-form .code-input { flex: 1; font-size: 1.6rem; letter-spacing: 6px; text-align: center; font-weight: 700; }
.picker-form .btn { min-height: 54px; padding: 0 28px; font-size: 1.1rem; }

/* ── lobby (join screen) ── */
.lobby { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 3vw; padding: 3vh 4vw; align-items: center; min-height: 0; width: 100%; max-width: 1500px; margin: 0 auto; }
.lobby-left { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 0.6vh; }
.lobby-brand { font-size: 2.2rem; font-weight: 800; letter-spacing: 1px; }
.lobby-name { font-size: 1.6rem; color: var(--accent); font-weight: 700; }
.lobby-hint { font-size: 1.2rem; margin-top: 1vh; }
.lobby-code { font-size: clamp(4rem, 14vh, 9rem); font-weight: 900; letter-spacing: 0.12em; line-height: 1; font-variant-numeric: tabular-nums; text-shadow: 0 0 30px rgba(255,179,71,0.45); }
.lobby-url { font-size: 1rem; margin-bottom: 1.5vh; word-break: break-all; }
.lobby-qr canvas { border-radius: 12px; box-shadow: var(--shadow); display: block; max-width: 100%; }
.lobby-right { display: flex; flex-direction: column; gap: 1.2vh; min-width: 0; width: 100%; max-width: 640px; justify-self: center; }
.lobby-right h3 { font-size: 1rem; margin: 0.8vh 0 0; }
.lobby-seats { display: flex; flex-direction: column; gap: 10px; }
.lobby-seat { display: flex; align-items: center; gap: 16px; padding: 12px 18px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); font-size: 1.6rem; }
.lobby-seat-name { flex: 1; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.lobby-seat .dot-online { width: 12px; height: 12px; }
.lobby-config { display: flex; flex-wrap: wrap; gap: 8px; }
.lobby-config .pill { font-size: 0.95rem; padding: 6px 12px; }
.lobby-wait { margin-top: 2vh; font-size: 1.4rem; font-weight: 700; color: var(--accent); display: flex; align-items: center; gap: 10px; }
.spin { width: 18px; height: 18px; border-radius: 50%; border: 3px solid rgba(255,179,71,0.3); border-top-color: var(--accent); animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── playing ── */
.tv-play { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 10px 14px 14px; gap: 10px; }
.tv-header { display: flex; align-items: center; gap: 26px; padding: 8px 18px; background: rgba(0,0,0,0.28); border: 1px solid var(--border); border-radius: var(--radius); flex: 0 0 auto; }
.tv-h-left { flex: 1; min-width: 0; }
.tv-h-name { font-size: 1.5rem; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tv-h-code { font-size: 0.95rem; }
.tv-h-stat { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.tv-h-stat .lbl { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; font-weight: 600; white-space: nowrap; }
.tv-h-stat .val { font-size: 1.9rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.tv-h-stat.score .val { font-size: 2.6rem; }
.tv-h-stat .val .of { font-size: 0.55em; color: var(--muted); font-weight: 700; }
.tv-h-stat .sub { font-size: 0.8rem; color: var(--warn); }
.tv-clues .token { width: 24px; height: 24px; }
.tv-strikes .token.strike { width: 30px; height: 30px; font-size: 18px; }
.tv-final { font-size: 1.1rem; padding: 8px 16px; animation: pulse 1.4s infinite; }
.tv-h-turn { display: flex; align-items: center; gap: 16px; }
.tv-h-cur { display: flex; align-items: center; gap: 10px; font-size: 1.2rem; }
.tv-timer { font-size: 2rem; min-width: 110px; text-align: right; }

.tv-main { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) clamp(300px, 22vw, 420px); gap: 12px; min-height: 0; }
.tv-board { display: flex; flex-direction: column; justify-content: space-evenly; gap: 10px; min-height: 0; min-width: 0; }
.tv-row { display: flex; gap: 12px; justify-content: center; align-items: center; flex: 1; min-height: 0; }
.tv-row > .tv-player { flex: 1 1 0; max-width: 560px; }

.tv-piles { display: flex; justify-content: center; gap: 22px; padding: 10px 0 26px; flex: 0 0 auto; }
.tv-piles .card-xl { width: 100px; height: 140px; font-size: 56px; }
.tv-piles .pile .lbl { font-size: 0.95rem; font-weight: 600; color: var(--text); margin-top: 6px; }
.tv-piles .pile .lbl .cnt { color: var(--muted); font-weight: 500; }
.tv-piles .card.empty { background: rgba(255,255,255,0.04); border: 2px dashed rgba(255,255,255,0.3); opacity: 0.85; }
.tv-piles .card.empty .rank { opacity: 0.5; }
.tv-piles .card.empty.suit-multi { border: 2px solid transparent; background: linear-gradient(#151d3d, #151d3d) padding-box, linear-gradient(135deg,#e53935,#fdd835,#43a047,#1e88e5) border-box; }

.tv-player { padding: 10px 14px 8px; display: flex; flex-direction: column; gap: 6px; position: relative; transition: box-shadow 0.2s, background 0.2s, border-color 0.2s; min-width: 0; }
.tv-player.current { background: rgba(255,179,71,0.12); border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent), 0 0 28px rgba(255,179,71,0.35), var(--shadow); }
.tv-player.offline { opacity: 0.7; }
.tv-player-head { display: flex; align-items: center; gap: 12px; }
.tv-player-name { display: flex; align-items: center; gap: 8px; font-size: 1.35rem; min-width: 0; flex: 1; }
.tv-player-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-player-name .dot-online { width: 12px; height: 12px; flex: 0 0 auto; }
.tv-playing { font-size: 1rem; padding: 6px 14px; animation: pulse 1.4s infinite; white-space: nowrap; flex: 0 0 auto; }
.tv-player-name b { min-width: 3ch; }
.tv-hand .card.back:has(.hints.ranks) .rank { opacity: 0.25; }
.tv-hand { justify-content: center; padding: 12px 4px 14px; gap: 12px; overflow: visible; }
.tv-hand .card-lg { width: 96px; height: 136px; font-size: 56px; }
.tv-hand .card .clue-badges { top: -8px; right: -8px; gap: 3px; }
.tv-hand .card .clue-badges .badge { width: 22px; height: 22px; font-size: 13px; }
.tv-hand .card .hints .dot { width: 11px; height: 11px; }
.tv-hand .card .hints.ranks b { font-size: 12px; padding: 2px 3px; }
.tv-hand .card .hints { bottom: 8px; gap: 3px; }
.tv-hand .card .hints.ranks { top: 8px; }
.tv-hand .card.fresh { box-shadow: 0 0 0 4px #fff, 0 0 26px #fff; animation: fresh-glow 1.2s ease-in-out infinite alternate; }
@keyframes fresh-glow { from { box-shadow: 0 0 0 4px #fff, 0 0 14px #fff; } to { box-shadow: 0 0 0 4px #fff, 0 0 34px #fff; } }
.tv-hand-caption { display: flex; justify-content: space-between; font-size: 0.75rem; padding: 0 6px; margin-top: -8px; }
.tv-reactions { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.tv-reaction { position: absolute; bottom: 20%; font-size: 3rem; animation: float-up 2.5s ease-out forwards; filter: drop-shadow(0 2px 6px rgba(0,0,0,0.6)); }
@keyframes float-up { 0% { transform: translateY(0) scale(0.6); opacity: 0; } 15% { opacity: 1; transform: translateY(-10px) scale(1.1); } 100% { transform: translateY(-140px) scale(1); opacity: 0; } }

.tv-side { display: flex; flex-direction: column; gap: 12px; min-height: 0; min-width: 0; }
.tv-side .panel { margin: 0; }
.tv-discards { flex: 0 0 auto; }
.tv-discards h3 { margin-bottom: 8px; }
.tv-discard-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.tv-discard-suit { font-size: 1.1rem; width: 26px; text-align: center; flex: 0 0 auto; }
.tv-discard-cards { display: flex; gap: 4px; flex-wrap: wrap; min-height: 46px; align-items: center; }
.tv-discard-cards .card-sm { width: 34px; height: 46px; font-size: 20px; }
.tv-discard-cards .none { padding-left: 4px; }
.tv-log { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tv-log h3 { margin-bottom: 8px; }
.tv-log .log { max-height: none; flex: 1; min-height: 0; font-size: 1.05rem; overflow-y: auto; }
.tv-log .log .entry { padding: 6px 10px; }
.tv-log .log .entry:last-child { background: rgba(255,255,255,0.12); font-weight: 700; }

/* ── action banner ── */
.tv-banner { position: fixed; top: 14vh; left: 50%; transform: translate(-50%, -20px) scale(0.96); z-index: 8000; display: flex; align-items: center; gap: 18px; padding: 18px 36px; border-radius: 20px; font-size: 2.2rem; font-weight: 800; color: #fff; background: rgba(20,28,60,0.92); box-shadow: 0 12px 50px rgba(0,0,0,0.6); border: 2px solid rgba(255,255,255,0.2); opacity: 0; transition: opacity 0.25s, transform 0.25s; pointer-events: none; max-width: 90vw; text-align: center; }
.tv-banner.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.tv-banner .icon { font-size: 1.3em; }
.tv-banner .sub { font-size: 0.55em; font-weight: 600; opacity: 0.8; }
.tv-banner.ok { background: rgba(46,125,50,0.94); border-color: #81c784; }
.tv-banner.bad { background: rgba(183,28,28,0.94); border-color: #ef9a9a; }
.tv-banner.clue { background: rgba(21,101,192,0.94); border-color: #90caf9; }
.tv-banner.discard { background: rgba(69,90,100,0.94); border-color: #b0bec5; }
.tv-banner.warn { background: rgba(245,124,0,0.94); border-color: #ffcc80; color: #1b0f12; }

/* ── ended ── */
.ended { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.4vh; padding: 3vh 4vw; text-align: center; overflow: auto; }
.ended-title { font-size: 2.4rem; font-weight: 800; }
.ended-name { font-size: 1.1rem; }
.ended-score { font-size: clamp(4rem, 14vh, 8rem); font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; text-shadow: 0 0 30px rgba(255,179,71,0.45); }
.ended-score .of { font-size: 0.4em; color: var(--muted); font-weight: 700; }
.ended-score.perfect { color: var(--accent); }
.ended-verdict { font-size: 1.6rem; font-weight: 700; color: var(--accent); }
.ended-reason { font-size: 1.1rem; padding: 8px 18px; }
.ended-piles .tv-piles { padding: 6px 0 22px; }
.ended-players { display: flex; gap: 22px; flex-wrap: wrap; justify-content: center; font-size: 1.2rem; font-weight: 700; }
.ended-player { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ended-stats, .ended-games { font-size: 1rem; }

/* ── controls ── */
.tv-controls { position: fixed; right: 14px; bottom: 12px; z-index: 8500; display: flex; gap: 8px; align-items: center; transition: opacity 0.4s; padding: 6px; border-radius: 14px; background: rgba(0,0,0,0.35); backdrop-filter: blur(6px); }
.tv-controls.idle { opacity: 0.08; }
.tv-controls:hover { opacity: 1; }
.tv-controls .pill { font-size: 0.85rem; }
.tv-controls:empty { display: none; }

/* ── responsive: smaller landscape (iPad 1024/1180) ── */
@media (max-width: 1400px) {
  body.tv { font-size: 16px; }
  .tv-main { grid-template-columns: minmax(0, 1fr) clamp(260px, 24vw, 340px); }
  .tv-hand { gap: 8px; }
  .tv-hand .card-lg { width: 60px; height: 86px; font-size: 34px; }
  .tv-piles { gap: 14px; }
  .tv-piles .card-xl { width: 76px; height: 108px; font-size: 44px; }
  .tv-header { gap: 16px; padding: 6px 14px; }
  .tv-h-stat.score .val { font-size: 2.1rem; }
  .tv-timer { font-size: 1.6rem; min-width: 90px; }
  .tv-player-head .avatar-lg { width: 44px; height: 44px; font-size: 26px; }
  .tv-discard-cards .card-sm { width: 28px; height: 38px; font-size: 17px; }
  .tv-banner { font-size: 1.6rem; padding: 14px 26px; }
}
@media (max-width: 1100px) {
  .tv-h-code { display: none; }
  .tv-hand .card-lg { width: 52px; height: 74px; font-size: 30px; }
  .tv-hand-caption { display: none; }
  .tv-h-cur > span > .small { display: none; }
  .tv-playing { font-size: 0.8rem; padding: 4px 8px; }
  .tv-playing .txt { display: none; }
  .tv-hand .card .hints.ranks b { font-size: 9px; padding: 1px 2px; }
}
/* ── portrait tablet: side panel moves below the board, page scrolls ── */
@media (orientation: portrait) {
  body.tv { overflow: auto; }
  .tv-app { height: auto; min-height: 100vh; }
  .tv-main { grid-template-columns: 1fr; }
  .tv-side { flex-direction: row; }
  .tv-side > .panel { flex: 1; }
  .tv-log .log { max-height: 300px; }
  .tv-header { flex-wrap: wrap; gap: 12px 18px; justify-content: center; }
  .tv-h-left { flex: 1 1 100%; text-align: center; }
  .tv-row { flex-wrap: wrap; }
  .tv-row > .tv-player { flex: 1 1 300px; }
  .lobby { grid-template-columns: 1fr; align-content: start; }
  .ended { justify-content: flex-start; }
}
