/* ─── Klaverjassen Web — felt-table theme ─────────────────────────────── */

:root {
    --felt:       #2e7d32;
    --table-bg:   #1a3a1a;
    --win-bg:     #0d2d0d;
    --card-face:  #fffef0;
    --card-back:  #1a5276;
    --red-suit:   #cc0000;
    --black-suit: #111111;
    --accent:     #f1c40f;
    --green-txt:  #2ecc71;
    --red-txt:    #e74c3c;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background: var(--table-bg);
    color: #cccccc;
    font-family: 'Segoe UI', Helvetica, Arial, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.noscript-warning {
    background: #9a2a2a;
    color: #fff;
    text-align: center;
    padding: 8px 12px;
}

/* ─── Score panel ─────────────────────────────────────────────────────── */

#score-panel {
    background: var(--win-bg);
    width: 100%;
    max-width: 900px;
    padding: 8px 16px;
    border-radius: 0 0 8px 8px;
}

.score-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.score-team0 { color: var(--green-txt); font-weight: bold; font-size: 14px; }
.score-team1 { color: var(--red-txt);   font-weight: bold; font-size: 14px; }
#trump-label { color: var(--accent); font-weight: bold; font-size: 15px; display: flex; align-items: center; gap: 6px; }
.trump-suit {
    font-size: 28px;
    line-height: 1;
    filter: drop-shadow(0 0 4px currentColor);
}
.trump-suit.trump-red { color: var(--red-suit); }
.trump-suit.trump-black { color: var(--card-face); }

.score-buttons { display: flex; gap: 6px; }

