﻿:root {
  --bg-top: #efe8d8;
  --bg-bottom: #d4c2a6;
  --wood-1: #8a5a32;
  --wood-2: #6f431f;
  --wood-3: #b07a45;
  --felt-1: #1c6f4b;
  --felt-2: #15543a;
  --hero-1: #2a6e4b;
  --hero-2: #143d2a;
  --topbar-1: #235f42;
  --topbar-2: #17452f;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-solid: #ffffff;
  --text: #19251f;
  --muted: #5a685f;
  --line: rgba(30, 62, 48, 0.18);
  --line-strong: rgba(30, 62, 48, 0.28);
  --danger: #c43f3f;
  --danger-dark: #9d2f2f;
  --shadow-soft: 0 12px 32px rgba(18, 33, 26, 0.14);
  --shadow-strong: 0 20px 46px rgba(18, 33, 26, 0.24);
  --toast-bg: rgba(25, 52, 39, 0.95);
  --toast-text: #f2f7f4;
  --table-seat-bg: rgba(248, 253, 250, 0.95);
  --card-bg-1: #ffffff;
  --card-bg-2: #f5f6f5;
  --card-border: #cfd4d1;
  --card-overlay: rgba(0, 0, 0, 0.05);
}

body[data-theme="modern"] {
  --bg-top: #eaf4f2;
  --bg-bottom: #cfddd8;
  --wood-1: #96a7a0;
  --wood-2: #75857f;
  --wood-3: #b2c1bb;
  --felt-1: #1f6a53;
  --felt-2: #164d3e;
  --hero-1: #2a5f70;
  --hero-2: #203b4f;
  --topbar-1: #244f5d;
  --topbar-2: #183943;
  --line: rgba(33, 65, 70, 0.2);
  --line-strong: rgba(33, 65, 70, 0.34);
  --toast-bg: rgba(22, 40, 52, 0.96);
}

body[data-theme="rustikal"] {
  --bg-top: #dfc7a4;
  --bg-bottom: #b18a5d;
  --wood-1: #7a3f17;
  --wood-2: #4c240d;
  --wood-3: #9f6332;
  --felt-1: #2a6b3f;
  --felt-2: #1c4d2f;
  --hero-1: #7a451e;
  --hero-2: #47240f;
  --topbar-1: #6a3a18;
  --topbar-2: #3f200d;
  --line: rgba(69, 39, 16, 0.24);
  --line-strong: rgba(69, 39, 16, 0.34);
  --toast-bg: rgba(66, 36, 16, 0.96);
}

body[data-theme="turnier"] {
  --bg-top: #e9f2dc;
  --bg-bottom: #c2d8af;
  --wood-1: #6f6f57;
  --wood-2: #4a4a37;
  --wood-3: #8d8d71;
  --felt-1: #0f7243;
  --felt-2: #0a5632;
  --hero-1: #1f6f42;
  --hero-2: #0f4f2f;
  --topbar-1: #1e5f39;
  --topbar-2: #124028;
  --line: rgba(34, 70, 42, 0.22);
  --line-strong: rgba(34, 70, 42, 0.34);
}

body[data-theme="alpin"] {
  --bg-top: #eaf3f6;
  --bg-bottom: #c8dce6;
  --wood-1: #6b808f;
  --wood-2: #465866;
  --wood-3: #8fa4b1;
  --felt-1: #286a6a;
  --felt-2: #1a4f50;
  --hero-1: #2d5f7a;
  --hero-2: #20455b;
  --topbar-1: #244d66;
  --topbar-2: #19384b;
  --line: rgba(29, 59, 73, 0.2);
  --line-strong: rgba(29, 59, 73, 0.34);
}

body[data-theme="holzstube"] {
  --bg-top: #ead5b5;
  --bg-bottom: #b78655;
  --wood-1: #7a4a24;
  --wood-2: #4c2b14;
  --wood-3: #a26d3a;
  --felt-1: #275e3c;
  --felt-2: #1a402a;
  --hero-1: #6b4220;
  --hero-2: #3f2411;
  --topbar-1: #5c3418;
  --topbar-2: #38200f;
  --card-bg-1: #fffef8;
  --card-bg-2: #f4eee1;
  --card-border: #cfb992;
}

