/* Kaiser — LuckyLobby Card Game */
:root {
    --bg-dark: #0d0d12;
    --bg-card: #1a1a24;
    --border: #2a2a3a;
    --accent: #d4a853;
    --accent-dim: rgba(212,168,83,0.15);
    --text: #e8e4dc;
    --text-muted: #8a8a9a;
    --radius: 12px;
    --font-head: 'Cinzel', serif;
    --team-a: #60a5fa;
    --team-b: #f472b6;
}

.kaiser-game-wrapper {
    min-height: 100vh;
    background: var(--bg-dark);
    color: var(--text);
    font-family: 'Exo 2', sans-serif;
}

/* ---- Lobby ---- */
.kaiser-lobby {
    max-width: 480px;
    margin: 0 auto;
    padding: 2rem 1rem;
}
.lobby-header { text-align: center; margin-bottom: 1.5rem; }
.lobby-logo { display: flex; flex-direction: column; align-items: center; gap: 0.25rem; }
.logo-icon { font-size: 3rem; filter: drop-shadow(0 0 12px rgba(212,168,83,0.4)); }
.lobby-logo h1 { font-family: var(--font-head); color: var(--accent); font-size: 2.25rem; margin: 0; letter-spacing: 0.1em; }
.logo-tagline { font-size: 0.8rem; color: var(--text-muted); letter-spacing: 0.05em; }
.lobby-body { display: flex; flex-direction: column; gap: 1rem; }
.rules-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; }
.rules-card h3 { font-family: var(--font-head); color: var(--accent); margin: 0 0 0.75rem; font-size: 0.9rem; }
.rules-card ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.rules-card li { font-size: 0.8rem; padding-left: 1.2rem; position: relative; line-height: 1.45; color: var(--text-muted); }
.rules-card li::before { content: '♠'; position: absolute; left: 0; color: var(--accent); }

/* Lobby buttons, avatar picker, room code — shared styles */
.lobby-btn { width: 100%; padding: 0.85rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card); color: var(--text); font-family: var(--font-head); font-size: 0.9rem; cursor: pointer; transition: all 0.2s; display: flex; flex-direction: column; align-items: center; gap: 0.15rem; }
.lobby-btn:hover { border-color: var(--accent); background: var(--accent-dim); }
.lobby-btn small { font-family: 'Exo 2', sans-serif; font-size: 0.7rem; color: var(--text-muted); }
.primary-btn { border-color: var(--accent); background: linear-gradient(135deg, rgba(212,168,83,0.15), rgba(212,168,83,0.05)); }
.primary-btn:hover { background: linear-gradient(135deg, rgba(212,168,83,0.3), rgba(212,168,83,0.1)); }
.lobby-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.avatar-picker { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; text-align: center; }
.avatar-picker-label { font-family: var(--font-head); font-size: 0.8rem; color: var(--accent); display: block; margin-bottom: 0.6rem; }
.avatar-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.4rem; }
.avatar-option { width: 42px; height: 42px; font-size: 1.3rem; border: 2px solid var(--border); border-radius: 50%; background: var(--bg-dark); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.15s; }
.avatar-option:hover { border-color: var(--accent); transform: scale(1.1); }
.avatar-option.selected { border-color: var(--accent); background: var(--accent-dim); box-shadow: 0 0 10px rgba(212,168,83,0.3); }

.timer-selector { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.85rem 1rem; text-align: center; }
.timer-label { font-family: var(--font-head); font-size: 0.8rem; color: var(--accent); display: block; margin-bottom: 0.5rem; }
.timer-buttons { display: flex; gap: 0.4rem; justify-content: center; }
.timer-btn { padding: 0.4rem 0.85rem; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-dark); color: var(--text); cursor: pointer; font-size: 0.8rem; transition: all 0.15s; }
.timer-btn:hover { border-color: var(--accent); }
.timer-btn.active { border-color: var(--accent); background: var(--accent-dim); color: var(--accent); }

.bot-selector { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.85rem 1rem; text-align: center; }
.bot-selector-label { font-family: var(--font-head); font-size: 0.8rem; color: var(--accent); display: block; margin-bottom: 0.4rem; }
.bot-selector-hint { font-size: 0.7rem; color: var(--text-muted); }