.btn {
    padding: 4px 12px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    color: white;
}
.btn-new    { background: #555; }
.btn-hist   { background: #1a4a6a; }
.btn-hands  { background: #4a1a6a; }
.btn-leave  { background: #6a1a1a; }
.btn-new:hover   { background: #777; }
.btn-hist:hover  { background: #2a6a9a; }
.btn-hands:hover { background: #6a3a8a; }
.btn-leave:hover { background: #9a2a2a; }
#new-game-btn { display: none; }
#leave-game-btn { display: none; }

.btn-leave-confirm {
    background: #9a2a2a;
    color: white;
    font-size: 14px;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}
.btn-leave-confirm:hover { background: #c0392b; }

.score-bottom {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
    font-size: 12px;
}
.round-team0 { color: #aaddaa; }
.round-team1 { color: #ddaaaa; }

/* ─── Table layout ────────────────────────────────────────────────────── */

#table {
    width: 100%;
    max-width: 900px;
    display: grid;
    grid-template-areas:
        ".      north  ."
        "west   trick  east"
        "trump  south  .";
    grid-template-columns: 1fr 2fr 1fr;
    grid-template-rows: auto 1fr auto;
    gap: 4px;
    padding: 8px;
    min-height: 420px;
}

#trump-card-indicator {
    grid-area: trump;
    display: none;
    justify-content: center;
    align-items: flex-end;
    padding: 4px;
}
#trump-card-indicator.active { display: flex; }
#trump-card-indicator .card {
    width: 52px;
    height: 68px;
    background: var(--card-face);
    border: 2px solid #888;
    box-shadow: 1px 2px 4px rgba(0,0,0,0.3);
    font-size: 24px;
}
#trump-card-indicator .card.red { color: var(--red-suit); }
#trump-card-indicator .card:not(.red) { color: var(--black-suit); }

.seat { display: flex; flex-direction: column; align-items: center; padding: 4px; }
.seat-label { color: #aaa; font-size: 12px; margin-bottom: 4px; transition: all 0.3s; }
.seat-label.declaring {
    color: var(--accent);
    font-weight: bold;
    text-shadow: 0 0 6px var(--accent);
}

/* Bid result badges */
.bid-badge {
    display: inline-block;
    font-size: 25px;
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 4px;
    margin-left: 6px;
    vertical-align: middle;
    animation: bidBadgeFade 2.5s ease forwards;
}
.bid-badge.bid-declared { background: var(--felt); color: #fff; border: 1px solid var(--green-txt); }
.bid-badge.bid-passed   { background: #333; color: #aaa; border: 1px solid #555; }
@keyframes bidBadgeFade {
    0%   { opacity: 1; }
    60%  { opacity: 1; }
    100% { opacity: 0; }
}

#north-seat { grid-area: north; }
#west-seat  { grid-area: west; }
#east-seat  { grid-area: east; }
#south-seat { grid-area: south; }

/* ─── Trick area ──────────────────────────────────────────────────────── */

#trick-area {
    grid-area: trick;
    display: grid;
    position: relative;
    grid-template-areas:
        ".  n  ."
        "w  .  e"
        ".  s  .";
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
    background: var(--felt);
    border: 4px groove #3a8a3a;
    border-radius: 8px;
    padding: 8px;
    min-height: 200px;
    place-items: center;
}

.trick-slot {
    width: 60px;
    height: 72px;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
}
.trick-slot.empty {
    background: transparent;
}
.trick-slot.filled {
    background: var(--card-face);
    border: 2px solid #888;
    box-shadow: 1px 2px 4px rgba(0,0,0,0.3);
}

#trick-n { grid-area: n; }
#trick-w { grid-area: w; }
#trick-e { grid-area: e; }
#trick-s { grid-area: s; }

/* Turn arrow — centered over the felt, pointing toward the active player */
#trick-center {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 1;
}
#trick-arrow {
    font-size: 32px;
    color: var(--accent);
    display: none;
    filter: drop-shadow(0 0 6px var(--accent));
    transition: transform 0.2s ease;
}
#trick-arrow.visible { display: block; animation: arrowPulse 1.2s ease-in-out infinite; }
#trick-arrow.dir-n { transform: rotate(0deg); }
#trick-arrow.dir-w { transform: rotate(270deg); }
#trick-arrow.dir-s { transform: rotate(180deg); }
#trick-arrow.dir-e { transform: rotate(90deg); }
@keyframes arrowPulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.35; }
}

/* Card play animations */
@keyframes cardFromSouth { from { transform: translateY(52px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes cardFromNorth { from { transform: translateY(-52px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes cardFromWest  { from { transform: translateX(-52px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes cardFromEast  { from { transform: translateX(52px); opacity: 0; } to { transform: none; opacity: 1; } }

.trick-slot.anim-s { animation: cardFromSouth 0.28s ease; }
.trick-slot.anim-n { animation: cardFromNorth 0.28s ease; }
.trick-slot.anim-w { animation: cardFromWest  0.28s ease; }
.trick-slot.anim-e { animation: cardFromEast  0.28s ease; }

/* ─── Cards ───────────────────────────────────────────────────────────── */

.card-row { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }

.card {
    width: 52px;
    height: 68px;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    border: 2px solid #888;
    box-shadow: 1px 2px 4px rgba(0,0,0,0.3);
    font-size: 15px;
    line-height: 1.2;
    user-select: none;
}

.card-face {
    background: var(--card-face);
    color: var(--black-suit);
}
.card-face.red { color: var(--red-suit); }

.card-face.legal {
    cursor: pointer;
    border-color: var(--green-txt);
    box-shadow: 0 0 6px var(--green-txt);
}
.card-face.legal:hover {
    transform: translateY(-4px);
    box-shadow: 0 0 12px var(--green-txt);
}

.card-face.disabled {
    opacity: 0.5;
    cursor: default;
}

/* Drag-to-reorder */
#south-cards .card-face { cursor: grab; }
#south-cards .card-face.legal { cursor: pointer; }
.card-face.dragging { opacity: 0.3; }
.card-face.drag-over {
    box-shadow: -6px 0 0 var(--accent);
    transform: translateX(4px);
}

.card-back {
    background: var(--card-back);
    border-color: #0e3a5a;
}

.card-back-small {
    width: 28px;
    height: 36px;
    background: var(--card-back);
    border: 1px solid #0e3a5a;
    border-radius: 3px;
}

/* ─── Modals (bid, game over, hands, history) ─────────────────────────── */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 100;
    justify-content: center;
    align-items: center;
}
.modal-overlay.active { display: flex; }

/* Bid overlay: no backdrop so cards remain visible; anchored below score panel */
#bid-overlay {
    background: transparent;
    align-items: flex-start;
    padding-top: 70px;
    pointer-events: none;
}
#bid-overlay .modal {
    pointer-events: auto;
    border-color: var(--accent);
    box-shadow: 0 4px 24px rgba(0,0,0,0.8);
}

/* While bid overlay is open, show disabled cards at full opacity so the
   declaring player can clearly see their hand */
body:has(#bid-overlay.active) .card-face.disabled {
    opacity: 1;
}

.modal {
    background: var(--table-bg);
    border: 2px solid #555;
    border-radius: 8px;
    padding: 20px;
    max-width: 90vw;
    max-height: 85vh;
    overflow-y: auto;
    min-width: 280px;
}

.modal h2 { color: var(--accent); margin-bottom: 12px; text-align: center; }
.modal h3 { color: #3498db; margin: 8px 0 4px; }

.bid-suit {
    text-align: center;
    font-size: 36px;
    font-weight: bold;
    margin: 8px 0;
}
.bid-suit.red { color: var(--red-suit); }
.bid-suit.black { color: var(--card-face); }

.bid-msg { text-align: center; color: var(--accent); margin-bottom: 12px; }

.bid-buttons { display: flex; gap: 10px; justify-content: center; }

.btn-declare {
    background: var(--felt);
    color: white;
    font-size: 14px;
    font-weight: bold;
    padding: 10px 24px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}
.btn-declare:hover { background: #3a9a3a; }

.btn-pass {
    background: #555;
    color: white;
    font-size: 14px;
    padding: 10px 24px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}
.btn-pass:hover { background: #777; }

.btn-declare:focus-visible,
.btn-pass:focus-visible,
.btn:focus-visible,
input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.mode-btn { font-size: 12px; padding: 6px 14px; }
.mode-btn.active { background: var(--felt); border: 2px solid var(--green-txt); }

.spinner {
    width: 28px; height: 28px;
    border: 3px solid #444;
    border-top-color: var(--green-txt);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Next round banner ──────────────────────────────────────────────── */

#nextround-banner {
    display: none;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--win-bg);
    border-top: 2px solid var(--accent);
    padding: 10px 16px;
    text-align: center;
    z-index: 90;
    gap: 12px;
    justify-content: center;
    align-items: center;
}
#nextround-banner.active { display: flex; }
#nextround-msg { color: #ccc; font-size: 14px; font-weight: bold; }
#nextround-wait { display: none; color: var(--accent); font-size: 12px; }
#nextround-banner .btn-declare { padding: 6px 18px; font-size: 13px; }
#nextround-btn { display: none; }

/* ─── Lobby ───────────────────────────────────────────────────────────── */

#lobby-overlay .modal { min-width: 360px; }
#lobby-subtitle {
    text-align: center;
    color: #aaa;
    margin-bottom: 16px;
}

#lobby-reconnecting {
    display: none;
    text-align: center;
    padding: 8px 0 16px;
}
#lobby-reconnecting p {
    color: #aaa;
    margin-bottom: 12px;
}
#lobby-reconnecting .spinner { margin: 0 auto 14px; }

#lobby-name-section {
    text-align: center;
    margin-bottom: 16px;
}
#lobby-name-section > label { color: #ccc; font-size: 13px; }
#lobby-name {
    margin-top: 4px;
    padding: 6px 12px;
    font-size: 14px;
    border-radius: 4px;
    border: 1px solid #555;
    background: #0a0a1a;
    color: #ccc;
    width: 180px;
}
#lobby-name-hint {
    color: #7d7d7d;
    font-size: 12px;
    margin-top: 8px;
}

#lobby-actions { text-align: center; }
#lobby-create-btn { margin: 4px; }
#lobby-or-divider {
    margin: 12px 0;
    color: #666;
}
.lobby-join-row {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

#join-code {
    padding: 6px 12px;
    font-size: 16px;
    width: 80px;
    text-align: center;
    letter-spacing: 3px;
    text-transform: uppercase;
    border-radius: 4px;
    border: 1px solid #555;
    background: #0a0a1a;
    color: #ccc;
}

#join-code-hint {
    color: #7d7d7d;
    font-size: 12px;
    margin-top: 8px;
}

#lobby-error {
    color: #e74c3c;
    margin-top: 8px;
    display: none;
}

#lobby-seat-picker { display: none; }
#lobby-seat-picker > p {
    text-align: center;
    color: #ccc;
    margin-bottom: 10px;
}
.lobby-seat-picker-actions {
    text-align: center;
    margin-top: 10px;
}

#lobby-waiting { display: none; }
.lobby-room-code-row {
    text-align: center;
    margin-bottom: 12px;
}
#lobby-room-code-label { color: #aaa; }
#lobby-code {
    font-size: 24px;
    font-weight: bold;
    color: var(--accent);
    letter-spacing: 4px;
    margin-left: 8px;
}
#lobby-copy-code {
    padding: 4px 10px;
    font-size: 12px;
    margin-left: 10px;
}

#lobby-team-names {
    display: none;
    margin-top: 10px;
    text-align: center;
}
#lobby-team-names > p {
    color: #aaa;
    font-size: 12px;
    margin-bottom: 6px;
}
.lobby-team-inputs {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}
.lobby-team-label { font-size: 11px; }
.lobby-team-label.team0 { color: var(--green-txt); }
.lobby-team-label.team1 { color: var(--red-txt); }
#team0-name,
#team1-name {
    width: 110px;
    padding: 4px 8px;
    font-size: 13px;
    border-radius: 4px;
    border: 1px solid #555;
    background: #0a0a1a;
    text-align: center;
}
#team0-name { color: var(--green-txt); }
#team1-name { color: var(--red-txt); }

