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

body {
    font-family: "Arial", sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    /* align-items: center; */
    color: #333;
}

.game-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    max-width: 800px;
    width: 100%;
}

/* Modern Header Design */
.header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    margin-bottom: 15px;
    padding: 8px 16px;
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.1),
        rgba(255, 255, 255, 0.05)
    );
    border-radius: 12px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.header-left {
    display: flex;
    justify-content: flex-start;
}

.header-center {
    display: flex;
    justify-content: center;
}

.header-right {
    display: flex;
    justify-content: flex-end;
}

/* Game Title */
.game-title {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    font-size: 1.3em;
    font-weight: 700;
    color: var(--header-color);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.title-icon {
    font-size: 1.1em;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

.title-text {
    background: linear-gradient(
        135deg,
        var(--header-color),
        var(--score-color)
    );
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Score Display */
.score-display {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 4px 12px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.1);
}

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

.score-label {
    font-size: 0.65em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-color);
    opacity: 0.7;
    margin-bottom: 1px;
}

.score-value {
    font-size: 1.1em;
    font-weight: 700;
    color: var(--score-color);
    line-height: 1;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.current-score .score-value {
    color: #4facfe;
}

.best-score .score-value {
    color: #ffbe0b;
}

.score-divider {
    width: 1px;
    height: 20px;
    background: linear-gradient(
        180deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    margin: 0 12px;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

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

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

.restart-btn {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
    padding: 6px 12px;
    font-size: 0.85em;
}

.restart-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.4);
}

.settings-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 6px;
    width: 24px;
    height: 24px;
    justify-content: center;
}

.settings-btn:hover {
    transform: translateY(-1px) rotate(90deg);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-icon {
    font-size: 1em;
    line-height: 1;
}

.btn-text {
    font-size: 0.85em;
    line-height: 1;
}

.game-area {
    display: flex;
    gap: 30px;
    justify-content: space-between;
}

.grid-container {
    flex: 1;
    position: relative;
}

.game-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    grid-template-rows: repeat(10, 1fr);
    gap: 2px;
    background: #2d3748;
    padding: 10px;
    border-radius: 10px;
    width: 400px;
    height: 400px;
}

.grid-cell {
    background: #4a5568;
    border-radius: 3px;
    transition: all 0.2s ease;
    border: 1px solid #2d3748;
    cursor: pointer;
}

.grid-cell.filled {
    background: linear-gradient(135deg, #4facfe, #00f2fe);
    box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.3);
}

.grid-cell.preview {
    border: 2px solid #4facfe;
    box-shadow: inset 0 0 8px rgba(79, 172, 254, 0.5);
    transform: scale(1.05);
    transition: all 0.1s ease;
}

.grid-cell.invalid {
    background: rgba(255, 107, 107, 0.7) !important;
    border: 2px solid #ff6b6b;
    box-shadow: inset 0 0 8px rgba(255, 107, 107, 0.5);
    transform: scale(1.05);
    transition: all 0.1s ease;
}

.pieces-container {
    width: 200px;
    background: rgba(255, 255, 255, 0.8);
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.pieces-container h3 {
    text-align: center;
    margin-bottom: 10px;
    color: #2d3748;
    font-size: 1.2em;
}

.interaction-hint {
    text-align: center;
    font-size: 0.85em;
    color: #666;
    margin-bottom: 15px;
    font-style: italic;
    opacity: 0.8;
}

.pieces-queue {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.piece-preview {
    width: 100%;
    height: 80px;
    background: #f7fafc;
    border: 2px dashed #cbd5e0;
    border-radius: 10px;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.piece-preview:hover {
    transform: scale(1.05);
    border-color: #4facfe;
}

.piece-preview.dragging {
    opacity: 0.3;
    transform: scale(0.85);
    transition: all 0.2s ease;
}

.piece-preview.selected {
    border: 3px solid #4facfe;
    border-style: solid;
    background: rgba(79, 172, 254, 0.1);
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(79, 172, 254, 0.5);
    animation: selectedPulse 1.5s ease-in-out infinite;
}

@keyframes selectedPulse {
    0%,
    100% {
        box-shadow: 0 0 15px rgba(79, 172, 254, 0.5);
    }
    50% {
        box-shadow: 0 0 25px rgba(79, 172, 254, 0.8);
    }
}

.piece-preview .piece-grid {
    display: grid;
    gap: 2px;
}

.piece-preview .piece-cell {
    width: 12px;
    height: 12px;
    background: linear-gradient(135deg, #4facfe, #00f2fe);
    border-radius: 2px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.game-over-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    animation: modalAppear 0.3s ease forwards;
}

@keyframes modalAppear {
    to {
        transform: scale(1);
    }
}

.modal-content h2 {
    color: #2d3748;
    margin-bottom: 20px;
    font-size: 2em;
}

.modal-content p {
    font-size: 1.3em;
    margin-bottom: 30px;
    color: #4a5568;
}

.play-again-btn {
    background: linear-gradient(135deg, #48bb78, #38a169);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 25px;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.play-again-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.settings-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.settings-modal .modal-content {
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 2px solid #eee;
}

.modal-header h2 {
    margin-bottom: 0;
}

.close-btn {
    background: none;
    border: none;
    font-size: 2em;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: #f0f0f0;
    color: #333;
}

.settings-content {
    text-align: left;
}

.settings-section {
    margin-bottom: 40px;
}

.settings-section:last-child {
    margin-bottom: 0;
}

.settings-content h3 {
    margin-bottom: 20px;
    color: #2d3748;
    font-size: 1.4em;
}

.theme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
}

.theme-option {
    cursor: pointer;
    padding: 15px;
    border-radius: 10px;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    text-align: center;
}

.theme-option:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.theme-option.active {
    border-color: #4facfe;
    background: rgba(79, 172, 254, 0.1);
}

.theme-preview {
    width: 100%;
    height: 60px;
    border-radius: 8px;
    margin-bottom: 10px;
    position: relative;
    overflow: hidden;
}

.theme-preview::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border-radius: 3px;
    box-shadow:
        0 0 0 2px currentColor,
        8px 0 0 2px currentColor,
        16px 0 0 2px currentColor,
        0 8px 0 2px currentColor,
        8px 8px 0 2px currentColor;
}

.theme-option span {
    font-size: 0.9em;
    font-weight: bold;
    color: #4a5568;
}

.default-preview {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.default-preview::before {
    color: #4facfe;
}

.neon-preview {
    background: linear-gradient(135deg, #0f0f23 0%, #1a1a2e 100%);
}

.neon-preview::before {
    color: #00ffff;
    box-shadow:
        0 0 0 2px currentColor,
        8px 0 0 2px currentColor,
        16px 0 0 2px currentColor,
        0 8px 0 2px currentColor,
        8px 8px 0 2px currentColor,
        0 0 10px currentColor;
}

.ocean-preview {
    background: linear-gradient(135deg, #006994 0%, #004d6b 100%);
}

.ocean-preview::before {
    color: #20b2aa;
}

.space-preview {
    background: linear-gradient(135deg, #0c0c0c 0%, #1a0a2e 100%);
    position: relative;
}

.space-preview::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(circle at 20% 20%, white 1px, transparent 1px),
        radial-gradient(circle at 60% 40%, white 0.5px, transparent 0.5px),
        radial-gradient(circle at 80% 80%, white 1px, transparent 1px);
    background-size:
        30px 30px,
        20px 20px,
        40px 40px;
}

.space-preview::before {
    color: #9932cc;
    z-index: 1;
}

.forest-preview {
    background: linear-gradient(135deg, #2d5016 0%, #1a3409 100%);
}

.forest-preview::before {
    color: #32cd32;
}

.retro-preview {
    background: linear-gradient(135deg, #ff006e 0%, #8338ec 100%);
}

.retro-preview::before {
    color: #ffbe0b;
}

.minimalist-preview {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.minimalist-preview::before {
    color: #495057;
}

.candy-preview {
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
}

.candy-preview::before {
    color: #ff6b9d;
}

.high-scores-container {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
    padding: 20px;
}

.high-scores-list {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 15px;
}

.high-score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    border-left: 4px solid #4facfe;
}

.high-score-item.current-best {
    border-left-color: #ffbe0b;
    background: rgba(255, 190, 11, 0.1);
}

.score-details {
    display: flex;
    flex-direction: column;
}

.score-value {
    font-size: 1.2em;
    font-weight: bold;
    color: #2d3748;
}

.score-date {
    font-size: 0.9em;
    color: #666;
    margin-top: 2px;
}

.score-rank {
    font-size: 1.1em;
    font-weight: bold;
    color: #4facfe;
    min-width: 30px;
}

.no-scores {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 20px;
}

.clear-scores-btn {
    width: 100%;
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.clear-scores-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 107, 107, 0.3);
}

.clear-scores-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Score Tabs */
.score-tabs {
    display: flex;
    margin-bottom: 15px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid #e0e0e0;
}

.score-tab {
    flex: 1;
    padding: 12px 20px;
    background: #f5f5f5;
    border: none;
    cursor: pointer;
    font-weight: bold;
    color: #666;
    transition: all 0.3s ease;
}

.score-tab:hover {
    background: #e8e8e8;
    color: #333;
}

.score-tab.active {
    background: #4facfe;
    color: white;
}

.scores-content {
    display: none;
}

.scores-content.active {
    display: block;
}

.refresh-global-btn {
    width: 100%;
    background: linear-gradient(135deg, #4facfe, #00f2fe);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.refresh-global-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(79, 172, 254, 0.3);
}

.loading {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 20px;
}

.global-score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    border-left: 4px solid #4facfe;
}

.global-score-item.top-3 {
    border-left-color: #ffbe0b;
    background: rgba(255, 190, 11, 0.1);
}

.global-score-item.current-player {
    border-left-color: #48bb78;
    background: rgba(72, 187, 120, 0.1);
}

.score-name {
    font-size: 1em;
    font-weight: bold;
    color: #4a5568;
    margin-top: 2px;
}

/* Name Input Modal */
.name-input-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.name-input-content {
    text-align: center;
}

.name-input-content p {
    font-size: 1.1em;
    margin-bottom: 15px;
    color: #4a5568;
}

.name-input-group {
    position: relative;
    margin: 20px 0;
}

#player-name-input {
    width: 100%;
    padding: 15px 20px;
    font-size: 1.2em;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    outline: none;
    transition: all 0.3s ease;
    background: #f8f9fa;
}

#player-name-input:focus {
    border-color: #4facfe;
    background: white;
    box-shadow: 0 0 0 3px rgba(79, 172, 254, 0.1);
}

.character-count {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.9em;
    color: #666;
    pointer-events: none;
}

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

.submit-score-btn {
    background: linear-gradient(135deg, #48bb78, #38a169);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 25px;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.submit-score-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(72, 187, 120, 0.3);
}

.submit-score-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.skip-score-btn {
    background: #f0f0f0;
    color: #666;
    border: none;
    padding: 15px 30px;
    border-radius: 25px;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.skip-score-btn:hover {
    background: #e0e0e0;
    color: #333;
}

.submission-status {
    margin-top: 15px;
    padding: 10px;
    border-radius: 8px;
    font-weight: bold;
    text-align: center;
}

.submission-status.success {
    background: rgba(72, 187, 120, 0.1);
    color: #2f855a;
}

.submission-status.error {
    background: rgba(245, 101, 101, 0.1);
    color: #c53030;
}

.submission-status.loading {
    background: rgba(79, 172, 254, 0.1);
    color: #2b6cb0;
}

.audio-settings {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
    padding: 20px;
}

.sound-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

.sound-toggle label {
    font-size: 1.1em;
    font-weight: bold;
    color: #2d3748;
    cursor: pointer;
}

.sound-toggle input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.toggle-slider {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
    background: #ccc;
    border-radius: 24px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.sound-toggle input:checked + .toggle-slider {
    background: #4facfe;
}

.sound-toggle input:checked + .toggle-slider::before {
    transform: translateX(26px);
}

.sound-toggle:hover .toggle-slider {
    box-shadow: 0 0 0 3px rgba(79, 172, 254, 0.2);
}

/* Score Animation System */
.score-animations {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.floating-score {
    position: absolute;
    font-size: 1.5em;
    font-weight: bold;
    color: #4facfe;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    animation: floatUp 2s ease-out forwards;
    pointer-events: none;
}

.floating-score.bonus {
    color: #ffbe0b;
    font-size: 1.8em;
}

.floating-score.combo {
    color: #ff6b9d;
    font-size: 2em;
    text-shadow: 0 0 10px rgba(255, 107, 157, 0.8);
}

.floating-score.perfect {
    color: #48bb78;
    font-size: 2.2em;
    text-shadow: 0 0 15px rgba(72, 187, 120, 0.9);
}

@keyframes floatUp {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    20% {
        transform: translateY(-20px) scale(1.2);
    }
    100% {
        opacity: 0;
        transform: translateY(-100px) scale(0.8);
    }
}

/* Combo Indicator */
.combo-indicator {
    position: absolute;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #ff6b9d, #f06292);
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    box-shadow: 0 5px 15px rgba(255, 107, 157, 0.4);
    animation: comboPulse 0.6s ease-out;
    z-index: 20;
}

.combo-text {
    font-size: 0.9em;
    font-weight: bold;
    text-align: center;
    margin-bottom: 2px;
}

.combo-count {
    font-size: 1.4em;
    font-weight: bold;
    text-align: center;
}

@keyframes comboPulse {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Line Clear Effects */
.grid-cell.clearing {
    animation: clearFlash 0.5s ease-out;
}

@keyframes clearFlash {
    0% {
        background: var(--filled-cell-bg);
        transform: scale(1);
    }
    50% {
        background: linear-gradient(135deg, #ffbe0b, #fb8500);
        transform: scale(1.1);
        box-shadow: 0 0 20px rgba(255, 190, 11, 0.8);
    }
    100% {
        background: var(--grid-cell-bg);
        transform: scale(1);
        box-shadow: none;
    }
}

/* Perfect Clear Effect */
.perfect-clear-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(
        circle,
        rgba(72, 187, 120, 0.3) 0%,
        transparent 70%
    );
    animation: perfectClearEffect 1.5s ease-out forwards;
    pointer-events: none;
    z-index: 15;
}

@keyframes perfectClearEffect {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    50% {
        opacity: 1;
        transform: scale(1.2);
    }
    100% {
        opacity: 0;
        transform: scale(1);
    }
}

/* Size Bonus Indicator */
.size-bonus {
    position: absolute;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 1.2em;
    font-weight: bold;
    animation: sizeBonusAppear 1s ease-out forwards;
    z-index: 25;
}

@keyframes sizeBonusAppear {
    0% {
        opacity: 0;
        transform: scale(0.5) rotate(-10deg);
    }
    50% {
        opacity: 1;
        transform: scale(1.1) rotate(5deg);
    }
    100% {
        opacity: 0;
        transform: scale(0.9) rotate(0deg);
    }
}

/* Theme Styles */
:root {
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --container-bg: rgba(255, 255, 255, 0.95);
    --text-color: #333;
    --header-color: #4a5568;
    --score-color: #2d3748;
    --grid-bg: #2d3748;
    --grid-cell-bg: #4a5568;
    --grid-cell-border: #2d3748;
    --filled-cell-bg: linear-gradient(135deg, #4facfe, #00f2fe);
    --preview-cell-bg: rgba(79, 172, 254, 0.5);
    --preview-border: #4facfe;
    --invalid-cell-bg: rgba(255, 107, 107, 0.5);
    --invalid-border: #ff6b6b;
    --piece-container-bg: rgba(255, 255, 255, 0.8);
    --piece-preview-bg: #f7fafc;
    --piece-preview-border: #cbd5e0;
    --piece-cell-bg: linear-gradient(135deg, #4facfe, #00f2fe);
}

body.theme-neon {
    --bg-gradient: linear-gradient(135deg, #0f0f23 0%, #1a1a2e 100%);
    --container-bg: rgba(16, 20, 50, 0.95);
    --text-color: #00ffff;
    --header-color: #00ffff;
    --score-color: #00ffff;
    --grid-bg: #0a0a0a;
    --grid-cell-bg: #1a1a2e;
    --grid-cell-border: #0a0a0a;
    --filled-cell-bg: linear-gradient(135deg, #00ffff, #ff00ff);
    --preview-cell-bg: rgba(0, 255, 255, 0.3);
    --preview-border: #00ffff;
    --invalid-cell-bg: rgba(255, 0, 255, 0.3);
    --invalid-border: #ff00ff;
    --piece-container-bg: rgba(26, 26, 46, 0.9);
    --piece-preview-bg: #16213e;
    --piece-preview-border: #00ffff;
    --piece-cell-bg: linear-gradient(135deg, #00ffff, #ff00ff);
}

body.theme-neon * {
    text-shadow: 0 0 10px currentColor;
}

body.theme-neon .grid-cell.filled {
    box-shadow:
        inset 0 0 10px rgba(0, 255, 255, 0.5),
        0 0 15px rgba(0, 255, 255, 0.3);
}

body.theme-ocean {
    --bg-gradient: linear-gradient(135deg, #006994 0%, #004d6b 100%);
    --container-bg: rgba(0, 77, 107, 0.95);
    --text-color: #e0f7fa;
    --header-color: #b2ebf2;
    --score-color: #e0f7fa;
    --grid-bg: #003847;
    --grid-cell-bg: #004d5c;
    --grid-cell-border: #003847;
    --filled-cell-bg: linear-gradient(135deg, #20b2aa, #4dd0e1);
    --preview-cell-bg: rgba(32, 178, 170, 0.4);
    --preview-border: #20b2aa;
    --invalid-cell-bg: rgba(255, 107, 107, 0.4);
    --invalid-border: #ff6b6b;
    --piece-container-bg: rgba(0, 77, 107, 0.8);
    --piece-preview-bg: #006064;
    --piece-preview-border: #4dd0e1;
    --piece-cell-bg: linear-gradient(135deg, #20b2aa, #4dd0e1);
}

body.theme-space {
    --bg-gradient: linear-gradient(135deg, #0c0c0c 0%, #1a0a2e 100%);
    --container-bg: rgba(16, 16, 32, 0.95);
    --text-color: #e6e6fa;
    --header-color: #9932cc;
    --score-color: #e6e6fa;
    --grid-bg: #000;
    --grid-cell-bg: #1a0a2e;
    --grid-cell-border: #000;
    --filled-cell-bg: linear-gradient(135deg, #9932cc, #ff69b4);
    --preview-cell-bg: rgba(153, 50, 204, 0.4);
    --preview-border: #9932cc;
    --invalid-cell-bg: rgba(255, 105, 180, 0.4);
    --invalid-border: #ff69b4;
    --piece-container-bg: rgba(26, 10, 46, 0.9);
    --piece-preview-bg: #2e1065;
    --piece-preview-border: #9932cc;
    --piece-cell-bg: linear-gradient(135deg, #9932cc, #ff69b4);
}

body.theme-space {
    background-image:
        radial-gradient(circle at 25% 25%, white 2px, transparent 2px),
        radial-gradient(circle at 75% 75%, white 1px, transparent 1px),
        radial-gradient(circle at 50% 10%, white 1px, transparent 1px),
        var(--bg-gradient);
    background-size:
        100px 100px,
        60px 60px,
        80px 80px,
        100% 100%;
}

body.theme-forest {
    --bg-gradient: linear-gradient(135deg, #2d5016 0%, #1a3409 100%);
    --container-bg: rgba(45, 80, 22, 0.95);
    --text-color: #f1f8e9;
    --header-color: #8bc34a;
    --score-color: #f1f8e9;
    --grid-bg: #1b5e20;
    --grid-cell-bg: #2e7d32;
    --grid-cell-border: #1b5e20;
    --filled-cell-bg: linear-gradient(135deg, #32cd32, #228b22);
    --preview-cell-bg: rgba(50, 205, 50, 0.4);
    --preview-border: #32cd32;
    --invalid-cell-bg: rgba(255, 107, 107, 0.4);
    --invalid-border: #ff6b6b;
    --piece-container-bg: rgba(45, 80, 22, 0.8);
    --piece-preview-bg: #388e3c;
    --piece-preview-border: #8bc34a;
    --piece-cell-bg: linear-gradient(135deg, #32cd32, #228b22);
}

body.theme-retro {
    --bg-gradient: linear-gradient(135deg, #ff006e 0%, #8338ec 100%);
    --container-bg: rgba(131, 56, 236, 0.95);
    --text-color: #ffbe0b;
    --header-color: #ffbe0b;
    --score-color: #ffbe0b;
    --grid-bg: #3a015c;
    --grid-cell-bg: #560bad;
    --grid-cell-border: #3a015c;
    --filled-cell-bg: linear-gradient(135deg, #ffbe0b, #fb8500);
    --preview-cell-bg: rgba(255, 190, 11, 0.4);
    --preview-border: #ffbe0b;
    --invalid-cell-bg: rgba(255, 0, 110, 0.4);
    --invalid-border: #ff006e;
    --piece-container-bg: rgba(131, 56, 236, 0.8);
    --piece-preview-bg: #7209b7;
    --piece-preview-border: #ffbe0b;
    --piece-cell-bg: linear-gradient(135deg, #ffbe0b, #fb8500);
}

body.theme-minimalist {
    --bg-gradient: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    --container-bg: rgba(255, 255, 255, 0.95);
    --text-color: #495057;
    --header-color: #495057;
    --score-color: #495057;
    --grid-bg: #dee2e6;
    --grid-cell-bg: #f8f9fa;
    --grid-cell-border: #dee2e6;
    --filled-cell-bg: linear-gradient(135deg, #495057, #6c757d);
    --preview-cell-bg: rgba(73, 80, 87, 0.3);
    --preview-border: #495057;
    --invalid-cell-bg: rgba(220, 53, 69, 0.3);
    --invalid-border: #dc3545;
    --piece-container-bg: rgba(255, 255, 255, 0.9);
    --piece-preview-bg: #ffffff;
    --piece-preview-border: #ced4da;
    --piece-cell-bg: linear-gradient(135deg, #495057, #6c757d);
}

body.theme-candy {
    --bg-gradient: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
    --container-bg: rgba(254, 207, 239, 0.95);
    --text-color: #ad1457;
    --header-color: #e91e63;
    --score-color: #ad1457;
    --grid-bg: #f8bbd9;
    --grid-cell-bg: #fce4ec;
    --grid-cell-border: #f8bbd9;
    --filled-cell-bg: linear-gradient(135deg, #ff6b9d, #f06292);
    --preview-cell-bg: rgba(255, 107, 157, 0.4);
    --preview-border: #ff6b9d;
    --invalid-cell-bg: rgba(255, 87, 34, 0.4);
    --invalid-border: #ff5722;
    --piece-container-bg: rgba(254, 207, 239, 0.8);
    --piece-preview-bg: #fce4ec;
    --piece-preview-border: #f48fb1;
    --piece-cell-bg: linear-gradient(135deg, #ff6b9d, #f06292);
}

/* Apply theme variables */
body {
    background: var(--bg-gradient);
    color: var(--text-color);
}

.game-container {
    background: var(--container-bg);
}

.header h1 {
    color: var(--header-color);
}

.score {
    color: var(--score-color);
}

.game-grid {
    background: var(--grid-bg);
}

.grid-cell {
    background: var(--grid-cell-bg);
    border-color: var(--grid-cell-border);
}

.grid-cell.filled {
    background: var(--filled-cell-bg);
}

.grid-cell.preview {
    background: var(--preview-cell-bg);
    border-color: var(--preview-border);
}

.grid-cell.invalid {
    background: var(--invalid-cell-bg);
    border-color: var(--invalid-border);
}

.pieces-container {
    background: var(--piece-container-bg);
}

.piece-preview {
    background: var(--piece-preview-bg);
    border-color: var(--piece-preview-border);
}

.piece-preview .piece-cell {
    background: var(--piece-cell-bg);
}

/* Drag indicator for mobile */
.drag-indicator {
    pointer-events: none;
    z-index: 1000;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

/* Modern touch optimizations */
.game-container {
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

.piece-preview {
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
}

.game-grid {
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

.modern-drag-indicator {
    will-change: transform;
    transform-origin: center;
}

/* Improve touch targets on mobile */
@media (max-width: 768px) {
    .game-area {
        flex-direction: column;
        gap: 20px;
    }

    .game-grid {
        width: 100%;
        max-width: 350px;
        height: 350px;
        margin: 0 auto;
    }

    .grid-cell {
        min-height: 30px;
        min-width: 30px;
    }

    .pieces-container {
        width: 100%;
        max-width: 350px;
        margin: 0 auto;
        padding: 15px;
    }

    .pieces-queue {
        flex-direction: row;
        justify-content: space-around;
        gap: 10px;
    }

    .piece-preview {
        width: 90px;
        height: 90px;
        min-height: 90px;
        touch-action: none;
        user-select: none;
        -webkit-user-select: none;
        -webkit-touch-callout: none;
    }

    .piece-preview .piece-cell {
        width: 15px;
        height: 15px;
    }

    .interaction-hint {
        font-size: 0.9em;
        margin-bottom: 20px;
    }

    .header {
        grid-template-columns: auto 1fr auto;
        grid-template-rows: auto;
        gap: 8px;
        align-items: center;
        padding: 6px 12px;
        margin-bottom: 12px;
    }

    .header-left {
        justify-content: flex-start;
    }

    .header-center {
        justify-content: flex-end;
    }

    .header-right {
        justify-content: flex-end;
    }

    .game-title {
        font-size: 1.1em;
        font-weight: 600;
        gap: 4px;
    }

    .title-icon {
        font-size: 1em;
    }

    .score-display {
        padding: 2px 8px;
        border-radius: 6px;
    }

    .score-item {
        min-width: 35px;
    }

    .score-label {
        font-size: 0.55em;
        margin-bottom: 0;
    }

    .score-value {
        font-size: 0.9em;
    }

    .score-divider {
        height: 14px;
        margin: 0 6px;
    }

    .action-buttons {
        gap: 6px;
    }

    .restart-btn {
        background: transparent;
        border: none;
        padding: 0;
        font-size: 1.2em;
        width: auto;
        height: auto;
        min-width: 0;
        min-height: 0;
        justify-content: center;
    }

    .restart-btn:hover {
        background: transparent;
        transform: none;
        box-shadow: none;
    }

    .restart-btn .btn-text {
        display: none;
    }

    .settings-btn {
        background: transparent;
        border: none;
        width: auto;
        height: auto;
        min-width: 0;
        min-height: 0;
        padding: 0;
        font-size: 1.2em;
    }

    .settings-btn:hover {
        background: transparent;
        transform: none;
        box-shadow: none;
    }

    .btn-icon {
        font-size: 1em;
    }

    .btn-text {
        font-size: 0.7em;
    }
}

/* Improve touch responsiveness */
@media (pointer: coarse) {
    .piece-preview {
        border-width: 3px;
    }

    .piece-preview:hover {
        transform: scale(1.02);
    }

    .piece-preview.selected {
        transform: scale(1.08);
    }

    .grid-cell {
        transition: all 0.1s ease;
    }

    .action-btn {
        min-height: 48px;
        min-width: 48px;
    }
}
