:root {
    --bg-primary: #CCE4FF;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e9ecef;
    --accent-primary: #005bea;
    --accent-light: #66a6ff;
    --accent-lighter: #89f7fe;
    --accent-dark: #004494;
    --accent-pink: #d63384;
    --accent-green: #198754;
    --accent-red: #dc3545;
    --accent-yellow: #ffc107;
    --text-primary: #2d3748;
    --text-secondary: #495057;
    --text-muted: #6c757d;
    --grid-line: #dee2e6;
    --grid-line-dark: #adb5bd;
    --border-color: #ced4da;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 15px 30px rgba(102, 166, 255, 0.15);
}

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

body {
    font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #CCE4FF 0%, #a8d5ff 50%, #CCE4FF 100%);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

.header:hover {
    box-shadow: var(--shadow-md);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.logo:hover {
    opacity: 0.8;
    transform: translateY(-2px);
}

.logo-icon {
    font-size: 24px;
    transition: transform 0.3s ease;
}

.logo:hover .logo-icon {
    transform: rotate(-10deg) scale(1.1);
}

.logo-text {
    font-family: 'Segoe UI', sans-serif;
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav {
    display: flex;
    gap: 12px;
}

.nav-btn {
    background: transparent;
    border: 2px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-btn:hover {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-light));
    border-color: transparent;
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.nav-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 91, 234, 0.3);
}

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.view {
    display: none;
    flex: 1;
    animation: fadeInUp 0.4s ease;
}

.view.active {
    display: flex;
    flex-direction: column;
}

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

.page-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 24px;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

#welcome-view {
    justify-content: center;
    align-items: center;
    padding: 24px;
}

.welcome-content {
    text-align: center;
    max-width: 600px;
    width: 100%;
}

.welcome-title {
    margin-bottom: 24px;
}

.title-main {
    display: block;
    font-family: 'Segoe UI', sans-serif;
    font-size: 48px;
    font-weight: 900;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-light), var(--accent-lighter));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
    animation: shimmer 3s ease-in-out infinite;
    background-size: 200% auto;
}

@keyframes shimmer {
    0% { background-position: -100% center; }
    100% { background-position: 200% center; }
}

.title-sub {
    display: block;
    font-family: 'Consolas', monospace;
    font-size: 18px;
    color: var(--text-secondary);
    letter-spacing: 4px;
}

.welcome-animation {
    margin: 32px 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.sudoku-icon {
    display: inline-block;
    transition: transform 0.3s ease;
}

.sudoku-icon:hover {
    transform: scale(1.05) rotate(2deg);
}

.grid-preview {
    display: grid;
    grid-template-columns: repeat(4, 40px);
    grid-template-rows: repeat(4, 40px);
    gap: 3px;
    background: linear-gradient(135deg, var(--accent-light), var(--accent-primary));
    padding: 4px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.grid-preview .row {
    display: contents;
}

.grid-preview span {
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Consolas', monospace;
    font-size: 16px;
    font-weight: 700;
    color: var(--accent-primary);
    background: white;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.grid-preview span:not(.empty) {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 91, 234, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(0, 91, 234, 0); }
}

.grid-preview .empty {
    background: rgba(255, 255, 255, 0.3);
}

.welcome-desc {
    color: var(--text-secondary);
    font-size: 16px;
    line-height: 1.8;
    margin-bottom: 32px;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px 48px;
    font-size: 18px;
    font-weight: 700;
    color: white;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-light));
    background-size: 200% 200%;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: 'Segoe UI', sans-serif;
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

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

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

.btn-primary:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: var(--shadow-lg);
    background-position: 100% 0;
}

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

.btn-primary:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 91, 234, 0.3), var(--shadow-lg);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: 'Segoe UI', sans-serif;
    text-decoration: none;
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 91, 234, 0.3);
}

.welcome-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
    width: 100%;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
}

.welcome-buttons .btn-primary,
.welcome-buttons .btn-secondary {
    width: 100%;
    min-width: 200px;
}

.stats-preview {
    display: flex;
    justify-content: center;
    gap: 48px;
    margin-top: 32px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.3s ease;
}

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

.stat-value {
    font-family: 'Consolas', monospace;
    font-size: 32px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
    font-weight: 500;
}

#level-select-view {
    padding: 24px;
    align-items: center;
}

.level-select-header {
    text-align: center;
    margin-bottom: 32px;
}

.level-select-header h2 {
    font-family: 'Segoe UI', sans-serif;
    font-size: 28px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.level-hint {
    color: var(--text-secondary);
    font-size: 14px;
}

.level-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 24px;
    max-width: 800px;
    width: 100%;
    min-height: 200px;
}

.loading-placeholder {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

.loading-placeholder p {
    color: var(--text-secondary);
    font-size: 16px;
    padding: 20px;
}

.error-msg {
    grid-column: 1 / -1;
    color: var(--accent-red);
    text-align: center;
    padding: 20px;
    font-size: 16px;
}

.level-card {
    position: relative;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 2px solid var(--border-color);
    border-radius: 20px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.level-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(102, 166, 255, 0.1), transparent);
    transition: left 0.6s ease;
}

