/* Mobile Touch Action Optimizations */
button,
.premium-btn,
.control-icon,
.card,
.settings-icon,
.close-btn,
.avatar {
    touch-action: manipulation;
}

#top-controls {
    position: absolute;
    top: calc(30px + env(safe-area-inset-top, 0px));
    right: calc(30px + env(safe-area-inset-right, 0px));
    display: flex;
    gap: 15px;
    z-index: 100;
    align-items: center;
}

#trial-status {
    position: absolute;
    top: calc(30px + env(safe-area-inset-top, 0px));
    left: calc(30px + env(safe-area-inset-left, 0px));
    background: rgba(245, 158, 11, 0.2);
    border: 1px solid rgba(245, 158, 11, 0.4);
    color: #f59e0b;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    z-index: 9999;
    backdrop-filter: blur(10px);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    pointer-events: auto !important;
}

#trial-status:hover {
    background: rgba(245, 158, 11, 0.4);
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.3);
}

#trial-status:active {
    transform: scale(0.95);
}

.premium-btn.mini {
    padding: 8px 15px;
    font-size: 13px;
    min-width: auto;
}


.control-icon {
    width: 35px;
    height: 35px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

#lang-toggle {
    font-size: 18px; /* Slightly larger for the emoji */
}


#info-icon {
    font-family: "Georgia", serif;
    font-style: italic;
    font-weight: 500;
    font-size: 22px;
    color: #93c5fd; /* Even brighter to perfectly match emoji glow */
}




@media (hover: hover) {
    #info-icon:hover {
        transform: scale(1.1);
    }
    .control-icon:hover {
        background: var(--primary-color);
        border-color: var(--primary-color);
        transform: scale(1.1);
    }
}

.control-icon:active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    transform: scale(0.95);
}


/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

#alert-modal,
#confirm-modal {
    z-index: 2000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #1e293b;
    padding: 30px;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    max-width: 500px;
    width: 90%;
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.modal-content h2 {
    margin-top: 0;
    color: var(--primary-color);
    padding-bottom: 5px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.rules-logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
    filter: drop-shadow(0 0 8px rgba(155, 89, 182, 0.5));
}

.rules-sections {
    display: flex;
    gap: 30px;
}

.rules-footer {
    margin-top: 25px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #64748b;
    font-family: monospace;
}

.rules-sections section {
    flex: 1;
}

.rules-sections h3 {
    color: var(--accent-color);
    font-size: 16px;
    margin-bottom: 10px;
}

.modal-content ul {
    list-style-type: none;
    padding: 0;
}

.modal-content li {
    margin-bottom: 12px;
    font-size: 14px;
    line-height: 1.5;
    color: #cbd5e1;
}

.modal-content li strong {
    color: white;
    margin-right: 5px;
}

.close-btn {
    position: absolute;
    top: 8px;
    right: 12px;
    font-size: 32px;
    cursor: pointer;
    color: #94a3b8;
    padding: 10px; /* Generous 48px hit target area for mobile thumbs */
    touch-action: manipulation;
    z-index: 50;
}

.close-btn:hover {
    color: white;
}

:root {
    --bg-color: #0f172a;
    --table-color: #064e3b;
    --primary-color: #3b82f6;
    --accent-color: #10b981;
    --card-bg: #ffffff;
    --text-main: #f8fafc;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
}


#game-container {
    display: grid;
    grid-template-rows: 180px 1fr 220px;
    grid-template-columns: 220px 1fr 220px;
    height: 100vh;
    padding: calc(40px + env(safe-area-inset-top, 0px)) 
             calc(30px + env(safe-area-inset-right, 0px)) 
             calc(30px + env(safe-area-inset-bottom, 0px)) 
             calc(30px + env(safe-area-inset-left, 0px));
    background: radial-gradient(circle at center, var(--table-color) 0%, var(--bg-color) 100%);
    position: relative;
}

/* AI Players Layout */
.player {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 15px;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    transition: all 0.3s ease;
    position: relative;
    /* Added for crown positioning */
}

.p2 {
    grid-area: 2 / 1;
}

.p3 {
    grid-area: 1 / 2;
    justify-self: center;
}

