/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #4CAF50; /* Match game background */
    font-family: Arial, sans-serif;
    display: flex;
    flex-direction: column;
    background-color: #4CAF50; /* Green field */
    touch-action: none;
    height: 100%;
}

html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    touch-action: none;
}

body {
    font-family: Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: white;
    position: fixed;
    width: 100%;
    height: 100%;
    -webkit-overflow-scrolling: touch;
}

#game {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    background-color: white;
    display: flex;
    flex-direction: column;
    max-width: 100vw;
    max-height: 100vh;
    margin: 0 auto;
}

#game-wrapper {
    width: 100%;
    flex: 1;
    position: relative;
    overflow: hidden;
    -webkit-overflow-scrolling: touch;
    margin-top: -30%;
}

/* Game Footer */
#game-footer {
    height: 20px;
    width: 100%;
    background: transparent;
    flex-shrink: 0;
}

#game-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    background-color: white;
    background-image: url('../assets/stadium.png');
    background-size: cover;
    background-position: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    box-sizing: border-box;
}

/* Responsive adjustments */
@media (max-height: 700px) {
    #game-container {
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
}

/* Mobile landscape */
@media (max-width: 767px) and (orientation: landscape) {
    #game-container {
        max-width: 100vh;
        height: 100vw;
        transform: rotate(90deg) translateY(-100%);
        transform-origin: top left;
        position: absolute;
        top: 100%;
        left: 0;
    }
    
    #game-wrapper {
        padding: 0;
        height: 100vw;
        width: 100vh;
        transform: rotate(-90deg) translateX(-100%);
        transform-origin: top left;
        overflow: hidden;
        position: absolute;
        top: 0;
        left: 0;
    }
}

/* Ball */
#ball {
    position: absolute;
    width: 12vw;
    height: 12vw;
    max-width: 60px;
    max-height: 60px;
    min-width: 40px;
    min-height: 40px;
    background-image: url('../assets/ball.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    border-radius: 50%;
    cursor: pointer;
    user-select: none;
    touch-action: none;
    z-index: 10;
    transition: transform 0.1s ease-out;
    will-change: transform;
}

/* Ball rolling effect */
.ball-rolling {
    animation: roll 0.5s linear infinite;
}

@keyframes roll {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Washing Machine */
#washing-machine {
    position: relative;
    width: 180px;
    margin: 120px auto 0; /* Increased top margin to lower the machine */
    z-index: 5;
    padding: 0 10px;
    box-sizing: border-box;
}

/* Responsive adjustments */
@media (max-width: 400px) {
    #washing-machine {
        width: 160px;
    }
}

.machine-body {
    background: #e0e0e0;
    border-radius: 15px;
    padding: 10px 15px 15px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 0; /* Allow container to shrink */
}

