/* Base styles */
body {
    font-family: 'Arial', sans-serif;
    background-color: #2c3e50;
    color: white;
    margin: 0;
    padding: 20px;
    font-size: 16px;
}

header {
    text-align: center;
    margin-bottom: 20px;
}

h1 {
    color: #e74c3c;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

button {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
    min-height: 44px; /* Good size for touch targets */
}

button:hover {
    background-color: #2980b9;
}

.status-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.status-button {
    display: flex;
    align-items: center;
    gap: 5px;
}

.status-indicator {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    display: inline-block;
}

/* Game area - contains town square and trash bin */
.game-area {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    max-width: 900px;
    gap: 20px;
}

/* Responsive Town Square */
.town-square {
    position: relative;
    width: 100%;
    max-width: 800px;
    aspect-ratio: 1 / 1;
    border: 2px solid #7f8c8d;
    background-color: #34495e;
}

/* Make sure no trash bin appears inside town square */
.town-square .trash-bin {
    display: none !important;
}

/* Player styling */
.player {
    position: absolute;
    width: 13%;
    max-width: 80px;
    cursor: move;
    text-align: center;
    user-select: none;
    z-index: 10;
    transform: translate(-50%, -50%); /* Center player at its position point */
}

.player-circle {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    margin: 0 auto;
    border: 2px solid #fff;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.player-name {
    margin-top: 5px;
    background-color: rgba(0, 0, 0, 0.6);
    border-radius: 5px;
    padding: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

/* Player statuses */
.alive {
    background-color: #2ecc71;
}

.traveller.alive {
    background-color: #f1c40f;
}

.ghost {
    background-color: #2c3e50; /* Dark background like dead players */
    position: relative; /* For positioning the inner circle */
}

/* Add the inner blue circle to indicate voting power */
.ghost::after {
    content: "";
    position: absolute;
    width: 60%; /* Size of the inner circle - 40% of the parent circle */
    height: 60%;
    border-radius: 50%;
    background-color: #3498db; /* The original ghost blue color */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1; /* Ensure it appears above the background */
}

/* Ensure the status indicator matches the actual player appearance */
.status-indicator.ghost {
    background-color: #2c3e50;
}

.status-indicator.ghost::after {
    content: "";
    position: absolute;
    width: 60%;
    height: 60%;
    border-radius: 50%;
    background-color: #3498db;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.dead {
    background-color: #2c3e50;
    color: #7f8c8d;
}

.selected {
    border: 2px solid #e74c3c;
}

/* Form styling */
.player-form {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.traveller-checkbox {
    display: flex;
    align-items: center;
    gap: 5px;
}

#player-name {
    padding: 10px;
    border-radius: 5px;
    border: none;
    min-height: 44px;
}

.info-panel {
    margin-top: 20px;
    text-align: center;
}

/* Hide trash bin in clean mode */
.clean-mode #trash-bin-container {
    display: none !important;
}

/* Add this to your clean-mode adjustments section */
.clean-mode header {
    max-height: 0;
    overflow: hidden;
    margin: 0;
    padding: 0;
    opacity: 0;
}

/* Add this to your general styles to enable the transition */
header {
    transition: all 0.3s ease;
    max-height: 200px; /* Adjust based on your actual header height */
    opacity: 1;
}

/* Trash bin container styling - improved */
#trash-bin-container {
    flex-shrink: 0;
    display: flex !important; /* Force display */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 60px;
    min-height: 70px;
    padding: 10px;
    background-color: transparent;
    border-radius: 10px;
    z-index: 100; /* Ensure it's above other elements */
    position: relative; /* For proper positioning of child elements */
}

/* Enhanced trash bin styling */
.trash-bin {
    width: 60px;
    aspect-ratio: 6 / 7;
    min-width: 60px;
    min-height: 70px;
    background-color: #c0392b;
    border-radius: 5px 5px 0 0;
    display: flex !important; /* Force display */
    visibility: visible !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    border: 2px solid transparent;
}

.trash-bin::before {
    content: "";
    width: 133%;
    height: 15px;
    background-color: #e74c3c;
    border-radius: 5px 5px 0 0;
    position: absolute;
    top: -10px;
}

.trash-bin::after {
    content: "";
    width: 8%;
    height: 57%;
    background-color: #ecf0f1;
    position: absolute;
    top: 14%;
    box-shadow: 25% 0 0 #ecf0f1, 50% 0 0 #ecf0f1;
}

/* Stronger highlight effect when item is over the trash */
.trash-bin.highlight {
    transform: scale(1.3);
    box-shadow: 0 0 30px rgba(231, 76, 60, 1);
    background-color: #e74c3c;
    border: 2px solid yellow;
}

/* Make the trash text clearer */
#trash-bin-container::after {
    content: "Drag here to delete";
    display: block !important;
    font-weight: bold;
    color: #e74c3c;
    font-size: 1em;
    margin-top: 8px;
    text-align: center;
    white-space: nowrap;
}

/* Status notification */
.status-notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 15px;
    border-radius: 5px;
    z-index: 1000;
    animation: fadeIn 0.3s ease-in-out;
}

.fade-out {
    animation: fadeOut 0.5s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(20px); }
}