.p4 {
    grid-area: 2 / 3;
}

.p1 {
    grid-area: 3 / 1 / 4 / 4;
}

.player.active {
    border-color: var(--accent-color);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.3);
}

.player.has-lead::after {
    content: '👑';
    position: absolute;
    top: -10px;
    left: -10px;
    font-size: 24px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
    z-index: 20;
}

.avatar {
    font-size: 32px;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color);
    border-radius: 50%;
    overflow: hidden;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.info {
    text-align: center;
}

.name {
    font-weight: 600;
    display: block;
    font-size: 18px;
}

.score {
    font-size: 14px;
    color: #94a3b8;
    margin-top: 2px;
}

.cards-count {
    font-size: 20px;
    color: #fbbf24;
    font-weight: 700;
    margin-top: 5px;
    min-height: 30px;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
}

/* Table Center */
#table-center {
    grid-area: 2 / 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.played-cards-slot {
    min-height: 100px;
    min-width: 150px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: -40px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    border: 1px dashed rgba(255, 255, 255, 0.05);
}

.played-cards-slot:empty {
    background: transparent;
    border-color: transparent;
    pointer-events: none;
}

.played-cards-slot.active-play {
    z-index: 30;
}

.p1 .played-cards-slot {
    position: absolute;
    top: -120px;
    left: 50%;
    transform: translateX(-50%);
}

.p2 .played-cards-slot {
    position: absolute;
    right: -170px;
    top: 50%;
    transform: translateY(-50%);
}

.p3 .played-cards-slot {
    position: absolute;
    bottom: -120px;
    left: 50%;
    transform: translateX(-50%);
}

.p4 .played-cards-slot {
    position: absolute;
    left: -170px;
    top: 50%;
    transform: translateY(-50%);
}

.slot-pass {
    color: #ef4444;
    font-weight: 800;
    font-size: 24px;
    letter-spacing: 2px;
    text-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}

.slot-card {
    width: 60px !important;
    height: 85px !important;
    margin-right: -30px !important;
    font-size: 0.9em;
    cursor: default !important;
}

#status-message {
    font-size: 18px;
    font-weight: 500;
    color: #e2e8f0;
    background: rgba(0, 0, 0, 0.3);
    padding: 8px 20px;
    border-radius: 20px;
}

/* Human Hand */
#human-area {
    flex-direction: row;
    justify-content: center;
    align-items: center;
    padding: 20px;
    gap: 40px;
}

.hand {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: -30px;
    /* Overlap cards */
}

/* Card Style */
.card {
    width: 70px;
    height: 100px;
    background: white;
    border-radius: 8px;
    color: #1a1a1a;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    /* Ensure rank/suit are on the left */
    padding: 5px;
    position: relative;
    cursor: pointer;
    transition: transform 0.2s ease, margin 0.2s ease;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    user-select: none;
    margin-right: -30px;
    /* Card overlap */
}

.revealed-card {
    transform: scale(0.7);
    margin-right: -45px !important;
    cursor: default !important;
}

.revealed-card:hover {
    transform: scale(0.7) !important;
    /* Disable lift effect on reveal */
}

.card:last-child {
    margin-right: 0;
}

.card:hover {
    transform: translateY(-15px);
}

.card.selected {
    transform: translateY(-30px);
    border: 2px solid var(--primary-color);
    z-index: 10;
}

.card.red {
    color: #ef4444;
}

.card.black {
    color: #1a1a1a;
}

.card .rank {
    font-size: 20px;
    font-weight: bold;
    line-height: 1.2;
}

.card .suit {
    font-size: 22px;
    line-height: 1;
}

/* Buttons */
#controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.premium-btn {
    padding: 10px 24px;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.premium-btn:active {
    transform: scale(0.95);
}

#btn-play {
    background: var(--accent-color);
    color: white;
}

#btn-play:hover {
    background: #059669;
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.4);
}

#btn-pass {
    background: #475569;
    color: white;
}

.ghost {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: #94a3b8;
}

.ghost:hover {
    border-color: var(--primary-color);
    color: white;
}

/* AI card back */
.premium-btn.highlight {
    background: #f59e0b;
    color: white;
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.4);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