.machine-top {
    background: linear-gradient(to bottom, #e0e0e0, #c0c0c0);
    height: 20px;
    border-radius: 8px 8px 0 0;
    padding: 4px 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-bottom: 2px solid #b0b0b0;
    width: 100%;
    margin-bottom: 10px;
    box-sizing: border-box;
}

.door-container {
    width: 90%;
    max-width: 140px;
    aspect-ratio: 1/1; /* Maintain perfect circle */
    margin: 5px auto 10px;
    background: #f0f0f0;
    border-radius: 50%;
    box-shadow: inset 0 0 15px rgba(0,0,0,0.2);
    box-sizing: border-box;
    padding: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.control-panel {
    display: flex;
    align-items: center;
    gap: 12px;
}

.knob {
    width: 30px;
    height: 30px;
    background: radial-gradient(circle at 30% 30%, #fff, #888);
    border-radius: 50%;
    border: 3px solid #666;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    cursor: pointer;
    transition: transform 0.1s;
}

.knob:active {
    transform: rotate(30deg);
}

.display {
    background: #2c3e50;
    color: #4CAF50;
    padding: 6px 12px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    font-weight: bold;
    letter-spacing: 1px;
    text-shadow: 0 0 5px rgba(76, 175, 80, 0.7);
    box-shadow: inset 0 0 5px rgba(0,0,0,0.5);
    border: 1px solid #1a1a1a;
}

.machine-door {
    width: 100%;
    height: 100%;
    background: white;
    border: 8px solid #d0d0d0;
    border-radius: 50%;
    box-sizing: border-box;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}


.drum {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: white;
    box-shadow: inset 0 0 15px rgba(0,0,0,0.1);
    box-sizing: border-box;
    position: relative;
}

.goal-hole {
    width: 60%;
    height: 60%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #928c8c;
    /* background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="30" height="30" viewBox="0 0 30 30"><rect width="30" height="30" fill="%23928c8c" rx="15"/><text x="15" y="15" font-family="Arial" font-size="10" text-anchor="middle" dominant-baseline="middle" fill="white">DRUM</text></svg>'); */
    background-image: url('/assets/drum.png');
    background-size: cover;
    border-radius: 50%;
    z-index: 6;
    border: 2px solid #111;
    overflow: hidden;
    position: relative;
}

/* When you're ready to add a real drum image, use this format:
.goal-hole {
    background-image: url('../images/drum-texture.jpg');
    background-size: cover;
}
*/

.machine-base {
    height: 10px;
    background: #b0b0b0;
    border-radius: 0 0 8px 8px;
    margin-top: 10px;
}

/* Goal hole is now styled by the .goal-hole class */

/* UI Elements */
/* Game Header */
#game-header {
    position: relative;
    width: 100%;
    min-height: 90px;
    background-color: white;
    color: #333;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
    padding: 10px 0;
    flex-shrink: 0;
}

.header-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 0 15px;
    position: relative;
}

.header-section:not(:last-child)::after {
    content: '';
    position: absolute;
    right: 0;
    top: 20%;
    height: 60%;
    width: 1px;
    background: linear-gradient(to bottom, 
        transparent, 
        rgba(0,0,0,0.1), 
        transparent);
}

.header-logo {
    height: 40px;
    width: auto;
    margin-bottom: 5px;
}

.game-title {
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
    text-align: center;
    line-height: 1.2;
}

.stat-label {
    font-size: 12px;
    color: #7f8c8d;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
}

.score-value {
    font-size: 36px;
    font-weight: 800;
    color: #2c3e50;
    line-height: 1;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}

.time-section, .balls-section {
    text-align: center;
    margin: 5px 0;
}

.time-value {
    font-size: 24px;
    font-weight: 700;
    color: #2c3e50;
    font-family: 'Courier New', monospace;
    letter-spacing: 1px;
}

.balls-container {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 2px;
}

.score-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 100px;
}

.balls-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
}

.timer {
    margin-top: 8px;
    text-align: center;
}

.timer .stat-label {
    font-size: 11px;
    opacity: 0.8;
}

.stat-label {
    font-size: 12px;
    font-weight: 600;
    color: #ff0000;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#score {
    color: rgb(0, 0, 0);
    text-align: center;
}

#balls-left {
    display: flex;
    gap: 8px;
    align-items: center;
}

.ball-indicator {
    width: 20px;
    height: 20px;
    background-image: url('/assets/ball.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    transition: all 0.3s ease;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.2));
    transform: scale(1);
}

.ball-indicator.used {
    opacity: 0.3;
    filter: grayscale(100%) brightness(1.2) drop-shadow(0 1px 1px rgba(0, 0, 0, 0.1));
    transform: scale(0.9);
}

/* Desktop View */
@media (min-width: 769px) {
    body {
        background-color: #f5f5f5;
        display: flex;
        justify-content: center;
        align-items: center;
        min-height: 100vh;
        margin: 0;
        padding: 20px;
    }
    
    #game {
        width: 375px;
        height: 812px;
        border-radius: 40px;
        overflow: hidden;
        box-shadow: 0 10px 50px rgba(0, 0, 0, 0.2);
        position: relative;
        background: #fff;
    }
    
    /* Hide any potential scrollbars */
    html, body {
        overflow: hidden;
    }
    
    /* Adjust washing machine position for desktop */
    #game-container {
        position: relative;
        height: 100%;
    }
    #game-container #washing-machine {
        position: absolute;
        top: 30%;
        left: 50%;
        transform: translateX(-50%);
        margin: 0;
    }
}