body[data-theme="wirtshaus"] {
  --bg-top: #f3e3d1;
  --bg-bottom: #c9a27a;
  --wood-1: #87462a;
  --wood-2: #5a2d19;
  --wood-3: #b9784d;
  --felt-1: #3a693a;
  --felt-2: #264a28;
  --hero-1: #8b3f2e;
  --hero-2: #5b261d;
  --topbar-1: #7a3527;
  --topbar-2: #4a2119;
  --card-bg-1: #fffdfa;
  --card-bg-2: #f6efe9;
  --card-border: #d0b7a8;
}

body[data-theme="minimal"] {
  --bg-top: #f4f4f4;
  --bg-bottom: #e0e0e0;
  --wood-1: #8f8f8f;
  --wood-2: #6b6b6b;
  --wood-3: #b2b2b2;
  --felt-1: #3f6a63;
  --felt-2: #2a4f49;
  --hero-1: #5f5f5f;
  --hero-2: #3f3f3f;
  --topbar-1: #595959;
  --topbar-2: #353535;
  --panel: rgba(255, 255, 255, 0.95);
  --card-bg-1: #ffffff;
  --card-bg-2: #f8f8f8;
  --card-border: #cecece;
}

body[data-theme="dark-rustic"] {
  --bg-top: #2c221c;
  --bg-bottom: #1a1411;
  --wood-1: #6f462b;
  --wood-2: #472b1a;
  --wood-3: #8d5a39;
  --felt-1: #315437;
  --felt-2: #203726;
  --hero-1: #4b3528;
  --hero-2: #2b1f19;
  --topbar-1: #433027;
  --topbar-2: #241a15;
  --panel: rgba(28, 24, 21, 0.9);
  --text: #f2e7db;
  --muted: #d0bda8;
  --line: rgba(255, 233, 205, 0.16);
  --line-strong: rgba(255, 233, 205, 0.28);
  --table-seat-bg: rgba(46, 37, 30, 0.92);
  --card-bg-1: #f8f1e7;
  --card-bg-2: #e7dccd;
  --card-border: #b79f86;
}

body[data-theme="papierkarten"] {
  --bg-top: #f7f0dd;
  --bg-bottom: #eadab8;
  --wood-1: #b6996b;
  --wood-2: #90724a;
  --wood-3: #ceb387;
  --felt-1: #6f8f70;
  --felt-2: #557257;
  --hero-1: #9d875f;
  --hero-2: #73603f;
  --topbar-1: #8c7852;
  --topbar-2: #67573b;
  --panel: rgba(255, 252, 242, 0.94);
  --card-bg-1: #fffdf4;
  --card-bg-2: #f5eedc;
  --card-border: #cdbb95;
}
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  font-family: "Bahnschrift", "Segoe UI Variable Display", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 20% 14%, rgba(255, 255, 255, 0.35), transparent 34%),
    radial-gradient(circle at 90% 2%, rgba(250, 205, 146, 0.35), transparent 28%),
    repeating-linear-gradient(45deg, rgba(111, 67, 31, 0.045) 0 8px, rgba(255, 255, 255, 0) 8px 16px),
    linear-gradient(155deg, var(--bg-top), var(--bg-bottom));
  min-height: 100vh;
}

body[data-color-mode="dark"] {
  --bg-top: #151a20;
  --bg-bottom: #0f1318;
  --hero-1: #2d3f57;
  --hero-2: #1a2738;
  --topbar-1: #2c3b52;
  --topbar-2: #1b2636;
  --panel: rgba(20, 27, 36, 0.9);
  --panel-solid: #1a2430;
  --text: #e8edf3;
  --muted: #b6c1cf;
  --line: rgba(190, 208, 230, 0.2);
  --line-strong: rgba(190, 208, 230, 0.34);
  --toast-bg: rgba(21, 31, 44, 0.96);
  --toast-text: #ecf2f9;
  --table-seat-bg: rgba(30, 41, 54, 0.92);
  --card-bg-1: #f6f8fb;
  --card-bg-2: #e6ebf2;
  --card-border: #b7c4d6;
  --card-overlay: rgba(0, 0, 0, 0.08);
}

