/* Skip to main content link for accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary, #4a90d9);
    color: #fff;
    padding: 8px 16px;
    z-index: 10000;
    font-size: 14px;
    border-radius: 0 0 4px 0;
    transition: top 0.2s;
}
.skip-link:focus {
    top: 0;
}

/* === CSS Variables & Reset === */
:root {
    --bg-deep: #0a0a1a;
    --bg-surface: #12122a;
    --surface-glass: rgba(255, 255, 255, 0.04);
    --border-glass: rgba(255, 255, 255, 0.08);
    --border-glass-hover: rgba(255, 255, 255, 0.15);
    --text: #f0f0f5;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-dim: rgba(255, 255, 255, 0.4);
    --primary: #f4a261;
    --primary-glow: rgba(244, 162, 97, 0.3);
    --accent: #e76f51;
    --radius: 14px;
    --radius-sm: 8px;
    --transition: all 0.2s ease;
    --board-size: min(90vw, 400px);
    --cell-gap: 8px;
    --cell-size: calc((var(--board-size) - var(--cell-gap) * 5) / 4);

}

/* Light mode overrides */
[data-theme="light"] {
    --bg-deep: #f5f0e8;
    --bg-surface: #ede8e0;
    --surface-glass: rgba(244, 162, 97, 0.06);
    --border-glass: rgba(244, 162, 97, 0.12);
    --border-glass-hover: rgba(244, 162, 97, 0.25);
    --text: #1a1410;
    --text-secondary: rgba(26, 20, 16, 0.7);
    --text-dim: rgba(26, 20, 16, 0.4);
    --primary-glow: rgba(244, 162, 97, 0.15);
}
[data-theme="light"] body {
    background: var(--bg-deep);
    color: var(--text);
}
[data-theme="light"] .app-loader {
    background: var(--bg-deep);
}
[data-theme="light"] .board {
    background: rgba(244, 162, 97, 0.05);
    border-color: rgba(244, 162, 97, 0.12);
    box-shadow: 0 4px 16px rgba(244, 162, 97, 0.06);
}
[data-theme="light"] .cell {
    background: rgba(244, 162, 97, 0.04);
    border-color: rgba(244, 162, 97, 0.08);
}
[data-theme="light"] .cell:hover {
    background: rgba(244, 162, 97, 0.1);
    border-color: rgba(244, 162, 97, 0.2);
}
[data-theme="light"] .score-box {
    background: rgba(244, 162, 97, 0.06);
    border-color: rgba(244, 162, 97, 0.12);
}
[data-theme="light"] .ctrl-btn {
    background: rgba(244, 162, 97, 0.06);
    border-color: rgba(244, 162, 97, 0.15);
    color: var(--text);
}
[data-theme="light"] .ctrl-btn:hover {
    background: rgba(244, 162, 97, 0.12);
}
[data-theme="light"] .overlay {
    background: rgba(245, 240, 232, 0.85);
}
[data-theme="light"] .modal {
    background: rgba(237, 232, 224, 0.95);
    border-color: rgba(244, 162, 97, 0.15);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}
[data-theme="light"] .collection-item {
    background: rgba(244, 162, 97, 0.04);
    border-color: rgba(244, 162, 97, 0.1);
}
[data-theme="light"] .recommend-card {
    background: rgba(244, 162, 97, 0.04);
    border-color: rgba(244, 162, 97, 0.1);
}
[data-theme="light"] .lang-btn {
    background: rgba(244, 162, 97, 0.08);
    color: var(--text);
    border-color: rgba(244, 162, 97, 0.18);
}
[data-theme="light"] .lang-menu {
    background: rgba(245, 240, 232, 0.95);
    border-color: rgba(244, 162, 97, 0.18);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}
