/* ==========================================================================
   Agreeee: 2048 Edition - Premium CSS Design System
   ========================================================================== */

/* 1. 디자인 시스템 토큰 (차분하고 심플한 현대적 컬러셋) */
:root {
    --bg-color: #0e1117;
    --panel-bg: #151922;
    --panel-bg-solid: #151922;
    --panel-border: #272d39;
    --panel-border-pink: rgba(255, 255, 255, 0.08);
    
    /* 세련된 현대적 테마 컬러셋 */
    --cyan: #38bdf8;
    --cyan-hsl: 199, 89%, 60%;
    --pink: #f43f5e;
    --pink-hsl: 342, 93%, 60%;
    --emerald: #10b981;
    --emerald-hsl: 162, 76%, 46%;
    --purple: #a855f7;
    --purple-hsl: 271, 91%, 65%;
    --amber: #f59e0b;
    --amber-hsl: 38, 92%, 50%;
    
    /* 텍스트 & 타이포그래피 */
    --text-primary: #eef1f5;
    --text-muted: #8c95a5;
    --font-display: 'Orbitron', -apple-system, sans-serif;
    --font-sans: 'Plus Jakarta Sans', -apple-system, sans-serif;
    
    /* 트랜지션 속도 */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    --transition-slow: 0.5s ease;
}

/* 2. 전역 스타일 초기화 및 레이아웃 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-sans);
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* 배경 장식은 마크업 호환성만 유지하고 화면에서는 숨긴다. */
.bg-glow {
    display: none;
}

.bg-glow-primary {
    top: -10%;
    left: -10%;
    background: radial-gradient(circle, var(--cyan) 0%, transparent 80%);
}

.bg-glow-secondary {
    bottom: -10%;
    right: -10%;
    background: radial-gradient(circle, var(--purple) 0%, transparent 80%);
}

/* 스크롤바 스타일링 */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(11, 13, 22, 0.5);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* 3. 유틸리티 스타일 (심플하고 깔끔한 유리 질감 패널) */
.glass-panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    transition: border-color var(--transition-fast);
}

.glass-panel:hover {
    border-color: #363e4d;
    box-shadow: none;
}

/* 색상 텍스트 강조 (네온 글로우 제거) */
.glow-text {
    color: var(--cyan);
}

.glow-text-purple {
    color: var(--purple);
}

.glow-text-pink {
    color: var(--pink);
}

.glow-text-success {
    color: var(--emerald);
}

/* 배지 시스템 (심플화) */
.mode-badge {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 4px;
    letter-spacing: 1px;
}

.badge-cyan {
    background: rgba(56, 189, 248, 0.1);
    color: var(--cyan);
    border: 1px solid rgba(56, 189, 248, 0.2);
}

.badge-pink {
    background: rgba(244, 63, 94, 0.1);
    color: var(--pink);
    border: 1px solid rgba(244, 63, 94, 0.2);
}

/* 4. 고해상도 버튼 컴포넌트 (그림자 간소화) */
.btn {
    font-family: var(--font-sans);
    font-weight: 700;
    font-size: 0.95rem;
    padding: 13px 26px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: var(--transition-fast);
    display: inline-flex;
    justify-content: center;
    align-items: center;
    letter-spacing: 0;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: var(--cyan);
    color: #081018;
    box-shadow: none;
}

.btn-primary:hover {
    transform: translateY(-1px);
    background: #67cdf8;
    box-shadow: none;
}

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

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.btn-glow::after {
    display: none;
}

.btn-glow:hover::after {
    left: 150%;
}

.btn-glow-pink {
    background: var(--pink);
    color: #fff;
    box-shadow: none;
}

.btn-glow-pink:hover {
    transform: translateY(-1px);
    background: #fb7185;
    box-shadow: none;
}

/* 5. 오디오 고정 컨트롤러 */
.audio-control-fixed {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--panel-bg-solid);
    border: 1px solid var(--panel-border);
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.75rem;
    color: var(--text-primary);
    box-shadow: none;
    transition: var(--transition-fast);
}

