* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

:root {
    /* CLAUDE.md 색상 팔레트 */
    --bg-primary: #0a0a1a;
    --bg-secondary: #12122a;
    --bg-tertiary: #1a1a2e;
    --grid-bg: #0d0d1a;
    --grid-line: #1e1e2e;
    --cell-empty: #15151f;
    --cell-hover: rgba(255, 255, 255, 0.1);
    --cell-valid: rgba(100, 255, 150, 0.2);
    --cell-invalid: rgba(255, 100, 100, 0.2);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: #555566;
    --accent: #a855f7;
    --accent-glow: rgba(168, 85, 247, 0.4);
    --accent-gold: #ffd700;
    --accent-cyan: #00d4ff;
    --accent-pink: #ff6b9d;
    --accent-orange: #ff8c00;
    --accent-green: #22c55e;

    /* Block colors */
    --gray: #7a7a8a;
    --gray-light: #9a9aaa;
    --gray-dark: #5a5a6a;

    --red: #ef4444;
    --red-light: #f87171;
    --red-dark: #dc2626;

    --blue: #3b82f6;
    --blue-light: #60a5fa;
    --blue-dark: #2563eb;

    --green: #22c55e;
    --green-light: #4ade80;
    --green-dark: #16a34a;

    --yellow: #ffd700;
    --yellow-light: #ffdf33;
    --yellow-dark: #ccac00;

    --purple: #a855f7;
    --purple-light: #c084fc;
    --purple-dark: #9333ea;

    --cyan: #00d4ff;
    --cyan-light: #33ddff;
    --cyan-dark: #00a8cc;

    --orange: #ff8c00;
    --orange-light: #ffa333;
    --orange-dark: #cc7000;

    --pink: #ff6b9d;
    --pink-light: #ff8db3;
    --pink-dark: #cc567e;
}

body {
    font-family: 'Noto Sans KR', sans-serif;
    background: var(--bg-primary);
    min-height: 100vh;
    min-height: 100dvh;
    color: var(--text-primary);
    padding: 20px;
    padding-bottom: 40px;
}

/* 배경 효과 */
.bg-effects {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.bg-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.3;
    animation: float 15s ease-in-out infinite;
}

.bg-orb:nth-child(1) {
    width: 400px;
    height: 400px;
    background: var(--accent);
    top: -100px;
    left: -100px;
}

.bg-orb:nth-child(2) {
    width: 350px;
    height: 350px;
    background: var(--accent-gold);
    bottom: -50px;
    right: -100px;
    animation-delay: -7s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -30px) scale(1.05); }
    66% { transform: translate(-20px, 20px) scale(0.95); }
}

/* Container */
.container {
    max-width: 500px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    position: relative;
    z-index: 1;
}

/* Header */
header {
    width: 100%;
    text-align: center;
    margin-bottom: 10px;
}

.header-top {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 5px;
}

.back-btn {
    position: absolute;
    left: 0;
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--text-secondary);
    text-decoration: none;
    font-family: 'Jua', sans-serif;
    font-size: 0.9rem;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.3s;
    min-width: 44px;
    min-height: 44px;
}

.back-btn:hover {
    color: var(--accent-gold);
    background: rgba(255, 255, 255, 0.1);
}

.back-btn svg {
    width: 20px;
    height: 20px;
}