/* iPhone-specific adjustments */
@supports (-webkit-touch-callout: none) {
    /* Add bottom padding to account for home indicator */
    body {
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    #game {
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    #game-wrapper {
        padding-bottom: 0;
    }
    
    #game-footer {
        height: calc(20px + env(safe-area-inset-bottom));
        padding-bottom: env(safe-area-inset-bottom);
        background: rgba(0,0,0,0.1); /* Slight background to visualize the area */
    }
    /* Target iOS devices */
    #game {
        height: 100%;
        max-height: -webkit-fill-available;
    }
    
    #game-wrapper {
        height: calc(100% - 80px) !important;
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    #game-container {
        background-position: center 70%;
        background-size: cover;
    }
    
    #washing-machine {
        margin-top: 20px !important;
        transform: scale(0.9);
    }
    
    /* Adjust header for iPhone */
    #game-header {
        height: 80px !important;
        min-height: 80px !important;
        padding-top: env(safe-area-inset-top) !important;
    }
    
    /* Adjust message position */
    #message {
        top: 100px !important;
    }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    #game-header {
        min-height: 80px;
        padding: 8px 0;
    }
    
    .header-logo {
        height: 28px;
    }
    
    .game-title {
        font-size: 11px;
    }
    
    .score-value {
        font-size: 24px;
    }
    
    .time-value {
        font-size: 18px;
    }
    
    .ball-indicator {
        width: 14px;
        height: 14px;
    }
    
    #message {
        font-size: 24px;
        top: 90px;
    }
}

/* Small phones */
@media (max-width: 360px) {
    .header-section {
        padding: 0 8px;
    }
    
    .game-title {
        font-size: 10px;
    }
    
    .stat-label {
        font-size: 9px;
    }
    
    .score-value {
        font-size: 20px;
    }
    
    .time-value {
        font-size: 16px;
    }
    
    .ball-indicator {
        width: 12px;
        height: 12px;
    }
    
    #message {
        font-size: 22px;
        top: 85px;
    }
}

@media (max-width: 480px) {
    .header-section {
        padding: 0 8px;
    }
    
    .stat-label {
        font-size: 10px;
    }
    
    .score-value {
        font-size: 44px;
    }
    
    .time-value {
        font-size: 18px;
    }
    
    .ball-indicator {
        width: 14px;
        height: 14px;
    }
}

#message {
    font-size: 28px;
    font-weight: bold;
    font-style: italic;
    color: #ff0000 !important;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.7);
    opacity: 0;
    transition: opacity 0.5s;
    position: absolute;
    top: 140px;
    left: 0;
    width: 100%;
    text-align: center;
    z-index: 200;
    pointer-events: none;
}

/* Game Over Form */
#game-over-form {
    position: fixed;
    top: 65%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.96);
    padding: 25px;
    border-radius: 15px;
    color: #2c3e50;
    z-index: 1000;
    width: 90%;
    max-width: 400px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    box-shadow: 0 5px 30px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

#game-over-form.visible {
    opacity: 1;
    pointer-events: auto;
}

#game-over-form.hidden {
    display: none;
    opacity: 0;
    pointer-events: none;
}

#game-over-form h3 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 1.2em;
}

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

.form-group input[type="text"],
.form-group input[type="email"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    box-sizing: border-box;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 20px 0;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.checkbox-group label {
    font-size: 14px;
    color: #2c3e50;
    line-height: 1.4;
}

#privacy-policy {
    color: #3498db;
    text-decoration: none;
}

#privacy-policy:hover {
    text-decoration: underline;
}

.form-buttons {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    justify-content: space-between;
}

.submit-btn, .skip-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s;
}

.submit-btn {
    background-color: #4CAF50;
    color: white;
    flex: 2;
}

.submit-btn:hover {
    background-color: #45a049;
}

.skip-btn {
    background-color: #f44336;
    color: white;
    flex: 1;
}

.skip-btn:hover {
    background-color: #d32f2f;
}

.hidden {
    display: none;
}

/* Footer */
#footer {
    background: rgba(255, 255, 255, 0.9);
    padding: 10px 0;
    text-align: center;
    z-index: 100;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
    position: relative;
}

.footer-logo {
    height: 40px;
    width: auto;
    max-width: 200px;
    object-fit: contain;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #washing-machine {
        width: 150px;
        height: 225px;
        top: 30%;
    }
    
    #goal-hole {
        width: 60px;
        height: 60px;
    }
}