/* Mobile touch improvements for trash bin */
@media (max-width: 700px) {
    body {
        font-size: 14px;
        padding: 10px;
    }
    
    .player-name {
        font-size: 0.8em;
        padding: 2px;
    }
    
    .controls, .status-buttons {
        gap: 5px;
    }
    
    button {
        padding: 8px 12px;
    }
    
    /* Change layout to vertical on smaller screens */
    .game-area {
        flex-direction: column;
        gap: 10px;
    }
    
    /* Ensure the trash bin is visible and properly sized on mobile */
    #trash-bin-container {
        margin-top: 15px;
        padding: 15px;
        background-color: transparent;
        border: none;
    }
    
    /* Make sure the trash bin itself has a minimum size on mobile */
    .trash-bin {
        width: 50px;
        height: 58px; /* Set explicit height for mobile */
        min-width: 45px;
        min-height: 50px;
        display: flex !important; /* Force display */
        visibility: visible !important;
    }
    
    /* Ensure the trash bin details are visible */
    .trash-bin::before,
    .trash-bin::after {
        display: block !important;
        visibility: visible !important;
    }
    
    /* More obvious highlight when item is over the trash */
    .trash-bin.highlight {
        transform: scale(1.5);
        border: 3px solid yellow;
    }
}

@media (max-width: 450px) {
    body {
        font-size: 12px;
        padding: 5px;
    }
    
    button {
        padding: 12px 15px;
        font-size: 0.9em;
    }
    
    .player-form {
        flex-direction: column;
    }
    
    #player-name {
        width: 100%;
    }
    
    .status-button {
        font-size: 0.9em;
    }
    
    h1 {
        font-size: 1.5em;
    }
    
    .trash-bin {
        width: 45px;
        height: 52px;
    }
}

@media (orientation: portrait) {
    /* Ensure the town square maintains its aspect ratio in portrait mode */
    .town-square {
        max-width: 95vw;
        max-height: 95vw;
    }

    /* Make player circles a bit smaller on narrower screens */
    .player {
        width: 11%;
    }

    /* Ensure player names are readable on small screens */
    .player-name {
        font-size: 0.8em;
        padding: 2px;
        max-width: 100%;
    }
}

/* Ensure the town square doesn't get too large on big screens */
@media (min-width: 1200px) {
    .town-square {
        max-width: 700px;
        max-height: 700px;
    }
}

/* Role distribution display styles */
.role-distribution {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.7);
    padding: 15px;
    border-radius: 10px;
    text-align: center;
    width: 60%;
    max-width: 250px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
    z-index: 5;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none; /* Make it non-interactive so it doesn't interfere with dragging */
}

.role-count {
    padding: 5px 10px;
    border-radius: 5px;
    font-weight: bold;
}

.townsfolk {
    background-color: rgba(41, 128, 255, 0.7); /* Lighter Blue */
    color: white;
}

.outsiders {
    background-color: rgba(52, 152, 219, 0.7); /* Blue */
    color: white;
}

.minions {
    background-color: rgba(243, 156, 18, 0.7); /* Orange */
    color: white;
}

.demons {
    background-color: rgba(231, 76, 60, 0.7); /* Red */
    color: white;
}

/* Make sure the display is visible in clean mode */
.clean-mode .role-distribution {
    display: flex;
}

/* Responsive styles */
@media (max-width: 650px) {
    .role-distribution {
        width: 80%;
        padding: 10px;
        font-size: 0.9em;
    }

    .role-count {
        padding: 4px 8px;
    }
}

@media (max-width: 450px) {
    .role-distribution {
        font-size: 0.8em;
    }
}

/* Wake Lock button styles */
.wake-lock-btn {
    background-color: #9b59b6; /* Purple color to distinguish from other buttons */
}

.wake-lock-btn:hover {
    background-color: #8e44ad;
}

.wake-lock-btn.active {
    background-color: #27ae60; /* Green color when active */
}

.wake-lock-btn.active:hover {
    background-color: #2ecc71;
}

/* Make sure the wake lock button is hidden in clean mode */
.clean-mode .wake-lock-btn {
    display: none;
}

/* Additional style for the notification about wake lock */
.wake-lock-notification {
    background-color: rgba(155, 89, 182, 0.9) !important;
}

/* Styles for iOS standalone web app mode */
.ios-standalone {
    /* Prevent overscroll/bounce */
    position: fixed;
    width: 100%;
    height: 100%;
    overflow: hidden;
    -webkit-overflow-scrolling: touch;
}

.ios-standalone body {
    /* Take up full height with no scrolling */
    width: 100vw;
    height: 100vh;
    margin: 0;
    padding: 10px;
    box-sizing: border-box;
    overflow: hidden;
}

/* Allow scrolling for specific elements */
.scrollable {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Make sure the town square fits well in standalone mode */
.ios-standalone .town-square {
    max-height: 80vh;
}

/* Improve touch target sizes in standalone mode */
.ios-standalone button,
.ios-standalone .player-circle {
    min-height: 44px;
    min-width: 44px;
}

/* Fix for Safari on iOS issues with 100vh */
@supports (-webkit-touch-callout: none) {
    .ios-standalone body {
        height: -webkit-fill-available;
    }
}

/* Full Screen Mode Indicator */
.fullscreen-indicator {
    display: none; /* Hidden by default */
    position: fixed;
    bottom: 15px;
    right: 15px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 12px;
    border-radius: 5px;
    font-size: 0.8em;
    z-index: 1000;
    animation: fadeIn 0.5s ease-out;
}

/* Show indicator when in standalone mode */
.ios-standalone .fullscreen-indicator {
    display: block;
}

/* Hide indicator after a delay */
@keyframes fadeIn {
    0% { opacity: 0; transform: translateY(20px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* Add animation for the indicator to fade out */
.fullscreen-indicator.fade-out {
    animation: fadeOut 0.5s ease-in forwards;
}

@keyframes fadeOut {
    0% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(20px); }
}

/* Button styles for Reset vs Clear */
#reset-btn {
    background-color: #3498db; /* Default blue */
}

#clear-btn {
    background-color: #e74c3c; /* Red for destructive action */
}

#clear-btn:hover {
    background-color: #c0392b; /* Darker red on hover */
}