#lobby-mode-picker {
    display: none;
    margin-top: 12px;
    text-align: center;
}
#lobby-mode-picker > p {
    color: #aaa;
    font-size: 12px;
    margin-bottom: 6px;
}
.lobby-mode-buttons {
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-wrap: wrap;
}

#score-limit-input { margin-top: 8px; }
#score-limit-input > label { color: #ccc; font-size: 12px; }
#mode-score-limit {
    width: 70px;
    padding: 4px 8px;
    font-size: 14px;
    border-radius: 4px;
    border: 1px solid #555;
    background: #0a0a1a;
    color: #ccc;
    text-align: center;
    margin-left: 6px;
}

#lobby-mode-display {
    display: none;
    margin-top: 8px;
    text-align: center;
}
#lobby-mode-text { color: #888; font-size: 12px; }

#lobby-ai-picker {
    display: none;
    margin-top: 10px;
    text-align: center;
}
#lobby-ai-picker > p {
    color: #aaa;
    font-size: 12px;
    margin-bottom: 6px;
}
.lobby-ai-buttons {
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-wrap: wrap;
}

#lobby-ai-display {
    display: none;
    margin-top: 8px;
    text-align: center;
}
#lobby-ai-text { color: #888; font-size: 12px; }

.lobby-start-row {
    text-align: center;
    margin-top: 12px;
}
#lobby-start-btn { display: none; }
#lobby-wait-msg {
    color: #aaa;
    font-size: 12px;
    margin-top: 6px;
}

