* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: url('/static/bg1.jpeg') center center / cover no-repeat fixed;
    min-height: 100vh;
    padding: 20px;
    position: relative;
    overflow-x: hidden;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    pointer-events: none;
    z-index: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

header {
    text-align: left;
    margin-bottom: 10px;
    padding: 10px 0;
}

.board-header {
    display: flex;
    justify-content: flex-start;
    padding: 0 0 10px 0;
}

/* Hamburger Menu */
.hamburger-menu {
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 10px 12px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 5px;
    transition: all 0.3s;
    border-radius: 8px;
}

.hamburger-menu span {
    display: block;
    width: 25px;
    height: 3px;
    background: white;
    transition: all 0.3s;
    border-radius: 2px;
}

.hamburger-menu:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

/* Side Menu */
.side-menu {
    position: fixed;
    top: 0;
    left: -320px;
    width: 300px;
    height: 100%;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.98) 0%, rgba(118, 75, 162, 0.98) 100%);
    backdrop-filter: blur(20px);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5);
    transition: left 0.3s ease;
    z-index: 1001;
    overflow-y: auto;
    padding: 20px;
}

.side-menu.open {
    left: 0;
}

.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    z-index: 1000;
}

.menu-overlay.open {
    opacity: 1;
    visibility: visible;
}

.menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.3);
}