[data-theme="light"] .lang-option {
    color: #5a4a30;
}
[data-theme="light"] .lang-option:hover {
    background: rgba(244, 162, 97, 0.1);
    color: var(--text);
}
[data-theme="light"] .lang-option.active {
    background: rgba(244, 162, 97, 0.15);
    color: var(--text);
}
[data-theme="light"] .loader-spinner {
    border-color: rgba(244, 162, 97, 0.12);
    border-top-color: var(--primary);
}
/* Light mode: scrollbar thumb visibility */
[data-theme="light"] .collection-grid::-webkit-scrollbar-thumb,
[data-theme="light"] .history-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
}
[data-theme="light"] .collection-grid::-webkit-scrollbar-thumb:hover,
[data-theme="light"] .history-list::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

/* 터치 최적화 */
button, a, input, [role="button"], [role="link"] {
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

input[type="text"], textarea {
    -webkit-user-select: text;
    user-select: text;
}

html {
    font-size: 16px;
    touch-action: manipulation;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-deep);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-user-select: none;
    user-select: none;
}

/* App Loader */
.app-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-deep);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
.app-loader.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.loader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}
.loader-emoji {
    font-size: 48px;
    animation: loader-bounce 1s ease-in-out infinite;
}
.loader-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: loader-spin 0.8s linear infinite;
}
.loader-text {
    font-size: 14px;
    color: var(--text-dim);
    letter-spacing: 1px;
    font-weight: 500;
}
@keyframes loader-spin {
    to { transform: rotate(360deg); }
}
@keyframes loader-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* === Theme Toggle === */
.theme-toggle {
    position: fixed;
    top: 12px;
    right: 108px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.08);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.3s ease, transform 0.3s ease, background-color 0.3s ease;
}
.theme-toggle:hover { transform: scale(1.1); }
.theme-toggle:active { transform: scale(0.95); }
[data-theme="light"] .theme-toggle {
    background: rgba(0,0,0,0.05);
    border-color: rgba(0,0,0,0.1);
    color: var(--text, #1a1410);
}

/* === Background Effects === */
.bg-effects {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.bg-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.15;
}

.bg-orb-1 {
    width: 300px;
    height: 300px;
    background: var(--primary);
    top: -100px;
    right: -80px;
    animation: float1 12s ease-in-out infinite;
}

.bg-orb-2 {
    width: 250px;
    height: 250px;
    background: var(--accent);
    bottom: -80px;
    left: -60px;
    animation: float2 15s ease-in-out infinite;
}

@keyframes float1 {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(-30px, 40px); }
}

@keyframes float2 {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(30px, -30px); }
}

/* === Container === */
.container {
    position: relative;
    z-index: 1;
    max-width: 440px;
    margin: 0 auto;
    padding: 12px 16px 24px;
    min-height: 100vh;
    min-height: 100dvh;
}

/* === Ad Banners === */
.ad-banner {
    background: var(--surface-glass);
    border: 1px dashed var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 10px;
    text-align: center;
    margin-bottom: 12px;
}

.ad-bottom { margin-top: 16px; margin-bottom: 0; }

.ad-placeholder {
    color: var(--text-dim);
    font-size: 11px;
    letter-spacing: 2px;
}

/* === Evolution Bar === */
.evolution-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.04), rgba(244, 162, 97, 0.04));
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    margin-bottom: 10px;
    overflow-x: auto;
    scrollbar-width: none;
    box-shadow: inset 0 1px 2px rgba(244, 162, 97, 0.1);
}

.evolution-bar::-webkit-scrollbar { display: none; }

.evo-step {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.evo-emoji {
    font-size: 16px;
    opacity: 0.5;
    transition: var(--transition);
}

.evo-emoji.reached {
    opacity: 1;
    transform: scale(1.1);
    animation: evoPulse 1.5s ease-in-out infinite;
    text-shadow: 0 0 12px rgba(244, 162, 97, 0.5);
}

@keyframes evoPulse {
    0%, 100% { transform: scale(1.1); text-shadow: 0 0 12px rgba(244, 162, 97, 0.5); }
    50% { transform: scale(1.2); text-shadow: 0 0 20px rgba(244, 162, 97, 0.8); }
}

.evo-arrow {
    color: var(--text-dim);
    font-size: 10px;
    margin: 0 1px;
}

/* === Chain Modal Extra === */
.chain-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.chain-option {
    padding: 14px;
    border: 2px solid var(--border-glass);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    background: var(--surface-glass);
}

.chain-option:hover { border-color: var(--border-glass-hover); }

.chain-option.active {
    border-color: var(--primary);
    background: rgba(244, 162, 97, 0.1);
}

.chain-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.chain-icon { font-size: 22px; }

.chain-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
}