.lobby-seat-row {
    display: flex;
    align-items: center;
    padding: 6px 10px;
    margin: 3px 0;
    border-radius: 4px;
    background: #0d2d0d;
    font-size: 13px;
}

.lobby-seat-row .seat-num {
    color: #888;
    width: 70px;
    font-weight: bold;
}

.lobby-seat-row .seat-player {
    flex: 1;
    color: #ccc;
}

.lobby-seat-row .seat-player.empty {
    color: #555;
    font-style: italic;
}

.lobby-seat-row .seat-team {
    color: #888;
    font-size: 11px;
    margin-left: 8px;
}

.seat-pick-row.open:hover {
    background: var(--felt);
    border-color: var(--green-txt);
}

.seat-pick-row.taken {
    opacity: 0.5;
    cursor: default;
}

/* ─── Hands viewer ────────────────────────────────────────────────────── */

.hands-modal { min-width: 340px; }

.hand-trick {
    background: #1a3a2a;
    border: 2px groove #2a5a3a;
    border-radius: 6px;
    padding: 8px;
    margin-bottom: 8px;
}

.hand-trick-header {
    color: var(--green-txt);
    font-weight: bold;
    font-size: 13px;
    margin-bottom: 6px;
    text-align: center;
}

.hand-trick-grid {
    display: grid;
    grid-template-areas:
        ".  n  ."
        "w  .  e"
        ".  s  .";
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: auto auto auto;
    gap: 4px;
    place-items: center;
}