.title {
    font-family: 'Black Han Sans', sans-serif;
    font-size: 2rem;
    background: linear-gradient(135deg, var(--accent-gold), var(--accent-orange));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Score Section */
.score-section {
    display: flex;
    gap: 16px;
    justify-content: center;
    width: 100%;
}

.score-box {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 12px 24px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.score-label {
    font-family: 'Jua', sans-serif;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.score-value {
    font-family: 'Black Han Sans', sans-serif;
    font-size: 1.5rem;
    color: var(--text-primary);
}

.high-score .score-value {
    color: var(--accent);
}

/* Progress Bar */
.progress-section {
    width: 100%;
    padding: 0 4px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.progress-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.next-unlock {
    font-size: 0.7rem;
    color: var(--accent);
}

.progress-bar {
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-gold));
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* Game Container */
.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    width: 100%;
}

/* Game Board */
.board-wrapper {
    position: relative;
    padding: 8px;
    background: var(--bg-secondary);
    border-radius: 16px;
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.05),
        0 20px 40px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.board {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 2px;
    background: var(--grid-line);
    padding: 2px;
    border-radius: 10px;
}

.cell {
    width: 32px;
    height: 32px;
    background: var(--cell-empty);
    border-radius: 4px;
    transition: all 0.15s ease;
    position: relative;
}

.cell.filled {
    box-shadow:
        inset 0 -2px 0 rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

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

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

.cell.preview-guide {
    background: rgba(0, 212, 255, 0.25);
    box-shadow: inset 0 0 0 2px var(--accent-cyan);
    animation: guideGlow 0.8s ease-in-out infinite;
}

@keyframes guideGlow {
    0%, 100% { box-shadow: inset 0 0 0 2px var(--accent-cyan); }
    50% { box-shadow: inset 0 0 0 2px var(--accent-cyan), 0 0 8px var(--accent-cyan); }
}

.cell.clearing {
    animation: clearPulse 0.4s ease-out;
}

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

/* Block colors - Board cells */
.cell.gray { background: var(--gray); }
.cell.red { background: var(--red); }
.cell.blue { background: var(--blue); }
.cell.green { background: var(--green); }
.cell.yellow { background: var(--yellow); }
.cell.purple { background: var(--purple); }
.cell.cyan { background: var(--cyan); }
.cell.orange { background: var(--orange); }
.cell.pink { background: var(--pink); }

/* Block colors - Draggable block pieces */
.block-cell.gray { background: var(--gray); }
.block-cell.red { background: var(--red); }
.block-cell.blue { background: var(--blue); }
.block-cell.green { background: var(--green); }
.block-cell.yellow { background: var(--yellow); }
.block-cell.purple { background: var(--purple); }
.block-cell.cyan { background: var(--cyan); }
.block-cell.orange { background: var(--orange); }
.block-cell.pink { background: var(--pink); }

/* Block Holder */
.block-holder {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 16px;
    width: 100%;
    min-height: 110px;
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.05),
        0 10px 30px rgba(0, 0, 0, 0.3);
}

.block-slot {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100px;
    height: 80px;
    position: relative;
}

.block-piece {
    display: grid;
    gap: 2px;
    cursor: grab;
    transition: transform 0.2s ease, opacity 0.2s ease;
    touch-action: none;
}

.block-piece:hover {
    transform: scale(1.05);
}

.block-piece.dragging {
    cursor: grabbing;
    opacity: 0.9;
    transform: scale(1.1);
    z-index: 1000;
    position: fixed;
    pointer-events: none;
}

.block-piece.used {
    opacity: 0;
    pointer-events: none;
}

.block-cell {
    width: 24px;
    height: 24px;
    border-radius: 3px;
    box-shadow:
        inset 0 -2px 0 rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.block-cell.empty {
    background: transparent;
    box-shadow: none;
}

/* Game Over Overlay */
.game-over-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 10, 26, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(8px);
}

.game-over-overlay.active {
    opacity: 1;
    visibility: visible;
}

.game-over-content {
    text-align: center;
    padding: 40px;
    background: var(--bg-secondary);
    border-radius: 24px;
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.1),
        0 30px 60px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.game-over-overlay.active .game-over-content {
    transform: scale(1);
}

.game-over-title {
    font-family: 'Black Han Sans', sans-serif;
    font-size: 2rem;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.game-over-score {
    font-family: 'Black Han Sans', sans-serif;
    font-size: 3rem;
    background: linear-gradient(135deg, var(--accent), var(--accent-gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.game-over-best {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.new-best {
    color: var(--accent-gold);
}

.restart-btn {
    font-family: 'Jua', sans-serif;
    padding: 14px 40px;
    font-size: 1rem;
    font-weight: 600;
    color: #000;
    background: linear-gradient(135deg, var(--accent-gold), var(--accent-orange));
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.4);
    min-height: 44px;
}

.restart-btn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.5);
}

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

/* Combo Display */
.combo-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Black Han Sans', sans-serif;
    font-size: 2rem;
    color: var(--accent-gold);
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
    opacity: 0;
    pointer-events: none;
    z-index: 50;
}

.combo-display.show {
    animation: comboPopup 0.8s ease-out;
}

@keyframes comboPopup {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    20% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
    100% { opacity: 0; transform: translate(-50%, -60%) scale(1); }
}

/* Score Popup */
.score-popup {
    position: fixed;
    font-family: 'Jua', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--accent);
    pointer-events: none;
    z-index: 60;
    animation: scoreFloat 1s ease-out forwards;
}

@keyframes scoreFloat {
    0% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-40px); }
}

