/* ==========================================================================
   Memory Game - Modern Redesign
   ========================================================================== */

/* Main Container - Fit content, not full viewport */
.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #ffffff;
    overflow: visible;
    padding: 1rem;
}

.game-content {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 600px;
    padding: 0;
    position: relative;
}

/* ==========================================================================
   Top Bar - Compact Settings Row
   ========================================================================== */
.settings {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.4rem 0.75rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(21, 174, 191, 0.2);
    flex-shrink: 0;
    gap: 0.75rem;
    margin: 0;
    border-radius: 0;
    border: none;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.08);
}

.setting-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: linear-gradient(135deg, #f8fbfc 0%, #e8f4f8 100%);
    padding: 0.3rem 0.5rem;
    border-radius: 1.5rem;
    border: 1px solid rgba(21, 174, 191, 0.2);
    cursor: pointer;
}

.setting-item:hover {
    border-color: rgba(21, 174, 191, 0.4);
    background: linear-gradient(135deg, #ffffff 0%, #f0f8fa 100%);
}

.setting-item input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    cursor: pointer;
    accent-color: var(--primary-color, #15aebf);
    margin: 0;
}

.setting-text {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary, #718096);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.time-item {
    gap: 0.2rem;
}

.time-input {
    width: 2.5rem;
    padding: 0.15rem 0.25rem;
    font-size: 0.8rem;
    border: 1px solid rgba(21, 174, 191, 0.3);
    border-radius: 0.4rem;
    background: white;
    font-family: inherit;
    font-weight: 600;
    color: var(--primary-color, #15aebf);
    text-align: center;
}

.time-input:focus {
    outline: none;
    border-color: var(--primary-color, #15aebf);
    box-shadow: 0 0 0 2px rgba(21, 174, 191, 0.15);
}

.time-input::-webkit-inner-spin-button,
.time-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.time-input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

.time-unit {
    font-size: 0.7rem;
    color: var(--text-secondary, #718096);
    font-weight: 600;
}

/* Stats - Inline in top bar style */
.stats {
    display: flex;
    gap: 0.5rem;
    padding: 0;
    margin: 0;
    background: transparent;
    border-radius: 0;
    flex-shrink: 0;
}

.stat {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    background: linear-gradient(135deg, var(--primary-color, #15aebf) 0%, #4ecdc4 100%);
    padding: 0.35rem 0.7rem;
    border-radius: 2rem;
    box-shadow: 0 2px 8px rgba(21, 174, 191, 0.3);
}

.stat-label {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin: 0;
}

.stat-value {
    font-size: 0.9rem;
    font-weight: 800;
    color: white;
    background: none;
    -webkit-background-clip: unset;
    -webkit-text-fill-color: white;
    background-clip: unset;
}

/* ==========================================================================
   Game Area - Centered, fit content
   ========================================================================== */
.game-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    gap: 1rem;
    position: relative;
}

/* Timer - Shows countdown number in palette area */
.timer-circle-palette {
    font-size: clamp(2rem, 6vmin, 3rem);
    font-weight: 900;
    color: #e53935;
    animation: timerPulse 1s ease-in-out infinite;
    flex-shrink: 0;
    padding: 0 0.5rem;
}

@keyframes timerPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* Message Banner - Compact */
.message {
    padding: 0.35rem 1rem;
    border-radius: 2rem;
    font-size: 0.75rem;
    font-weight: 600;
    display: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
    animation: slideDown 0.2s ease-out;
    text-align: center;
    margin: 0 auto 0.3rem auto;
    max-width: fit-content;
    width: auto;
}

@keyframes slideDown {
    from { transform: translateY(-10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.message.show {
    display: block;
}

.message.success {
    background: linear-gradient(135deg, #00b894 0%, #55efc4 100%);
    color: white;
    border: none;
}

.message.error {
    background: linear-gradient(135deg, #e17055 0%, #ff7675 100%);
    color: white;
    border: none;
}

.message.info {
    background: linear-gradient(135deg, var(--primary-color, #15aebf) 0%, #4ecdc4 100%);
    color: white;
    border: none;
}

/* ==========================================================================
   Game Board - Large and Centered with Round Corners
   ========================================================================== */
.game-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: clamp(0.4rem, 1.5vmin, 0.8rem);
    padding: clamp(0.6rem, 2.5vmin, 1.2rem);
    background: rgba(255, 255, 255, 0.95);
    border-radius: 2rem;
    box-shadow:
        0 10px 40px rgba(21, 174, 191, 0.2),
        0 2px 10px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);

    /* Dynamic sizing based on viewport */
    width: clamp(250px, 65vmin, 500px);
    height: clamp(250px, 65vmin, 500px);
}

.grid-cell {
    background: linear-gradient(145deg, #f8fbfc 0%, #e8f4f8 100%);
    border: 3px dashed rgba(21, 174, 191, 0.3);
    border-radius: 1.25rem;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

.grid-cell:hover {
    border-color: rgba(21, 174, 191, 0.5);
    background: linear-gradient(145deg, #ffffff 0%, #f0f8fa 100%);
}

.grid-cell.drop-over {
    background: linear-gradient(145deg, rgba(21, 174, 191, 0.15) 0%, rgba(78, 205, 196, 0.15) 100%);
    border-color: var(--primary-color, #15aebf);
    border-style: solid;
    transform: scale(1.02);
    box-shadow:
        0 0 20px rgba(21, 174, 191, 0.3),
        inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* ==========================================================================
   Circles - 3D Style
   ========================================================================== */
.circle {
    width: 75%;
    height: 75%;
    border-radius: 50%;
    cursor: grab;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    -webkit-user-select: none;
    position: relative;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.circle::after {
    display: none;
}

.circle:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.circle:active,
.circle.dragging {
    transform: scale(0.95);
    cursor: grabbing;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* ==========================================================================
   Circle Palette - Sleek Bar
   ========================================================================== */
.circle-palette {
    display: flex;
    flex-wrap: wrap;
    gap: clamp(0.4rem, 1.5vmin, 0.75rem);
    padding: clamp(0.5rem, 2vmin, 1rem);
    background: rgba(255, 255, 255, 0.9);
    border-radius: 3rem;
    justify-content: center;
    align-items: center;
    box-shadow:
        0 5px 25px rgba(21, 174, 191, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    min-height: clamp(50px, 8vmin, 80px);
    width: clamp(250px, 65vmin, 500px);
}

.palette-circle {
    width: clamp(36px, 6vmin, 55px);
    height: clamp(36px, 6vmin, 55px);
    flex-shrink: 0;
}

/* ==========================================================================
   Buttons - Modern Style
   ========================================================================== */
.buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 0.5rem;
}

.btn {
    padding: 0.6rem 1.5rem;
    border: none;
    border-radius: 3rem;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: inherit;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s ease;
}

.btn:hover::before {
    left: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, #ffd93d 0%, #ffcd00 100%);
    color: #1a1a1a;
    box-shadow: 0 4px 15px rgba(255, 217, 61, 0.5);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(255, 217, 61, 0.6);
    background: linear-gradient(135deg, #ffe066 0%, #ffd93d 100%);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: linear-gradient(135deg, #ff6b35 0%, #ff8c5a 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 107, 53, 0.4);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(255, 107, 53, 0.5);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Touch drag clone */
#touch-drag-clone {
    border-radius: 50%;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
    z-index: 10000;
}

/* ==========================================================================
   Fullscreen Mode - Centered Layout
   ========================================================================== */
.tool-page-wrapper:fullscreen,
.tool-page-wrapper:-webkit-full-screen,
.tool-page-wrapper:-moz-full-screen {
    background: #ffffff;
}

.tool-page-wrapper:fullscreen .game-container,
.tool-page-wrapper:-webkit-full-screen .game-container,
.tool-page-wrapper:-moz-full-screen .game-container {
    height: 100vh;
    min-height: 100vh;
    justify-content: center;
    padding: 0;
}

.tool-page-wrapper:fullscreen .game-content,
.tool-page-wrapper:-webkit-full-screen .game-content,
.tool-page-wrapper:-moz-full-screen .game-content {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    max-width: none;
}

.tool-page-wrapper:fullscreen .settings,
.tool-page-wrapper:-webkit-full-screen .settings,
.tool-page-wrapper:-moz-full-screen .settings {
    display: none;
}

.tool-page-wrapper:fullscreen .stats,
.tool-page-wrapper:-webkit-full-screen .stats,
.tool-page-wrapper:-moz-full-screen .stats {
    position: absolute;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
}

.tool-page-wrapper:fullscreen .game-area,
.tool-page-wrapper:-webkit-full-screen .game-area,
.tool-page-wrapper:-moz-full-screen .game-area {
    flex: 1;
    min-height: 0;
    justify-content: center;
    padding: 0.5rem;
}

.tool-page-wrapper:fullscreen .game-board,
.tool-page-wrapper:-webkit-full-screen .game-board,
.tool-page-wrapper:-moz-full-screen .game-board {
    width: clamp(280px, 75vmin, 550px);
    height: clamp(280px, 75vmin, 550px);
    border-radius: 2rem;
}

.tool-page-wrapper:fullscreen .grid-cell,
.tool-page-wrapper:-webkit-full-screen .grid-cell,
.tool-page-wrapper:-moz-full-screen .grid-cell {
    border-radius: 1.5rem;
}

.tool-page-wrapper:fullscreen .circle-palette,
.tool-page-wrapper:-webkit-full-screen .circle-palette,
.tool-page-wrapper:-moz-full-screen .circle-palette {
    width: clamp(280px, 75vmin, 550px);
    min-height: clamp(55px, 9vmin, 85px);
    border-radius: 2.5rem;
}

.tool-page-wrapper:fullscreen .palette-circle,
.tool-page-wrapper:-webkit-full-screen .palette-circle,
.tool-page-wrapper:-moz-full-screen .palette-circle {
    width: clamp(40px, 7vmin, 60px);
    height: clamp(40px, 7vmin, 60px);
}

.tool-page-wrapper:fullscreen .timer-circle-palette,
.tool-page-wrapper:-webkit-full-screen .timer-circle-palette,
.tool-page-wrapper:-moz-full-screen .timer-circle-palette {
    font-size: clamp(2.5rem, 8vmin, 4rem);
}

.tool-page-wrapper:fullscreen .message,
.tool-page-wrapper:-webkit-full-screen .message,
.tool-page-wrapper:-moz-full-screen .message {
    font-size: clamp(0.9rem, 2.5vmin, 1.2rem);
    padding: 0.6rem 1.5rem;
}

.tool-page-wrapper:fullscreen .buttons,
.tool-page-wrapper:-webkit-full-screen .buttons,
.tool-page-wrapper:-moz-full-screen .buttons {
    margin-top: 0.75rem;
}

.tool-page-wrapper:fullscreen .btn,
.tool-page-wrapper:-webkit-full-screen .btn,
.tool-page-wrapper:-moz-full-screen .btn {
    padding: 0.6rem 1.5rem;
    font-size: clamp(0.75rem, 2vmin, 1rem);
}

.tool-page-wrapper:fullscreen .stat,
.tool-page-wrapper:-webkit-full-screen .stat,
.tool-page-wrapper:-moz-full-screen .stat {
    padding: 0.4rem 0.8rem;
}

.tool-page-wrapper:fullscreen .stat-value,
.tool-page-wrapper:-webkit-full-screen .stat-value,
.tool-page-wrapper:-moz-full-screen .stat-value {
    font-size: clamp(0.8rem, 2vmin, 1.1rem);
}

/* Landscape Fullscreen - Side by side layout */
@media (orientation: landscape) {
    .tool-page-wrapper:fullscreen .game-area,
    .tool-page-wrapper:-webkit-full-screen .game-area,
    .tool-page-wrapper:-moz-full-screen .game-area {
        flex-direction: row;
        gap: 1.5rem;
        padding: 0.5rem 1rem;
    }

    .tool-page-wrapper:fullscreen .game-board,
    .tool-page-wrapper:-webkit-full-screen .game-board,
    .tool-page-wrapper:-moz-full-screen .game-board {
        width: clamp(250px, 60vh, 500px);
        height: clamp(250px, 60vh, 500px);
    }

    .tool-page-wrapper:fullscreen .circle-palette,
    .tool-page-wrapper:-webkit-full-screen .circle-palette,
    .tool-page-wrapper:-moz-full-screen .circle-palette {
        flex-direction: column;
        width: auto;
        height: clamp(250px, 60vh, 500px);
        min-height: unset;
        min-width: clamp(55px, 8vh, 80px);
        border-radius: 2rem;
    }

    .tool-page-wrapper:fullscreen .buttons,
    .tool-page-wrapper:-webkit-full-screen .buttons,
    .tool-page-wrapper:-moz-full-screen .buttons {
        position: absolute;
        bottom: 1rem;
        left: 50%;
        transform: translateX(-50%);
    }
}

/* ==========================================================================
   Mobile Responsive
   ========================================================================== */
@media (max-width: 600px) {
    .game-container {
        padding: 0.5rem;
    }

    .settings {
        padding: 0.3rem 0.5rem;
        gap: 0.4rem;
    }

    .setting-item {
        padding: 0.2rem 0.4rem;
    }

    .setting-item input[type="checkbox"] {
        width: 0.9rem;
        height: 0.9rem;
    }

    .setting-text {
        font-size: 0.6rem;
    }

    .time-input {
        width: 2rem;
        padding: 0.1rem 0.2rem;
        font-size: 0.7rem;
    }

    .time-unit {
        font-size: 0.6rem;
    }

    .stat {
        padding: 0.25rem 0.5rem;
    }

    .stat-label {
        font-size: 0.55rem;
    }

    .stat-value {
        font-size: 0.75rem;
    }

    .game-area {
        padding: 0.3rem;
        gap: 0.5rem;
    }

    .game-board {
        width: clamp(220px, 70vmin, 300px);
        height: clamp(220px, 70vmin, 300px);
        border-radius: 1.5rem;
        gap: 0.3rem;
        padding: 0.5rem;
    }

    .grid-cell {
        border-radius: 1rem;
        border-width: 2px;
    }

    .circle-palette {
        width: clamp(220px, 70vmin, 300px);
        min-height: 45px;
        padding: 0.4rem;
        gap: 0.4rem;
        border-radius: 2rem;
    }

    .palette-circle {
        width: clamp(30px, 7vmin, 40px);
        height: clamp(30px, 7vmin, 40px);
    }

    .buttons {
        gap: 0.5rem;
        margin-top: 0.25rem;
    }

    .btn {
        padding: 0.4rem 0.9rem;
        font-size: 0.75rem;
    }

    .timer-circle-palette {
        font-size: clamp(1.8rem, 5vmin, 2.5rem);
    }

    .message {
        font-size: 0.7rem;
        padding: 0.3rem 0.8rem;
    }
}

@media (max-width: 380px) {
    .game-container {
        padding: 0.25rem;
    }

    .settings {
        padding: 0.25rem 0.4rem;
        gap: 0.3rem;
    }

    .setting-item {
        padding: 0.15rem 0.3rem;
    }

    .game-area {
        padding: 0.2rem;
        gap: 0.4rem;
    }

    .game-board {
        width: clamp(200px, 72vmin, 270px);
        height: clamp(200px, 72vmin, 270px);
    }

    .circle-palette {
        width: clamp(200px, 72vmin, 270px);
        min-height: 40px;
    }

    .palette-circle {
        width: clamp(26px, 6vmin, 36px);
        height: clamp(26px, 6vmin, 36px);
    }

    .btn {
        padding: 0.35rem 0.7rem;
        font-size: 0.65rem;
    }

    .timer-circle-palette {
        font-size: clamp(1.5rem, 4vmin, 2rem);
    }
}


/* ==========================================================================
   Confetti Celebration Effect
   ========================================================================== */
.confetti-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 2000;
    overflow: hidden;
}

.confetti-piece {
    position: absolute;
    width: 10px;
    height: 10px;
    top: -20px;
    animation: confetti-fall 3s linear forwards;
}

@keyframes confetti-fall {
    0% {
        transform: translateY(-10px) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* Congratulations overlay */
.congratulations-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1500;
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.congratulations-text {
    font-size: clamp(1.5rem, 5vmin, 2.5rem);
    font-weight: 800;
    background: linear-gradient(135deg, #ffd93d 0%, #ff6b35 50%, #15aebf 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
    padding: 1rem;
    animation: celebratePulse 1s ease-in-out infinite;
}

@keyframes celebratePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.congratulations-score {
    font-size: clamp(1rem, 3vmin, 1.5rem);
    color: var(--primary-color, #15aebf);
    font-weight: 600;
    margin-top: 0.5rem;
}

.congratulations-btn {
    margin-top: 1.5rem;
    padding: 0.8rem 2rem;
    background: linear-gradient(135deg, #ffd93d 0%, #ffcd00 100%);
    color: #1a1a1a;
    border: none;
    border-radius: 3rem;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(255, 217, 61, 0.5);
    transition: all 0.2s ease;
}

.congratulations-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(255, 217, 61, 0.6);
}