body[data-color-mode="dark"] input,
body[data-color-mode="dark"] select,
body[data-color-mode="dark"] .auth-box,
body[data-color-mode="dark"] .active-room-card,
body[data-color-mode="dark"] .score-box,
body[data-color-mode="dark"] .stats-card,
body[data-color-mode="dark"] .history-card,
body[data-color-mode="dark"] .chat-panel,
body[data-color-mode="dark"] .chat-messages,
body[data-color-mode="dark"] .modal-card,
body[data-color-mode="dark"] .wiis-option {
  background: rgba(30, 41, 54, 0.94);
  color: #e8edf3;
}

body[data-color-mode="dark"] .room-phase,
body[data-color-mode="dark"] .room-phase.playing,
body[data-color-mode="dark"] .tab-btn.active,
body[data-color-mode="dark"] .theme-chip.active,
body[data-color-mode="dark"] .wiis-option.selected {
  background: rgba(58, 82, 112, 0.45);
  color: #eef4fb;
  border-color: rgba(176, 197, 224, 0.45);
}

body[data-color-mode="dark"] .chat-name,
body[data-color-mode="dark"] .chat-line.system .chat-name,
body[data-color-mode="dark"] .chat-text,
body[data-color-mode="dark"] .table-seat-info,
body[data-color-mode="dark"] .room-empty,
body[data-color-mode="dark"] .active-room-meta,
body[data-color-mode="dark"] .info-box,
body[data-color-mode="dark"] .modal-note {
  color: #d3dfec;
}

.page {
  position: relative;
  width: min(1260px, 94vw);
  margin: 24px auto 40px;
  animation: pageEnter 420ms ease-out;
}

.page::before,
.page::after {
  content: "";
  position: absolute;
  top: 6px;
  bottom: 6px;
  width: 12px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--wood-3), var(--wood-1));
  opacity: 0.35;
  pointer-events: none;
}

.page::before {
  left: -16px;
}

.page::after {
  right: -16px;
}

@keyframes pageEnter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero {
  margin-bottom: 16px;
  padding: 14px 18px;
  border-radius: 16px;
  color: #f5f0e6;
  background:
    radial-gradient(circle at 10% -30%, rgba(255, 255, 255, 0.26), transparent 40%),
    linear-gradient(145deg, var(--hero-1), var(--hero-2));
  border: 1px solid rgba(255, 255, 255, 0.24);
  box-shadow: var(--shadow-soft);
}

.hero-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.hero-match-counter {
  display: inline-flex;
  align-items: flex-end;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(10, 21, 16, 0.22);
  line-height: 1;
  white-space: nowrap;
}

.hero-match-label {
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.9;
}

#globalMatchCount {
  font-size: clamp(1rem, 2.2vw, 1.4rem);
}

.hero h1 {
  margin: 0;
  font-size: clamp(2rem, 4.4vw, 3rem);
  letter-spacing: 0.02em;
}

.hero-subtitle {
  margin: 6px 0 0;
  color: #d9eadf;
  font-size: 0.98rem;
}

.suit-strip {
  margin-top: 8px;
  letter-spacing: 0.35em;
  color: #ffdfb6;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(5px);
}

.hidden {
  display: none !important;
}

h2,
h3 {
  margin: 0 0 10px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 0.92rem;
}

input,
button,
select {
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 9px 12px;
  font: inherit;
}

input,
select {
  background: #fff;
}

button {
  cursor: pointer;
  color: #113324;
  background: linear-gradient(180deg, #ffffff 0%, #e9f3ed 100%);
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(14, 48, 34, 0.16);
  background: linear-gradient(180deg, #ffffff 0%, #def0e6 100%);
}

button:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

button.danger {
  border-color: transparent;
  color: #fff;
  background: linear-gradient(180deg, var(--danger) 0%, var(--danger-dark) 100%);
}

button.danger:hover:not(:disabled) {
  background: linear-gradient(180deg, #d65252 0%, #932828 100%);
}

button.ghost {
  background: transparent;
  color: var(--text);
}

button.ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.4);
}

.topbar,
.screen-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.topbar {
  margin-bottom: 12px;
  color: #f0f7f3;
  background:
    radial-gradient(circle at 0% 0%, rgba(255, 255, 255, 0.18), transparent 45%),
    linear-gradient(155deg, var(--topbar-1), var(--topbar-2));
  border-color: rgba(255, 255, 255, 0.2);
}

.topbar .mono,
.topbar #userLabel {
  color: #f3f8f5;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 8px;
}

