/* Reusing existing imports + new ones from HTML linking, 
   but let's tidy up and apply the user's aesthetic requests */

/* 
 * FONTS 
 * Title/Numbers: 'Playfair Display', serif (Classy)
 * Text: 'Gowun Dodum', sans-serif (Clean Korean)
 */

:root {
    --bg-color: #0d0d0d;
    --player-a-color: #ff4444;
    --player-b-color: #44ff44;
    --text-color: #f0f0f0;
    --gold: #d4af37;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    background-image: url('bg.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    color: var(--text-color);
    font-family: 'Gowun Dodum', sans-serif; /* Default font */
    overflow: hidden;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.game-container {
    display: flex;
    justify-content: space-between;
    align-items: center; /* Centered Vertically */
    width: 95%;
    max-width: 1400px;
    height: 90vh;
    position: relative;
}

/*Game Title */
.main-title {
    position: absolute;
    top: -20px; /* Moved up above the container's top edge */
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
    font-size: 4rem;
    white-space: nowrap;
    z-index: 10;
    
    /* Default Korean Font */
    font-family: 'Do Hyeon', sans-serif;
    
    /* Color Adjustment: White for contrast */
    color: #ffffff;
    text-shadow: 
        3px 3px 0 #000, 
        -1px -1px 0 #000,  
        1px -1px 0 #000,
        -1px 1px 0 #000,
        1px 1px 0 #000,
        0 0 20px rgba(255, 215, 0, 0.8); /* Gold Glow */
    
    pointer-events: none; /* Let clicks pass through */
    transition: all 0.3s ease;
}

/* English Title Font */
.main-title.font-en {
    font-family: 'Orbitron', sans-serif; /* Math/Sci-fi feel */
    font-size: 2.8rem; /* Adjust for font size difference */
    letter-spacing: 2px;
}

/* --- Player Areas --- */
.player-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 250px;
    transition: all 0.5s ease;
}

.player-avatar {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.avatar-head {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    margin-bottom: 10px;
    box-shadow: 0 0 15px rgba(0,0,0,0.5);
    background-size: cover;
    background-position: center;
    border: 3px solid rgba(255,255,255,0.7);
    transition: all 0.3s;
}

.player-a .avatar-head {
    background-image: url('player_a.png');
    border-color: #ff8888;
}

.player-b .avatar-head {
    background-image: url('player_b.png');
    border-color: #88ff88;
}

.avatar-body {
    /* Name Tag */
    background: rgba(0, 0, 0, 0.7);
    padding: 5px 20px;
    border-radius: 20px;
    font-size: 1.2rem;
    font-weight: bold;
    color: white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.2);
}

/* Active Turn Highlight */
.player-area.active .avatar-head {
    transform: scale(1.1);
    box-shadow: 0 0 25px var(--gold);
    border-color: var(--gold);
}
.player-area.active {
    opacity: 1;
}
.player-area:not(.active) {
    opacity: 0.6;
    transform: scale(0.95);
}


