/**
 * Chopsticks Game - Styles
 * Modern, mobile-responsive CSS with clean green theme
 * Features: Flexbox layouts, mobile-first responsive design, accessibility support
 */

/* ========================================
   UTILITY CLASSES & ACCESSIBILITY
   ======================================== */

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ========================================
   GAME ACTION BUTTONS
   ======================================== */

/* Clap/Split action button */
#clap-btn {
    display: block;
    width: 70%;
    margin: 18px auto 0 auto;
    padding: 10px 0;
    font-size: 1rem;
    font-family: 'Baloo 2', cursive;
    background: #fff;
    color: #219150;
    border: 2px solid #219150;
    border-radius: 14px;
    box-shadow: none;
    cursor: pointer;
    transition: background 0.18s, color 0.18s, border 0.18s;
    font-weight: 500;
    letter-spacing: 0.8px;
    outline: none;
}

#clap-btn:active:not(:disabled),
#clap-btn:hover:not(:disabled),
#clap-btn:focus:not(:disabled) {
    background: #eafaf1;
    color: #219150;
    border: 2px solid #219150;
    z-index: 2;
}

#clap-btn:disabled {
    background: #eafaf1;
    color: #bbb;
    border: 2px solid #b2f7b2;
    cursor: not-allowed;
    box-shadow: none;
    opacity: 0.7;
}

/* Reset Button Styling */
/* Top-right circular reset icon button */
.reset-icon-btn {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 2px solid #219150;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.18s, border 0.18s;
    box-shadow: none;
    outline: none;
    z-index: 10;
}

#game-ui {
    position: relative;
}

.reset-icon-btn svg {
    width: 20px;
    height: 20px;
    stroke: #219150;
    fill: none;
    pointer-events: none;
}

.reset-icon-btn:hover,
.reset-icon-btn:focus {
    background: #eafaf1;
    border-color: #43ea7a;
}

/* Menu Button Styling */
/* Top-left circular menu icon button */
.menu-icon-btn {
    position: absolute;
    top: 18px;
    left: 18px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 2px solid #219150;
    border-radius: 50%;
    color: #219150;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border 0.2s;
    outline: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
}

.menu-icon-btn svg {
    width: 20px;
    height: 20px;
    stroke: #219150;
    fill: none;
    pointer-events: none;
}

.menu-icon-btn:hover,
.menu-icon-btn:focus {
    background: #eafaf1;
    border-color: #43ea7a;
}

/* Modal error message styling */
.modal-error {
    font-size: 1rem;
    color: #d32f2f;
    margin-top: 10px;
}

/* Element hiding utility */
.hidden {
    display: none !important;
}

/* Specific hiding rules for key UI elements */
#message.hidden,
#menu.hidden,
.hand.hidden,
.count.hidden,
#turn-indicator.hidden,
.player-board.hidden {
    display: none !important;
}

/* ========================================
   BASE STYLES & TYPOGRAPHY
   ======================================== */

/* Unified Green Theme - Clean & Cool */
html,
body {
    margin: 0;
    padding: 0;
    font-family: 'Baloo 2', cursive;
    background-color: #f4f1de;
    height: 100%;
}

.background {
    background: linear-gradient(to bottom, #b2f7b2 0%, #d2fdd9 100%);
    background-repeat: no-repeat;
    background-size: cover;
    min-height: 100vh;
    padding: 20px;
    box-sizing: border-box;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    background-color: rgba(234, 250, 241, 0.95);
    border-radius: 20px;
    box-shadow: 0 4px 16px #21915044;
    text-align: center;
}

h1 {
    margin-bottom: 10px;
    font-size: 2.5rem;
    color: #2e7d32;
}

/* ========================================
   TURN INDICATOR & GAME STATUS
   ======================================== */

#turn-indicator {
    font-weight: bold;
    font-size: 1.2rem;
    margin-bottom: 20px;
    color: #1b5e20;
}

#message {
    font-size: 1.2rem;
    color: #2e7d32;
    margin-top: 20px;
}

/* ========================================
   GAME BOARD LAYOUT
   ======================================== */

.player-board {
    margin: 20px 0;
}

.player-board h2 {
    margin-bottom: 10px;
    color: #2e7d32;
}

/* Horizontal game board layout */
.game-board {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 60px;
    margin: 30px 0;
}

.container-p1 {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 20px;
}

.container-p2 {
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
    gap: 20px;
}

.player-section {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 100px;
    text-align: center;
}

.player-section h2 {
    margin: 0;
    color: #2e7d32;
    font-size: 1.5rem;
    width: 100%;
    text-align: center;
}

.hands-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.center-divider {
    width: 2px;
    height: 250px;
    background-color: #219150;
    opacity: 0.4;
}

/* ========================================
   HAND INTERACTION ELEMENTS
   ======================================== */

