body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #2c3e50;
    color: white;
    text-align: center;
    margin: 0;
    padding: 10px;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.game-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.game-selector {
    margin-bottom: 10px;
}

.table {
    background-color: #27ae60;
    border: 8px solid #8e44ad;
    border-radius: 20px;
    width: 90%;
    max-width: 800px;
    height: 600px; /* Fixed height for layout stability */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px;
    position: relative;
    box-sizing: border-box;
}

.hand {
    height: 130px;
    display: flex;
    justify-content: center;
    gap: 10px;
}

.play-area {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px dashed rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    margin: 20px 0;
    position: relative;
    min-height: 200px;
    transition: background-color 0.3s, border-color 0.3s;
}

.play-area.drag-over {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
}

#trick-area {
    display: flex;
    gap: 20px;
}

/* Stack Briscola and Deck */
#briscola-area {
    position: absolute;
    right: 50px;
    top: 50%;
    transform: translateY(-50%) rotate(90deg); /* Rotate the whole area */
    z-index: 5;
    width: 70px;
    height: 120px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.briscola-display {
    /* No additional transform needed if container is rotated */
    box-shadow: 2px 0 5px rgba(0,0,0,0.3);
}

#deck-area {
    position: absolute;
    right: 80px; /* Offset more to the left than briscola to show it underneath */
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 70px;
    height: 120px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: transparent;
}

.deck-stack {
    box-shadow: -2px 2px 5px rgba(0,0,0,0.4);
}

.briscola-info {
    font-size: 24px;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 1px 1px 2px black;
    transform: rotate(-90deg); /* Counter rotate text if needed */
}

.card-container {
    width: 70px; /* Adjusted for aspect ratio ~0.58 (96/165) */
    height: 120px;
    margin: 0 5px;
    border-radius: 5px;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.3);
    transition: transform 0.2s;
    background-color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    /* Ensure user interaction */
    user-select: none;
}

.card-img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Prevents stretching */
    display: block;
}

.card-container:hover {
    transform: translateY(-10px);
    cursor: pointer;
}

.card-container.disabled {
    opacity: 0.7;
    cursor: not-allowed;
}
.card-container.disabled:hover {
    transform: none;
}

.deck-counter {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-weight: bold;
    font-size: 20px;
    text-shadow: 1px 1px 2px black;
    pointer-events: none;
}

/* Fallback / Old Styles for reference or other games */
.card {
    background-color: white;
    color: black;
    border-radius: 8px;
    width: 80px;
    height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.3);
    border: 1px solid #ccc;
    user-select: none;
}

.star-icon {
    position: absolute;
    top: -15px;
    right: -15px;
    background: #f1c40f;
    color: #2c3e50;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    font-weight: bold;
    box-shadow: 0 0 10px rgba(241, 196, 15, 0.8);
    z-index: 10;
    transform: rotate(-90deg);
}

.card-star {
    position: absolute;
    top: 5px;
    right: 5px;
    color: #f1c40f;
    font-size: 14px;
}

.log-panel {
    width: 90%;
    max-width: 800px;
    background: #34495e;
    border: 2px solid #2c3e50;
    border-radius: 10px;
    margin-top: 10px;
    padding: 10px;
    box-sizing: border-box;
    text-align: left;
    height: 150px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.log-panel h3 {
    margin: 0 0 5px 0;
    font-size: 14px;
    text-transform: uppercase;
    color: #95a5a6;
    border-bottom: 1px solid #7f8c8d;
    padding-bottom: 5px;
}

#log-content {
    flex: 1;
    overflow-y: auto;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 13px;
    color: #ecf0f1;
}

/* Custom scrollbar for webkit */
#log-content::-webkit-scrollbar {
    width: 8px;
}
#log-content::-webkit-scrollbar-track {
    background: #2c3e50; 
}
#log-content::-webkit-scrollbar-thumb {
    background: #7f8c8d; 
    border-radius: 4px;
}
#log-content::-webkit-scrollbar-thumb:hover {
    background: #95a5a6; 
}

.log-entry {
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding: 2px 0;
    line-height: 1.4;
}

.log-entry:last-child {
    border-bottom: none;
    font-weight: bold;
    color: #fff;
}

/* ... existing styles ... */

/* Screen Shake Effects */
@keyframes shake-low {
    0% { transform: translate(0, 0); }
    25% { transform: translate(-5px, 0); }
    50% { transform: translate(5px, 0); }
    75% { transform: translate(-5px, 0); }
    100% { transform: translate(0, 0); }
}