/* --- Chips --- */
.chips-container {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.chip-count {
    font-family: 'Playfair Display', serif;
    font-size: 2.5rem;
    font-weight: bold;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

.player-a .chip-count { color: var(--player-a-color); }
.player-b .chip-count { color: var(--player-b-color); }

.chip-stack {
    display: flex;
    flex-direction: column-reverse; /* Stack upwards */
    gap: -5px; /* Slight overlap for realism */
    min-height: 60px;
}

.chip {
    width: 50px;
    height: 15px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.3);
    box-shadow: 0 3px 5px rgba(0,0,0,0.6);
    position: relative;
}

.red .chip { background: linear-gradient(to bottom, #ff5555, #cc0000); }
.green .chip { background: linear-gradient(to bottom, #55ff55, #009900); }
.yellow .chip { background: linear-gradient(to bottom, #ffd700, #b8860b); border-color: #ffeeb0; }

/* --- Board Area --- */
.board-area {
    flex-grow: 1;
    height: 100%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.plate-circle {
    width: 65vh; /* Reduced size to fit title */
    height: 65vh;
    max-width: 550px;
    max-height: 550px;
    position: relative;
    /* Maintain aspect ratio */
    min-width: 300px;
    min-height: 300px;
    
    /* Removed margin-top to center vertically with player areas */
    /* margin-top: 80px; */ 
}

/* --- Center Status Panel (New) --- */
.game-status {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 280px;
    height: 280px;
    border-radius: 50%;
    
    /* Aesthetics */
    background: rgba(0, 0, 0, 0.7); /* Dark semi-transparent */
    backdrop-filter: blur(5px);
    border: 2px solid var(--gold);
    box-shadow: 0 0 30px rgba(0,0,0,0.8);
    
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    z-index: 5;
    padding: 20px;
    box-sizing: border-box;
    gap: 8px; /* Use gap for even spacing */
}

.status-turn {
    font-size: 1.4rem;
    margin: 0; /* Remove margin for flex gap */
    font-weight: bold;
}
.status-main {
    font-size: 3rem; /* Timer or Big Number */
    font-family: 'Playfair Display', serif;
    color: var(--gold);
    margin: 0; /* Remove margin for flex gap */
    text-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
    line-height: 1.1;
}
.status-sub {
    font-size: 0.9rem;
    color: #ccc;
    line-height: 1.4;
    margin: 0;
}


/* --- Plates --- */
.plate-wrapper {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 80px;
    height: 80px;
    margin-left: -40px; /* Center offset */
    margin-top: -40px;
}

.plate {
    width: 70px;
    height: 70px;
    background: radial-gradient(circle at 30% 30%, #f0f0f0, #ccc);
    border-radius: 50%; /* Perfect circle from top view */
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    box-shadow: 0 10px 20px rgba(0,0,0,0.5); /* Drop shadow on table */
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 4px solid #fff; /* Rim */
}

.plate::before {
    /* Inner depression */
    content: '';
    position: absolute;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.2);
}

.plate:hover {
    transform: scale(1.1);
    box-shadow: 0 15px 30px rgba(0,0,0,0.6);
}

/* Lid / Closed State */
.plate.closed {
    /* Use a Cloche cover look? Or just dark? User wanted "put on plate and cover" */
    background: radial-gradient(circle at 30% 30%, #666, #333); /* Metallic dark cover */
    border-color: #444;
}
.plate.closed::before { box-shadow: none; } /* No depression on lid */

.plate.closed::after {
    /* Handle on top */
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    background: #222;
    border-radius: 50%;
    border: 2px solid #555;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.plate-lid-number {
    position: absolute;
    top: 50%;
    left: 50%;
    /* transform will be set by JS for radial positioning */
    font-family: 'Playfair Display', serif;
    font-size: 2rem; /* Increased size */
    font-weight: bold;
    color: #ffffff;
    text-shadow: 0 0 4px #000, 2px 2px 4px rgba(0,0,0,0.8); /* Strong shadow for visibility against wood */
    pointer-events: none;
    z-index: 20;
    white-space: nowrap;
}

/* Open State */
.plate.open {
    background: #fff;
    transform: scale(1.15);
    box-shadow: 0 0 25px rgba(255, 215, 0, 0.6);
    z-index: 10;
}
.plate-content {
    z-index: 2;
    font-family: 'Playfair Display', serif;
    font-size: 2rem;
    font-weight: bold;
    color: #333;
}

/* Selectable for Match */
.plate.selectable-match {
    animation: glowPulse 1.5s infinite alternate;
    border-color: #44ff44;
}

@keyframes glowPulse {
    from { box-shadow: 0 0 10px #44ff44; transform: scale(1.1); }
    to { box-shadow: 0 0 25px #44ff44; transform: scale(1.15); }
}

/* --- Chips Animation --- */
@keyframes placeChip {
    0% { transform: scale(2) translateY(-100px); opacity: 0; }
    50% { transform: scale(1.5) translateY(0); opacity: 1; }
    100% { transform: scale(1); }
}
.chip-placed { animation: placeChip 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275); }


/* --- Custom Modal --- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s;
}
.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: #1a1a1a;
    border: 1px solid var(--gold);
    width: 400px;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0,0,0,0.8);
    transform: translateY(0);
    transition: transform 0.3s;
}
.modal-overlay.hidden .modal-content {
    transform: translateY(20px);
}

.modal-content h2 {
    font-family: 'Playfair Display', serif;
    color: var(--gold);
    margin-top: 0;
    font-size: 2rem;
    margin-bottom: 20px;
}

.modal-content #modal-body {
    font-size: 1.1rem;
    line-height: 1.6;
    color: #ddd;
    margin-bottom: 30px;
    white-space: pre-line; /* Handle line breaks */
}

.modal-content button {
    background: transparent;
    border: 1px solid var(--gold);
    color: var(--gold);
    padding: 10px 40px;
    font-family: 'Gowun Dodum', sans-serif;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s;
    border-radius: 5px;
}
.modal-content button:hover {
    background: var(--gold);
    color: #000;
}

.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 15px; /* Space between buttons */
}

/* Cancel Button specific styles */
.modal-content button.cancel-btn {
    border-color: #ff4444;
    color: #ff4444;
}
.modal-content button.cancel-btn:hover {
    background: #ff4444;
    color: #fff;
}

/* Top Controls (Tutorial + Lang) */
.top-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    z-index: 100;
}

.control-btn {
    background: rgba(0,0,0,0.5);
    border: 1px solid var(--gold);
    color: var(--gold);
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-family: 'Gowun Dodum', sans-serif;
    font-weight: bold;
    transition: all 0.3s;
}

.control-btn:hover {
    background: var(--gold);
    color: #000;
}

/* English Font Class */
.font-en {
    font-family: 'Playfair Display', serif !important;
}

/* Tutorial Modal Specifics */
.tutorial-content {
    width: 600px;
    max-width: 90vw;
}

.tutorial-slide {
    display: none;
    flex-direction: column;
    align-items: center;
    animation: fadeIn 0.3s;
}
.tutorial-slide.active { display: flex; }

.tutorial-img {
    width: 100%;
    max-height: 300px;
    object-fit: contain;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    border: 1px solid #333;
}

.tutorial-text {
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 20px;
    color: #eee;
    text-align: left;
    width: 100%;
    background: rgba(255,255,255,0.05);
    padding: 15px;
    border-radius: 10px;
    box-sizing: border-box;
}
.tutorial-text h3 {
    color: var(--gold);
    margin-top: 0;
    font-family: 'Playfair Display', serif;
    border-bottom: 1px solid rgba(212, 175, 55, 0.3);
    padding-bottom: 5px;
}

.tut-ko {
    margin-bottom: 10px;
    font-weight: bold;
    color: #fff;
    border-bottom: 1px dashed #555;
    padding-bottom: 10px;
}

.tut-en {
    font-size: 0.95rem;
    color: #ccc;
    font-style: italic;
}

.tutorial-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    border-top: 1px solid #333;
    padding-top: 20px;
}

/* --- Mobile Support --- */

/* Portrait Warning */
.rotate-warning {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: #0d0d0d;
    z-index: 9999;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    text-align: center;
}

.warning-content h2 {
    color: var(--gold);
    font-family: 'Gowun Dodum', sans-serif;
    margin-bottom: 10px;
}

.warning-content p {
    color: #aaa;
    line-height: 1.5;
}

.phone-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    animation: rotatePhone 2s infinite ease-in-out;
}

@keyframes rotatePhone {
    0% { transform: rotate(0deg); }
    25% { transform: rotate(-90deg); }
    50% { transform: rotate(-90deg); }
    75% { transform: rotate(0deg); }
    100% { transform: rotate(0deg); }
}

@media screen and (orientation: portrait) {
    .rotate-warning {
        display: flex;
    }
    .game-container {
        display: none;
    }
}

/* Mobile Landscape Tweaks */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .main-title {
        font-size: 1.8rem;
        top: 0;
        width: 100%;
        text-align: center;
        pointer-events: none; /* Let clicks pass through if it overlaps */
        opacity: 0.8;
    }
    .top-controls {
        top: 10px;
        right: 10px;
    }
    .control-btn {
        padding: 5px 10px;
        font-size: 0.8rem;
    }
    .game-container {
        width: 100%;
        height: 100vh;
        padding: 0 20px;
        box-sizing: border-box;
    }
    .player-area {
        width: 120px;
    }
    .avatar-head {
        width: 60px;
        height: 60px;
    }
    .chip-count {
        font-size: 1.5rem;
    }
    .plate-wrapper {
        width: 60px;
        height: 60px;
        margin-left: -30px;
        margin-top: -30px;
    }
    .plate {
        width: 50px;
        height: 50px;
        border-width: 2px;
    }
    .plate-lid-number {
        font-size: 1.5rem;
        /* Adjust radial distance in JS if needed, but CSS scale might be easier */
    }
    .game-status {
        width: 180px;
        height: 180px;
    }
    .status-main {
        font-size: 2rem;
    }
}