.level-card:not(.locked):hover::before {
    left: 100%;
}

.level-card:not(.locked):hover {
    border-color: var(--accent-primary);
    transform: translateY(-8px) scale(1.02);
    box-shadow: var(--shadow-lg);
}

.level-card:not(.locked):focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 91, 234, 0.3), var(--shadow-lg);
}

.level-card.locked {
    opacity: 0.6;
    cursor: not-allowed;
}

.level-card.completed {
    border-color: var(--accent-green);
}

.level-card.completed::after {
    content: '';
    position: absolute;
    top: -1px;
    right: -1px;
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, var(--accent-green), #157347);
    border-radius: 0 20px 0 12px;
}

.level-number {
    font-family: 'Segoe UI', sans-serif;
    font-size: 48px;
    font-weight: 900;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
    margin-bottom: 8px;
}

.level-name {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.level-stars {
    font-size: 16px;
    color: var(--accent-yellow);
    margin-bottom: 8px;
}

.level-puzzles {
    font-size: 14px;
    color: var(--text-secondary);
}

.lock-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 48px;
    opacity: 0.8;
}

.check-icon {
    position: absolute;
    top: 12px;
    right: 12px;
    font-size: 20px;
    color: white;
}

#game-view {
    padding: 16px;
    align-items: center;
}

.game-container {
    max-width: 500px;
    width: 100%;
}