.hidden {
    display: none !important;
}

/* Shouted State */
.shouted-name {
    color: #ef4444 !important;
    animation: blink 1s infinite;
}

@keyframes blink {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

.llm-glow {
    box-shadow: 0 0 15px #9b59b6, inset 0 0 10px #9b59b6;
    border: 2px solid #9b59b6;
    animation: llmPulse 2s infinite ease-in-out;
}

@keyframes llmPulse {
    0% {
        box-shadow: 0 0 5px #9b59b6;
    }

    50% {
        box-shadow: 0 0 20px #9b59b6, 0 0 30px rgba(155, 89, 182, 0.4);
    }

    100% {
        box-shadow: 0 0 5px #9b59b6;
    }
}

.alert-content {

    text-align: center;
    max-width: 400px;
}

.alert-content p {
    font-size: 18px;
    margin-bottom: 25px;
    color: white;
}

#alert-ok {
    margin: 0 auto;
    display: block;
    width: 100px;
}

.confirm-content {
    text-align: center;
    max-width: 400px;
}

.confirm-content p {
    font-size: 18px;
    margin-bottom: 25px;
    color: white;
}

.confirm-btns {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.confirm-btns button {
    width: 100px;
}

/* Pass Indicator */
.pass-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(239, 68, 68, 0.9);
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-weight: 800;
    font-size: 14px;
    z-index: 100;
    pointer-events: none;
    animation: fadeUp 1s forwards;
    letter-spacing: 1px;
}

@keyframes fadeUp {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0;
    }

    20% {
        transform: translate(-50%, -80%) scale(1.2);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -120%) scale(1);
        opacity: 0;
    }
}

/* Speech Bubble Effects */
.speech-bubble {
    position: absolute;
    background: white;
    color: #1e293b;
    padding: 10px 20px;
    border-radius: 16px;
    font-weight: 800;
    font-size: 18px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    z-index: 500;
    pointer-events: none;
    --x-offset: 0px;
    transform: translateX(var(--x-offset));
    animation: bubblePop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 2px solid var(--primary-color);
    min-width: 200px;
    max-width: min(400px, 35vw);
    width: max-content;
    white-space: normal;
    word-break: break-word;
    line-height: 1.4;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.player:has(.speech-bubble:not(.hidden)) {
    z-index: 150;
}

.speech-bubble.short-bubble {
    min-width: unset;
    max-width: unset;
    width: auto;
    white-space: nowrap;
}

.speech-bubble.shrunk-bubble {
    min-width: unset;
    max-width: unset;
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    cursor: pointer;
    font-size: 18px;
}

.speech-bubble.shrunk-bubble::after {
    display: none !important;
}

.speech-bubble.hover-expanded {
    pointer-events: auto;
    cursor: pointer;
}

.speech-bubble::after {
    content: '';
    position: absolute;
    border: 10px solid transparent;
}

/* Positioning and Arrows for different players */
.p1 .speech-bubble {
    bottom: calc(100% + 15px);
    left: 10px;
}

.p1 .speech-bubble::after {
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    border-top-color: white;
}

.p2 .speech-bubble {
    top: 10px;
    left: calc(100% + 15px);
}

.p2 .speech-bubble::after {
    left: -10px;
    top: 50%;
    transform: translateY(-50%);
    border-right-color: white;
}

.p3 .speech-bubble {
    top: 10px;
    left: calc(100% + 15px);
}

.p3 .speech-bubble::after {
    left: -10px;
    top: 50%;
    transform: translateY(-50%);
    border-right-color: white;
}

.p4 .speech-bubble {
    top: 10px;
    right: calc(100% + 15px);
}

.p4 .speech-bubble::after {
    right: -10px;
    top: 50%;
    transform: translateY(-50%);
    border-left-color: white;
}

@keyframes bubblePop {
    0% {
        transform: translateX(var(--x-offset)) scale(0.5) translateY(20px);
        opacity: 0;
    }

    100% {
        transform: translateX(var(--x-offset)) scale(1) translateY(0);
        opacity: 1;
    }
}


/* Screen Shake Effect */
.shake {
    animation: shake 0.5s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes shake {

    10%,
    90% {
        transform: translate3d(-1px, 0, 0);
    }

    20%,
    80% {
        transform: translate3d(2px, 0, 0);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-4px, 0, 0);
    }

    40%,
    60% {
        transform: translate3d(4px, 0, 0);
    }
}

/* Settings Icon */
.settings-icon {
    position: absolute;
    top: -5px;
    right: -5px;
    background: rgba(0, 0, 0, 0.4);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s;
    border: 1px solid rgba(155, 89, 182, 0.5);
    z-index: 50;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.settings-icon:hover {
    background: var(--primary-color);
    transform: rotate(90deg);
}

/* Enhanced Settings Modal */
.settings-content {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid rgba(155, 89, 182, 0.3);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(155, 89, 182, 0.1);
    min-width: 450px;
    padding: 35px;
}

.settings-content h2 {
    text-align: center;
    color: #9b59b6;
    text-shadow: 0 0 10px rgba(155, 89, 182, 0.5);
    margin-bottom: 30px;
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    display: block;
    color: #94a3b8;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 10px;
    color: white;
    font-size: 14px;
    outline: none;
}

.form-group select option {
    background-color: #1e293b;
    color: white;
}

#ai-extra-prompt {
    min-height: 70px;
    line-height: 1.4;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #9b59b6;
    box-shadow: 0 0 10px rgba(155, 89, 182, 0.3);
}

.settings-btns {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    margin-top: 25px;
}

.settings-btns button {
    min-width: 100px;
}

#ai-settings-save {
    background: #9b59b6;
    box-shadow: 0 4px 12px rgba(155, 89, 182, 0.3);
}