.chain-desc {
    font-size: 11px;
    color: var(--text-dim);
    margin-bottom: 6px;
}

.chain-preview {
    display: flex;
    gap: 4px;
    font-size: 18px;
}

/* === Win Emoji === */
.win-emoji {
    font-size: 64px;
    margin: 12px 0;
    animation: winPulse 1s ease infinite;
}

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

.overlay-max-evo {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.overlay-max-evo span {
    font-size: 24px;
}

/* === Header === */
.game-header {
    margin-bottom: 12px;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.game-title {
    font-size: 42px;
    font-weight: 900;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
}

.game-subtitle {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 2px;
    font-weight: 500;
}

.scores-area {
    display: flex;
    gap: 6px;
}

.score-box {
    background: var(--surface-glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 6px 14px;
    text-align: center;
    min-width: 70px;
}

.score-box.best {
    border-color: rgba(244, 162, 97, 0.3);
}

.score-label {
    display: block;
    font-size: 10px;
    color: var(--text-dim);
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: 2px;
}

.score-value {
    display: block;
    font-size: 20px;
    font-weight: 800;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 8px rgba(244, 162, 97, 0.3);
}

.score-box.best .score-value {
    color: var(--primary);
    text-shadow: 0 0 12px rgba(244, 162, 97, 0.5);
}

/* === Header Controls === */
.header-controls {
    display: flex;
    gap: 6px;
}

.ctrl-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: var(--surface-glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    min-height: 44px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.ctrl-btn:hover {
    border-color: var(--border-glass-hover);
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
}

.ctrl-btn:active {
    transform: scale(0.96);
}

.ctrl-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.ctrl-btn:disabled:hover {
    border-color: var(--border-glass);
    color: var(--text-secondary);
    background: var(--surface-glass);
}

/* === Game Board === */
.game-area {
    position: relative;
    margin-bottom: 16px;
}

.board-container {
    display: flex;
    justify-content: center;
}

.board {
    position: relative;
    width: var(--board-size);
    height: var(--board-size);
    background:
        linear-gradient(90deg, rgba(244, 162, 97, 0.05) 1px, transparent 1px),
        linear-gradient(rgba(244, 162, 97, 0.05) 1px, transparent 1px),
        rgba(255, 255, 255, 0.06);
    background-size: calc(25% - 6px) calc(25% - 6px);
    background-position: var(--cell-gap) var(--cell-gap);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(244, 162, 97, 0.15);
    border-radius: 16px;
    padding: var(--cell-gap);
    touch-action: none;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5), 0 0 1px rgba(244, 162, 97, 0.1);
}

[data-theme="classic"] .board {
    background: var(--board-bg);
}

.grid-bg {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--cell-gap);
    position: absolute;
    inset: var(--cell-gap);
}

.cell {
    background: rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-sm);
}

[data-theme="classic"] .cell {
    background: var(--cell-bg);
}

.tiles-container {
    position: absolute;
    inset: var(--cell-gap);
}

/* === Tile === */
.tile {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-weight: 800;
    transition: top 0.12s ease, left 0.12s ease, transform 0.15s ease, box-shadow 0.15s ease;
    z-index: 1;
    box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.1), 0 4px 12px rgba(0, 0, 0, 0.3);
}

.tile.new {
    animation: tileAppear 0.2s ease forwards;
}

.tile.merged {
    animation: tileMerge 0.2s ease forwards, tileGlow 0.4s ease 0.1s;
    z-index: 2;
}

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