@keyframes shake-medium {
    0% { transform: translate(0, 0); }
    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); }
}

@keyframes shake-high {
    0% { transform: translate(0, 0) rotate(0deg); }
    10% { transform: translate(-10px, -10px) rotate(-5deg); }
    20% { transform: translate(10px, 10px) rotate(5deg); }
    30% { transform: translate(-10px, 10px) rotate(-5deg); }
    40% { transform: translate(10px, -10px) rotate(5deg); }
    50% { transform: translate(-10px, -10px) rotate(-5deg); }
    60% { transform: translate(10px, 10px) rotate(5deg); }
    70% { transform: translate(-10px, 10px) rotate(-5deg); }
    80% { transform: translate(10px, -10px) rotate(5deg); }
    90% { transform: translate(0, 0) rotate(0); }
    100% { transform: translate(0, 0) rotate(0); }
}

.shake-effect-low {
    animation: shake-low 0.4s cubic-bezier(.36,.07,.19,.97) both;
}

.shake-effect-medium {
    animation: shake-medium 0.6s cubic-bezier(.36,.07,.19,.97) both;
}

.shake-effect-high {
    animation: shake-high 0.8s cubic-bezier(.36,.07,.19,.97) both;
    border-color: #e74c3c !important; /* Red border flash */
    box-shadow: 0 0 20px #e74c3c;
}

/* Tennis Cards */
.tennis-card {
    background: #fff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    border: 2px solid #333;
    transition: transform 0.2s;
    color: #333; /* For emojis/text */
}

.tennis-card:hover:not(.disabled) {
    transform: translateY(-10px);
    cursor: pointer;
}

.table-card {
    border: 4px solid #f1c40f !important;
    width: 120px !important;
    height: 180px !important;
}

.is-match {
    box-shadow: 0 0 15px #2ecc71;
    border-color: #2ecc71;
    background: #e8f8f0;
}

.symbols {
    display: flex;
    gap: 10px;
}

.disabled {
    filter: grayscale(1);
    opacity: 0.7;
    cursor: not-allowed;
}

.card-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: bold;
    color: #ecf0f1;
}

.played-card-anim {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { transform: translateY(50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.action-cards {
    display: flex;
    gap: 20px;
    justify-content: center;
    width: 100%;
}

.action-btn {
    width: 80px;
    height: 120px;
    background: #f1c40f;
    border: 3px solid #d4ac0d;
    border-radius: 10px;
    font-size: 40px;
    font-weight: bold;
    color: #2c3e50;
    cursor: pointer;
    box-shadow: 0 6px #b7950b;
    transition: transform 0.1s, box-shadow 0.1s;
}

.action-btn:hover:not(:disabled) {
    background: #f4d03f;
    transform: translateY(-5px);
}

.action-btn:active:not(:disabled) {
    transform: translateY(2px);
    box-shadow: 0 2px #b7950b;
}

.action-btn:disabled {
    background: #bdc3c7;
    border-color: #95a5a6;
    box-shadow: 0 4px #7f8c8d;
    cursor: not-allowed;
    opacity: 0.6;
}

.deck-info {
    font-weight: bold;
    background: rgba(0,0,0,0.3);
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 14px;
}

.deck-info-bottom {
    margin-top: 10px;
    font-weight: bold;
    color: #bdc3c7;
    font-size: 14px;
}

.fatigue-active-banner {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    border: 3px solid #f1c40f;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 0 15px rgba(231, 76, 60, 0.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 140px;
    animation: fatiguePulse 1.5s infinite alternate ease-in-out;
}

.fatigue-title {
    font-size: 16px;
    font-weight: 900;
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    margin-bottom: 5px;
}

.fatigue-desc {
    font-size: 13px;
    font-weight: bold;
    color: #ffd700;
    text-align: center;
}

@keyframes fatiguePulse {
    from { transform: scale(1); box-shadow: 0 0 10px rgba(231, 76, 60, 0.4); }
    to { transform: scale(1.05); box-shadow: 0 0 25px rgba(231, 76, 60, 0.8); }
}

#tennis-play-btn {
    background-color: #27ae60;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    font-weight: bold;
    cursor: pointer;
    margin-left: 10px;
    box-shadow: 0 4px #219150;
}

#tennis-play-btn:active {
    box-shadow: 0 2px #219150;
    transform: translateY(2px);
}

#tennis-play-btn:hover {
    background-color: #2ecc71;
}