#ai-settings-save:hover {
    background: #8e44ad;
    box-shadow: 0 4px 20px rgba(155, 89, 182, 0.5);
}

.premium-btn.secondary {
    background: #334155;
    color: #cbd5e1;
}

.premium-btn.secondary:hover {
    background: #475569;
    color: white;
}


.learnings-list {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 10px;
    max-height: 250px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.learning-item {
    font-size: 13px;
    color: #10b981;
    background: rgba(16, 185, 129, 0.1);
    padding: 10px 12px;
    border-radius: 6px;
    border-left: 3px solid #10b981;
    line-height: 1.4;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.learning-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 2px;
}

.badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 800;
    text-transform: uppercase;
}

.badge.p0 {
    background: #ef4444;
    color: white;
}

.badge.p1 {
    background: #3b82f6;
    color: white;
}

.badge.p2 {
    background: #475569;
    color: white;
}

.count-badge {
    font-size: 10px;
    color: #94a3b8;
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 5px;
    border-radius: 4px;
}

.learning-text {
    word-break: break-word;
}

.learning-empty {
    color: #64748b;
    font-size: 13px;
    font-style: italic;
    text-align: center;
    padding: 10px;
}

.label-with-action {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.action-btns {
    display: flex;
    gap: 12px;
}

.text-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.text-btn:hover {
    opacity: 1;
}

.modal-footer {
    margin-top: 25px;
    padding-top: 15px;
    border-top: 1px solid var(--glass-border);
    text-align: right;
}

.version-text {
    font-size: 11px;
    color: #64748b;
    font-family: monospace;
}

.api-error-text {
    color: #ff0000; /* Pure red */
    margin-left: 10px;
    font-weight: 900;
    font-size: 12px;
    text-shadow: 0 0 8px rgba(255, 0, 0, 0.6);
    letter-spacing: 1px;
    animation: blink-red 1s infinite alternate;
}

@keyframes blink-red {
    from { opacity: 0.4; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* Keyboard Hints */
.kbd-hint {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 12px;
    margin-right: 8px;
    font-family: monospace;
    font-weight: 800;
    color: #ffffff;
    vertical-align: middle;
    text-transform: none;
    letter-spacing: 0;
    box-shadow: 0 0 5px rgba(0,0,0,0.5);
    border-color: rgba(255, 255, 255, 0.5);
}

#btn-play:hover .kbd-hint,
#btn-pass:hover .kbd-hint {
    border-color: rgba(255, 255, 255, 0.5);
    color: white;
}

#keyboard-legend {
    display: none; /* Removed from main screen */
}

/* Modal Tabs */
.modal-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 10px;
}