/* Unlock notification */
.unlock-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: linear-gradient(135deg, var(--accent), var(--accent-gold));
    color: #000;
    padding: 12px 24px;
    border-radius: 12px;
    font-family: 'Jua', sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 10px 30px var(--accent-glow);
    z-index: 70;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.unlock-notification.show {
    transform: translateX(-50%) translateY(0);
}

/* Game Content Article */
.game-content {
    width: 100%;
    margin-top: 30px;
    padding: 25px;
    background: var(--bg-secondary);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.game-content h2 {
    font-family: 'Jua', sans-serif;
    font-size: 1.2rem;
    color: var(--accent-gold);
    margin-bottom: 15px;
}

.game-content p {
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.tip-box {
    background: rgba(168, 85, 247, 0.1);
    border-left: 3px solid var(--accent);
    padding: 15px;
    border-radius: 0 8px 8px 0;
}

.tip-box p {
    margin-bottom: 10px;
}

.tip-box p:last-child {
    margin-bottom: 0;
}

/* Footer */
footer {
    width: 100%;
    text-align: center;
    padding: 20px;
    margin-top: 20px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

footer a {
    color: var(--accent-cyan);
    text-decoration: none;
    transition: color 0.3s;
}

footer a:hover {
    color: var(--accent-gold);
}

/* Help text */
.help {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 10px;
}

/* Responsive */
@media (max-width: 500px) {
    .cell {
        width: 28px;
        height: 28px;
    }

    .block-cell {
        width: 20px;
        height: 20px;
    }

    .block-slot {
        width: 85px;
        height: 70px;
    }

    .block-holder {
        gap: 8px;
        min-height: 95px;
    }

    .title {
        font-size: 1.5rem;
    }

    .back-btn span {
        display: none;
    }
}

@media (max-width: 400px) {
    body {
        padding: 10px;
    }

    .cell {
        width: 26px;
        height: 26px;
    }

    .block-cell {
        width: 18px;
        height: 18px;
    }

    .block-slot {
        width: 75px;
        height: 60px;
    }

    .score-box {
        padding: 10px 16px;
    }

    .score-value {
        font-size: 1.2rem;
    }
}

@media (max-height: 700px) {
    .container {
        gap: 10px;
    }

    .cell {
        width: 28px;
        height: 28px;
    }

    .board-wrapper {
        padding: 6px;
    }

    .game-content,
    footer {
        display: none;
    }
}

/* 모바일 하단 고정 */
@media (max-width: 600px) and (max-height: 800px) {
    .block-holder {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        border-radius: 16px 16px 0 0;
        z-index: 50;
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    }

    .game-container {
        padding-bottom: 130px;
    }

    .game-content,
    footer {
        display: none;
    }
}

/* Continue Modal */
.continue-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.continue-modal.active {
    opacity: 1;
    visibility: visible;
}

.continue-modal-content {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 30px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    max-width: 320px;
    width: 90%;
}

.continue-modal-title {
    font-family: 'Black Han Sans', sans-serif;
    font-size: 1.4rem;
    color: var(--text-primary);
    margin-bottom: 15px;
}

.continue-modal-score {
    font-family: 'Jua', sans-serif;
    font-size: 1.1rem;
    color: var(--accent-gold);
    margin-bottom: 25px;
}

.continue-modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.continue-btn {
    padding: 14px 30px;
    font-family: 'Jua', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--accent), #9333ea);
    color: #fff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.continue-btn:hover {
    transform: scale(1.03);
    box-shadow: 0 5px 20px var(--accent-glow);
}

.newgame-btn {
    padding: 12px 25px;
    font-family: 'Jua', sans-serif;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.newgame-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
}

/* Touch improvements */
.block-piece {
    touch-action: none;
    -webkit-touch-callout: none;
}

.block-slot {
    touch-action: none;
}