.game-info {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.info-card {
    flex: 1;
    min-width: 70px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 8px 12px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

.info-card:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.timer-card {
    flex: 2;
    min-width: 120px;
}

.info-label {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.info-value {
    font-family: 'Consolas', monospace;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}

.timer-value {
    font-size: 18px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.error-value {
    color: var(--accent-red);
}

.board-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 2px solid var(--border-color);
    border-radius: 16px;
    padding: 8px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-lg);
}

.sudoku-board {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 1px;
    background: linear-gradient(135deg, var(--accent-light), var(--accent-primary));
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 1;
}

.cell {
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    font-family: 'Consolas', monospace;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
    aspect-ratio: 1;
    position: relative;
    user-select: none;
    color: var(--text-primary);
}

.cell:nth-child(3n) {
    border-right: 2px solid var(--accent-primary);
}

.cell:nth-child(9n) {
    border-right: none;
}

.cell:nth-child(n+19):nth-child(-n+27),
.cell:nth-child(n+46):nth-child(-n+54) {
    border-bottom: 2px solid var(--accent-primary);
}

.cell:hover {
    background: linear-gradient(135deg, #e0f2fe, #bae6fd);
}

.cell.fixed {
    color: var(--text-muted);
    cursor: default;
    background: #f8fafc;
}

.cell.selected {
    background: linear-gradient(135deg, #cfe2ff, #b3d7ff);
    box-shadow: inset 0 0 0 2px var(--accent-primary);
    z-index: 1;
}

.cell.related {
    background: linear-gradient(135deg, #e0f2fe, #bae6fd);
}

.cell.same-number {
    background: linear-gradient(135deg, #f8d7da, #f1aeb5);
}

.cell.error {
    color: var(--accent-red);
    background: linear-gradient(135deg, #f8d7da, #f1aeb5);
    animation: shake 0.3s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

.cell.has-notes {
    font-size: 0;
}

.cell .note-cell {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    padding: 2px;
}

.cell .note-cell span {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    color: var(--text-muted);
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.number-pad {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 4px;
}

.num-btn {
    aspect-ratio: 1;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    color: var(--accent-primary);
    font-family: 'Consolas', monospace;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.num-btn:hover {
    background: linear-gradient(135deg, #e0f2fe, #bae6fd);
    border-color: var(--accent-primary);
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

.num-btn:active {
    transform: scale(0.95);
}

.num-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 91, 234, 0.3);
}

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

.btn-action {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-action:hover {
    background: linear-gradient(135deg, #e0f2fe, #bae6fd);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-action:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 91, 234, 0.3);
}

.btn-action.active {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-light));
    border-color: transparent;
    color: white;
}

.btn-icon {
    font-size: 16px;
}

.btn-back {
    display: block;
    width: 100%;
    margin-top: 16px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
    text-decoration: none;
}

.btn-back:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: linear-gradient(135deg, #e0f2fe, #bae6fd);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-back:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 91, 234, 0.3);
}

#victory-view {
    justify-content: center;
    align-items: center;
    padding: 24px;
}

.victory-content {
    text-align: center;
    max-width: 400px;
}

.victory-icon {
    font-size: 80px;
    animation: bounce 1s ease infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

.victory-title {
    font-family: 'Segoe UI', sans-serif;
    font-size: 36px;
    margin: 16px 0;
    background: linear-gradient(135deg, var(--accent-green), #157347);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.victory-details {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin: 24px 0;
}

.victory-level, .victory-time {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.victory-details .label {
    font-size: 12px;
    color: var(--text-secondary);
}

.victory-details .value {
    font-family: 'Consolas', monospace;
    font-size: 24px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.victory-stats {
    display: flex;
    justify-content: center;
    gap: 48px;
    margin: 32px 0;
}

.victory-stats .stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-num {
    font-family: 'Consolas', monospace;
    font-size: 32px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-pink), #a0276a);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

.victory-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 24px;
}

.victory-buttons .btn-secondary {
    flex: none;
    width: 100%;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    border: 2px solid var(--border-color);
    border-radius: 20px;
    padding: 32px;
    text-align: center;
    position: relative;
    max-width: 90%;
    animation: slideUp 0.3s ease;
    box-shadow: var(--shadow-lg);
}

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

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

.confirm-modal {
    max-width: 400px;
}

.confirm-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.confirm-message {
    font-size: 16px;
    color: var(--text-secondary);
    margin: 16px 0 24px;
    line-height: 1.6;
}

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

.btn-confirm {
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, var(--accent-red), #b02a37);
    background-size: 200% 200%;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-confirm:hover {
    background-position: 100% 0;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-cancel {
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-cancel:hover {
    background: linear-gradient(135deg, #e0f2fe, #bae6fd);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.modal-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, var(--accent-green), #157347);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    color: white;
    animation: pulse 2s ease-in-out infinite;
}

.modal-content h3 {
    font-size: 24px;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.modal-time-label {
    font-size: 14px;
    color: var(--text-secondary);
}

.modal-time {
    font-family: 'Consolas', monospace;
    font-size: 32px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 24px;
}

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

.btn-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 50%;
}

.btn-close:hover {
    color: var(--text-primary);
    background: linear-gradient(135deg, #e0f2fe, #bae6fd);
    transform: rotate(90deg);
}

.btn-close:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 91, 234, 0.3);
}

.puzzle-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin-top: 16px;
    max-height: 300px;
    overflow-y: auto;
}

.puzzle-btn {
    aspect-ratio: 1;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: 'Consolas', monospace;
    min-height: 60px;
}

.puzzle-btn span {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.puzzle-btn small {
    font-size: 10px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.puzzle-btn:hover {
    border-color: var(--accent-primary);
    background: linear-gradient(135deg, #e0f2fe, #bae6fd);
    transform: translateY(-3px) scale(1.05);
    box-shadow: var(--shadow-md);
}

.puzzle-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 91, 234, 0.3);
}

#help-modal .modal-content {
    max-width: 600px;
    text-align: left;
}

#help-modal h3 {
    text-align: center;
    margin-bottom: 20px;
}

.help-section {
    margin-bottom: 20px;
}

.help-section h4 {
    font-size: 16px;
    color: var(--accent-primary);
    margin-bottom: 8px;
    font-weight: 700;
}

.help-section p, .help-section ul {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.help-section ul {
    padding-left: 20px;
}

.help-section li {
    margin-bottom: 4px;
}

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

.shortcut {
    display: flex;
    justify-content: space-between;
    padding: 6px 12px;
    background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
    border-radius: 8px;
    font-size: 13px;
    transition: all 0.3s ease;
}

.shortcut:hover {
    transform: translateX(5px);
}

.shortcut kbd {
    background: white;
    padding: 2px 6px;
    border-radius: 6px;
    font-family: 'Consolas', monospace;
    font-size: 12px;
    border: 2px solid var(--border-color);
    font-weight: 600;
    color: var(--accent-primary);
}

@media (max-width: 640px) {
    .header {
        padding: 0 16px;
    }

    .logo-text {
        font-size: 16px;
    }

    .title-main {
        font-size: 32px;
    }

    .welcome-desc {
        font-size: 14px;
    }

    .welcome-buttons {
        gap: 10px;
    }

    .btn-primary {
        padding: 14px 36px;
        font-size: 16px;
    }

    .stats-preview {
        gap: 24px;
        padding: 16px;
    }

    .stat-value {
        font-size: 24px;
    }

    .level-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    .level-card {
        padding: 16px;
    }

    .level-number {
        font-size: 36px;
    }

    .level-name {
        font-size: 16px;
    }

    .cell {
        font-size: 14px;
    }

    .number-pad {
        grid-template-columns: repeat(5, 1fr);
    }

    .num-btn {
        font-size: 16px;
        padding: 8px;
    }

    .action-buttons {
        flex-wrap: wrap;
    }

    .btn-action {
        flex: none;
        width: calc(50% - 4px);
    }

    .puzzle-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .keyboard-shortcuts {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 400px) {
    .game-info {
        gap: 6px;
    }

    .info-card {
        padding: 6px 8px;
    }

    .info-value {
        font-size: 12px;
    }

    .timer-value {
        font-size: 14px;
    }

    .level-card {
        padding: 12px;
    }

    .grid-preview {
        grid-template-columns: repeat(4, 32px);
        grid-template-rows: repeat(4, 32px);
    }

    .grid-preview span {
        font-size: 13px;
    }
}

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: linear-gradient(135deg, #e0f2fe, #bae6fd);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-light));
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, var(--accent-dark), var(--accent-primary));
}