.tab-btn {
    background: transparent;
    border: 1px solid transparent;
    color: #94a3b8;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.info-modal-content {
    max-width: 650px; /* Slightly wider for tabs */
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.info-modal-content .tab-content.active {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    padding-right: 8px; /* Extra spacing for scrollbar */
}

.keyboard-sections {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 10px 0;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 15px;
    color: #cbd5e1;
}

.key {
    background: #1e293b;
    border: 1px solid #475569;
    border-bottom: 3px solid #475569;
    border-radius: 4px;
    padding: 3px 10px;
    font-family: monospace;
    font-weight: 700;
    color: #f8fafc;
    min-width: 32px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.key.space-key {
    min-width: 45px;
    height: 20px;
    position: relative;
    padding: 0;
}

.key.enter-key {
    min-width: 45px;
    height: 25px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    box-sizing: border-box;
}

.enter-svg {
    display: inline-block;
    vertical-align: middle;
    height: 12px;
}

.key.space-key::after,
.kbd-hint.space-key::after {
    display: none;
}

.kbd-hint.space-key {
    min-width: 30px;
    height: 16px;
    padding: 0;
    margin-right: 8px;
    display: inline-flex;
    vertical-align: middle;
}

.kbd-hint.space-key.small::after {
    bottom: 4px;
    height: 6px;
}

.legend-item [data-i18n] {
    font-weight: 500;
}

/* License & Sponsor Tab Styling */
.license-sponsor-section {
    padding: 10px 0;
}

.license-text {
    margin: 0;
    font-size: 15px;
    line-height: 1.8;
    color: #cbd5e1;
}

.rules-link {
    color: #a855f7;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s, text-shadow 0.2s;
    border-bottom: 1px dashed rgba(168, 85, 247, 0.4);
    padding-bottom: 1px;
}

.rules-link:hover {
    color: #d8b4fe;
    text-shadow: 0 0 8px rgba(168, 85, 247, 0.5);
    border-bottom-color: #d8b4fe;
}

/* ==========================================
   📱 MOBILE ERGONOMIC VERTICAL STACK LAYOUT
   ========================================== */
.mobile-layout .modal-content {
    padding: 20px;
    border-radius: 14px;
}

.mobile-layout .modal-content h2 {
    margin-bottom: 10px;
}

.mobile-layout .rules-footer {
    margin-top: 15px;
    padding-top: 10px;
}

.mobile-layout #game-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: calc(75px + env(safe-area-inset-top, 0px)) 
             calc(15px + env(safe-area-inset-right, 0px)) 
             calc(15px + env(safe-area-inset-bottom, 0px)) 
             calc(15px + env(safe-area-inset-left, 0px));
    gap: 12px;
    justify-content: flex-start;
    overflow: hidden;
}

/* Vertical Order Configuration */
.mobile-layout #player-2 { order: 1; } /* Alex (Top) */
.mobile-layout #player-3 { order: 2; } /* Bella (Middle-Top) */
.mobile-layout #player-4 { order: 3; } /* Diana (Middle-Bottom) */
.mobile-layout #human-area { order: 4; } /* You (Bottom) */
.mobile-layout #table-center { order: 5; } /* Status messages (Absolute Bottom) */

/* Horizontal Row Player Layouts for AI */
.mobile-layout .player.ai {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    padding: 8px 12px;
    gap: 12px;
    width: 100%;
    height: auto;
    position: relative;
    border-radius: 12px;
}

.mobile-layout .player.ai .avatar {
    width: 50px;
    height: 50px;
    font-size: 24px;
    flex-shrink: 0;
}

.mobile-layout .player.ai .info {
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 90px;
    flex-shrink: 0;
}

.mobile-layout .player.ai .name {
    font-size: 15px;
    white-space: nowrap;
}

.mobile-layout .player.ai .cards-count {
    font-size: 16px;
    margin-top: 0;
    min-height: auto;
    justify-content: flex-start;
}

/* Horizontal Row Played Cards Slot Override */
.mobile-layout .played-cards-slot {
    position: static !important;
    transform: none !important;
    flex: 1;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: -25px; /* Overlap slot cards slightly */
    min-height: 55px;
    min-width: 120px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    padding: 2px 6px;
    margin: 0 !important;
    border: 1px dashed rgba(255, 255, 255, 0.1);
}

/* Scale down played slot cards on mobile to prevent horizontal overflow */
.mobile-layout .slot-card {
    width: 42px !important;
    height: 60px !important;
    margin-right: -22px !important;
    font-size: 0.8em;
    padding: 4px;
    border-radius: 4px;
}

.mobile-layout .slot-pass {
    font-size: 16px;
    letter-spacing: 1px;
    padding-left: 8px;
}

/* Speech Bubbles Alignment on mobile (aligned safely to the far right) */
.mobile-layout .player .speech-bubble {
    position: absolute !important;
    top: 50% !important;
    right: 15px !important;
    left: auto !important;
    bottom: auto !important;
    transform: translateY(-50%) !important;
    animation: bubblePop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
    z-index: 1000 !important;
    font-size: 15px;
    padding: 6px 12px;
    border-radius: 12px;
}

.mobile-layout .player .speech-bubble::after {
    display: none !important; /* Hide arrows on mobile to keep it clean */
}

/* Ergonomic Human Player CSS Grid Structure */
.mobile-layout #human-area {
    display: grid;
    grid-template-columns: auto auto 1fr;
    grid-template-rows: auto auto auto;
    gap: 8px;
    align-items: center;
    padding: 10px;
    border-radius: 14px;
    width: 100%;
}