.audio-control-fixed:hover {
    border-color: #3a4352;
    background: #1a1f2a;
}

.audio-status-text {
    min-width: 24px;
    text-align: center;
}

/* 6. 메인 헤더 레이아웃 (타이머 & 상태창) */
.game-header {
    width: 90%;
    max-width: 1000px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    font-family: var(--font-display);
    margin-bottom: 12px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    z-index: 10;
}

.header-left, .header-right {
    flex: 1;
    display: flex;
}

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

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

/* 단계 표시기 */
.stage-indicator {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.indicator-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 2px;
    font-weight: 500;
}

.stage-number {
    font-size: 1.6rem;
    font-weight: 900;
    color: var(--cyan);
}

/* 타이머 디자인 */
.timer-display {
    background: transparent;
    border: 0;
    border-radius: 0;
    padding: 8px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 180px;
}

.timer-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    letter-spacing: 3px;
    margin-bottom: 2px;
}

.timer-digits {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: var(--text-primary);
}

/* 인내심(생명) 게이지 */
.patience-meter {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.patience-label {
    font-family: var(--font-sans);
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 700;
}

.heart-container {
    display: flex;
    gap: 5px;
}

.heart {
    font-size: 1.4rem;
    color: var(--pink);
    transition: var(--transition-normal);
}

.heart.lost-heart {
    color: rgba(255, 255, 255, 0.1);
    transform: scale(0.85);
}

/* 7. 스크린 전환 제어 */
.screen {
    display: none;
    width: 100%;
    max-width: 680px;
    padding: 20px;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.screen.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.hidden {
    display: none !important;
}

/* 8. 화면 1: 인트로 / 메뉴 */
#screen-intro {
    max-width: 750px;
}

.logo-area {
    text-align: center;
    margin-bottom: 28px;
}

.logo-title {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    letter-spacing: -1px;
}

.multiply-sign {
    color: var(--text-muted);
    font-size: 2.2rem;
}

.logo-subtitle {
    margin-top: 10px;
    font-size: 0.95rem;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

/* 모드 선택 카드 디자인 */
.mode-selection-panel {
    width: 38%;
    padding: 14px;
    margin-right: auto;
    margin-bottom: 24px;
}

.mode-toggle {
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.mode-toggle-arrow {
    color: var(--cyan);
    font-size: 0.65rem;
    transition: transform var(--transition-fast);
}

.mode-selection-panel:not(.collapsed) .mode-toggle-arrow {
    transform: rotate(180deg);
}

.mode-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 280px;
    margin-top: 12px;
    opacity: 1;
    overflow: hidden;
    transition: max-height var(--transition-normal), margin-top var(--transition-normal), opacity var(--transition-fast);
}

.mode-selection-panel.collapsed .mode-options {
    max-height: 0;
    margin-top: 0;
    opacity: 0;
    pointer-events: none;
}

.mode-card {
    flex: 1;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 9px;
    padding: 12px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    transition: var(--transition-normal);
}

.mode-card:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.15);
}

.mode-card.active {
    background: rgba(56, 189, 248, 0.07);
    border-color: var(--cyan);
    box-shadow: none;
}

#mode-card-speedrun.active {
    background: rgba(244, 63, 94, 0.05);
    border-color: var(--pink);
    box-shadow: none;
}

.mode-title {
    font-size: 0.9rem;
    font-weight: 800;
    color: var(--text-primary);
}

.mode-desc {
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1.4;
    user-select: none;
}

.action-area {
    display: flex;
    justify-content: center;
    margin-bottom: 28px;
}

.action-area.flex-column {
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

/* 9. 화면 2: 약관 동의 퍼즐 박스 (Phase 1) */
.agreement-box {
    width: 100%;
    min-height: 400px;
    position: relative;
    padding: 26px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
}

.stage-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
}