.menu-header h2 {
    color: white;
    margin: 0;
    font-size: 1.8em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.close-menu {
    background: transparent;
    border: none;
    color: white;
    font-size: 2em;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    box-shadow: none;
}

.close-menu:hover {
    transform: scale(1.2) rotate(90deg);
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
}

.menu-section {
    margin-bottom: 30px;
}

.menu-section h3 {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.2em;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.menu-btn {
    width: 100%;
    margin-bottom: 10px;
    text-align: left;
    padding: 12px 20px;
    font-size: 16px;
    justify-content: flex-start;
}

.difficulty-indicator {
    color: white;
    font-size: 1.1em;
    margin-bottom: 15px;
    font-weight: 500;
}

.difficulty-indicator #currentDifficulty {
    font-weight: bold;
    color: #ffe66d;
    text-shadow: 0 0 10px rgba(255, 230, 109, 0.5);
}

.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

button {
    padding: 10px 20px;
    font-size: 16px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow:
        0 4px 15px rgba(76, 175, 80, 0.3),
        0 2px 5px rgba(0, 0, 0, 0.2);
    font-weight: 500;
}

button:hover {
    background: linear-gradient(135deg, #45a049 0%, #4CAF50 100%);
    transform: translateY(-2px);
    box-shadow:
        0 6px 20px rgba(76, 175, 80, 0.4),
        0 4px 8px rgba(0, 0, 0, 0.3);
}

button:active {
    transform: translateY(1px);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: linear-gradient(135deg, #999 0%, #888 100%);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

button:disabled:hover {
    transform: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

#soundToggle, #helpButton {
    font-size: 16px;
    padding: 8px 15px;
    min-width: 50px;
}

.difficulty-selector {
    display: flex;
    gap: 5px;
    background: rgba(255, 255, 255, 0.1);
    padding: 4px;
    border-radius: 8px;
}

.difficulty-btn {
    padding: 8px 15px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    transition: all 0.3s;
}

.difficulty-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.difficulty-btn.active {
    background: linear-gradient(135deg, #ffe66d 0%, #ffd700 100%);
    color: #333;
    font-weight: bold;
    border-color: #ffd700;
    box-shadow: 0 4px 15px rgba(255, 230, 109, 0.4);
}

.game-type-selector {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 10px;
}

.game-type-btn {
    padding: 10px 25px;
    font-size: 16px;
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    transition: all 0.3s;
    font-weight: 500;
}

.game-type-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
}

.game-type-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #764ba2;
    color: white;
    font-weight: bold;
    box-shadow: 0 6px 15px rgba(102, 126, 234, 0.5);
}

.left-area {
    display: flex;
    gap: 10px;
    align-items: center;
}

.stock-pile, .waste-pile {
    cursor: pointer;
}

.stock-pile {
    border: 2px dashed rgba(255, 255, 255, 0.4);
}

.card.face-down {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.card.face-down .card-rank,
.card.face-down .card-suit,
.card.face-down .card-corner {
    display: none;
}

.card.face-down::before {
    content: '🂠';
    font-size: 48px;
    color: rgba(255, 255, 255, 0.3);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.game-board {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 25px;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    touch-action: none;
}

.top-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 30px;
    gap: 30px;
}

.freecells, .foundations {
    display: flex;
    gap: 10px;
}

.card-slot {
    width: 90px;
    height: 125px;
    border: 2px dashed rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    position: relative;
    transition: all 0.2s;
}

.card-slot.drag-over {
    background: rgba(76, 175, 80, 0.5);
    border-color: #4CAF50;
    border-width: 3px;
    transform: scale(1.08);
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.6);
}

.foundation-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 48px;
    opacity: 0.3;
}

.tableau {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.column {
    width: 90px;
    min-height: 150px;
    border: 2px dashed rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 5px;
    position: relative;
    background: rgba(255, 255, 255, 0.03);
    transition: all 0.2s;
    margin: 0 2px;
}

.column.drag-over {
    background: rgba(76, 175, 80, 0.4);
    border-color: #4CAF50;
    border-width: 3px;
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.5);
}

.card {
    width: 80px;
    height: 115px;
    background: linear-gradient(180deg, #fffdf7 0%, #f7efe4 100%);
    border: 2px solid #1f1f1f;
    border-radius: 8px;
    padding: 5px;
    cursor: grab;
    position: absolute;
    left: 5px;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.28), inset 0 0 0 1px rgba(255, 255, 255, 0.6);
    transition: all 0.1s;
    user-select: none;
    touch-action: none;
}

.card:not(.face-down)::before {
    content: '';
    position: absolute;
    inset: 6px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 6px;
    pointer-events: none;
}

.card:not(.face-down)::after {
    content: attr(data-suit);
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 56px;
    opacity: 0.12;
    pointer-events: none;
}

.card:active {
    cursor: grabbing;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}

.card.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.card.red {
    color: #d32f2f;
}

.card.black {
    color: #212121;
}

.card-rank {
    font-size: 20px;
    font-weight: bold;
    font-family: "Georgia", "Times New Roman", serif;
    pointer-events: none;
}

.card-suit {
    font-size: 26px;
    text-align: center;
    margin-top: 10px;
    pointer-events: none;
}

.card-corner {
    position: absolute;
    bottom: 5px;
    right: 5px;
    font-size: 14px;
    font-family: "Georgia", "Times New Roman", serif;
    pointer-events: none;
}

/* Card positioning in columns */
.column .card {
    position: absolute;
}

.freecell .card,
.foundation .card {
    position: static;
    margin: 0 auto;
}

.win-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    text-align: center;
    z-index: 1000;
    animation: winPopIn 0.5s ease-out;
}

.win-message h2 {
    color: #4CAF50;
    font-size: 2em;
    margin-bottom: 20px;
    animation: winPulse 1s ease-in-out infinite;
}

.win-message p {
    font-size: 1.2em;
    margin-bottom: 20px;
}

@keyframes winPopIn {
    0% {
        transform: translate(-50%, -50%) scale(0.3);
        opacity: 0;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.1);
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

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

/* Confetti celebration */
.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #f0f;
    animation: confettiFall 3s linear forwards;
    z-index: 999;
}

@keyframes confettiFall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

.confetti:nth-child(1) { background: #ff6b6b; left: 10%; animation-delay: 0s; }
.confetti:nth-child(2) { background: #4ecdc4; left: 20%; animation-delay: 0.1s; }
.confetti:nth-child(3) { background: #ffe66d; left: 30%; animation-delay: 0.2s; }
.confetti:nth-child(4) { background: #a8e6cf; left: 40%; animation-delay: 0.3s; }
.confetti:nth-child(5) { background: #ff8b94; left: 50%; animation-delay: 0.4s; }
.confetti:nth-child(6) { background: #c7ceea; left: 60%; animation-delay: 0.5s; }
.confetti:nth-child(7) { background: #ffd3b6; left: 70%; animation-delay: 0.6s; }
.confetti:nth-child(8) { background: #dcedc1; left: 80%; animation-delay: 0.7s; }
.confetti:nth-child(9) { background: #ffaaa5; left: 90%; animation-delay: 0.8s; }
.confetti:nth-child(10) { background: #ff8c94; left: 15%; animation-delay: 0.9s; }

.auto-complete-message {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 30px;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    text-align: center;
    z-index: 999;
    animation: slideUp 0.4s ease-out;
}

.auto-complete-message p {
    font-size: 1.1em;
    margin-bottom: 15px;
    font-weight: 500;
}

.auto-complete-message button {
    background: white;
    color: #667eea;
    font-weight: bold;
    border: none;
    padding: 10px 25px;
    font-size: 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.auto-complete-message button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.3);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.stack-error-message {
    position: fixed;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    color: white;
    padding: 15px 25px;
    border-radius: 10px;
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.4);
    text-align: center;
    z-index: 998;
    animation: slideDown 0.3s ease-out;
    max-width: 90%;
}

.stack-error-message p {
    margin: 0;
    font-size: 1em;
    font-weight: 500;
    line-height: 1.4;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.hidden {
    display: none;
}

/* Card dealing animation */
@keyframes dealCard {
    0% {
        transform: translateY(-200px) translateX(-100px) rotateZ(-10deg);
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        transform: translateY(0) translateX(0) rotateZ(0);
        opacity: 1;
    }
}

.card.dealing {
    animation: dealCard 0.4s ease-out forwards;
}

/* Hint highlight animation */
@keyframes hintPulse {
    0%, 100% {
        box-shadow: 0 0 20px 5px rgba(255, 215, 0, 0.8), 0 2px 5px rgba(0, 0, 0, 0.3);
        transform: translateY(-8px) scale(1.05);
    }
    50% {
        box-shadow: 0 0 30px 8px rgba(255, 215, 0, 1), 0 4px 10px rgba(0, 0, 0, 0.4);
        transform: translateY(-12px) scale(1.08);
    }
}

.card.hint-highlight {
    animation: hintPulse 0.6s ease-in-out 3;
    z-index: 100;
    border-color: gold;
    border-width: 3px;
}

.card-slot.hint-highlight {
    animation: hintPulse 0.6s ease-in-out 3;
    border-color: gold;
    border-width: 3px;
}

/* Responsive design */
@media (max-width: 900px) {
    body {
        padding: 10px;
    }

    header h1 {
        font-size: 1.8em;
        margin-bottom: 8px;
    }

    .difficulty-indicator {
        font-size: 0.95em;
        margin-bottom: 10px;
    }

    .controls {
        gap: 8px;
        flex-wrap: wrap;
    }

    button {
        padding: 8px 15px;
        font-size: 14px;
    }

    .difficulty-selector {
        order: -1;
        width: 100%;
        justify-content: center;
    }

    .difficulty-btn {
        flex: 1;
        font-size: 13px;
        padding: 6px 10px;
    }

    .game-board {
        padding: 15px;
    }

    .top-row {
        gap: 10px;
        margin-bottom: 20px;
    }

    .freecells, .foundations {
        gap: 6px;
    }

    .tableau {
        gap: 4px;
    }

    .column {
        width: 42px;
        min-height: 100px;
        padding: 3px;
    }

    .card-slot {
        width: 42px;
        height: 58px;
    }

    .card {
        width: 36px;
        height: 52px;
        left: 3px;
        padding: 3px;
    }

    .card-rank {
        font-size: 22px;
    }

    .card-suit {
        font-size: 14px;
        margin-top: 4px;
    }

    .card-corner {
        font-size: 16px;
        bottom: 3px;
        right: 3px;
    }

    .foundation-label {
        font-size: 24px;
    }

    .column .card {
        left: 3px;
    }

    .card:hover {
        transform: translateY(-3px);
    }

    .win-message {
        padding: 30px;
        max-width: 90%;
    }

    .win-message h2 {
        font-size: 1.5em;
    }

    .win-message p {
        font-size: 1em;
    }

    .auto-complete-message {
        bottom: 20px;
        padding: 15px 20px;
        max-width: 90%;
    }

    .auto-complete-message p {
        font-size: 0.95em;
        margin-bottom: 10px;
    }

    .auto-complete-message button {
        font-size: 14px;
        padding: 8px 20px;
    }

    .stack-error-message {
        top: 80px;
        padding: 12px 20px;
        font-size: 0.9em;
    }
}

@media (max-width: 480px) {
    body {
        padding: 0;
    }

    .container {
        max-width: 100%;
        margin: 0;
        padding: 0;
    }

    header {
        padding: 5px;
        margin-bottom: 5px;
    }

    .hamburger-menu {
        padding: 8px 10px;
    }

    .hamburger-menu span {
        width: 20px;
        height: 2px;
    }

    .game-board {
        padding: 3px;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
    }

    .top-row {
        gap: 3px;
        margin-bottom: 10px;
        padding: 0 2px;
    }

    .freecells, .foundations, .left-area {
        gap: 3px;
    }

    .freecell, .foundation, .stock-pile, .waste-pile {
        flex: 1;
        min-width: 48px;
        max-width: 60px;
    }

    .tableau {
        gap: 1px;
        padding: 0;
        justify-content: space-evenly;
    }

    .column {
        flex: 1;
        min-width: 48px;
        max-width: 60px;
        min-height: 80px;
        padding: 1px;
    }

    .card-slot {
        width: 100%;
        height: 70px;
    }

    .card {
        width: calc(100% - 2px);
        height: 68px;
        left: 1px;
        padding: 2px;
    }

    .card-rank {
        font-size: 24px;
    }

    .card-suit {
        font-size: 16px;
        margin-top: 5px;
    }

    .card-corner {
        font-size: 18px;
        bottom: 2px;
        right: 2px;
    }

    .foundation-label {
        font-size: 24px;
    }

    .column .card {
        left: 1px;
    }

    .card.face-down::before {
        font-size: 32px;
    }
}

/* Landscape orientation on mobile - use larger cards */
@media (max-height: 500px) and (orientation: landscape) {
    body {
        padding: 5px !important;
    }

    header h1 {
        font-size: 1.4em !important;
        margin-bottom: 5px !important;
    }

    .controls {
        gap: 5px !important;
    }

    button {
        padding: 5px 10px !important;
        font-size: 12px !important;
    }

    .game-board {
        padding: 8px !important;
    }

    .top-row {
        gap: 6px !important;
        margin-bottom: 10px !important;
    }

    .freecells, .foundations {
        gap: 4px !important;
    }

    .tableau {
        gap: 4px !important;
    }

    .column {
        width: 52px !important;
        min-height: 100px !important;
        padding: 3px !important;
    }

    .card-slot {
        width: 52px !important;
        height: 72px !important;
    }

    .card {
        width: 46px !important;
        height: 66px !important;
        left: 3px !important;
        padding: 3px !important;
    }

    .card-rank {
        font-size: 13px !important;
    }

    .card-suit {
        font-size: 18px !important;
        margin-top: 6px !important;
    }

    .card-corner {
        font-size: 9px !important;
    }

    .foundation-label {
        font-size: 30px !important;
    }

    .column .card {
        left: 3px !important;
    }

    .card:hover {
        transform: translateY(-3px) !important;
    }
}
