body {
    font-family: sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #f0f0f0;
    margin: 0; /* Remove default body margin */
    padding: 0; /* Remove default body padding */
    user-select: none; /* Prevent text selection during interaction */
    -webkit-user-select: none;
    -ms-user-select: none;
    overflow: hidden; /* Prevent scrollbars if glass tilts off */
}

.game-container {
    text-align: center;
    background-color: #fff;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    max-width: 90%; /* Ensure it fits smaller screens */
    box-sizing: border-box; /* Include padding in width */
}

#sensor-status {
    min-height: 1.2em;
    color: #666;
    font-style: italic;
    margin-bottom: 10px;
}

.glass-container {
    margin: 15px auto; /* Reduced margin */
    width: 150px;
    height: 320px; /* Give rotation room */
    display: flex;
    justify-content: center;
    align-items: flex-end; /* Align base of wrapper */
}

.glass-wrapper {
    width: 100%;
    height: 300px; /* Actual glass height */
    transform-origin: bottom center; /* Rotate around the base center */
    transition: transform 0.2s ease-out; /* Smooth visual tilt */
     /* Improve rendering during rotation */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    will-change: transform; /* Hint browser about upcoming transforms */
}

.glass {
    width: 100%;
    height: 100%; /* Fill the wrapper */
    border: 5px solid #333;
    border-top: none; /* Open top */
    border-radius: 0 0 30px 30px; /* Rounded bottom */
    background-color: #e0e0e0; /* Empty glass color */
    position: relative;
    overflow: hidden; /* Important: hides liquid overflow */
    margin: 0 auto;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.2);
}

.liquid {
    background-color: #1a0e00; /* Dark Guinness color */
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%; /* Start full */
    /* Height transition handled by JS game loop */
    display: flex;
    flex-direction: column; /* Stack head on top */
}

.head {
    height: 15%; /* Percentage height for the creamy head */
    background-color: #f3e5ab; /* Creamy head color */
    width: 100%;
    box-shadow: inset 0 -5px 5px rgba(0,0,0,0.1); /* Subtle shadow below head */
    flex-shrink: 0; /* Prevent head from shrinking when liquid level is low */
}

.g-line {
    position: absolute;
    /* TARGET LEVEL: Higher position - MUST match JS TARGET_G_LEVEL */
    bottom: 67%;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: rgba(255, 255, 255, 0.5); /* Faint line */
    color: rgba(255, 255, 255, 0.8);
    font-weight: bold;
    font-size: 1.5em;
    line-height: 0; /* Adjust vertical text position */
    text-align: center;
    padding-top: 1px; /* Nudge text relative to line */
    z-index: 1; /* Ensure G is above liquid */
    pointer-events: none; /* Make sure it doesn't interfere */
}

.message-area {
    margin-top: 15px;
    min-height: 6em; /* Reserve space for messages */
}

#instructions {
    color: #333;
    margin-bottom: 10px;
    transition: opacity 0.3s ease-in-out; /* Smooth fade for instructions */
}

#result {
    font-weight: bold;
    font-size: 1.3em;
    margin-top: 5px;
    min-height: 1.5em; /* Prevent layout jump when text appears */
}

/* Result styling classes */
#result.perfect { color: #28a745; } /* Green */
#result.great { color: #17a2b8; }   /* Teal/Info Blue */
#result.good { color: #ffc107; }    /* Amber/Warning Yellow */
#result.close { color: #fd7e14; }   /* Orange */
#result.far { color: #dc3545; }     /* Red */

#reset-button, #permission-button {
    margin-top: 10px;
    padding: 10px 20px;
    font-size: 1em;
    cursor: pointer;
    color: white;
    border: none;
    border-radius: 5px;
    transition: background-color 0.2s;
}
#reset-button { background-color: #007bff; }
#reset-button:hover { background-color: #0056b3; }

#permission-button { background-color: #ffc107; color: #333;}
#permission-button:hover { background-color: #e0a800; }

/* Basic responsiveness */
@media (max-width: 400px) {
    .game-container {
        padding: 15px;
    }
    .glass-container {
        width: 120px;
        height: 260px; /* Adjusted height */
    }
     .glass-wrapper {
        height: 240px; /* Adjusted height */
    }
    h1 {
        font-size: 1.5em;
    }
     #result {
        font-size: 1.2em;
    }
    #reset-button, #permission-button {
        padding: 8px 16px;
        font-size: 0.9em;
    }
}