.mobile-layout #human-area .avatar {
    grid-area: 1 / 1;
    width: 50px;
    height: 50px;
    font-size: 24px;
}

.mobile-layout #human-area .info {
    grid-area: 1 / 2;
    text-align: left;
}

.mobile-layout #human-area .name {
    font-size: 15px;
}

.mobile-layout #human-area .played-cards-slot {
    grid-area: 1 / 3;
}

/* Responsive Hand Overlaps to perfectly fit small screens */
.mobile-layout #human-area .hand {
    grid-area: 2 / 1 / 3 / 4;
    width: 100%;
    display: flex;
    justify-content: center;
    gap: -35px; /* Squeeze cards overlap for mobile */
    padding: 10px 0;
    min-height: 85px;
}

.mobile-layout #human-area .card {
    width: 52px !important;
    height: 75px !important;
    margin-right: -28px !important;
    padding: 4px;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.mobile-layout #human-area .card .rank {
    font-size: 15px;
}

.mobile-layout #human-area .card .suit {
    font-size: 16px;
}

/* Mobile lift distance adjustments */
.mobile-layout #human-area .card:not(.selected):hover {
    transform: none !important; /* Disable ghost hover lift on mobile screens */
}

.mobile-layout #human-area .card.selected {
    transform: translateY(-16px);
    border-width: 1.5px;
}

/* Touch-friendly Gameplay Action Buttons Bar */
.mobile-layout #controls {
    grid-area: 3 / 1 / 4 / 4;
    display: flex;
    flex-direction: row;
    justify-content: center;
    width: 100%;
    gap: 12px;
    margin-top: 2px;
}

.mobile-layout #controls .premium-btn {
    padding: 8px 16px;
    font-size: 14px;
    flex: 1;
    max-width: 150px;
    border-radius: 8px;
    height: 38px;
}

/* Hide Keyboard Keyboard Hints on Mobile */
.mobile-layout .kbd-hint {
    display: none !important;
}

/* Status Message置底面板 */
.mobile-layout #table-center {
    width: 100%;
    margin-top: auto;
    padding: 0;
    gap: 0;
}

.mobile-layout #status-message {
    font-size: 14px;
    padding: 6px 16px;
    border-radius: 12px;
    text-align: center;
    width: auto;
    max-width: 90%;
    margin: 0 auto;
}

/* Toggle Switch Component */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 22px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #334155;
    transition: .3s;
    border-radius: 22px;
    border: 1px solid var(--glass-border);
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: #cbd5e1;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

input:checked + .slider:before {
    transform: translateX(22px);
    background-color: white;
}