@keyframes tileMerge {
    0% { transform: scale(1); box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.1), 0 4px 12px rgba(0, 0, 0, 0.3); }
    40% { transform: scale(1.25); box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.15), 0 8px 24px rgba(244, 162, 97, 0.4); }
    100% { transform: scale(1); box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.1), 0 4px 12px rgba(0, 0, 0, 0.3); }
}

@keyframes tileGlow {
    0%, 100% { box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.1), 0 4px 12px rgba(0, 0, 0, 0.3); }
    50% { box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.15), 0 8px 20px rgba(244, 162, 97, 0.3); }
}

/* Tile colors - applied dynamically by JS via inline styles */
/* Base tile has no background - set by JS based on evolution chain */

/* === Score Popup === */
.score-popup {
    position: absolute;
    font-size: 16px;
    font-weight: 800;
    color: var(--primary);
    pointer-events: none;
    z-index: 10;
    animation: scoreFloat 0.7s ease forwards;
    text-shadow: 0 0 12px rgba(244, 162, 97, 0.8);
}

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

/* === Overlays === */
.overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 100;
    animation: fadeIn 0.3s ease;
}

.overlay.hidden { display: none; }

.overlay-content {
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    padding: 32px;
    text-align: center;
    max-width: 320px;
    width: 90%;
    animation: slideUp 0.3s ease;
}

.overlay-content.win {
    border-color: rgba(244, 162, 97, 0.4);
    box-shadow: 0 0 40px var(--primary-glow);
}

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

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

.overlay-title {
    font-size: 28px;
    font-weight: 900;
    margin-bottom: 12px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.overlay-score {
    font-size: 18px;
    color: var(--text);
    margin-bottom: 4px;
}

.overlay-score span {
    font-weight: 800;
    color: var(--primary);
}

.overlay-best {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.overlay-title-badge {
    font-size: 14px;
    color: var(--accent);
    margin-bottom: 20px;
    font-weight: 600;
}

.overlay-buttons {
    display: flex;
    gap: 8px;
}

.btn-primary, .btn-secondary {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
}

.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px var(--primary-glow); }
.btn-primary:active { transform: scale(0.97); }

.btn-secondary {
    background: var(--surface-glass);
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
}

.btn-secondary:hover { border-color: var(--border-glass-hover); color: var(--text); }

/* === Modal === */
.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal.hidden { display: none; }

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
}

.modal-content {
    position: relative;
    z-index: 1;
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    padding: 24px;
    max-width: 320px;
    width: 90%;
    animation: slideUp 0.3s ease;
}

.modal-title {
    font-size: 18px;
    font-weight: 800;
    margin-bottom: 16px;
    text-align: center;
}

.theme-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.theme-option {
    padding: 12px;
    border: 2px solid var(--border-glass);
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: center;
    transition: var(--transition);
    background: var(--surface-glass);
}

.theme-option:hover {
    border-color: var(--border-glass-hover);
}

.theme-option.active {
    border-color: var(--primary);
    background: rgba(244, 162, 97, 0.1);
}

.theme-option .theme-preview {
    display: flex;
    gap: 3px;
    margin-bottom: 6px;
    justify-content: center;
}

.theme-option .theme-dot {
    width: 16px;
    height: 16px;
    border-radius: 4px;
}

.theme-option .theme-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.theme-option.active .theme-name {
    color: var(--primary);
}