.style-picker {
  color: #e7f4ec;
  font-size: 0.85rem;
  gap: 4px;
}

.style-picker select {
  min-width: 156px;
  padding: 7px 10px;
}

#colorModeToggle.active {
  color: #eef4fb;
  border-color: rgba(176, 197, 224, 0.46);
  background: linear-gradient(180deg, #425b79 0%, #2f4158 100%);
}

.mono {
  font-family: "JetBrains Mono", "Consolas", monospace;
}

.auth-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.auth-box {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
}

.auth-message {
  min-height: 20px;
  color: #9a3030;
  margin: 6px 0 10px;
  font-weight: 700;
}

.auth-note,
.screen-note {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.92rem;
}

.screen {
  margin-top: 12px;
}

.top-gap {
  margin-top: 12px;
}

.active-rooms {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}

.active-room-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: linear-gradient(180deg, #fffef8 0%, #f9f4e8 100%);
  display: grid;
  gap: 8px;
  box-shadow: 0 8px 18px rgba(14, 47, 34, 0.1);
}

.active-room-card::before {
  content: "â™£";
  position: absolute;
  right: 10px;
  bottom: 6px;
  color: rgba(18, 51, 36, 0.2);
  font-size: 1rem;
}

.active-room-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.active-room-meta {
  color: #496055;
  font-size: 0.9rem;
}

.active-room-actions {
  display: flex;
  gap: 8px;
}

.active-room-actions button {
  flex: 1 1 auto;
}

.room-phase {
  border: 1px solid #cadad1;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.76rem;
  background: #f5f8f6;
}

.room-phase.playing {
  border-color: #80bc9c;
  background: #e8f7ef;
}

.room-empty {
  color: #55685e;
  font-size: 0.92rem;
}

.score-board {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.score-box {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: linear-gradient(180deg, #ffffff 0%, #f2f8f4 100%);
}

.info-box {
  min-height: 24px;
  color: #2b473a;
  margin-bottom: 10px;
  font-weight: 600;
}

.mode-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.table-stage {
  display: grid;
  gap: 12px;
  padding: 10px;
  border-radius: 22px;
  background: linear-gradient(150deg, var(--wood-3) 0%, var(--wood-1) 45%, var(--wood-2) 100%);
  box-shadow: var(--shadow-strong);
}

.table-felt {
  position: relative;
  min-height: 420px;
  border-radius: 18px;
  border: 1px solid #1a6846;
  background:
    radial-gradient(circle at 50% 42%, rgba(111, 211, 160, 0.28) 0%, rgba(22, 97, 62, 0.94) 68%),
    linear-gradient(150deg, var(--felt-1) 0%, var(--felt-2) 100%);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.08), inset 0 0 42px rgba(8, 29, 20, 0.38);
  overflow: hidden;
}

.table-spectator-count {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 5;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 999px;
  padding: 4px 10px;
  background: rgba(9, 26, 18, 0.56);
  color: #f2fbf6;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.table-felt::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.022) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.03) 0 1px, transparent 1px 5px);
  opacity: 0.55;
  pointer-events: none;
}

.table-felt::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: radial-gradient(circle at 50% 50%, transparent 36%, rgba(0, 0, 0, 0.22) 100%);
  pointer-events: none;
}

.table-seats,
.trick-layer,
.trick-flash {
  position: absolute;
  inset: 0;
}

.table-seats {
  z-index: 2;
}

.trick-layer {
  z-index: 3;
}

.trick-flash {
  z-index: 4;
}

.table-seat {
  position: absolute;
  transform: translate(-50%, -50%);
  min-width: 130px;
  background: var(--table-seat-bg);
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 11px;
  padding: 7px 10px;
  text-align: center;
  box-shadow: 0 6px 14px rgba(5, 19, 12, 0.22);
}

.table-seat.top {
  top: 14%;
  left: 50%;
}

.table-seat.right {
  top: 50%;
  left: 88%;
}