/* 약관 내용 텍스트 영역 */
.agreement-title {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 12px;
    border-bottom: 1px solid var(--panel-border);
    padding-bottom: 10px;
}

.agreement-scroll-box {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 15px;
    font-size: 0.88rem;
    color: var(--text-muted);
    line-height: 1.6;
    height: 220px;
    overflow-y: scroll;
    margin-bottom: 20px;
    position: relative;
}

.agreement-scroll-box p {
    margin-bottom: 15px;
}

/* 동의 행동 구역 */
.agreement-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 15px;
    margin-top: auto;
    position: relative;
}

/* 약관 미션용 전용 제한 시간 막대 */
.limit-timer-container {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    height: 6px;
    border-radius: 3px;
    margin-top: 15px;
    overflow: hidden;
    position: relative;
}

.limit-timer-bar {
    height: 100%;
    background: var(--cyan);
    transition: width 0.1s linear;
}

.limit-timer-text {
    position: absolute;
    right: 0;
    top: 10px;
    font-family: var(--font-display);
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* 3단계 팝업 지옥용 스폰 영역 */
.popup-spawn-area {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

.ad-popup {
    position: absolute;
    width: 250px;
    background: #141826;
    border: 1px solid var(--cyan);
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
    pointer-events: auto;
    z-index: 110;
    overflow: hidden;
}

.ad-popup.danger-ad {
    border-color: var(--pink);
}

.ad-header {
    background: rgba(56, 189, 248, 0.1);
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: 800;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(56, 189, 248, 0.15);
}

.danger-ad .ad-header {
    background: rgba(244, 63, 94, 0.1);
    border-bottom-color: rgba(244, 63, 94, 0.15);
}

.ad-close-btn {
    cursor: pointer;
    font-weight: 900;
    color: var(--text-muted);
    font-size: 0.9rem;
    transition: var(--transition-fast);
}

.ad-close-btn:hover {
    color: #fff;
}

.ad-body {
    padding: 15px;
    font-size: 0.8rem;
    text-align: center;
}

.ad-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
}

.ad-btn {
    font-size: 0.7rem;
    padding: 6px 12px;
    border-radius: 4px;
    border: none;
    font-weight: 700;
    cursor: pointer;
}

.ad-btn-cyan {
    background: var(--cyan);
    color: #0b0d16;
}

.ad-btn-pink {
    background: var(--pink);
    color: #fff;
}

/* 4단계 마우스 반전 패널 */
.inverted-zone {
    border: 1px dashed rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.01);
    border-radius: 8px;
    padding: 20px;
    position: relative;
    height: 240px;
    overflow: hidden;
    cursor: none; /* 실제 커서를 숨김 */
}

.inverted-cursor {
    position: absolute;
    width: 14px;
    height: 14px;
    background: var(--cyan);
    border-radius: 50%;
    pointer-events: none;
    z-index: 50;
    transform: translate(-50%, -50%);
}

.inverted-target {
    position: absolute;
    top: 50%;
    left: 80%;
    width: 60px;
    height: 30px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid var(--emerald);
    color: var(--emerald);
    font-size: 0.75rem;
    font-weight: 800;
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
    transform: translate(-50%, -50%);
    transition: background var(--transition-fast), color var(--transition-fast);
}

.inverted-target.ready {
    background: var(--emerald);
    color: #07130f;
}

/* 6단계 오타 방지용 텍스트 입력창 */
.typing-instruction {
    background: rgba(255, 255, 255, 0.03);
    border-left: 3px solid var(--cyan);
    padding: 10px 15px;
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 700;
    margin-bottom: 15px;
}

.typing-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    color: #fff;
    padding: 12px 15px;
    font-size: 1rem;
    font-family: var(--font-sans);
    outline: none;
    transition: var(--transition-fast);
}

.typing-input:focus {
    border-color: var(--cyan);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.15);
}

/* 8단계 황당 캡차 */
.captcha-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: 15px 0;
}