.hand {
    font-size: 2rem;
    padding: 15px 25px;
    margin: 0;
    border: 3px solid #219150;
    background-color: #eafaf1;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s, box-shadow 0.2s;
}

.hand.selected {
    background-color: #b9fbc0;
    box-shadow: 0 0 10px #81c784;
    border-color: #81c784;
}

.hand:hover:not(:disabled) {
    transform: scale(1.1);
    background-color: #c8facc;
}

.hand:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.count {
    display: block;
    font-size: 1rem;
    margin-top: 4px;
    color: #219150;
}

/* ========================================
   MENU & NAVIGATION BUTTONS
   ======================================== */

#menu button {
    display: block;
    width: 80%;
    margin: 12px auto;
    padding: 10px 0;
    font-size: 1rem;
    font-family: 'Baloo 2', cursive;
    background: #fff;
    color: #219150;
    border: 2px solid #219150;
    border-radius: 14px;
    box-shadow: none;
    cursor: pointer;
    transition: background 0.18s, color 0.18s, border 0.18s;
    font-weight: 500;
    letter-spacing: 0.8px;
    outline: none;
    position: relative;
}

#menu button:active:not(:disabled),
#menu button:hover:not(:disabled),
#menu button:focus:not(:disabled) {
    background: #eafaf1;
    color: #219150;
    border: 2px solid #219150;
    z-index: 2;
}

#menu button:disabled {
    background: #eafaf1;
    color: #bbb;
    border: 2px solid #b2f7b2;
    cursor: not-allowed;
    box-shadow: none;
    opacity: 0.7;
}

/* Name input styling */
.name-inputs {
    margin: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

.name-input-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    width: 80%;
}

.name-input-group label {
    font-family: 'Baloo 2', cursive;
    font-size: 1rem;
    color: #2e7d32;
    font-weight: 500;
}

.name-input-group input {
    width: 100%;
    padding: 8px 12px;
    font-size: 1rem;
    font-family: 'Baloo 2', cursive;
    border: 2px solid #219150;
    border-radius: 8px;
    background: #fff;
    color: #2e7d32;
    text-align: center;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.name-input-group input:focus {
    border-color: #1976d2;
    box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.2);
}

.name-input-group input::placeholder {
    color: #999;
    font-style: italic;
}

/* Name setup screen styling */
#name-setup {
    text-align: center;
}

#name-setup h2 {
    color: #2e7d32;
    margin-bottom: 20px;
}

.name-setup-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 25px;
}

.name-setup-buttons button {
    padding: 10px 20px;
    font-size: 1rem;
    font-family: 'Baloo 2', cursive;
    background: #fff;
    color: #219150;
    border: 2px solid #219150;
    border-radius: 14px;
    cursor: pointer;
    transition: background 0.18s, color 0.18s, border 0.18s;
    font-weight: 500;
    letter-spacing: 0.8px;
    outline: none;
    min-width: 100px;
}

.name-setup-buttons button:hover,
.name-setup-buttons button:focus {
    background: #eafaf1;
    border-color: #43ea7a;
}

@media (max-width: 600px) {
    /* Mobile layout adjustments */
    .container {
        padding: 15px;
        margin: 10px;
        border-radius: 15px;
    }
    
    h1 {
        font-size: 2rem;
        margin-bottom: 15px;
    }
    
    /* Stack game board vertically on mobile */
    .game-board {
        flex-direction: column;
        gap: 30px;
        margin: 20px 0;
    }
    
    /* Flip player order on mobile - Player 2 first, then Player 1 */
    .container-p1 {
        order: 3;
        flex-direction: column;
        gap: 15px;
    }
    
    .container-p2 {
        order: 1;
        flex-direction: column; /* Override row-reverse for mobile */
    }
    
    /* Move divider between players */
    .center-divider {
        order: 2;
        width: 80%;
        height: 2px;
        margin: 0 auto;
    }
    
    /* Swap Player 1 section - hands first, then name */
    .container-p1 .player-section {
        order: 2;
    }
    
    .container-p1 .hands-section {
        order: 1;
    }
    
    /* Player 2 section - name first, then hands */
    .container-p2 .player-section {
        order: 1;
    }
    
    .container-p2 .hands-section {
        order: 2;
    }
    
    .center-divider {
        width: 80%;
        height: 2px;
        margin: 0 auto;
    }
    
    .player-section {
        min-width: auto;
        width: 100%;
    }
    
    .player-section h2 {
        font-size: 1.3rem;
    }
    
    .hands-section {
        flex-direction: row;
        gap: 15px;
        justify-content: center;
    }
    
    .hand {
        font-size: 1.5rem;
        padding: 10px 15px;
    }
    
    #turn-indicator {
        font-size: 1.1rem;
        margin-bottom: 15px;
    }
    
    /* Mobile button adjustments */
    .reset-icon-btn, .menu-icon-btn {
        top: 10px;
        width: 32px;
        height: 32px;
    }
    
    .reset-icon-btn {
        right: 10px;
    }
    
    .menu-icon-btn {
        left: 10px;
    }
    
    .reset-icon-btn svg, .menu-icon-btn svg {
        width: 16px;
        height: 16px;
    }
    
    /* Name input mobile adjustments */
    .name-inputs {
        margin: 15px 0;
        gap: 12px;
    }
    
    .name-input-group {
        width: 90%;
    }
    
    .name-setup-buttons {
        flex-direction: column;
        gap: 10px;
        align-items: center;
    }
    
    .name-setup-buttons button {
        width: 80%;
        min-width: 120px;
    }
    
    #menu button {
        width: 90%;
        margin: 10px auto;
        padding: 12px 0;
    }
    
    #clap-btn {
        width: 80%;
        margin: 15px auto 0 auto;
    }
    
    /* Mobile modal adjustments */
    .modal-content {
        padding: 30px 20px;
        font-size: 1.8rem;
        margin: 0 10px;
    }
    
    .modal-content h3 {
        font-size: 1.5rem;
    }
    
    .modal-desc {
        font-size: 0.9rem;
    }
    
    .modal-inputs input {
        width: 50px;
        height: 35px;
        font-size: 1.1rem;
    }
    
    .modal-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .modal-btn {
        width: 100%;
        padding: 12px 0;
    }
}