.hand-trick-grid .pos-n { grid-area: n; }
.hand-trick-grid .pos-w { grid-area: w; }
.hand-trick-grid .pos-e { grid-area: e; }
.hand-trick-grid .pos-s { grid-area: s; }

.hand-card {
    text-align: center;
    padding: 4px 8px;
    border-radius: 4px;
    border: 2px solid #888;
    background: var(--card-face);
    min-width: 60px;
}
.hand-card .card-name { font-size: 10px; color: #888; }
.hand-card .card-val  { font-size: 14px; font-weight: bold; }
.hand-card.red .card-val { color: var(--red-suit); }
.hand-card.black .card-val { color: var(--black-suit); }

.hand-card.winner {
    background: #d4edda;
    border-color: var(--green-txt);
}
.hand-card.winner .card-name { color: var(--green-txt); }

/* ─── History viewer ──────────────────────────────────────────────────── */

.history-modal { min-width: 700px; display: flex; gap: 12px; }

.history-list {
    min-width: 140px;
    max-height: 400px;
    overflow-y: auto;
}

.history-list-item {
    padding: 4px 8px;
    cursor: pointer;
    font-family: monospace;
    font-size: 12px;
    border-radius: 3px;
}
.history-list-item:hover { background: #2a5a2a; }
.history-list-item.selected { background: var(--felt); color: white; }
.history-empty { color: #aaa; }

.history-detail {
    flex: 1;
    background: #0a0a1a;
    color: #ccc;
    padding: 10px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
    max-height: 400px;
    overflow-y: auto;
    white-space: pre-wrap;
}

.close-btn {
    position: absolute;
    top: 8px;
    right: 12px;
    background: none;
    border: none;
    color: #aaa;
    font-size: 20px;
    cursor: pointer;
}
.close-btn:hover { color: white; }

.modal-wrapper { position: relative; }
#gameover-msg {
    text-align: center;
    font-size: 16px;
    margin: 12px 0;
}
#gameover-actions { text-align: center; }
#gameover-newgame-btn { display: none; }

#leave-overlay .modal { max-width: 320px; }
#leave-msg {
    text-align: center;
    color: #aaa;
    margin-bottom: 16px;
}
#leave-actions {
    text-align: center;
    display: flex;
    gap: 10px;
    justify-content: center;
}

#paused-msg {
    text-align: center;
    font-size: 14px;
    color: #f1c40f;
}

.history-main-pane { flex: 1; }

/* ─── Language switcher ──────────────────────────────────────────────── */

#lang-switcher {
    position: fixed;
    top: 8px;
    right: 12px;
    z-index: 200;
    display: flex;
    gap: 4px;
}

.lang-btn {
    background: none;
    border: 2px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
    padding: 2px 4px;
    opacity: 0.5;
    transition: opacity 0.15s, border-color 0.15s;
}

.lang-btn:hover { opacity: 0.85; }
.lang-btn.active {
    opacity: 1;
    border-color: var(--accent);
}

/* ─── Chat panel ─────────────────────────────────────────────────────── */

#chat-panel {
    position: fixed;
    top: 44px;
    right: -290px;
    bottom: 0;
    width: 270px;
    background: var(--win-bg);
    border-left: 2px solid #444;
    z-index: 150;
    display: flex;
    flex-direction: column;
    transition: right 0.25s ease;
}
#chat-panel.open { right: 0; }

#chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid #444;
    color: var(--accent);
    font-weight: bold;
    font-size: 14px;
    flex-shrink: 0;
}

#chat-close-btn {
    background: none;
    border: none;
    color: #aaa;
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
    padding: 0 2px;
}
#chat-close-btn:hover { color: white; }

#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-msg {
    font-size: 12px;
    line-height: 1.5;
    word-break: break-word;
}
.chat-sender {
    font-weight: bold;
    margin-right: 4px;
}
.chat-msg.team-0 .chat-sender { color: var(--green-txt); }
.chat-msg.team-1 .chat-sender { color: var(--red-txt); }