.captcha-card {
    aspect-ratio: 1;
    border: 2px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: var(--transition-fast);
    background-size: cover;
    background-position: center;
    display: flex;
    justify-content: center;
    align-items: center;
}

.captcha-card-label {
    text-align: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.6);
    width: 100%;
    padding: 6px 4px;
    position: absolute;
    bottom: 0;
}

.captcha-card.selected {
    border-color: var(--cyan);
}

.captcha-card.selected::before {
    content: '✓';
    position: absolute;
    top: 5px;
    right: 5px;
    background: var(--cyan);
    color: #0b0d16;
    font-weight: 900;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.7rem;
    z-index: 5;
}

/* 9단계 리듬 타이밍 */
.rhythm-rail-container {
    height: 60px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    margin-bottom: 20px;
}

.rhythm-target-zone {
    position: absolute;
    top: 0;
    left: 45%;
    width: 10%;
    height: 100%;
    background: rgba(16, 185, 129, 0.15);
    border-left: 2px solid var(--emerald);
    border-right: 2px solid var(--emerald);
}

.rhythm-slider-button {
    position: absolute;
    top: 10%;
    left: 0;
    width: 48px;
    height: 80%;
    background: var(--cyan);
    border-radius: 6px;
    cursor: pointer;
}

/* 10단계 체크박스 퍼즐 */
.checkbox-matrix-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    max-width: 240px;
    margin: 20px auto;
}

.matrix-cell-btn {
    aspect-ratio: 1;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    justify-content: center;
    align-items: center;
}

.matrix-cell-btn.active {
    background: rgba(56, 189, 248, 0.1);
    border-color: var(--cyan);
    color: var(--cyan);
}

/* 12단계 최종 보스전 약관 보스 */
.boss-container {
    height: 250px;
    position: relative;
    border: 1px solid var(--panel-border);
    background: rgba(244, 63, 94, 0.02);
    border-radius: 8px;
    overflow: hidden;
    cursor: crosshair;
}

.boss-health-bar-container {
    position: absolute;
    top: 10px;
    left: 5%;
    width: 90%;
    height: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(244, 63, 94, 0.2);
    border-radius: 5px;
    overflow: hidden;
}

.boss-health-bar {
    height: 100%;
    background: var(--pink);
    width: 100%;
    transition: width 0.15s ease-out;
}

.boss-phase-label {
    position: absolute;
    top: 26px;
    left: 12px;
    z-index: 3;
    color: var(--cyan);
    font-family: var(--font-display);
    font-size: 0.65rem;
    font-weight: 900;
    letter-spacing: 1px;
}

.boss-phase-label.phase-2 {
    color: #fbbf24;
}

.boss-phase-label.phase-3 {
    color: var(--pink);
    animation: pulse 0.35s infinite alternate;
}

.boss-warning {
    position: absolute;
    top: 48px;
    left: 50%;
    z-index: 4;
    color: #fff;
    font-family: var(--font-display);
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 1px;
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) scale(0.85);
    transition: opacity 0.12s, transform 0.12s;
    white-space: nowrap;
}

.boss-warning.visible {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

.boss-container.boss-telegraph {
    box-shadow: inset 0 0 30px rgba(244, 63, 94, 0.22);
}

.boss-entity {
    position: absolute;
    width: 90px;
    height: 45px;
    background: var(--pink);
    border-radius: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    font-family: var(--font-display);
    font-weight: 900;
    font-size: 0.8rem;
    cursor: pointer;
    transform: translate(-50%, -50%);
    transition: left 0.1s linear, top 0.1s linear;
}

.boss-projectile {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--pink);
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

.boss-projectile.aimed {
    width: 13px;
    height: 7px;
    border-radius: 2px;
    box-shadow: 0 0 8px var(--pink);
}

.boss-projectile.radial {
    background: #fbbf24;
    box-shadow: 0 0 7px rgba(251, 191, 36, 0.8);
}

.boss-projectile.wall {
    width: 8px;
    height: 16px;
    border-radius: 2px;
    background: #a855f7;
    box-shadow: 0 0 7px rgba(168, 85, 247, 0.8);
}

/* 10. 화면 3: 해금된 2048 게임 스크린 (Phase 2) */
#screen-game2048 {
    max-width: 500px;
}