.table-seat.bottom {
  top: 86%;
  left: 50%;
}

.table-seat.left {
  top: 50%;
  left: 12%;
}

.table-seat.self {
  border-color: #7ec29e;
}

.table-seat.turn {
  box-shadow: 0 0 0 3px rgba(255, 226, 145, 0.58), 0 6px 14px rgba(5, 19, 12, 0.22);
}

.table-seat-name {
  font-size: 0.84rem;
  font-weight: 700;
}

.table-seat-info {
  font-size: 0.72rem;
  color: #4f665a;
}

.trick-empty {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #deefe4;
  font-size: 0.94rem;
}

.trick-slot,
.flash-slot {
  position: absolute;
  transform: translate(-50%, -50%);
  display: grid;
  justify-items: center;
  gap: 4px;
}

.trick-slot.top,
.flash-slot.top {
  top: 33%;
  left: 50%;
}

.trick-slot.right,
.flash-slot.right {
  top: 50%;
  left: 64%;
}

.trick-slot.bottom,
.flash-slot.bottom {
  top: 67%;
  left: 50%;
}

.trick-slot.left,
.flash-slot.left {
  top: 50%;
  left: 36%;
}

.trick-owner {
  color: #e8f5ec;
  font-size: 0.72rem;
  font-weight: 700;
}

.trick-flash {
  pointer-events: none;
  animation: flashFadeIn 120ms ease-out;
}

@keyframes flashFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.hand-dock {
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 14px;
  padding: 10px;
  background: linear-gradient(180deg, rgba(22, 78, 54, 0.9) 0%, rgba(17, 63, 43, 0.9) 100%);
}

.hand-title {
  margin: 0 0 8px;
  color: #e6f3ea;
}

.hand-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
}

.hand-card-button {
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  animation: cardRise 240ms ease-out both;
}

.hand-card-button:hover:not(:disabled) {
  transform: translateY(-6px);
}

@keyframes cardRise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fr-card {
  width: 74px;
  height: 106px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: linear-gradient(165deg, var(--card-bg-1) 0%, var(--card-bg-2) 100%);
  box-shadow: 0 6px 14px rgba(10, 25, 15, 0.22);
  position: relative;
  display: block;
  overflow: hidden;
}

.fr-card::after {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 8px;
  border: 1px solid var(--card-overlay);
  pointer-events: none;
}

.fr-card.small {
  width: 58px;
  height: 84px;
}

.fr-card.legal {
  border-color: var(--card-border);
  box-shadow: 0 8px 16px rgba(10, 25, 15, 0.22);
}

.fr-card.red {
  color: #cb202f;
}

.fr-card.black {
  color: #121820;
}

.fr-card.blocked {
  filter: grayscale(0.35) brightness(0.84);
}

.fr-card.blocked::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(120, 130, 138, 0.28);
  z-index: 3;
  pointer-events: none;
}

.hand-card-button:disabled {
  opacity: 1;
}

.corner {
  position: absolute;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  z-index: 2;
}

.corner.top {
  top: 6px;
  left: 6px;
}

.corner.bottom {
  bottom: 6px;
  right: 6px;
  transform: rotate(180deg);
}

.card-center {
  position: absolute;
  inset: 3px;
  display: grid;
  place-items: center;
}

.original-card-art {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-family: "Segoe UI Symbol", "Noto Sans Symbols2", "Arial Unicode MS", serif;
  font-size: 2.6rem;
  line-height: 1;
  text-rendering: geometricPrecision;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.12));
  user-select: none;
}

.original-card-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: auto;
  border-radius: 3px;
}

.original-card-art.fallback-glyph {
  font-size: 2.6rem;
}

.fr-card.small .original-card-art {
  font-size: 2.02rem;
}

.fr-card.small .original-card-art.fallback-glyph {
  font-size: 2.02rem;
}

.pip-grid {
  position: relative;
  width: 100%;
  height: 100%;
}

.pip {
  position: absolute;
  left: var(--x);
  top: var(--y);
  transform: translate(-50%, -50%);
}

.pip.flip {
  transform: translate(-50%, -50%) rotate(180deg);
}