.modal-close {
    width: 100%;
    padding: 10px;
    background: var(--surface-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.modal-close:hover {
    border-color: var(--border-glass-hover);
    color: var(--text);
}

/* === Stats Section === */
.stats-section {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.stat-item {
    background: var(--surface-glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 12px 8px;
    text-align: center;
}

.stat-number {
    display: block;
    font-size: 20px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 2px;
}

.stat-label {
    font-size: 11px;
    color: var(--text-dim);
    font-weight: 600;
}

/* === How To Play === */
.how-to-play {
    background: var(--surface-glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}

.how-to-play h2 {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 12px;
    text-align: center;
    color: var(--text-secondary);
}

.how-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.how-item {
    text-align: center;
}

.how-icon {
    font-size: 24px;
    display: block;
    margin-bottom: 6px;
}

.how-item p {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.how-item strong {
    color: var(--primary);
}

/* === Footer === */
.game-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.back-link {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--text-dim);
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    transition: var(--transition);
}

.back-link:hover { color: var(--primary); }

.copyright {
    font-size: 11px;
    color: var(--text-dim);
}

/* === Responsive === */
@media (max-width: 360px) {
    :root {
        --cell-gap: 6px;
    }
    .game-title { font-size: 36px; }
    .score-box { min-width: 60px; padding: 5px 10px; }
    .score-value { font-size: 17px; }
}

@media (min-width: 500px) {
    .container { padding: 16px 24px 32px; }
}

/* === Premium Section === */
.premium-section {
    margin-bottom: 16px;
}

.premium-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px;
    background: linear-gradient(135deg, rgba(244,162,97,0.15), rgba(231,111,81,0.15));
    border: 1px solid rgba(244,162,97,0.3);
    border-radius: var(--radius);
    color: var(--primary);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

.premium-btn:hover {
    background: linear-gradient(135deg, rgba(244,162,97,0.25), rgba(231,111,81,0.25));
    transform: translateY(-1px);
    box-shadow: 0 4px 16px var(--primary-glow);
}

.premium-btn:active { transform: scale(0.97); }

.premium-icon { font-size: 20px; }

.premium-badge {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 1px;
}

/* Interstitial Ad */
.overlay-content.interstitial {
    padding: 24px;
}

.ad-notice {
    font-size: 11px;
    color: var(--text-dim);
    letter-spacing: 2px;
    margin-bottom: 12px;
}

.ad-placeholder-large {
    background: var(--surface-glass);
    border: 1px dashed var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 60px 20px;
    color: var(--text-dim);
    font-size: 24px;
    letter-spacing: 4px;
    margin-bottom: 16px;
}

.ad-timer {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.ad-timer span {
    color: var(--primary);
    font-weight: 800;
}

/* Premium Result */
.premium-result {
    background: var(--surface-glass);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(244,162,97,0.3);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.premium-result-title {
    font-size: 16px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 14px;
    text-align: center;
}

.premium-analysis-item {
    background: rgba(255,255,255,0.03);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 10px;
}

.premium-analysis-item:last-child { margin-bottom: 0; }

.premium-analysis-item h4 {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
}

.premium-analysis-item p {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.premium-stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 8px;
}

.premium-stat {
    text-align: center;
    padding: 8px;
    background: rgba(255,255,255,0.03);
    border-radius: var(--radius-sm);
}

.premium-stat .stat-val {
    font-size: 18px;
    font-weight: 800;
    color: var(--primary);
    display: block;
}

.premium-stat .stat-lbl {
    font-size: 10px;
    color: var(--text-dim);
}

/* === Recommendation Cards === */
.rec-section {
    margin-bottom: 16px;
}

.rec-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 12px;
}

.rec-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.rec-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 14px 10px;
    background: var(--surface-glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: var(--transition);
}

.rec-card:hover {
    border-color: var(--border-glass-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.rec-emoji {
    font-size: 28px;
    margin-bottom: 6px;
}

.rec-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 2px;
}

.rec-desc {
    font-size: 11px;
    color: var(--text-dim);
}

/* === Language Selector === */
.language-selector {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.lang-btn {
    background: rgba(6, 182, 212, 0.3);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(6, 182, 212, 0.4);
    color: #fff;
    font-size: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
}

.lang-btn:hover {
    background: rgba(6, 182, 212, 0.5);
    transform: scale(1.05);
}

.lang-menu {
    position: absolute;
    top: 52px;
    right: 0;
    background: rgba(10, 15, 25, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(6, 182, 212, 0.3);
    border-radius: 12px;
    padding: 8px;
    min-width: 150px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.lang-menu.hidden {
    display: none;
}

.lang-option {
    width: 100%;
    padding: 10px 14px;
    background: transparent;
    border: none;
    text-align: left;
    cursor: pointer;
    border-radius: 8px;
    font-size: 14px;
    color: #c8e8e8;
    transition: background 0.2s;
}

.lang-option:hover {
    background: rgba(6, 182, 212, 0.2);
}

.lang-option.active {
    background: rgba(6, 182, 212, 0.3);
    font-weight: 600;
}

/* === Focus Visible === */
*:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* === DOPAMINE ENHANCEMENT EFFECTS === */

/* Screen Shake */
@keyframes screenShake {
    0%, 100% { transform: translate(0, 0); }
    20% { transform: translate(-2px, -2px); }
    40% { transform: translate(2px, -2px); }
    60% { transform: translate(-2px, 2px); }
    80% { transform: translate(2px, 2px); }
}

.container.shake {
    animation: screenShake 0.3s ease-in-out;
}

/* Screen Flash */
@keyframes screenFlash {
    0%, 100% { background-color: transparent; }
    50% { background-color: rgba(255, 255, 255, 0.15); }
}

.container.flash {
    animation: screenFlash 0.2s ease-in-out;
}

.container.flash-success {
    animation: screenFlash 0.2s ease-in-out;
}

.container.flash-danger {
    animation: screenFlash 0.2s ease-in-out;
}

/* Floating Score Popup */
@keyframes scoreFloating {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-60px) scale(1.2);
    }
}

.score-popup {
    position: fixed;
    font-weight: 900;
    font-size: 28px;
    pointer-events: none;
    z-index: 100;
    animation: scoreFloating 0.8s ease-out forwards;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

.score-popup.normal {
    color: var(--primary);
}

.score-popup.bonus {
    color: var(--accent);
    font-size: 36px;
}

.score-popup.milestone {
    color: #ffd700;
    font-size: 32px;
    font-weight: 900;
}

/* Merge Indicator */
.merge-indicator {
    position: fixed;
    pointer-events: none;
    z-index: 100;
    text-align: center;
}

.merge-text {
    font-size: 48px;
    font-weight: 900;
    color: var(--primary);
    text-shadow: 0 0 20px rgba(244, 162, 97, 0.8);
    animation: mergePulse 0.6s ease-out forwards;
}

@keyframes mergePulse {
    0% {
        opacity: 0;
        transform: scale(0.5) rotateZ(0deg);
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: scale(2) rotateZ(360deg);
    }
}

/* Confetti Particles */
@keyframes confetti-fall {
    to { transform: translateY(100vh) rotateZ(720deg); }
}

.confetti {
    position: fixed;
    width: 8px;
    height: 8px;
    pointer-events: none;
    z-index: 100;
}

.confetti.type-1 { background: linear-gradient(135deg, #f4a261, #ff8c42); }
.confetti.type-2 { background: linear-gradient(135deg, #e76f51, #ff6b5b); }
.confetti.type-3 { background: linear-gradient(135deg, #06b6d4, #0891b2); }
.confetti.type-4 { background: linear-gradient(135deg, #fbbf24, #f59e0b); }
.confetti.type-5 { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }

/* Milestone Banner - compact top toast */
@keyframes toastIn {
    0% { opacity: 0; transform: translateX(-50%) translateY(-16px) scale(0.9); }
    100% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}
@keyframes toastOut {
    0% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-16px) scale(0.9); }
}

.milestone-banner {
    position: fixed;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, var(--primary) 0%, #ff8c42 100%);
    color: white;
    padding: 6px 16px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 800;
    text-align: center;
    pointer-events: none;
    z-index: 150;
    opacity: 0.9;
    box-shadow: 0 2px 10px rgba(244, 162, 97, 0.4);
    animation: toastIn 0.2s ease-out, toastOut 0.2s ease-in 0.7s forwards;
    display: flex;
    align-items: center;
    gap: 6px;
}

.milestone-banner .icon {
    font-size: 14px;
    display: inline;
    margin-bottom: 0;
}

/* === Stage Popup - compact top toast, never blocks gameplay === */
.stage-popup-overlay {
    position: fixed;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    z-index: 250;
    pointer-events: none;
    animation: toastIn 0.2s ease-out, toastOut 0.2s ease-in 1s forwards;
}

.stage-popup {
    background: linear-gradient(135deg, rgba(244,162,97,0.9), rgba(231,111,81,0.9));
    border: 1px solid var(--primary);
    border-radius: 16px;
    padding: 6px 16px;
    text-align: center;
    box-shadow: 0 2px 12px var(--primary-glow);
    display: flex;
    align-items: center;
    gap: 8px;
}

.stage-emoji {
    font-size: 20px;
    animation: none;
}

.stage-title {
    font-size: 12px;
    font-weight: 800;
    color: white;
    -webkit-text-fill-color: white;
    background: none;
    white-space: nowrap;
}

.stage-desc {
    display: none;
}

.stage-bonus {
    font-size: 11px;
    font-weight: 700;
    color: #ffd700;
    background: none;
    padding: 0;
    white-space: nowrap;
}

/* === Evolution Bar Enhancement === */
.evo-step.target {
    animation: targetPulse 1s ease-in-out infinite;
}

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

.evo-target {
    font-size: 14px;
    margin-left: 2px;
    display: inline-block;
    animation: targetTwinkle 0.8s ease-in-out infinite;
}

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

.evo-badge {
    font-size: 12px;
    margin-left: 2px;
    display: inline-block;
    animation: badgePulse 1.5s ease-in-out infinite;
}

@keyframes badgePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1) rotateZ(5deg); }
}

/* === Game Over Stats === */
.game-over-stats {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin-bottom: 16px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: var(--text-secondary);
    padding: 6px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-row span:first-child {
    color: var(--text-dim);
}

.stat-row .stat-value {
    color: var(--primary);
    font-weight: 700;
}

/* === Collection Modal === */
.collection-modal .modal-content {
    max-width: 360px;
}

.modal-header {
    margin-bottom: 16px;
}

.collection-progress {
    margin-top: 12px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 6px;
}

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

.progress-text {
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
}

.collection-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 16px;
    max-height: 400px;
    overflow-y: auto;
    padding: 4px;
}

.collection-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-sm);
    padding: 8px;
    text-align: center;
    transition: all 0.2s ease;
    opacity: 0.5;
}

.collection-item.discovered {
    background: linear-gradient(135deg, rgba(244, 162, 97, 0.15), rgba(231, 111, 81, 0.15));
    border-color: rgba(244, 162, 97, 0.3);
    opacity: 1;
    box-shadow: 0 0 12px rgba(244, 162, 97, 0.2);
}

.collection-emoji {
    font-size: 24px;
    margin-bottom: 4px;
}

.collection-name {
    font-size: 10px;
    color: var(--text-secondary);
    word-break: break-word;
}

.collection-item.discovered .collection-name {
    color: var(--text);
}

/* === History Modal === */
.history-modal .modal-content {
    max-width: 340px;
}

.history-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.history-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 12px;
}

.history-stat .stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.history-stat .stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 16px;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 14px;
}

.history-emoji {
    font-size: 18px;
}

.history-arrow {
    margin: 0 6px;
    color: var(--primary);
    font-weight: 700;
}

.history-time {
    font-size: 11px;
    color: var(--text-dim);
    margin-left: 8px;
}

.history-empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 24px 0;
}

/* === Daily Challenge Modal === */
.daily-modal .modal-content {
    max-width: 320px;
}

.daily-challenge-container {
    background: linear-gradient(135deg, rgba(244, 162, 97, 0.1), rgba(231, 111, 81, 0.1));
    border: 1px solid rgba(244, 162, 97, 0.2);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.daily-goal {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 16px;
    font-size: 16px;
    font-weight: 600;
}

.goal-icon {
    font-size: 28px;
}

.daily-progress {
    margin-bottom: 16px;
}

.daily-progress .progress-bar {
    margin-bottom: 8px;
}

.daily-progress .progress-text {
    font-size: 13px;
}

.daily-badge {
    text-align: center;
    background: linear-gradient(135deg, rgba(42, 157, 143, 0.2), rgba(38, 70, 83, 0.2));
    border: 1px solid rgba(42, 157, 143, 0.3);
    border-radius: var(--radius-sm);
    padding: 8px;
    color: var(--primary);
    font-weight: 600;
    font-size: 13px;
}

/* === Milestone Reward Badge - compact top toast === */
.milestone-reward-badge {
    position: fixed;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, var(--bg-surface), rgba(244, 162, 97, 0.2));
    border: 1px solid var(--primary);
    border-radius: 16px;
    padding: 6px 16px;
    text-align: center;
    z-index: 500;
    pointer-events: none;
    opacity: 0.9;
    animation: toastIn 0.2s ease-out, toastOut 0.2s ease-in 1s forwards;
    box-shadow: 0 2px 10px rgba(244, 162, 97, 0.3);
    display: flex;
    align-items: center;
    gap: 8px;
}

.milestone-emoji {
    font-size: 18px;
    margin-bottom: 0;
}

.milestone-text {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 0;
    white-space: nowrap;
}

.milestone-count {
    font-size: 12px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0;
    white-space: nowrap;
}

.milestone-bonus {
    font-size: 11px;
    color: var(--accent);
    font-weight: 600;
    white-space: nowrap;
}

/* === Daily Challenge Complete Banner - compact top toast === */
.daily-challenge-complete {
    position: fixed;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, rgba(42, 157, 143, 0.9), rgba(38, 70, 83, 0.9));
    border: 1px solid rgba(42, 157, 143, 0.5);
    border-radius: 16px;
    padding: 5px 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text);
    font-size: 11px;
    z-index: 500;
    pointer-events: none;
    opacity: 0.9;
    animation: toastIn 0.2s ease-out, toastOut 0.2s ease-in 1.2s forwards;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.daily-challenge-complete .icon {
    font-size: 14px;
}

/* === Collection Badge on Button === */
.collection-badge {
    font-size: 10px;
    background: var(--primary);
    color: var(--bg-deep);
    border-radius: 10px;
    padding: 2px 6px;
    margin-left: 4px;
    font-weight: 700;
    display: inline-block;
    min-width: 32px;
    text-align: center;
}

/* === Modal Scrollbar === */
.collection-grid::-webkit-scrollbar,
.history-list::-webkit-scrollbar {
    width: 6px;
}

.collection-grid::-webkit-scrollbar-track,
.history-list::-webkit-scrollbar-track {
    background: transparent;
}

.collection-grid::-webkit-scrollbar-thumb,
.history-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.collection-grid::-webkit-scrollbar-thumb:hover,
.history-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* === Utility === */
.hidden { display: none !important; }

/* === Accessibility Improvements === */
button:focus-visible,a:focus-visible,input:focus-visible,[role="button"]:focus-visible{outline:3px solid #00b894;outline-offset:2px;}
button,a[href],input[type="button"],input[type="submit"],[role="button"]{min-width:44px;min-height:44px;display:inline-flex;align-items:center;justify-content:center;}
.skip-link{position:absolute;top:-40px;left:0;background:#00b894;color:white;padding:8px;text-decoration:none;z-index:100;}
.skip-link:focus{top:0;}
[role="dialog"]{z-index:1000;}
@media (prefers-reduced-motion: reduce){*{animation-duration:0.01ms !important;animation-iteration-count:1 !important;transition-duration:0.01ms !important;scroll-behavior:auto !important;}}
@media (prefers-contrast: more){button{border:2px solid #00b894;}}
.game-card:focus-visible{outline:3px solid #00b894;outline-offset:4px;}

/* Selection Color */
::selection {
    background: #f4a261;
    color: white;
}

::-moz-selection {
    background: #f4a261;
    color: white;
}