/* Extra small mobile devices (iPhone SE, etc.) */
@media (max-width: 375px) {
    .container {
        padding: 10px;
        margin: 5px;
    }
    
    h1 {
        font-size: 1.8rem;
    }
    
    .hand {
        font-size: 1.3rem;
        padding: 8px 12px;
    }
    
    .player-section h2 {
        font-size: 1.2rem;
    }
    
    .game-board {
        gap: 20px;
    }
    
    /* Extra small modal adjustments */
    .modal-content {
        padding: 25px 15px;
        font-size: 1.6rem;
    }
    
    .modal-content h3 {
        font-size: 1.3rem;
    }
    
    .modal-desc {
        font-size: 0.85rem;
    }
    
    .modal-inputs input {
        width: 45px;
        height: 32px;
        font-size: 1rem;
    }
    
    .modal-inputs .plus {
        font-size: 1.3rem;
    }
}

/* ========================================
   MODAL POPOUT SYSTEM
   ======================================== */

/* Modal container for clap/split events */
#game-ui,
.game-ui {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 400px;
    /* adjust as needed for your game area */
}

.modal-popout {
    position: absolute;
    inset: 0;
    background: transparent;
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-popout.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: #eafaf1;
    border-radius: 22px;
    box-shadow: 0 12px 40px #21915088, 0 2px 8px #21915022;
    border: 3px solid #43ea7a;
    padding: 48px 36px;
    text-align: center;
    color: #2e7d32;
    font-size: 2.2rem;
    font-family: 'Baloo 2', cursive;
    font-weight: bold;
    animation: popout-bounce 0.4s cubic-bezier(.68, -0.55, .27, 1.55);
}

.modal-content h3 {
    margin: 0 0 15px 0;
    font-size: 1.8rem;
    color: #2e7d32;
}

.modal-desc {
    font-size: 1rem;
    margin-bottom: 20px;
    color: #2e7d32;
    font-weight: normal;
}

.modal-inputs {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 20px 0;
}

.modal-inputs input {
    width: 60px;
    height: 40px;
    font-size: 1.2rem;
    text-align: center;
    border: 2px solid #219150;
    border-radius: 8px;
    background: #fff;
    color: #2e7d32;
    font-family: 'Baloo 2', cursive;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.modal-inputs input:focus {
    border-color: #1976d2;
    box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.2);
}

.modal-inputs .plus {
    font-size: 1.5rem;
    color: #2e7d32;
    font-weight: bold;
    margin: 0 5px;
}

.modal-actions {
    margin-top: 20px;
    display: flex;
    gap: 15px;
    justify-content: center;
}

.modal-btn {
    padding: 10px 20px;
    font-size: 1rem;
    font-family: 'Baloo 2', cursive;
    border: 2px solid #219150;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.18s, color 0.18s;
    font-weight: 500;
    outline: none;
    min-width: 80px;
}

.modal-btn.confirm {
    background: #219150;
    color: #fff;
}

.modal-btn.confirm:hover,
.modal-btn.confirm:focus {
    background: #1976d2;
    border-color: #1976d2;
}

.modal-btn.cancel {
    background: #fff;
    color: #219150;
}

.modal-btn.cancel:hover,
.modal-btn.cancel:focus {
    background: #eafaf1;
    border-color: #43ea7a;
}

@keyframes popout-bounce {
    0% {
        transform: scale(0.7);
        opacity: 0;
    }

    60% {
        transform: scale(1.1);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.hands-divider {
    display: none;
}