#chat-input-area {
    display: flex;
    padding: 10px;
    gap: 6px;
    border-top: 1px solid #444;
    flex-shrink: 0;
}
#chat-input {
    flex: 1;
    padding: 6px 10px;
    font-size: 13px;
    border-radius: 4px;
    border: 1px solid #555;
    background: #0a0a1a;
    color: #ccc;
    min-width: 0;
}
#chat-input-area .btn-declare {
    padding: 6px 12px;
    font-size: 12px;
    flex-shrink: 0;
}

/* Chat button and unread badge */
.chat-btn-wrapper {
    position: relative;
    display: inline-block;
}
.btn-chat           { background: #4a4a1a; }
.btn-chat:hover     { background: #6a6a2a; }

.chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #e74c3c;
    color: white;
    font-size: 9px;
    font-weight: bold;
    min-width: 15px;
    height: 15px;
    border-radius: 8px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    pointer-events: none;
}
.chat-badge.visible { display: flex; }

/* ─── Responsive — mobile ────────────────────────────────────────────── */

@media (max-width: 600px) {
    /* Language switcher: smaller, don't overlap score */
    #lang-switcher {
        top: 4px;
        right: 4px;
        gap: 2px;
    }
    .lang-btn {
        font-size: 18px;
        padding: 1px 3px;
    }

    /* Score panel: stack vertically */
    #score-panel {
        padding: 6px 8px;
        padding-right: 60px; /* make room for lang switcher */
    }
    .score-top {
        flex-wrap: wrap;
        gap: 4px;
        font-size: 12px;
    }
    .score-team0, .score-team1 { font-size: 12px; }
    #trump-label { font-size: 12px; order: -1; width: 100%; justify-content: center; }
    .trump-suit { font-size: 22px; }
    .score-buttons { order: 10; width: 100%; justify-content: center; }
    .score-bottom { font-size: 10px; flex-wrap: wrap; gap: 2px; }

    /* Table: tighter */
    #table {
        gap: 2px;
        padding: 4px;
        min-height: 320px;
    }

    /* Cards: smaller */
    .card {
        width: 40px;
        height: 54px;
        font-size: 12px;
        border-width: 1.5px;
    }
    .card-row { gap: 2px; }
    .card-back-small {
        width: 22px;
        height: 30px;
    }

    /* Trick area: smaller cards */
    #trick-area {
        padding: 4px;
        min-height: 150px;
        border-width: 3px;
    }
    .trick-slot {
        width: 46px;
        height: 56px;
        font-size: 13px;
    }

    /* Modals: full-width on mobile */
    .modal {
        max-width: 96vw;
        min-width: unset !important;
        width: 96vw;
        padding: 14px 10px;
        max-height: 90vh;
    }
    .modal h2 { font-size: 16px; margin-bottom: 8px; }
    .modal h3 { font-size: 14px; }

    /* History modal: stack vertically instead of side-by-side */
    .history-modal {
        flex-direction: column;
        min-width: unset !important;
        width: 96vw;
    }
    .history-list {
        min-width: unset;
        max-height: 120px;
    }
    .history-detail {
        max-height: 250px;
        font-size: 10px;
    }

    /* Hands modal */
    .hands-modal {
        min-width: unset !important;
        width: 96vw;
    }
    .hand-card { min-width: 48px; padding: 3px 5px; }
    .hand-card .card-val { font-size: 12px; }
    .hand-card .card-name { font-size: 9px; }
    .hand-trick { padding: 6px; }
    .hand-trick-header { font-size: 11px; }

    /* Lobby modal */
    #lobby-overlay .modal { min-width: unset !important; width: 92vw; }

    /* Bid modal: move to top so cards stay visible */
    #bid-overlay { align-items: flex-start; padding-top: 8px; }
    #bid-overlay .modal { margin-top: 0; }

    /* Bid modal: bigger touch targets */
    .btn-declare, .btn-pass {
        padding: 12px 20px;
        font-size: 15px;
    }
    .bid-suit { font-size: 28px; }

    /* Seat labels */
    .seat-label { font-size: 10px; }
}

/* Medium screens (tablets) */
@media (max-width: 768px) and (min-width: 601px) {
    #score-panel { padding-right: 70px; }
    .history-modal { min-width: unset !important; width: 90vw; }
    .hands-modal { min-width: unset !important; }
    .modal { min-width: unset !important; }
}
