:root {
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --text-color: #ffffff;
    --accent: #bb86fc;
    --tier1: #4caf50;
    --tier2: #2196f3;
    --tier3: #ff9800;
    --tier4: #f44336;
    --secondary-btn: #333333;
}

* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Segoe UI', Roboto, Helvetica, sans-serif;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-bottom: env(safe-area-inset-bottom);
}

/*Utility Class*/
.hidden { display: none !important; }

/* --- OVERLAYS & MODALS (start screen & history) --- */
.overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 20px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal h1 { margin-bottom: 10px; font-size: 1.8rem; }
.modal p { margin-bottom: 20px; opacity: 0.7; font-size: 0.9rem; }

.input-group {
    text-align: left;
    margin-bottom: 15px;
}

.input-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--accent);
    margin-bottom: 5px;
    margin-left: 5px;
}

input[type="text"] {
    width: 100%;
    padding: 12px;
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 10px;
    color: white;
    font-size: 1rem;
    margin-bottom: 10px;
}

/* --- BUTTONS --- */
button {
    cursor: pointer;
    font-family: inherit;
    transition: transform 0.1s, background 0.2s;
}

button:active { transform: scale(0.96); }

.primary-btn {
    width: 100%;
    padding: 15px;
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: 12px;
    font-weight: bold;
    font-size: 1rem;
    margin-top: 10px;
}

.secondary-btn {
    width: 100%;
    padding: 12px;
    background: var(--secondary-btn);
    color: white;
    border: none;
    border-radius: 10px;
    margin-top: 10px;
}

/* --- GAME HEADER & SWIPE AREA --- */
.game-header {
    padding: 15px;
    background: var(--card-bg);
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    text-align: center;
}

.game-header h2 {
    font-size: 1rem;
    opacity: 0.6;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.swipe-area {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
    user-select: none;
}

.player-card {
    flex: 1;
    padding: 15px 10px;
    background: #252525;
    border-radius: 15px;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0.4;   /* quasi trasparente se non attivo */
}

/* Evidenziazione player 1 */
.player-card#p1-area.active {
    opacity: 1;
    background: #2d2438;
    border-color: var(--accent);
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(187, 134, 252, 0.4);
}

.player-card#p2-area.active {
    opacity: 1;
    background: #1a2733;
    border-color: var(--tier2);
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(33, 150, 243, 0.4);
}

.player-name { 
    font-size: clamp(0.9rem, 4vw, 1.1rem); 
    margin-bottom: 2px;
    font-weight: bold; 
}

.score { 
    font-size: clamp(2rem, 10vw, 3rem); 
    font-weight: bold; 
    line-height: 1;
}

.swipe-hint {
    font-size: 0.85rem; /* leggermente più grande per visibilità */
    transition: all 0.3s ease;
    min-height: 1.2rem; /* evita che il layout "salti" quando il testo cambia */
    margin-top: 5px;
    /* opacity: 0.4;
    font-style: italic; */
}

#last-action-msg strong {
    color: var(--accent);
}

/* --- PLATE GRID --- */
#plate-grid {
    flex: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: clamp(5px, 2vw, 10px);
    padding: 10px 15px;
}

.plate-btn {
    background: var(--card-bg);
    border: 2px solid transparent;
    border-radius: 15px;
    padding: 15px 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.plate-btn .flag { 
    font-size: clamp(1.5rem, 6vw, 2.2rem); 
    margin-bottom: 2px; 
}

.plate-btn .pts { font-weight: bold; font-size: 0.9rem; color: var(--accent) }
.plate-btn .plate-id {
    font-size: 0.7rem;
    font-weight: bold;
    opacity: 0.6;
    margin-top: 2px;
    text-transform: uppercase;
}

/* Border Tiers */
.btn-tier-1 { border-color: var(--tier1); }
.btn-tier-2 { border-color: var(--tier2); }
.btn-tier-3 { border-color: var(--tier3); }
.btn-tier-4 { border-color: var(--tier4); }

/* --- FOOTER CONTROLS --- */
.controls {
    display: flex;
    padding: 10px 15px;
    gap: 8px;
    background: var(--card-bg);
    flex-shrink: 0;
}

.controls button {
    flex: 1;
    padding: 12px 5px;
    border-radius: 10px;
    border: none;
    background: #333;
    color: white;
    font-size: clamp(0.7rem, 2.5vw, 0.9rem);
    white-space: nowrap;
}

#finish-btn { background: #b00020; }

/* --- HISTORY LOG LIST --- */
#history-list {
    max-height: 300px;
    overflow-y: auto;
    margin: 20px 0;
    text-align: left;
}

.history-item {
    padding: 10px;
    border-bottom: 1px solid #333;
    font-size: 0.9rem;
}

/* stili per la lista completa ricercabile */
.full-list-modal {
    width: 95%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

#searchable-list {
    flex: 1;
    overflow-y: auto;
    margin: 15px 0;
    border-top: 1px solid #333;
}

.search-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid #2a2a2a;
    cursor: pointer;
}

.search-item:active { background: #333; }

.search-item .flag { font-size: 1.5rem; margin-right: 15px; }
.search-item .name { flex: 1; text-align: left; font-size: 1rem; }
.search-item .pts { font-weight: bold; }

.pts-tier-1 { color: var(--tier1) !important; }
.pts-tier-2 { color: var(--tier2) !important; }
.pts-tier-3 { color: var(--tier3) !important; }
.pts-tier-4 { color: var(--tier4) !important; }

#country-search {
    background: #121212;
    border: 1px solid var(--accent);
    padding: 12px;
    border-radius: 10px;
    color: white;
    margin-bottom: 10px;
}

/* fix per la history */
.hist-header { display: flex; justify-content: space-between; font-size: 0.9rem; }
.hist-scores { font-size: 0.8rem; opacity: 0.7; margin-top: 4px; }

.winner-highlight {
    color: var(--accent);
    font-weight: bold;
    text-shadow: 0 0 5px rgba(187, 134, 252, 0.3);  /* un leggero bagliore */
}