.figure-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.figure-frame {
  width: 42px;
  height: 64px;
  border-radius: 8px;
  border: 1px solid rgba(12, 25, 18, 0.25);
  background: linear-gradient(180deg, #ffffff 0%, #edf0ee 100%);
  display: grid;
  grid-template-rows: 1fr auto 1fr;
  align-items: center;
  justify-items: center;
  padding: 2px 0;
  overflow: hidden;
}

.figure-half {
  width: 100%;
  display: grid;
  justify-items: center;
  gap: 1px;
}

.figure-half.mirrored {
  transform: rotate(180deg);
}

.figure-cap {
  font-size: 0.48rem;
  line-height: 1;
}

.figure-head {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #f6d9b9;
  border: 1px solid rgba(0, 0, 0, 0.2);
}

.figure-body {
  width: 24px;
  height: 12px;
  border-radius: 4px;
  position: relative;
  background: linear-gradient(120deg, #2b6ec9 0%, #c92535 100%);
  border: 1px solid rgba(0, 0, 0, 0.16);
}

.figure-sash {
  position: absolute;
  inset: 0;
  background: linear-gradient(140deg, transparent 37%, #f9cf59 37% 49%, transparent 49% 58%, #f9cf59 58% 69%, transparent 69%);
}

.figure-emblem {
  position: absolute;
  right: -3px;
  bottom: -3px;
  background: #fff;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.16);
  width: 10px;
  height: 10px;
}

.figure-emblem .suit-icon {
  width: 100%;
  height: 100%;
}

.figure-mid-rank {
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
}

.figure-frame.rank-j .figure-body {
  background: linear-gradient(120deg, #266dbf 0%, #de4f39 100%);
}

.figure-frame.rank-q .figure-body {
  background: linear-gradient(120deg, #328850 0%, #d53b4a 100%);
}

.figure-frame.rank-k .figure-body {
  background: linear-gradient(120deg, #2f58b0 0%, #c63c2f 100%);
}

.suit-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.suit-icon.tiny {
  width: 9px;
  height: 9px;
}

.suit-icon.mid {
  width: 13px;
  height: 13px;
}

.suit-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.suit-icon.red {
  color: #cb202f;
}

.suit-icon.black {
  color: #121820;
}

.app-toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  max-width: min(380px, 88vw);
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--toast-text);
  background: var(--toast-bg);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: var(--shadow-soft);
  z-index: 50;
  animation: toastIn 180ms ease-out;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.table-stage:fullscreen {
  width: 100%;
  height: 100%;
  padding: 14px;
  background: linear-gradient(150deg, var(--wood-3) 0%, var(--wood-1) 45%, var(--wood-2) 100%);
  grid-template-rows: minmax(0, 1fr) auto;
}

.table-stage:fullscreen .table-felt {
  min-height: min(72vh, 760px);
}

.table-stage:fullscreen .hand-dock {
  align-self: end;
}

@media (max-width: 900px) {
  .page::before,
  .page::after {
    display: none;
  }

  .table-seat.right {
    left: 84%;
  }

  .table-seat.left {
    left: 16%;
  }
}


.table-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 12px;
}

.table-settings {
  display: flex;
  justify-content: flex-end;
}

.table-settings label {
  min-width: 170px;
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(200px, 1fr) auto;
  gap: 10px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(247, 251, 248, 0.96));
  box-shadow: var(--shadow-soft);
  min-height: 0;
}

.chat-panel h3 {
  margin: 0;
}

.chat-messages {
  min-height: 240px;
  max-height: 560px;
  overflow: auto;
  padding: 6px 8px;
  font-size: 0.93rem;
  line-height: 1.45;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.82);
}

.chat-empty {
  color: #5d6e65;
  font-size: 0.92rem;
}

.chat-line {
  padding: 2px 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-name {
  font-weight: 700;
  color: #244536;
}

.chat-line.system .chat-name {
  color: #4f5e57;
}

.chat-text {
  color: #1f3328;
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.chat-form input {
  min-width: 0;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(9, 26, 18, 0.56);
}

.modal-card {
  width: min(700px, 94vw);
  max-height: min(86vh, 780px);
  overflow: auto;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #ffffff;
  box-shadow: var(--shadow-strong);
  padding: 14px;
  display: grid;
  gap: 10px;
}

.modal-card h3 {
  margin: 0;
}

.modal-note {
  margin: 0;
  color: #3f564b;
}

.wiis-options {
  display: grid;
  gap: 8px;
}

.wiis-option {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fcfa;
  display: grid;
  gap: 8px;
  text-align: left;
}

.wiis-option.selected {
  border-color: #55967a;
  box-shadow: inset 0 0 0 1px rgba(65, 135, 104, 0.26);
  background: #ecf8f1;
}

.wiis-option-title {
  font-weight: 700;
}

.wiis-option-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}


@media (max-width: 760px) {
  .table-layout {
    grid-template-columns: 1fr;
  }

  .chat-messages {
    max-height: 300px;
  }
}




.app-tabs {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
}

.tab-btn {
  border-radius: 999px;
  padding: 8px 14px;
}

.tab-btn.active {
  background: linear-gradient(180deg, #fefcf5 0%, #e7f4ec 100%);
  border-color: var(--line-strong);
  box-shadow: inset 0 0 0 1px rgba(34, 81, 58, 0.16);
}

.dashboard-stats {
  display: grid;
  gap: 10px;
}

.dashboard-stats-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.stats-list-card {
  grid-column: span 2;
}

.stats-list {
  margin-top: 8px;
  display: grid;
  gap: 6px;
}

.stats-list-item {
  font-size: 0.88rem;
  line-height: 1.35;
  color: var(--text);
}
.stats-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.stats-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: linear-gradient(180deg, #ffffff 0%, #f6f9f7 100%);
  box-shadow: 0 8px 16px rgba(11, 31, 21, 0.08);
}

.stats-title {
  color: var(--muted);
  font-size: 0.88rem;
}

.stats-value {
  margin-top: 4px;
  display: block;
  font-size: 1.16rem;
}

.match-history {
  display: grid;
  gap: 10px;
}

.history-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.88);
  padding: 11px;
  display: grid;
  gap: 7px;
}

.history-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.92rem;
}

.history-summary {
  color: var(--muted);
  font-size: 0.88rem;
}

.history-rounds {
  display: grid;
  gap: 4px;
}

.history-round-line {
  font-size: 0.87rem;
  line-height: 1.35;
}

.settings-form {
  display: grid;
  gap: 10px;
  max-width: 380px;
}

.theme-quick-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.theme-chip {
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.9rem;
}

.theme-chip.active {
  background: linear-gradient(180deg, #fffef5 0%, #e8f5ee 100%);
  border-color: var(--line-strong);
  box-shadow: inset 0 0 0 1px rgba(35, 84, 61, 0.18);
}

body[data-theme="dark-rustic"] input,
body[data-theme="dark-rustic"] select,
body[data-theme="dark-rustic"] .history-card,
body[data-theme="dark-rustic"] .stats-card,
body[data-theme="dark-rustic"] .chat-panel,
body[data-theme="dark-rustic"] .modal-card {
  color: #1f1915;
}

@media (max-width: 760px) {
  .hero-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .hero-match-counter {
    align-self: flex-start;
  }
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar {
    width: 100%;
    justify-content: flex-start;
  }

  .app-tabs {
    justify-content: center;
  }

  .tab-btn {
    flex: 1 1 calc(50% - 8px);
    text-align: center;
  }

  .screen-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .screen-header .toolbar {
    width: 100%;
  }

  .table-felt {
    min-height: 360px;
  }

  .chat-panel {
    min-height: 260px;
  }
}

@media (max-width: 760px) and (orientation: portrait) {
  .page {
    width: min(98vw, 620px);
    margin-top: 12px;
  }

  .table-seat.top {
    top: 12%;
  }

  .table-seat.bottom {
    top: 88%;
  }

  .table-seat.left {
    left: 18%;
  }

  .table-seat.right {
    left: 82%;
  }

  .trick-slot.top,
  .flash-slot.top {
    top: 32%;
  }

  .trick-slot.bottom,
  .flash-slot.bottom {
    top: 68%;
  }

  .hand-dock {
    position: sticky;
    bottom: 0;
    z-index: 5;
  }

  .hand-grid {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .hand-card-button {
    flex: 0 0 auto;
  }
}