.room-code-card { background: var(--bg-card); border: 1px solid var(--accent); border-radius: var(--radius); padding: 1.25rem; text-align: center; }
.room-code-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.1em; }
.room-code-value { font-family: var(--font-head); font-size: 2rem; color: var(--accent); letter-spacing: 0.3em; margin: 0.25rem 0; }
.room-code-hint { font-size: 0.7rem; color: var(--text-muted); }
.room-players-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.room-players-label { font-family: var(--font-head); font-size: 0.8rem; color: var(--accent); margin-bottom: 0.5rem; }
.room-player-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.room-player-list li { padding: 0.4rem 0.6rem; background: var(--bg-dark); border-radius: 6px; font-size: 0.8rem; }
.room-player-list li.is-you { border: 1px solid var(--accent); }

/* ---- Game Table ---- */
.kaiser-table-screen { display: flex; flex-direction: column; min-height: 100vh; padding: 0.5rem; }

.table-hud { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 0.75rem; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 0.3rem; }
.hud-left, .hud-right { display: flex; align-items: center; gap: 0.5rem; }
.hud-center { display: flex; align-items: center; gap: 0.4rem; }
.hud-logo { font-family: var(--font-head); color: var(--accent); font-size: 0.85rem; }
.hud-hand { font-size: 0.75rem; color: var(--text-muted); }
.hud-room-code { font-size: 0.7rem; color: var(--text-muted); }
.hud-score { font-family: var(--font-head); font-size: 1.3rem; font-weight: 700; min-width: 2rem; text-align: center; }
.hud-score.team-a { color: var(--team-a); }
.hud-score.team-b { color: var(--team-b); }
.hud-score-sep { color: var(--text-muted); font-size: 0.9rem; }
.hud-trump { font-size: 0.8rem; color: var(--accent); background: var(--accent-dim); padding: 0.2rem 0.5rem; border-radius: 6px; }
.hud-timer { font-family: var(--font-head); font-size: 0.85rem; color: #4ade80; }
.hud-timer.timer-urgent { color: #e74c3c; animation: pulse 0.5s ease infinite alternate; }
.hud-player-name { font-size: 0.8rem; }

.team-bar { display: flex; justify-content: space-between; align-items: center; padding: 0.35rem 0.75rem; font-size: 0.75rem; }
.team-name { font-family: var(--font-head); letter-spacing: 0.05em; }
.team-name.team-a { color: var(--team-a); }
.team-name.team-b { color: var(--team-b); }
.team-bid { color: var(--accent); font-size: 0.7rem; }

.game-message { text-align: center; padding: 0.4rem 0.75rem; font-size: 0.8rem; color: var(--accent); background: var(--accent-dim); border-radius: 8px; margin-bottom: 0.3rem; transition: opacity 0.15s ease, transform 0.15s ease; }
.game-message.error { color: #e74c3c; background: rgba(231,76,60,0.1); }
.game-message.msg-fade { opacity: 0; transform: translateY(-4px); }

/* ---- Round Table ---- */
.round-table-container { display: flex; flex-direction: column; align-items: center; flex: 1; padding: 0.25rem 0; }
.round-table { width: 100%; max-width: 520px; aspect-ratio: 1.2 / 1; border: 4px solid #5c3a1e; border-radius: 50%; background: radial-gradient(ellipse at 50% 40%, #2d5a2d 0%, #1a4a1a 50%, #0f350f 100%); box-shadow: inset 0 0 40px rgba(0,0,0,0.5), 0 6px 20px rgba(0,0,0,0.6); position: relative; }
.table-felt { position: absolute; inset: 0; border-radius: 50%; }

/* ---- Seat positions ---- */
.table-seat { position: absolute; display: flex; flex-direction: column; align-items: center; gap: 0.15rem; transform: translate(-50%, -50%); z-index: 2; }
.seat-north { left: 50%; top: 8%; }
.seat-west  { left: 8%; top: 50%; }
.seat-east  { right: 8%; top: 50%; left: auto; transform: translate(50%, -50%); }
.my-seat { display: flex; flex-direction: column; align-items: center; gap: 0.15rem; margin-top: 0.5rem; }

.seat-avatar { width: 48px; height: 48px; background: var(--bg-dark); border: 2px solid var(--border); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; transition: all 0.3s; }
.seat-avatar-lg { width: 52px; height: 52px; font-size: 1.6rem; }
.seat-name { font-size: 0.65rem; color: rgba(255,255,255,0.7); max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; text-shadow: 0 1px 3px rgba(0,0,0,0.8); }
.seat-cards { font-size: 0.6rem; color: rgba(255,255,255,0.4); text-shadow: 0 1px 3px rgba(0,0,0,0.8); }
.seat-partner-label { font-size: 0.55rem; color: var(--accent); font-family: var(--font-head); letter-spacing: 0.05em; }

.table-seat.active-turn .seat-avatar,
.my-seat.active-turn .seat-avatar { border-color: var(--accent); box-shadow: 0 0 12px rgba(212,168,83,0.5); animation: glowPulse 1.5s ease-in-out infinite; }
.table-seat.team-a .seat-avatar { border-color: rgba(96,165,250,0.4); }
.table-seat.team-b .seat-avatar { border-color: rgba(244,114,182,0.4); }
.my-seat.team-a .seat-avatar { border-color: rgba(96,165,250,0.5); }
.my-seat.team-b .seat-avatar { border-color: rgba(244,114,182,0.5); }

@keyframes glowPulse {
    0%, 100% { box-shadow: 0 0 8px rgba(212,168,83,0.4); }
    50%      { box-shadow: 0 0 20px rgba(212,168,83,0.7); }
}
@keyframes pulse { 0% { opacity: 1; } 100% { opacity: 0.5; } }

.bot-thinking {
    display: flex; gap: 3px; justify-content: center; margin-top: 3px;
}
.bot-thinking span {
    width: 5px; height: 5px; border-radius: 50%;
    background: var(--accent); opacity: 0.3;
    animation: thinkDot 1s ease-in-out infinite;
}
.bot-thinking span:nth-child(2) { animation-delay: 0.2s; }
.bot-thinking span:nth-child(3) { animation-delay: 0.4s; }
@keyframes thinkDot {
    0%, 100% { opacity: 0.2; transform: scale(0.8); }
    50%      { opacity: 1; transform: scale(1.3); }
}

/* ---- Trick Area ---- */
.trick-area { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 180px; height: 140px; z-index: 3; }
.trick-card { position: absolute; transition: all 0.3s ease; }
.trick-card.trick-north { left: 50%; top: 0; transform: translateX(-50%); }
.trick-card.trick-south { left: 50%; bottom: 0; transform: translateX(-50%); }
.trick-card.trick-west  { left: 0; top: 50%; transform: translateY(-50%); }
.trick-card.trick-east  { right: 0; top: 50%; transform: translateY(-50%); }
.trick-info { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); font-size: 0.6rem; color: rgba(255,255,255,0.3); white-space: nowrap; }

.trick-fading { opacity: 0.35; transition: opacity 0.4s ease; }
.trick-winner {
    border: 2px solid var(--accent) !important;
    box-shadow: 0 0 18px rgba(212,168,83,0.7), 0 0 40px rgba(212,168,83,0.3);
    animation: trickWinPulse 0.6s ease-in-out infinite alternate;
}
@keyframes trickWinPulse {
    from { box-shadow: 0 0 12px rgba(212,168,83,0.5), 0 0 30px rgba(212,168,83,0.2); transform: scale(1); }
    to   { box-shadow: 0 0 22px rgba(212,168,83,0.8), 0 0 50px rgba(212,168,83,0.4); transform: scale(1.06); }
}

/* Card slide-in animations from each seat direction */
.card-slide-north { animation: slideFromNorth 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
.card-slide-south { animation: slideFromSouth 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
.card-slide-west  { animation: slideFromWest  0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
.card-slide-east  { animation: slideFromEast  0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both; }

@keyframes slideFromNorth {
    0% { transform: translateY(-60px) scale(0.6) rotate(-8deg); opacity: 0; }
    100% { transform: translateY(0) scale(1) rotate(0deg); opacity: 1; }
}
@keyframes slideFromSouth {
    0% { transform: translateY(60px) scale(0.6) rotate(8deg); opacity: 0; }
    100% { transform: translateY(0) scale(1) rotate(0deg); opacity: 1; }
}
@keyframes slideFromWest {
    0% { transform: translateX(-60px) scale(0.6) rotate(8deg); opacity: 0; }
    100% { transform: translateX(0) scale(1) rotate(0deg); opacity: 1; }
}
@keyframes slideFromEast {
    0% { transform: translateX(60px) scale(0.6) rotate(-8deg); opacity: 0; }
    100% { transform: translateX(0) scale(1) rotate(0deg); opacity: 1; }
}

/* ---- Cards ---- */
.card { width: 56px; height: 80px; background: #fffef8; border: 2px solid #ddd; border-radius: 7px; display: flex; flex-direction: column; justify-content: space-between; padding: 3px 5px; font-family: 'Exo 2', sans-serif; font-weight: 600; position: relative; user-select: none; transition: all 0.15s ease; box-shadow: 0 2px 6px rgba(0,0,0,0.2); }
.card.interactive { cursor: pointer; }
.card.interactive:hover { transform: translateY(-8px); box-shadow: 0 8px 20px rgba(0,0,0,0.35); }
.card-rank-top { font-size: 0.75rem; line-height: 1; }
.card-suit-center { font-size: 1.5rem; text-align: center; flex: 1; display: flex; align-items: center; justify-content: center; }
.card-rank-bottom { font-size: 0.75rem; line-height: 1; text-align: right; transform: rotate(180deg); }
.card-special-good { border-color: #4ade80 !important; box-shadow: 0 0 8px rgba(74,222,128,0.3); }
.card-special-bad  { border-color: #e74c3c !important; box-shadow: 0 0 8px rgba(231,76,60,0.3); }

/* ---- Player Hand ---- */
.player-hand-area { padding: 0.5rem; text-align: center; position: relative; z-index: 101; }
.hand-label { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 0.3rem; }
.player-hand { display: flex; justify-content: center; flex-wrap: wrap; gap: 0.15rem; }

/* ---- Bidding Overlay ---- */
.bid-overlay { position: fixed; inset: 0; background: rgba(13,13,18,0.85); display: flex; align-items: flex-start; justify-content: center; padding-top: 15vh; z-index: 100; }
.bid-overlay-content { background: var(--bg-card); border: 1px solid var(--accent); border-radius: var(--radius); padding: 1.5rem 2rem; max-width: 380px; width: 90%; text-align: center; }
.bid-overlay-content h2 { font-family: var(--font-head); color: var(--accent); margin: 0 0 0.75rem; font-size: 1.1rem; }
.bid-current { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 1rem; }
.bid-buttons { display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: center; margin-bottom: 0.75rem; }
.bid-btn { min-width: 50px; padding: 0.6rem 0.75rem; font-size: 1rem; font-family: var(--font-head); }
.bid-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.action-btn { padding: 0.6rem 1.25rem; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-dark); color: var(--text); font-family: var(--font-head); font-size: 0.85rem; cursor: pointer; transition: all 0.2s; }
.action-btn:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-dim); }
.play-btn { border-color: var(--accent); color: var(--accent); }
.pass-btn { border-color: var(--border); color: var(--text-muted); }

/* ---- Trump Buttons ---- */
.trump-buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; }
.trump-btn { padding: 0.75rem 1.25rem; border: 2px solid var(--border); border-radius: var(--radius); background: var(--bg-dark); color: var(--text); font-size: 0.9rem; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; gap: 0.4rem; }
.trump-btn:hover { border-color: var(--accent); background: var(--accent-dim); transform: scale(1.05); }
.trump-suit { font-size: 1.3rem; }
.suit-red { color: #e74c3c; }
.trump-none { font-size: 0.8rem; }

/* ---- Hand Over / Game Over ---- */
.round-overlay { position: fixed; inset: 0; background: rgba(13,13,18,0.92); display: flex; align-items: center; justify-content: center; z-index: 200; }
.round-overlay-content { background: var(--bg-card); border: 1px solid var(--accent); border-radius: var(--radius); padding: 2rem; max-width: 420px; width: 90%; text-align: center; position: relative; overflow: hidden; }
.round-overlay-content h2 { font-family: var(--font-head); color: var(--accent); margin: 0 0 1rem; font-size: 1.25rem; }

.hand-over-body { margin-bottom: 1.25rem; }
.score-summary { display: flex; flex-direction: column; gap: 0.3rem; text-align: left; }
.score-row { display: flex; justify-content: space-between; padding: 0.35rem 0.5rem; font-size: 0.82rem; background: var(--bg-dark); border-radius: 6px; }
.score-row.special-good { color: #4ade80; }
.score-row.special-bad  { color: #e74c3c; }
.score-row.result.made   { color: #4ade80; font-weight: 600; }
.score-row.result.missed { color: #e74c3c; font-weight: 600; }
.score-row.totals { font-family: var(--font-head); color: var(--accent); font-size: 0.85rem; }
.score-summary hr { border: none; border-top: 1px solid var(--border); margin: 0.3rem 0; }

/* ---- Play Log ---- */
.play-log-panel { position: fixed; bottom: 0; right: 0; width: 280px; max-height: 50vh; background: var(--bg-card); border: 1px solid var(--border); border-bottom: none; border-radius: var(--radius) var(--radius) 0 0; z-index: 50; display: flex; flex-direction: column; box-shadow: -2px -2px 12px rgba(0,0,0,0.4); }
.play-log-header { display: flex; align-items: center; justify-content: space-between; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); cursor: pointer; user-select: none; }
.play-log-title { font-family: var(--font-head); font-size: 0.8rem; color: var(--accent); letter-spacing: 0.05em; }
.play-log-toggle { background: none; border: none; color: var(--text-muted); font-size: 0.75rem; cursor: pointer; padding: 0 0.25rem; }
.play-log-body { overflow-y: auto; max-height: 40vh; transition: max-height 0.3s ease; }
.play-log-body.collapsed { max-height: 0; overflow: hidden; }
.play-log-entries { padding: 0.4rem 0.6rem; display: flex; flex-direction: column; gap: 0.2rem; }
.log-empty { color: var(--text-muted); font-size: 0.75rem; text-align: center; padding: 1rem 0; }
.log-entry { font-size: 0.72rem; line-height: 1.5; padding: 0.2rem 0.4rem; border-radius: 4px; color: var(--text); }
.log-entry.log-play { background: rgba(255,255,255,0.03); }
.log-entry.log-bid_pass { color: var(--text-muted); font-style: italic; }
.log-entry.log-deal, .log-entry.log-trump, .log-entry.log-score { text-align: center; color: var(--accent); font-family: var(--font-head); font-size: 0.7rem; padding: 0.25rem 0; border-top: 1px solid rgba(212,168,83,0.15); border-bottom: 1px solid rgba(212,168,83,0.15); margin: 0.15rem 0; }
.log-name { font-weight: 600; }
.log-action { color: var(--text-muted); }
.log-card { font-weight: 700; margin: 0 0.1rem; }
.log-clear { color: var(--accent); }
.log-out { color: #4ade80; }

/* ---- Responsive ---- */
@media (max-width: 600px) {
    .kaiser-game-wrapper { padding: 0; }
    .round-table { max-width: 100%; }
    .card { width: 46px; height: 66px; }
    .card-rank-top, .card-rank-bottom { font-size: 0.65rem; }
    .card-suit-center { font-size: 1rem; }
    .player-hand { gap: 0.1rem; }
    .seat-avatar { width: 40px; height: 40px; font-size: 1.2rem; }
    .seat-avatar-lg { width: 46px; height: 46px; font-size: 1.4rem; }
    .seat-name { font-size: 0.55rem; max-width: 55px; }
    .trick-area { width: 140px; height: 110px; }
    .play-log-panel { width: 100%; }
    .bid-overlay-content { padding: 1rem; }
    .hud-score { font-size: 1.1rem; }
}

@media (max-width: 400px) {
    .card { width: 40px; height: 58px; }
    .card-suit-center { font-size: 0.85rem; }
    .seat-avatar { width: 34px; height: 34px; font-size: 1rem; }
    .seat-avatar-lg { width: 40px; height: 40px; font-size: 1.2rem; }
    .trick-area { width: 110px; height: 90px; }
}
