/* Global Styles */
:root {
    --bg-color: #0b0d17;
    --text-color: #e0e6ed;
    --accent-color: #ffd700;
    --planet-p1: #ff6b6b;
    --planet-p2: #4facfe;

    /* Dice Colors */
    --color-red: #ff4500;
    --color-orange: #FF4500;
    /* Changed to OrangeRed for better visibility against Yellow */
    --color-yellow: #ffd700;
    --color-white: #ffffff;
    --color-lightblue: #87ceeb;
    --color-blue: #0000cd;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Noto Sans KR', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow: hidden;
    /* Prevent scroll */
    user-select: none;
}

h1,
h2,
h3 {
    font-family: 'Orbit', sans-serif;
    margin: 0;
}

#game-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    position: relative;
    background: radial-gradient(circle at center, #1b2735 0%, #090a0f 100%);
}

/* Background Stars */
#stars-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    background-image:
        radial-gradient(white, rgba(255, 255, 255, .2) 2px, transparent 3px),
        radial-gradient(white, rgba(255, 255, 255, .15) 1px, transparent 2px),
        radial-gradient(white, rgba(255, 255, 255, .1) 2px, transparent 3px);
    background-size: 550px 550px, 350px 350px, 250px 250px;
    background-position: 0 0, 40px 60px, 130px 270px;
    animation: starMove 100s linear infinite;
    pointer-events: none;
}

@keyframes starMove {
    from {
        background-position: 0 0, 40px 60px, 130px 270px;
    }

    to {
        background-position: 550px 550px, 390px 410px, 680px 820px;
    }
}

/* Header */
header {
    z-index: 10;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    /* Added for absolute centering of turn info */
}

.subtitle {
    font-size: 0.6em;
    color: var(--accent-color);
}

#game-info {
    display: flex;
    gap: 15px;
    align-items: center;
}

/* Centered Turn Indicator */
#turn-indicator-container {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.2em;
    font-weight: bold;
    text-align: center;
}

.action-btn {
    padding: 10px 20px;
    font-size: 1.1em;
    font-weight: bold;
    font-family: 'Orbit', sans-serif;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    background: linear-gradient(45deg, #ff00cc, #333399);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 0, 204, 0.3);
    transition: transform 0.1s, box-shadow 0.1s;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 0, 204, 0.5);
}

.action-btn:active {
    transform: translateY(1px);
}

.secondary-btn {
    background: linear-gradient(45deg, #4facfe, #00f2fe);
    box-shadow: 0 4px 15px rgba(0, 242, 254, 0.3);
}

#dice-container {
    display: flex;
    gap: 15px;
    justify-content: center;
    /* Center Dice */
    margin-bottom: 20px;
}

.dice {
    width: 50px;
    height: 50px;
    background: #222;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
    border: 2px solid #555;
    transition: transform 0.5s ease-out;
}

/* Game Message Area */
#game-message {
    margin-top: 15px;
    min-height: 24px;
    color: #ffcc00;
    font-weight: bold;
    text-align: center;
    font-size: 1.1em;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.8);
    background: rgba(0, 0, 0, 0.3);
    padding: 8px 15px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    opacity: 0;
    transition: opacity 0.3s;
}

#game-message.visible {
    opacity: 1;
}

/* Main Layout */
main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    z-index: 5;
}

/* Player Planets */
.player-area {
    width: 250px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.planet {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    padding: 15px;
    height: 80%;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 2px solid rgba(255, 255, 255, 0.1);
    box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.5);
    transition: box-shadow 0.3s;
}

.p1-planet {
    border-color: var(--planet-p1);
}

.p2-planet {
    border-color: var(--planet-p2);
}

.current-turn-p1 .p1-planet {
    box-shadow: 0 0 30px var(--planet-p1);
    background: rgba(255, 107, 107, 0.1);
}

.current-turn-p2 .p2-planet {
    box-shadow: 0 0 30px var(--planet-p2);
    background: rgba(79, 172, 254, 0.1);
}

.collected-penguins {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 15px;
    justify-content: center;
    overflow-y: auto;
    max-height: 400px;
    width: 100%;
}

/* Central Game Zone */
#central-zone {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    /* Evenly distribute top, controls, bottom */
    align-items: center;
    height: 100%;
    margin: 0 10px;
}

/* Fairy Clusters */
.fairy-cluster {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    width: 100%;
    max-width: 900px;
    /* Constrain width to keep them grouped */
    padding: 10px;
    background: rgba(255, 255, 255, 0.02);
    /* Slight background to see the zone */
    border-radius: 15px;
}

/* Star Fairy Item (Formerly Penguin) */
.star-fairy {
    width: 60px;
    height: 60px;
    /* Circular aspect */
    background: rgba(255, 255, 255, 0.1);
    /* Subtle background */
    border-radius: 50%;
    position: relative;
    cursor: pointer;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.5s, box-shadow 0.3s;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.star-fairy::before {
    content: '🧚';
    /* Fairy icon */
    font-size: 30px;
    z-index: 2;
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.5));
}

.star-fairy::after {
    /* The Hidden Star */
    content: '⭐';
    font-size: 0px;
    /* Hidden by default */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: font-size 0.3s;
    z-index: 1;
}

.star-fairy:hover {
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.2);
}

.star-fairy.collected {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 0.8em;
    cursor: default;
    /* Show colored star when collected */
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

.star-fairy.collected::before {
    content: '★';
    /* Star Symbol */
    font-size: 30px;
    color: var(--star-color);
    text-shadow: 0 0 10px var(--star-color);
    filter: brightness(1.5);
    z-index: 10;
}

/* IMPORTANT: Override the emoji star color if we want specific colors. 
   Emoji stars are usually yellow. To tint them or use colored divs:
   We can make ::before be a colored circle or use text-shadow. 
   For now, we will rely on the JS setting a --star-color variable and maybe using a colored block or icon.
   Actually, let's keep it simple: When collected, show the star. Use CSS filter to tint if possible, or just the glow.
*/

/* Revealed State */
.star-fairy.revealed {
    transform: scale(1.1);
    box-shadow: 0 0 30px var(--star-color);
    /* Glow with the specific color */
    background: rgba(255, 255, 255, 0.1);
}

.star-fairy.revealed::before {
    opacity: 0;
    /* Hide fairy */
}

.star-fairy.revealed::after {
    font-size: 35px;
    /* Show Star */
    color: transparent;
    text-shadow: 0 0 0 var(--star-color);
    /* Trick to color the emoji if supported, or just rely on the glow */
}

/* Better approach for colored stars: 
   The '⭐' emoji is always yellow. 
   We can use a colored div circle instead.
*/
.star-fairy.revealed::after {
    content: '';
    width: 30px;
    height: 30px;
    background-color: var(--star-color);
    border-radius: 50%;
    box-shadow: 0 0 20px var(--star-color);
    font-size: 0;
    /* Reset font size for shape */
}

/* Peek Mode Highlight */
.star-fairy.peek-highlight {
    border: 2px dashed var(--accent-color);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(255, 215, 0, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(255, 215, 0, 0);
    }
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.hidden {
    display: none !important;
}

.modal-content {
    background: #1e1e2f;
    padding: 30px;
    border-radius: 20px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
}

.victory-content {
    background: linear-gradient(135deg, #1e1e2f, #3a1c71);
}

#quiz-options button {
    display: block;
    width: 100%;
    padding: 10px;
    margin: 10px 0;
    border: none;
    border-radius: 10px;
    background: #2d2d44;
    color: white;
    cursor: pointer;
    transition: background 0.2s;
}

#quiz-options button:hover {
    background: #4facfe;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}