.congratulations-banner {
    text-align: center;
    font-size: 0.9rem;
    font-weight: 800;
    margin-bottom: 20px;
    line-height: 1.4;
}

.game2048-top-info {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 15px;
}

.score-container, .target-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    text-align: center;
}

.score-label, .target-label {
    font-size: 0.65rem;
    font-family: var(--font-display);
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.score-value, .target-value {
    font-size: 1.25rem;
    font-family: var(--font-display);
    font-weight: 800;
}

.target-value {
    font-size: 1.4rem;
}

/* 2048 보드 그리드 레이아웃 */
.board-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
}

.grid-container {
    position: relative;
    padding: 12px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    width: 360px;
    height: 360px;
    box-shadow: none;
}

.grid-row {
    margin-bottom: 12px;
    display: flex;
    gap: 12px;
}

.grid-row:last-child {
    margin-bottom: 0;
}

.grid-cell {
    width: 70px;
    height: 70px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.03);
}

/* 동적 2048 타일 컨테이너 */
.tile-container {
    position: absolute;
    z-index: 2;
    top: 12px;
    left: 12px;
}

.tile {
    position: absolute;
    width: 70px;
    height: 70px;
    border-radius: 6px;
    font-family: var(--font-display);
    font-weight: 900;
    font-size: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 100ms ease-in-out;
}

.tile-new {
    animation: tile-appear 200ms ease-out;
}

/* 타일 위치 포지셔닝 클래스 (0-indexed) */
.tile-position-0-0 { transform: translate(0px, 0px); }
.tile-position-0-1 { transform: translate(82px, 0px); }
.tile-position-0-2 { transform: translate(164px, 0px); }
.tile-position-0-3 { transform: translate(246px, 0px); }

.tile-position-1-0 { transform: translate(0px, 82px); }
.tile-position-1-1 { transform: translate(82px, 82px); }
.tile-position-1-2 { transform: translate(164px, 82px); }
.tile-position-1-3 { transform: translate(246px, 82px); }

.tile-position-2-0 { transform: translate(0px, 164px); }
.tile-position-2-1 { transform: translate(82px, 164px); }
.tile-position-2-2 { transform: translate(164px, 164px); }
.tile-position-2-3 { transform: translate(246px, 164px); }

.tile-position-3-0 { transform: translate(0px, 246px); }
.tile-position-3-1 { transform: translate(82px, 246px); }
.tile-position-3-2 { transform: translate(164px, 246px); }
.tile-position-3-3 { transform: translate(246px, 246px); }

/* 각 타일 숫자 값별 글로우 및 그림자 제거 후 심플 채색화 */
.tile-2 {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.15);
    font-size: 1.7rem;
}

.tile-4 {
    background: rgba(56, 189, 248, 0.15);
    color: var(--cyan);
    border: 1px solid rgba(56, 189, 248, 0.3);
    font-size: 1.7rem;
}

.tile-8 {
    background: rgba(16, 185, 129, 0.15);
    color: var(--emerald);
    border: 1px solid rgba(16, 185, 129, 0.3);
    font-size: 1.7rem;
}

.tile-16 {
    background: rgba(168, 85, 247, 0.15);
    color: #dfb3ff;
    border: 1px solid rgba(168, 85, 247, 0.3);
    font-size: 1.6rem;
}

.tile-32 {
    background: rgba(244, 63, 94, 0.15);
    color: #ff9ebe;
    border: 1px solid rgba(244, 63, 94, 0.3);
    font-size: 1.6rem;
}

