.saphir-game {
  min-height: 100vh;
  color: var(--outpost-muted);
  background: #1b1f1e;
  --game-accent: #cbb895;
  --game-accent-ink: #221e16;
  --game-surface: #252925;
  --game-inset: #1a1e1c;
  --game-prop-width: 340px;
}

.saphir-game--scribble {
  --game-accent: #d4b794;
  --game-surface: #2a2824;
  --game-inset: #201e1b;
  --game-prop-width: 355px;
}

.saphir-game--schafkopf {
  --game-accent: #ddba82;
  --game-surface: #262a24;
  --game-inset: #1c211c;
  --game-prop-width: 300px;
}

.game-masthead {
  overflow: hidden;
  border-bottom: 1px solid var(--outpost-line);
  background: #272a26;
  background-image: linear-gradient(100deg, #252925 0 35%, #25292599 64%, #242723e8),
    url("assets/world/images/lake.png");
  background-size: cover;
  background-position: center 49%;
}

.saphir-game--scribble .game-masthead {
  background-color: #302a24;
  background-image: linear-gradient(100deg, #2c2924 0 35%, #3b3028a8 76%, #2c2924eb),
    url("assets/world/images/lake.png");
}

.game-masthead-inner {
  display: grid;
  grid-template-columns: 1fr minmax(180px, 34%);
  min-height: 245px;
  align-items: center;
  gap: 10px;
  width: min(calc(100% - 2 * var(--outpost-gutter)), var(--outpost-width));
  margin-inline: auto;
}

.game-intro { position: relative; z-index: 1; padding-block: 30px; }
.saphir-game .game-masthead h1 {
  margin: 0;
  color: var(--outpost-text);
  font-family: var(--font-body);
  font-size: clamp(2.3rem, 5.1vw, 4.75rem);
  font-weight: 630;
  letter-spacing: -0.065em;
  line-height: 1.02;
}

.game-subtitle {
  max-width: 47ch;
  margin: 12px 0 0;
  color: #d2d4ca;
  font-size: clamp(0.9rem, 1.45vw, 1.05rem);
  line-height: 1.5;
}

.game-prop {
  width: min(100%, var(--game-prop-width));
  height: 228px;
  justify-self: center;
  object-fit: contain;
  margin-block: 8px;
  filter: drop-shadow(2px 14px 12px #0c0d0bb0);
  user-select: none;
  pointer-events: none;
}

.saphir-game--schafkopf .game-prop { height: 213px; }
.saphir-game--stadt .game-prop { height: 215px; }

.saphir-game .connection-status {
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  min-height: 0;
  margin: 20px 0 0;
  padding: 0;
  border: 0;
  color: var(--outpost-muted);
  font-size: 0.78rem;
  line-height: 1.3;
}

.connection-status::before {
  flex: 0 0 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--game-accent);
  content: "";
}

.saphir-game .connection-status.connected { color: #c0ccbd; }
.connection-status.connected::before { background: #a0bd93; }
.saphir-game .connection-status.disconnected { color: #f1b0a8; }
.connection-status.disconnected::before { background: #dd9285; }

.game-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 24px;
  width: min(calc(100% - 2 * var(--outpost-gutter)), var(--outpost-width));
  margin: 0 auto 24px;
  border-bottom: 1px solid var(--outpost-line);
}

.game-switch a {
  display: flex;
  align-items: center;
  min-height: 45px;
  padding: 0 2px;
  border-bottom: 2px solid transparent;
  color: var(--outpost-muted);
  font-size: .89rem;
  text-decoration: none;
  transition: color 160ms, border-color 160ms;
}

.game-switch a:hover { color: var(--outpost-text); border-color: #ffffff40; }
.game-switch a[aria-current="page"] { color: var(--outpost-text); border-color: var(--game-accent); }

.saphir-game :is(.game-main, .scribble-main, .schafkopf-main) {
  width: min(calc(100% - 2 * var(--outpost-gutter)), var(--outpost-width));
  margin-inline: auto;
  padding-bottom: 44px;
  opacity: 1;
  transform: none;
  animation: none;
}

.saphir-game :is(.game-dashboard, .scribble-dashboard, .schafkopf-dashboard) {
  grid-template-columns: minmax(0, 1.12fr) minmax(0, .88fr);
  align-items: start;
  gap: 18px;
}

.saphir-game :is(.game-dashboard, .scribble-dashboard, .schafkopf-dashboard) > .panel {
  padding: clamp(18px, 2.5vw, 33px);
}

.saphir-game :is(.game-dashboard, .scribble-dashboard, .schafkopf-dashboard) > form {
  border-top: 2px solid var(--game-accent);
}

.saphir-game :is(.game-dashboard, .scribble-dashboard, .schafkopf-dashboard) > section {
  background: #202420;
}

.saphir-game :is(.panel, .round-status, .letter-reveal, .waiting-panel, .scribble-status,
  .word-choice, .scribble-scoreboard, .chat-panel, .canvas-panel, .table-status, .score-panel,
  .history-panel, .play-area, .finish-view, .round-result-card) {
  border: 1px solid var(--outpost-line);
  border-radius: 4px;
  background: var(--game-surface);
  box-shadow: none;
  backdrop-filter: none;
}

.saphir-game .card-number {
  margin: 0 0 4px;
  color: var(--outpost-muted);
  font-size: 0.76rem;
  font-weight: 550;
  letter-spacing: 0;
  text-transform: none;
}

.saphir-game :is(.panel, .lobby-topbar, .scribble-status, .table-status, .round-status, .finish-view) :is(h2,h3) {
  color: var(--outpost-text);
  font-size: clamp(1.18rem, 2vw, 1.65rem);
  font-weight: 620;
  letter-spacing: -.03em;
  line-height: 1.25;
}

.saphir-game .panel-heading { margin-bottom: 12px; }
.saphir-game .panel-heading h2 { margin: 0; }
.saphir-game label { color: #daddd5; font-size: .88rem; }

.saphir-game :is(input:not([type="checkbox"], [type="color"]), textarea, select) {
  min-height: 43px;
  border: 1px solid #ffffff2e;
  border-radius: 3px;
  color: var(--outpost-text);
  background: var(--game-inset);
  box-shadow: none;
  transition: border-color 160ms, background-color 160ms;
}

.saphir-game :is(input,textarea)::placeholder { color: #9ca69c; }
.saphir-game :is(input:not([type="checkbox"], [type="color"]),textarea,select):focus {
  border-color: var(--game-accent);
  background: #ffffff0a;
  box-shadow: none;
}
.saphir-game input[type="checkbox"] { accent-color: var(--game-accent); }

.game-settings-extras { margin: 0 0 16px; border-block: 1px solid var(--outpost-line); }
.game-settings-extras summary {
  min-height: 42px;
  padding: 10px 0;
  color: var(--game-accent);
  cursor: pointer;
  font-size: .88rem;
}
.game-settings-extras[open] summary { margin-bottom: 8px; }

.saphir-game :is(.button, .icon-button, .info-button, .word-choice button, .drawing-tools .tool-button, .palette-tool) {
  border: 1px solid #ffffff44;
  border-radius: 3px;
  color: var(--outpost-text);
  background: #2f352e;
  box-shadow: none;
  transition: border-color 160ms, background-color 160ms;
}
.saphir-game :is(.button, .icon-button, .info-button, .word-choice button, .drawing-tools .tool-button, .palette-tool):hover {
  border-color: var(--game-accent);
  background: #3a4038;
}
.saphir-game .button { min-height: 44px; }
.saphir-game .button.primary-button {
  border-color: var(--game-accent);
  color: var(--game-accent-ink);
  background: var(--game-accent);
  font-weight: 650;
}
.saphir-game .button.primary-button:hover { border-color: #f0d3aa; background: #f0d3aa; }
.saphir-game .subtle-button { background: transparent; }
.saphir-game .join-code-button { min-height: 43px; }

.saphir-game #lobby-code,
.saphir-game #join-code-form input[name="roomId"] {
  font-size: 1.2rem;
  font-weight: 650;
  letter-spacing: .09em;
}

.saphir-game #lobby-code {
  margin-inline-start: .35em;
  color: var(--outpost-text);
}

.saphir-game .game-presence {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 15px;
  margin-bottom: 12px;
  border: 1px solid var(--outpost-line);
  border-radius: 6px;
  background: #282e28;
}

.saphir-game .game-presence[hidden] { display: none; }
.saphir-game .game-presence--quiet {
  justify-content: flex-end;
  margin-bottom: 8px;
  padding: 0;
  border: 0;
  background: transparent;
}
.game-presence-status { font-weight: 650; }
.game-presence-list { list-style: none; margin: 6px 0 0; padding: 0; color: var(--outpost-muted); }
.game-presence-list li,
.game-presence-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.game-presence-list time {
  min-width: 3ch;
  color: var(--game-accent);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.saphir-game .room-list { margin-top: 14px; }
.saphir-game .empty-state {
  display: grid;
  place-items: center;
  min-height: 106px;
  margin: 0;
  border: 1px dashed #ffffff30;
  border-radius: 3px;
  color: var(--outpost-muted);
  background: var(--game-inset);
  text-align: center;
}

.saphir-game :is(.room-item,.player-item,.score-item,.review-player,.finish-player,.round-result-player,.game-mode,.bot-info-panel,.mini-card,.finish-team),
.saphir-game :is(.wordlist-fieldset,.wordlist-option,.bot-area,.start-area,.answer-actions,.hand) {
  border-color: var(--outpost-line);
  border-radius: 3px;
  color: var(--outpost-text);
  background: var(--game-inset);
  box-shadow: none;
}
.saphir-game :is(.room-item,.wordlist-option):hover,
.saphir-game .wordlist-option:has(input:checked) { border-color: var(--game-accent); background: #ffffff0a; }
.saphir-game :is(.host-badge,.turn-badge,.bot-badge,.guessed-badge,.mark-badge) {
  border-color: #ffffff4d;
  color: var(--game-accent);
  text-transform: none;
}
.saphir-game :is(.timer,.scribble-timer) {
  border: 1px solid #ffffff4d;
  border-radius: 3px;
  color: var(--outpost-text);
  background: var(--game-inset);
  font-variant-numeric: tabular-nums;
  box-shadow: none;
}
.saphir-game .timer.urgent { border-color: #e9a08d; color: #ffd3c5; }
.saphir-game .toast {
  z-index: 105;
  border-color: var(--game-accent);
  border-radius: 3px;
  color: var(--outpost-text);
  background: var(--game-inset);
  box-shadow: 0 5px 20px #0007;
}
.saphir-game .round-result { background: #0d0f0ed6; }

.saphir-game--scribble .canvas-panel { padding: 8px; background: #332c25; }
.saphir-game #drawing-canvas { border: 1px solid #0009; border-radius: 1px; }
.saphir-game .drawing-tools { padding: 3px; }
.saphir-game .drawing-tools .color-tool { border-color: #ffffff36; box-shadow: none; }
.saphir-game .drawing-tools .color-tool.active { outline: 2px solid var(--game-accent); outline-offset: 1px; }
.saphir-game .drawing-tools .tool-button.active { border-color: var(--game-accent); background: #493e2f; }
.saphir-game .score-player,
.saphir-game .chat-message,
.saphir-game #chat-form { border-color: var(--outpost-line); }
.saphir-game .score-player.drawer { background: #e3b87f14; }
.saphir-game .chat-message { color: #c3c2b7; }
.saphir-game .chat-message.success { color: #aed3a0; text-shadow: none; }
.saphir-game #chat-form button { color: var(--game-accent); background: #322b23; }
.saphir-game :is(.tool-button,.palette-tool)::after { border-color: var(--outpost-line); background: #211e1a; }

.saphir-game--stadt .letter-orbit {
  width: clamp(110px, 24vw, 156px);
  height: clamp(110px, 24vw, 156px);
  border: 1px solid #ae8d66;
  border-radius: 9px;
  background: #544432;
  box-shadow: inset 0 2px #dec09b35, 0 8px 0 #211911, 0 20px 36px #18151099;
  animation: letter-tile-wait 600ms ease-in-out infinite alternate;
}
.saphir-game--stadt .letter-reveal.revealed .letter-orbit { animation: letter-tile-land 460ms ease-out both; }

@keyframes letter-tile-wait {
  from { transform: translateY(0) rotate(-2deg); }
  to { transform: translateY(-4px) rotate(2deg); }
}

@keyframes letter-tile-land {
  from { opacity: .45; transform: translateY(-20px) rotate(-10deg) scale(.94); }
  75% { opacity: 1; transform: translateY(3px) rotate(1deg); }
  to { opacity: 1; transform: translateY(0) rotate(0); }
}
.saphir-game--stadt .letter-orbit span {
  color: #f2e4cb;
  font: 650 clamp(3rem, 10vw, 5.6rem)/1 Georgia, serif;
  text-shadow: 0 2px #392e22;
}
.saphir-game--stadt .letter-reveal { min-height: 300px; }
.saphir-game--stadt .letter-reveal p { letter-spacing: normal; text-transform: none; }
.saphir-game--stadt .round-status { padding: 12px 16px; }
.saphir-game--stadt .waiting-pulse { border-color: var(--game-accent); box-shadow: none; }
.saphir-game--stadt .answer-grid {
  gap: 0;
  border: 1px solid #b9b09a;
  border-radius: 4px;
  overflow: hidden;
  background: #e6dfcb;
}
.saphir-game--stadt .answer-card {
  padding: clamp(10px, 2vw, 22px);
  border: 0;
  border-bottom: 1px solid #7e715a55;
  border-radius: 0;
  background: transparent;
}
.saphir-game--stadt .answer-card span { color: #473d32; font-size: .82rem; letter-spacing: 0; text-transform: none; }
.saphir-game--stadt .answer-card input {
  border: 0;
  border-bottom: 1px solid #82735d;
  border-radius: 0;
  color: #282219;
  background: transparent;
  box-shadow: none;
}
.saphir-game--stadt .answer-card input:focus { border-color: #5a4124; background: #faf2dc; }
.saphir-game--stadt .answer-card input::placeholder { color: #726654; }

.saphir-game--schafkopf .play-area {
  min-height: 635px;
  padding: clamp(18px, 3.1vw, 42px);
  border: 2px solid #5a4b39;
  background: radial-gradient(ellipse at 50% 32%, #394438, #232d24 68%, #1c2520);
  box-shadow: inset 0 0 0 6px #322920, inset 0 0 0 7px #664f39, 0 12px 34px #171916;
}
.saphir-game--schafkopf .play-area::before { border-color: #b7b89b26; box-shadow: none; }
.saphir-game--schafkopf .opponent {
  border-color: #d4d1bb39;
  color: #e3e1d4;
  background: #212823;
  box-shadow: 0 4px 12px #171a1690;
}
.saphir-game--schafkopf .opponent:is(:hover,:focus-visible) { border-color: var(--game-accent); box-shadow: none; }
.saphir-game--schafkopf :is(.self-label,.table-zone-label) { color: #ddd9c3; text-shadow: none; }
.saphir-game--schafkopf .call-panel { border-color: #c8a87587; background: #252a23; box-shadow: 0 10px 28px #171b16; }
.saphir-game--schafkopf .opponent-card-back {
  border-color: #b6a180;
  background-image:
    repeating-linear-gradient(45deg, transparent 0 3px, #b6a18066 3px 4px),
    repeating-linear-gradient(-45deg, #563b32 0 3px, #b6a18066 3px 4px);
}
.saphir-game--schafkopf .trick-card-slot { border-color: #e0d6b538; background: #171e1760; }
.saphir-game--schafkopf :is(.hand-hint, .trick-card-slot .played-by, .history-panel #last-trick) { color: #c9c4af; }
.saphir-game--schafkopf .hand {
  display: grid;
  min-height: 0;
  grid-template-columns: repeat(8,minmax(0,1fr));
  align-items: end;
  justify-items: center;
  gap: clamp(4px, .7vw, 10px);
  padding: 16px 9px 9px;
  border-color: #d9ceb64f;
  background: #17201955;
  overflow: visible;
}
.saphir-game--schafkopf .hand :is(.sk-card,.playing-card) {
  width: 100%;
  min-width: 0;
  max-width: 104px;
  height: auto;
  aspect-ratio: 7 / 10;
  padding: clamp(3px, .7vw, 7px);
}
.saphir-game--schafkopf .sk-card {
  border-color: #9e8b69;
  color: #27251e;
  background: linear-gradient(145deg, #fff8e9, #e1d3b8);
}
.saphir-game--schafkopf .hand .sk-card .suit-mark {
  width: clamp(26px, 4vw, 47px);
  height: clamp(29px, 4.5vw, 52px);
  font-size: clamp(1rem, 2vw, 1.8rem);
}
.saphir-game--schafkopf .sk-card .card-name { color: #453d2e; }
.saphir-game--schafkopf .sk-card .trump-label { color: #37271b; background: #d4b488; }
.saphir-game--schafkopf .suit-eichel .suit-mark { color: #4d4638; background: #d3c5aa; }
.saphir-game--schafkopf .suit-gras .suit-mark { color: #29452f; background: #bfd0b3; }
.saphir-game--schafkopf .suit-herz .suit-mark { color: #6b2832; background: #e1b9b4; }
.saphir-game--schafkopf .suit-schellen .suit-mark { color: #62461a; background: #e6ca8e; }
.saphir-game--schafkopf .sk-card.playable { box-shadow: 0 0 0 2px #d7b77c, 0 8px 15px #130e0a8c; }
.saphir-game--schafkopf .sk-card.playable:focus-visible { outline: 2px solid #ffe0a6; outline-offset: 3px; }

.saphir-game:not(:has(#dashboard:not(.hidden))) .game-masthead-inner { min-height: 110px; }
.saphir-game:not(:has(#dashboard:not(.hidden))) .game-intro { padding-block: 18px; }
.saphir-game:not(:has(#dashboard:not(.hidden))) .game-masthead h1 { font-size: clamp(1.55rem, 4vw, 2.35rem); }
.saphir-game:not(:has(#dashboard:not(.hidden))) .game-subtitle { display: none; }
.saphir-game:not(:has(#dashboard:not(.hidden))) .connection-status { margin-top: 8px; }
.saphir-game:not(:has(#dashboard:not(.hidden))) .game-prop { height: 80px; }
.saphir-game:not(:has(#dashboard:not(.hidden))) .game-switch { display: none; }
.saphir-game:not(:has(#dashboard:not(.hidden))) :is(.game-main,.scribble-main,.schafkopf-main) { padding-top: 20px; }

@media (max-width: 760px) {
  .saphir-game :is(.game-dashboard,.scribble-dashboard,.schafkopf-dashboard) { grid-template-columns: minmax(0,1fr); }
  .game-masthead-inner { grid-template-columns: minmax(0,1fr) minmax(86px,34%); min-height: 174px; }
  .game-intro { padding-block: 20px; }
  .game-prop,
  .saphir-game--schafkopf .game-prop,
  .saphir-game--stadt .game-prop { height: clamp(102px, 26vw, 188px); }
  .game-switch { gap: 4px 18px; margin-bottom: 15px; }
  .game-switch a { font-size: .82rem; }
  .saphir-game--schafkopf .play-area { min-height: 0; padding: 15px; }
  .saphir-game--schafkopf .hand { grid-template-columns: repeat(4,minmax(0,1fr)); gap: 8px; }
  .saphir-game--schafkopf .hand .sk-card .card-name { font-size: .54rem; }
}

@media (max-width: 420px) {
  .game-masthead-inner { min-height: 164px; grid-template-columns: minmax(0,1fr) minmax(78px,32%); }
  .saphir-game .game-masthead h1 { font-size: clamp(1.8rem, 8.4vw, 2.2rem); letter-spacing: -.05em; }
  .game-subtitle { margin-block-start: 7px; font-size: .82rem; }
  .saphir-game .connection-status { margin-block-start: 12px; }
  .saphir-game .answer-grid { grid-template-columns: 1fr; }
  .saphir-game--schafkopf .play-area { padding: 11px; }
  .saphir-game--schafkopf .hand { gap: 5px; padding-inline: 5px; }
  .saphir-game--schafkopf .hand .sk-card .corner { top: 4px; left: 4px; font-size: .69rem; }
  .saphir-game--schafkopf .hand .sk-card .corner.bottom { inset: auto 4px 4px auto; }
  .saphir-game--schafkopf .hand .sk-card .trump-label { top: 4px; right: 4px; font-size: .48rem; }
  .saphir-game--schafkopf .hand .sk-card .card-name { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .saphir-game *, .saphir-game *::before, .saphir-game *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
