:root {
  color-scheme: dark;
  font-family: Inter, Segoe UI, Arial, sans-serif;
  --page: #101418;
  --surface: #151b22;
  --surface-strong: #121820;
  --border: #303944;
  --border-soft: #252e38;
  --text: #eef3f7;
  --muted: #94a3b8;
  --accent: #f4c542;
  --accent-text: #161300;
  --felt: #17231f;
  --effect-duration: 650ms;
  --shake-distance: 8px;
  background: var(--page);
  color: var(--text);
}
[data-theme="club"] {
  --page: #0d1713;
  --surface: #14251d;
  --surface-strong: #102019;
  --border: #365648;
  --border-soft: #263e34;
  --text: #f2f5ed;
  --muted: #a8b9ad;
  --accent: #e4bd57;
  --accent-text: #181306;
  --felt: #174f38;
}
[data-theme="burgundy"] {
  --page: #190f12;
  --surface: #28171c;
  --surface-strong: #211216;
  --border: #62404a;
  --border-soft: #412b32;
  --text: #f7f1ee;
  --muted: #c1a9ae;
  --accent: #d8b45f;
  --accent-text: #1d1608;
  --felt: #4b202a;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--page); color: var(--text); }
button, input, select, textarea { font: inherit; }
.app { width: min(1180px, 100%); margin: 0 auto; padding: 20px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; border-bottom: 1px solid #2b333c; padding-bottom: 14px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.tabs button { background: transparent; color: #aebccd; border: 1px solid transparent; padding: 9px 11px; }
.tabs button.selected, .tabs button:hover { color: #fff; border-color: #45515f; background: #1b242d; }
h1 { margin: 0 0 4px; font-size: 34px; }
h2 { margin: 18px 0 10px; font-size: 18px; color: #cbd7e1; }
h3 { margin: 18px 0 8px; font-size: 15px; color: #aebccd; }
p { margin: 0; color: #94a3b8; }
.panel { margin-top: 28px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: end; }
.view { margin-top: 22px; }
.split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.box { border-top: 1px solid #2b333c; padding: 6px 0 18px; }
label { display: grid; gap: 6px; color: #cbd7e1; }
.checkline { display: flex; align-items: center; gap: 8px; min-height: 46px; }
.checkline input { width: auto; }
input, select, textarea { width: 100%; border: 1px solid #334155; background: #151c23; color: #fff; border-radius: 8px; padding: 12px; }
select { appearance: auto; }
textarea { resize: vertical; min-height: 180px; font: 13px/1.45 Consolas, monospace; }
button { border: 0; background: #f4c542; color: #161300; border-radius: 8px; padding: 12px 14px; cursor: pointer; font-weight: 700; }
button:disabled { opacity: .45; cursor: not-allowed; }
.ghost { background: #1f2933; color: #e2e8f0; border: 1px solid #3c4652; }
.hidden { display: none !important; }
.actions, .inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section-heading h2 { margin-right: auto; }
.icon-button { width: 42px; height: 42px; padding: 0; display: inline-grid; place-items: center; font-size: 18px; }
.room-list { display: grid; gap: 8px; }
.room-row { display: grid; grid-template-columns: minmax(180px, 1fr) 110px auto; align-items: center; gap: 12px; border: 1px solid #303944; background: #151b22; border-radius: 8px; padding: 10px 12px; }
.room-row > div { display: grid; gap: 3px; }
.room-row span, .room-row small { color: #94a3b8; }
.inline-form input { flex: 1 1 220px; }
.grid-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; align-items: end; }
.grid-form button { min-height: 46px; }
.kv { display: grid; gap: 8px; }
.kv > div { display: flex; justify-content: space-between; gap: 16px; border-bottom: 1px solid #252e38; padding: 8px 0; }
.kv span { color: #94a3b8; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.mini-card { border: 1px solid #303944; background: #151b22; border-radius: 8px; padding: 12px; }
.mini-card p { margin: 7px 0; font-size: 14px; overflow-wrap: anywhere; }
.mini-card span { display: inline-block; margin: 3px 5px 0 0; padding: 3px 6px; border: 1px solid #3c4652; border-radius: 4px; color: #cbd5e1; font-size: 12px; }
.mini-card .card-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.mini-card .card-actions button { padding: 8px 10px; font-size: 13px; }
.danger { background: #3b1d22; color: #fecaca; border: 1px solid #7f1d1d; }
.warning { background: #3a2d12; color: #fde68a; border: 1px solid #854d0e; }
.catalog-item { display: grid; gap: 8px; align-content: start; }
.catalog-item button { margin-top: auto; }
.roomline { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 20px 0; }
.turn-timer { min-width: 92px; color: #f4c542; font-variant-numeric: tabular-nums; }
.players { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.player { border: 1px solid #303944; background: #151b22; border-radius: 8px; padding: 12px; min-height: 98px; }
.player.active { outline: 2px solid #f4c542; }
.player strong { display: block; margin-bottom: 8px; }
.player-block { margin-top: 9px; padding: 6px 8px; font-size: 12px; }
.player .card-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.standings { margin-top: 12px; border-top: 1px solid #303944; padding-top: 10px; }
.standings h3 { margin: 0 0 8px; font-size: 16px; }
.standings > div { display: grid; grid-template-columns: 90px 1fr auto; gap: 10px; padding: 7px 0; border-bottom: 1px solid #252e38; }
.meta { display: grid; gap: 4px; color: #aebccd; font-size: 14px; }
.table { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-top: 14px; }
.trick, .bidbox, .log { min-height: 96px; border: 1px solid #303944; background: #121820; border-radius: 8px; padding: 12px; }
.trick { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.trick .card { width: 104px; }
.card small { display: block; margin-top: 6px; font-weight: 600; font-size: 11px; }
.hand { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 10px; }
.card { min-height: 118px; border-radius: 8px; border: 1px solid #45515f; background: #f8fafc; color: #111827; padding: 10px; display: flex; align-items: center; justify-content: center; text-align: center; font-weight: 800; }
.card.red { color: #b91c1c; }
.card.joker { background: #f4c542; }
.card.playable { box-shadow: 0 0 0 2px #22c55e inset; }
.bidgrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.bidgrid button { padding: 8px; }
.log { display: grid; gap: 4px; color: #cbd5e1; max-height: 190px; overflow: auto; font-size: 14px; }
.room-social { margin-top: 16px; }
.room-music { margin-top: 16px; }
.room-video { margin-top: 16px; }
.video-controls { display: flex; align-items: center; gap: 7px; }
.video-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.video-tile { position: relative; aspect-ratio: 16 / 9; min-width: 0; overflow: hidden; border: 1px solid #303944; border-radius: 8px; background: #080b0e; }
.video-tile video { width: 100%; height: 100%; display: block; object-fit: cover; }
.video-tile span { position: absolute; left: 8px; bottom: 8px; max-width: calc(100% - 16px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: rgb(8 11 14 / 78%); color: #eef3f7; border-radius: 4px; padding: 4px 7px; font-size: 12px; }
.music-controls { display: flex; align-items: center; gap: 7px; }
.music-controls input[type="range"] { width: 110px; padding: 0; }
.music-now { min-height: 52px; display: grid; align-content: center; border-left: 3px solid #f4c542; padding: 8px 12px; background: #151b22; }
.music-now strong { display: block; }
.music-now span { color: #94a3b8; font-size: 13px; }
.music-queue { display: grid; gap: 5px; margin-top: 9px; }
.music-queue div { display: flex; justify-content: space-between; gap: 12px; color: #aebccd; font-size: 13px; border-bottom: 1px solid #252e38; padding: 6px 0; }
.social-feed { min-height: 72px; max-height: 160px; overflow: auto; display: grid; align-content: start; gap: 6px; border: 1px solid #303944; background: #121820; border-radius: 8px; padding: 10px; }
.social-message { display: flex; gap: 8px; align-items: baseline; font-size: 14px; }
.social-message strong { color: #f4c542; white-space: nowrap; }
.social-message span { color: #dbe5ee; overflow-wrap: anywhere; }
.social-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.social-actions button { padding: 8px 10px; background: #1f2933; color: #e2e8f0; border: 1px solid #3c4652; }
.social-actions.emoji-actions button { min-width: 42px; font-size: 20px; line-height: 1; }
dialog { width: min(560px, calc(100% - 28px)); border: 1px solid #45515f; border-radius: 8px; background: #151b22; color: #eef3f7; padding: 0; }
dialog::backdrop { background: rgb(5 8 12 / 75%); }
.dialog-form { display: grid; gap: 14px; padding: 18px; }
.dialog-form h2 { margin: 0; }
.dialog-form textarea { min-height: 110px; }
details { margin-top: 10px; color: #aebccd; }
details summary { cursor: pointer; }
details pre { max-height: 190px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; color: #cbd5e1; font: 12px/1.45 Consolas, monospace; }
.choicebar, .joker-choice { border: 1px solid #45515f; background: #151b22; border-radius: 8px; padding: 12px; margin: 14px 0; }
.violation-notice { display: flex; align-items: center; gap: 14px; border: 1px solid #b45309; background: #261b12; border-radius: 8px; padding: 12px; margin: 14px 0; }
.violation-notice .card { width: 82px; min-height: 96px; flex: 0 0 82px; }
.violation-notice strong { color: #fbbf24; }
.choicebar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.choicebar strong { margin-right: 8px; }
.joker-choice { display: grid; gap: 8px; }
.joker-row { display: grid; grid-template-columns: minmax(150px, 1.5fr) repeat(4, 1fr); gap: 8px; align-items: center; }
.joker-row button { min-width: 0; padding: 10px 6px; }
.settings-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; align-items: end; margin-bottom: 12px; }
.effect-overlay { position: fixed; inset: 0; z-index: 9999; pointer-events: none; opacity: 0; background: rgb(190 16 35 / 48%); box-shadow: inset 0 0 42px 14px rgb(255 28 46 / 80%); }
.effect-overlay.effect-active { animation: red-discipline-pulse var(--effect-duration) ease-out both; }
.discipline-shake .app { animation: discipline-shake var(--effect-duration) ease-out both; }
.animations-disabled .effect-overlay.effect-active { animation: none; opacity: .42; }
.animations-disabled .app, .animations-disabled .card { animation: none !important; transition: none !important; }
.card { transition: transform 150ms ease, box-shadow 150ms ease; }
.card.playable:hover { transform: translateY(-4px); }

@keyframes red-discipline-pulse {
  0%, 100% { opacity: 0; }
  18% { opacity: .78; }
  48% { opacity: .22; }
  72% { opacity: .62; }
}
@keyframes discipline-shake {
  0%, 100% { transform: translate(0, 0); }
  15% { transform: translate(var(--shake-distance), 0); }
  30% { transform: translate(calc(0px - var(--shake-distance)), 2px); }
  48% { transform: translate(var(--shake-distance), -2px); }
  66% { transform: translate(calc(0px - var(--shake-distance)), 0); }
  82% { transform: translate(2px, 0); }
}

body, input, select, textarea { background-color: var(--page); color: var(--text); }
.topbar, .box { border-color: var(--border); }
.tabs button.selected, .tabs button:hover, .ghost, .choicebar, .joker-choice { background: var(--surface); border-color: var(--border); color: var(--text); }
input, select, textarea, .room-row, .mini-card, .player, .music-now { background: var(--surface); border-color: var(--border); color: var(--text); }
.trick, .bidbox, .log, .social-feed { background: var(--surface-strong); border-color: var(--border); }
.trick { background-color: var(--felt); }
.kv > div, .standings > div, .music-queue div { border-color: var(--border-soft); }
button { background: var(--accent); color: var(--accent-text); }
.turn-timer, .social-message strong { color: var(--accent); }
.player.active { outline-color: var(--accent); }
.music-now { border-left-color: var(--accent); }
.card.joker { background: var(--accent); }
@media (max-width: 760px) {
  .panel, .split, .table, .players, .grid-form { grid-template-columns: 1fr; }
  .app { padding: 14px; }
  .card { min-height: 92px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .tabs { justify-content: flex-start; }
  .joker-row { grid-template-columns: repeat(2, 1fr); }
  .joker-row strong { grid-column: 1 / -1; }
  .room-row { grid-template-columns: 1fr auto; }
  .room-row > div:first-child { grid-column: 1 / -1; }
  .video-grid { grid-template-columns: 1fr; }
}
@media (max-height: 600px) and (orientation: landscape) {
  .app { width: 100%; padding: 8px 10px; }
  .topbar { min-height: 48px; padding-bottom: 6px; flex-direction: row; align-items: center; }
  .topbar h1 { font-size: 22px; margin: 0; }
  .topbar p { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; justify-content: flex-end; }
  .tabs button { padding: 7px 8px; white-space: nowrap; }
  .view { margin-top: 8px; }
  h2 { margin: 8px 0 6px; font-size: 15px; }
  .split { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .players { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .player { min-height: 72px; padding: 8px; }
  .player strong { margin-bottom: 4px; font-size: 13px; }
  .meta { font-size: 11px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .roomline { margin: 8px 0; gap: 7px; }
  .roomline button { padding: 7px 9px; }
  .table { grid-template-columns: minmax(0, 2fr) minmax(170px, .8fr); gap: 8px; margin-top: 7px; }
  .trick, .bidbox { min-height: 82px; padding: 7px; }
  .trick .card { width: 64px; min-height: 74px; }
  .hand { grid-template-columns: repeat(9, minmax(48px, 1fr)); gap: 5px; }
  .hand .card { min-height: 76px; padding: 5px; }
  .settings-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  .discipline-shake .app { animation: none; }
  .card { transition: none; }
}