.tile-64 {
    background: rgba(244, 63, 94, 0.22);
    color: #fff;
    border: 1px solid rgba(244, 63, 94, 0.4);
    font-size: 1.6rem;
}

.tile-128 {
    background: rgba(245, 158, 11, 0.15);
    color: var(--amber);
    border: 1px solid rgba(245, 158, 11, 0.3);
    font-size: 1.4rem;
}

.tile-256 {
    background: rgba(245, 158, 11, 0.22);
    color: #fff;
    border: 1px solid rgba(245, 158, 11, 0.4);
    font-size: 1.4rem;
}

.tile-512 {
    background: rgba(16, 185, 129, 0.25);
    color: #fff;
    border: 1px solid rgba(16, 185, 129, 0.4);
    font-size: 1.4rem;
}

.tile-1024 {
    background: var(--purple);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 1.2rem;
    animation: none;
}

.tile-2048 {
    background: var(--amber);
    color: #171006;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    font-size: 1.2rem;
    animation: none;
}

.game2048-controls {
    margin-top: 20px;
    text-align: center;
}

.controls-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* 11. 화면 4: 게임오버 */
.gameover-box, .victory-box {
    padding: 40px;
}

.title-large {
    font-family: var(--font-display);
    font-size: 2.35rem;
    font-weight: 900;
    margin-bottom: 5px;
}

.font-sub {
    font-size: 0.7rem;
    letter-spacing: 4px;
    margin-bottom: 25px;
}

.gameover-reason {
    padding: 15px;
    font-size: 0.88rem;
    color: var(--text-muted);
    border-color: var(--panel-border-pink);
    line-height: 1.5;
    margin-bottom: 25px;
}

.gameover-stats {
    display: flex;
    justify-content: space-around;
    font-size: 0.95rem;
    margin-bottom: 30px;
}

.text-highlight-cyan {
    color: var(--cyan);
    font-family: var(--font-display);
    font-weight: 800;
}

.text-highlight-pink {
    color: var(--pink);
    font-family: var(--font-display);
    font-weight: 800;
}

/* 12. 화면 5: 승리 (명예의 전당 등록) */
.victory-desc {
    font-size: 0.92rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 25px;
}

.record-showcase {
    padding: 20px;
    margin-bottom: 25px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.record-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.record-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
}

.record-value {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 900;
}

/* 닉네임 입력 그룹 */
.record-submit-area {
    padding: 20px;
    margin-bottom: 25px;
}

.record-submit-area h3 {
    font-size: 0.95rem;
    margin-bottom: 4px;
    font-weight: 700;
}

.record-submit-area p {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.submit-input-group {
    display: flex;
    gap: 10px;
}

.submit-input-group input {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    color: #fff;
    padding: 10px 12px;
    font-family: var(--font-sans);
    outline: none;
    font-size: 0.9rem;
    text-transform: uppercase;
}

.submit-input-group input:focus {
    border-color: var(--cyan);
}

.submit-input-group button {
    padding: 10px 20px;
    font-size: 0.85rem;
}

.record-submitted-msg {
    color: var(--emerald);
    font-weight: 800;
    font-size: 1rem;
    margin-bottom: 25px;
    animation: pulse 1s infinite alternate;
}

/* 전체 순위 테이블 */
.leaderboard-area {
    padding: 20px;
    margin-bottom: 30px;
}

.leaderboard-area h3 {
    font-size: 0.95rem;
    margin-bottom: 15px;
    text-align: center;
}

.table-wrapper {
    overflow-x: auto;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    text-align: left;
}

.leaderboard-table th, .leaderboard-table td {
    padding: 10px 15px;
}

.leaderboard-table th {
    background: rgba(255, 255, 255, 0.04);
    font-family: var(--font-display);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 1px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.leaderboard-table tr {
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}

.leaderboard-table tr:last-child {
    border-bottom: none;
}

.leaderboard-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.01);
}

