:root {
    --primary: #1a73e8;
    --danger: #d93025;
    --success: #188038;
    --bg: #f8f9fa;
    --card-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg);
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    color: #3c4043;
}

#game-container {
    width: 100%;
    max-width: 1000px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#battle-arena {
    display: flex;
    gap: 20px;
    width: 100%;
    align-items: stretch;
}

/* Enemy Section */
#enemy-section {
    flex: 0 0 250px;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: white;
    padding: 15px;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
}

.card-display {
    width: 130px;
    height: 190px;
    border: 3px solid #dadce0;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: 5px;
    background: #fff;
    box-shadow: 0 8px 15px rgba(0,0,0,0.1);
}

#enemy-suit-icon {
    font-size: 3.5rem;
}

#enemy-hp-bar {
    width: 100%;
    height: 15px;
    background: #e8eaed;
    border-radius: 10px;
    margin-top: 10px;
    overflow: hidden;
    border: 1px solid #ccc;
}

#enemy-hp-fill {
    width: 100%;
    height: 100%;
    background: var(--danger);
    transition: width 0.3s ease;
}

#enemy-hp-text {
    font-size: 1.1rem;
    font-weight: bold;
    margin-top: 3px;
}

/* Table Section */
#table-section {
    flex: 1;
    min-height: 200px;
    background: #fff;
    border: 3px dashed #dadce0;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding: 15px;
    gap: 10px;
}

#table-label {
    font-weight: bold;
    color: #70757a;
    font-size: 0.9rem;
}

#cards-on-table {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

/* Bottom Area (Player Hand + Side Column) */
#bottom-area {
    display: flex;
    gap: 15px;
    align-items: stretch;
}

#player-section {
    flex: 1;
    background: white;
    padding: 20px;
    border-radius: 15px;
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#event-log {
    height: 100px;
    overflow-y: auto;
    background: #202124;
    color: #e8eaed;
    padding: 12px;
    border-radius: 10px;
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-family: 'Consolas', monospace;
    position: relative;
    z-index: 1;
}

.log-entry {
    border-left: 4px solid var(--primary);
    padding-left: 10px;
    animation: slideIn 0.3s ease-out;
}

.log-entry.suit-heart { border-color: #ea4335; }
.log-entry.suit-diamond { border-color: #fbbc04; }
.log-entry.suit-club { border-color: #34a853; }
.log-entry.suit-spade { border-color: #4285f4; }
.log-entry.enemy-action { border-color: var(--danger); font-weight: bold; }

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

#player-hand {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    overflow: visible;
    padding: 10px 0;
    justify-content: center;
    min-height: 150px;
    position: relative;
    z-index: 100;
}

.hand-card {
    width: 85px;
    height: 120px;
    border: 2px solid #dadce0;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: white;
    user-select: none;
    position: relative;
    z-index: 101;
}

.card-suit {
    font-size: 2rem;
}

.card-value {
    font-size: 1.2rem;
    font-weight: bold;
}

/* Colori semi */
.hand-card.hearts .card-suit, .hand-card.hearts .card-value { color: #d93025; }
.hand-card.diamonds .card-suit, .hand-card.diamonds .card-value { color: #f9ab00; }
.hand-card.clubs .card-suit, .hand-card.clubs .card-value { color: #188038; }
.hand-card.spades .card-suit, .hand-card.spades .card-value { color: #1a73e8; }

.hand-card.selected {
    border-color: var(--primary);
    border-width: 4px;
    transform: translateY(-20px);
    box-shadow: 0 10px 20px rgba(26,115,232,0.3);
    z-index: 105;
}

/* Tooltip Styles */
.card-tooltip {
    position: absolute;
    bottom: 115%;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: #202124;
    color: white;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: bold;
    width: 240px;
    text-align: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease-out;
    pointer-events: none;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    border: 3px solid var(--primary);
    line-height: 1.4;
}

.card-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 10px solid transparent;
    border-top-color: var(--primary);
}

.hand-card:hover .card-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Controls */
#controls {
    display: flex;
    gap: 15px;
    justify-content: center;
}

button {
    padding: 15px 30px;
    font-size: 1.1rem;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

#btn-play { background: var(--primary); color: white; }
#btn-play:disabled { background: #dadce0; cursor: not-allowed; }
#btn-yield { background: #f1f3f4; color: #3c4043; }

/* Deck Info */
#deck-info {
    display: flex;
    justify-content: space-around;
    font-size: 1.1rem;
    color: #70757a;
    font-weight: bold;
}

.back-home {
    text-align: center;
    text-decoration: none;
    color: var(--primary);
    font-weight: bold;
    font-size: 1.1rem;
}

/* Phase Popups */
.phase-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.5);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 40px 80px;
    border-radius: 25px;
    font-size: 3rem;
    font-weight: bold;
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-align: center;
    box-shadow: 0 15px 40px rgba(0,0,0,0.6);
    border: 4px solid var(--primary);
}

.phase-popup.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.phase-popup.enemy { border-color: var(--danger); }
.phase-popup.victory { border-color: var(--success); }

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.modal-overlay.show {
    display: flex;
}

#modal-content {
    background: var(--bg);
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    border-radius: 20px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}

#modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #dadce0;
    padding-bottom: 15px;
    margin-bottom: 15px;
}

#modal-title {
    margin: 0;
    font-size: 1.5rem;
}

#modal-close {
    background: none;
    border: none;
    font-size: 2.5rem;
    cursor: pointer;
    color: #70757a;
    padding: 0;
    line-height: 1;
}

#modal-body {
    overflow-y: auto;
    flex: 1;
}

#deck-viewer-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    padding: 10px;
}

#deck-viewer-grid .hand-card {
    cursor: default;
}

#deck-info > div {
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 5px;
    transition: background 0.2s;
}

/* Solo Jesters Area (Side Column) */
#solo-jesters-area {
    width: 100px;
    background: white;
    padding: 15px 10px;
    border-radius: 15px;
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.solo-jester-label {
    font-size: 0.8rem;
    font-weight: bold;
    color: #5f6368;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
}

#solo-jesters-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.solo-jester-card {
    width: 60px;
    height: 85px;
    background: white;
    border: 2px solid #dadce0;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.5rem;
    transition: all 0.2s;
    position: relative;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.solo-jester-card:hover:not(.consumed) {
    border-color: var(--primary);
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(26,115,232,0.2);
}

.solo-jester-card.consumed {
    background: #e8eaed;
    border-color: #bdc1c6;
    color: #9aa0a6;
    cursor: not-allowed;
    opacity: 0.6;
}

.solo-jester-card.consumed::after {
    content: '✖';
    position: absolute;
    font-size: 2.5rem;
    color: rgba(217, 48, 37, 0.4);
}

/* Modal for Jester Choice */
.jester-choice-container {
    display: flex;
    gap: 20px;
    padding: 20px;
    justify-content: center;
}

.jester-choice-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 20px;
    background: white;
    border: 2px solid #dadce0;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.2s;
    flex: 1;
    max-width: 250px;
    text-align: center;
}

.jester-choice-btn:hover {
    border-color: var(--primary);
    background: #e8f0fe;
    transform: scale(1.05);
}

.jester-choice-icon {
    font-size: 3rem;
}

.jester-choice-title {
    font-weight: bold;
    font-size: 1.2rem;
}

.jester-choice-desc {
    font-size: 0.9rem;
    color: #70757a;
}
