* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f0f2f5;
    color: #333;
    line-height: 1.6;
}

#game {
    max-width: 600px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    gap: 1rem;
    position: relative;
}

#player-info {
    background: white;
    padding: 1rem;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

#player-emoji {
    font-size: 1.5rem;
}

#player-name {
    font-weight: bold;
    flex-grow: 1;
}

#player-class {
    color: #666;
    text-transform: capitalize;
    margin-right: 3rem; /* Added margin to move class name left */
}

.player-stats {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

#player-emoji-stats {
    font-size: 1.5rem;
    margin-right: 0.5rem;
}

#player-name-stats {
    font-weight: bold;
}

#player-class-stats {
    text-transform: capitalize;
    color: #666;
}

#stats-button {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.5rem;
    cursor: pointer;
    background: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 100;
    transition: transform 0.3s ease;
}

#stats-button:hover {
    transform: scale(1.1);
}

#game-panel {
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

#game-panel.flipped {
    transform: rotateY(180deg);
}

.panel-content {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.panel-content.back {
    transform: rotateY(180deg);
    background: white;
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.panel-content.front {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#stats-bar {
    background: white;
    padding: 1rem;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.stat {
    font-size: 1.1rem;
    font-weight: 500;
}

#game-area {
    flex-grow: 1;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    position: relative;
    min-height: 300px;
}

#encounter-display {
    width: 100%;
}

#encounter-emoji {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: bounce 0.5s ease;
}

#encounter-text {
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

#countdown {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 4rem;
    font-weight: bold;
    animation: fadeInOut 0.9s ease-in-out;
}

#stamina-bar {
    background: white;
    padding: 1rem;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    text-align: center;
}

#stamina-timer {
    font-size: 0.9rem;
    color: #666;
    margin-top: 0.5rem;
}

.achievement {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 1rem 0;
}

.save-load-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin-top: auto;
}

.save-load-buttons button {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 0.8rem;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.save-load-buttons button:hover {
    background: #45a049;
}

#share-button {
    grid-column: 1 / -1;
    background: #2196F3 !important;
}

#share-button:hover {
    background: #1976D2 !important;
}

#adventure-button {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 1rem;
    font-size: 1.2rem;
    font-weight: bold;
    border-radius: 12px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    width: 100%;
    touch-action: manipulation;
}

#adventure-button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

#adventure-button:active {
    transform: scale(0.98);
}

#repo-link {
    text-align: center;
    margin-top: 1rem;
    padding: 0.5rem;
}

#repo-link a {
    color: #4CAF50;
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.3s ease;
}

#repo-link a:hover {
    color: #45a049;
    text-decoration: underline;
}

.hidden {
    display: none !important;
}

@keyframes bounce {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.1); }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    20% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
    80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
}

@media (max-width: 480px) {
    #stats-bar {
        grid-template-columns: 1fr;
    }

    #encounter-emoji {
        font-size: 3rem;
    }

    #encounter-text {
        font-size: 1rem;
    }

    .save-load-buttons {
        grid-template-columns: 1fr;
    }

    #share-button {
        grid-column: auto;
    }
}