/* 13. CSS 애니메이션 핵심 키프레임 */
@keyframes tile-appear {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes tile-pulse {
    0% { opacity: 0.9; }
    100% { opacity: 1; }
}

@keyframes tile-rainbow {
    0% { filter: hue-rotate(0deg); }
    100% { filter: hue-rotate(360deg); }
}

@keyframes pulse {
    0% { opacity: 0.6; }
    100% { opacity: 1; }
}

/* 전체 요동 흔들림(Shake) 효과 (오류/실패 시 바디 또는 특정 판넬에 주입) */
.screen-shake {
    animation: shake-anim 0.4s ease-in-out;
}

@keyframes shake-anim {
    0%, 100% { transform: translate(0, 0); }
    15% { transform: translate(-12px, -3px); }
    30% { transform: translate(10px, 4px); }
    45% { transform: translate(-10px, -2px); }
    60% { transform: translate(8px, 2px); }
    75% { transform: translate(-4px, -1px); }
}

/* 플래시 경고 효과 */
.flash-red {
    animation: flash-red-anim 0.3s ease-out;
}

@keyframes flash-red-anim {
    0% { background: rgba(244, 63, 94, 0.25); }
    100% { background: transparent; }
}

/* 파티클 효과용 캔버스 데코레이션 */
.merge-particle {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 10;
}

/* 14. 모바일 반응형 최적화 */
@media (max-width: 500px) {
    .mode-selection-panel {
        width: 100%;
    }

    .audio-control-fixed {
        top: 12px;
        right: 12px;
        padding: 7px 9px;
    }

    .audio-status-text {
        display: none;
    }

    .game-header {
        width: calc(100% - 24px);
        padding: 10px 12px;
        margin-top: 56px;
    }

    .indicator-label,
    .patience-label {
        display: none;
    }

    .heart {
        font-size: 1.1rem;
    }

    .logo-title {
        font-size: 2.2rem;
    }
    
    .multiply-sign {
        font-size: 1.5rem;
    }
    
    .mode-options {
        flex-direction: column;
        gap: 15px;
    }
    
    .timer-display {
        min-width: 120px;
        padding: 4px 8px;
    }
    
    .timer-digits {
        font-size: 1.25rem;
    }
    
    .stage-number {
        font-size: 1.1rem;
    }

    .screen {
        padding: 14px;
    }

    .agreement-box,
    .gameover-box,
    .victory-box {
        padding: 20px;
    }
    
    .grid-container {
        width: 300px;
        height: 300px;
        padding: 10px;
    }
    
    .grid-row {
        margin-bottom: 8px;
        gap: 8px;
    }
    
    .grid-cell {
        width: 58px;
        height: 58px;
    }
    
    .tile-container {
        top: 10px;
        left: 10px;
    }
    
    .tile {
        width: 58px;
        height: 58px;
        font-size: 1.2rem;
    }
    
    /* 포지셔닝 재정의 */
    .tile-position-0-0 { transform: translate(0px, 0px); }
    .tile-position-0-1 { transform: translate(66px, 0px); }
    .tile-position-0-2 { transform: translate(132px, 0px); }
    .tile-position-0-3 { transform: translate(198px, 0px); }
    
    .tile-position-1-0 { transform: translate(0px, 66px); }
    .tile-position-1-1 { transform: translate(66px, 66px); }
    .tile-position-1-2 { transform: translate(132px, 66px); }
    .tile-position-1-3 { transform: translate(198px, 66px); }
    
    .tile-position-2-0 { transform: translate(0px, 132px); }
    .tile-position-2-1 { transform: translate(66px, 132px); }
    .tile-position-2-2 { transform: translate(132px, 132px); }
    .tile-position-2-3 { transform: translate(198px, 132px); }
    
    .tile-position-3-0 { transform: translate(0px, 198px); }
    .tile-position-3-1 { transform: translate(66px, 198px); }
    .tile-position-3-2 { transform: translate(132px, 198px); }
    .tile-position-3-3 { transform: translate(198px, 198px); }
}
