/* ===== RESET AND BASE STYLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    overflow-x: hidden;
}

/* ===== CONTAINER AND LAYOUT ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    text-align: center;
}

.screen {
    display: none;
    min-height: 100vh;
    position: relative;
}

.screen.active {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Special handling for written exercise screen */
#written-exercise-screen.active {
    justify-content: flex-start;
    padding-top: 20px;
}

#written-exercise-screen .container {
    padding: 10px 20px;
}

/* ===== MODE SELECTION SCREEN ===== */
.tracking-options {
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: 2rem;
    margin: 2rem 0;
    flex-wrap: wrap;
}

.tracking-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
    flex: 1;
    min-width: 280px;
    max-width: 350px;
    text-align: center;
}

.tracking-card:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.tracking-card h3 {
    font-size: 1.5rem;
    color: white;
    margin-bottom: 1rem;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.tracking-card p {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1rem;
    line-height: 1.5;
    margin-bottom: 1.5rem;
    min-height: 3rem;
}

.tracking-card .primary-btn {
    width: 100%;
    margin-top: auto;
}

/* ===== HELP SCREEN UPDATES ===== */
.mode-explanation, .response-modes {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 1.5rem;
    margin: 1.5rem 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.mode-response {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.mode-response:last-child {
    margin-bottom: 0;
}

/* ===== EXPANDABLE SECTIONS ===== */
.expandable-section {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    margin: 1.5rem 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
    transition: all 0.3s ease;
}

.section-header {
    display: flex;
    align-items: center;
    padding: 1.5rem;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.3s ease;
}

.section-header:hover {
    background: rgba(255, 255, 255, 0.05);
}

.expand-icon {
    font-size: 1.5rem;
    font-weight: bold;
    margin-right: 1rem;
    color: #4ecdc4;
    transition: transform 0.3s ease;
    min-width: 25px;
    text-align: center;
}

.expand-icon.expanded {
    transform: rotate(45deg);
}

.section-header h4 {
    margin: 0;
    color: #4ecdc4;
    font-size: 1.3rem;
}

.section-content {
    padding: 0 1.5rem 1.5rem 1.5rem;
    transition: all 0.3s ease;
}

.section-content.hidden {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    overflow: hidden;
}

.section-content:not(.hidden) {
    max-height: 1000px;
}

/* ===== TYPOGRAPHY ===== */
.game-title {
    font-size: 3rem;
    font-weight: 700;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    margin-bottom: 2rem;
}

h2 {
    font-size: 2.5rem;
    color: white;
    margin-bottom: 2rem;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

/* Compact spacing for written exercise */
#written-exercise-screen h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

#written-exercise-screen p {
    margin-bottom: 1rem;
    font-size: 1rem;
}

h3 {
    font-size: 1.8rem;
    color: white;
    margin-bottom: 1rem;
}

h4 {
    font-size: 1.2rem;
    color: white;
    margin-bottom: 0.5rem;
}

p {
    color: white;
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 1rem;
}

/* ===== BUTTONS ===== */
.button-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
    margin-top: 2rem;
}

.primary-btn, .secondary-btn, .level-btn, .control-btn {
    padding: 15px 30px;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 250px;
    width: 250px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.primary-btn {
    background: linear-gradient(135deg, #ff6b6b, #ee5a52);
    color: white;
    box-shadow: 0 4px 15px rgba(238, 90, 82, 0.4);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(238, 90, 82, 0.6);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.level-card .level-btn {
    background: linear-gradient(135deg, #4ecdc4, #44a08d);
    color: white;
    min-width: 150px;
    margin-top: auto;
    align-self: center;
}

.level-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(68, 160, 141, 0.4);
}

.control-btn {
    padding: 8px 16px;
    min-width: 80px;
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ===== SETTINGS SCREEN ===== */
.settings-group {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 2rem;
    margin: 2rem 0;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.setting-item label {
    color: white;
    font-weight: 600;
    font-size: 1.1rem;
    flex: 1;
    text-align: left;
    min-width: 180px;
}

.setting-item input[type="range"] {
    flex: 1;
    max-width: 200px;
    margin: 0 1rem;
}

.setting-item select {
    padding: 8px 12px;
    border-radius: 5px;
    border: 1px solid #ccc;
    background: white;
    font-size: 1rem;
    min-width: 150px;
}

.setting-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-right: 10px;
}

.checkbox-label {
    color: white;
    font-size: 1rem;
}

#tempo-value, #acceleration-value {
    color: #4ecdc4;
    font-weight: bold;
    font-size: 1.1rem;
    min-width: 60px;
    text-align: center;
}

/* ===== SPINNING WHEEL SCREEN ===== */
.wheel-phase {
    transition: all 0.3s ease;
}

/* Level Selection Phase */
#wheel-level-selection {
    text-align: center;
    margin: 2rem 0;
}

#wheel-level-selection h3 {
    color: white;
    font-size: 2rem;
    margin-bottom: 2rem;
}

.level-buttons {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.wheel-level-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 15px;
    padding: 2rem;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.wheel-level-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.level-number {
    font-size: 1.5rem;
    font-weight: bold;
    color: #4ecdc4;
}

.level-reps {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.9);
}

/* Wheel Game Phase - instruction display removed */

.wheel-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3rem;
    margin: 2rem 0;
    flex-wrap: wrap;
}

.wheel-container {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    flex-shrink: 0;
}

.spinning-wheel {
    width: 300px;
    height: 300px;
    border-radius: 50%;
    position: relative;
    border: 4px solid white;
    overflow: hidden;
    transition: transform 3s cubic-bezier(0.25, 0.1, 0.25, 1);
    background: conic-gradient(
        #ff6b6b 0deg 30deg,
        #4ecdc4 30deg 60deg,
        #ffe66d 60deg 90deg,
        #ff8b94 90deg 120deg,
        #95e1d3 120deg 150deg,
        #fce38a 150deg 180deg,
        #ee5a52 180deg 210deg,
        #44a08d 210deg 240deg,
        #ffb347 240deg 270deg,
        #87ceeb 270deg 300deg,
        #dda0dd 300deg 330deg,
        #98fb98 330deg 360deg
    );
}

.wheel-section {
    position: absolute;
    width: 50%;
    height: 50%;
    top: 50%;
    left: 50%;
    transform-origin: 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.8rem;
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
    padding: 10px;
    text-align: center;
}

.wheel-section:nth-child(1) { transform: rotate(0deg); }
.wheel-section:nth-child(2) { transform: rotate(30deg); }
.wheel-section:nth-child(3) { transform: rotate(60deg); }
.wheel-section:nth-child(4) { transform: rotate(90deg); }
.wheel-section:nth-child(5) { transform: rotate(120deg); }
.wheel-section:nth-child(6) { transform: rotate(150deg); }
.wheel-section:nth-child(7) { transform: rotate(180deg); }
.wheel-section:nth-child(8) { transform: rotate(210deg); }
.wheel-section:nth-child(9) { transform: rotate(240deg); }
.wheel-section:nth-child(10) { transform: rotate(270deg); }
.wheel-section:nth-child(11) { transform: rotate(300deg); }
.wheel-section:nth-child(12) { transform: rotate(330deg); }

.wheel-pointer {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 15px solid transparent;
    border-right: 15px solid transparent;
    border-top: 30px solid #ff6b6b;
    z-index: 10;
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.3));
}

.wheel-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
    min-width: 200px;
}

.large-btn {
    font-size: 1.3rem;
    padding: 20px 40px;
    min-width: 250px;
}

.hidden {
    display: none !important;
}

/* Mobile responsiveness for spinning wheel */
@media (max-width: 768px) {
    .wheel-layout {
        flex-direction: column;
        gap: 2rem;
    }
    
    .wheel-container {
        margin-bottom: 1rem;
    }
    
    .spinning-wheel {
        width: 250px;
        height: 250px;
    }
    
    .wheel-section {
        font-size: 0.7rem;
        padding: 5px;
    }
    
    .level-buttons {
        flex-direction: column;
        align-items: center;
        gap: 1rem;
    }
    
    .wheel-level-btn {
        width: 250px;
        min-width: 250px;
    }
    
    .large-btn {
        font-size: 1.1rem;
        padding: 15px 30px;
        min-width: 200px;
    }
}

/* ===== HELP SCREEN ===== */
.help-content {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 2rem;
    margin: 2rem 0;
    border: 1px solid rgba(255, 255, 255, 0.2);
    text-align: left;
}

.position-guide {
    margin: 1.5rem 0;
}

.level-guide {
    background: rgba(255, 255, 255, 0.1);
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 8px;
}

.help-content ul {
    margin-left: 2rem;
    margin-bottom: 1rem;
}

.help-content li {
    color: white;
    margin-bottom: 0.5rem;
}

/* ===== LEVEL SELECT SCREEN ===== */
.level-options {
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: 2rem;
    margin: 2rem 0;
    flex-wrap: wrap;
}

.level-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: transform 0.3s ease;
    flex: 1;
    min-width: 250px;
    max-width: 300px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.level-card:hover {
    transform: translateY(-5px);
}

.level-preview {
    margin: 1.5rem 0;
    display: flex;
    justify-content: center;
}

.mini-grid {
    display: grid;
    gap: 3px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
}

.grid-2x2 {
    grid-template-columns: repeat(2, 25px);
    grid-template-rows: repeat(2, 25px);
}

.grid-2x3 {
    grid-template-columns: repeat(3, 25px);
    grid-template-rows: repeat(2, 25px);
}

.grid-3x3 {
    grid-template-columns: repeat(3, 25px);
    grid-template-rows: repeat(3, 25px);
}

.mini-cell {
    background: rgba(255, 255, 255, 0.6);
    border-radius: 2px;
    width: 25px;
    height: 25px;
}

.auto-progression {
    margin: 2rem 0;
}

.auto-progression label {
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.1rem;
    gap: 0.5rem;
}

/* ===== GAME SCREEN ===== */
#game-screen.active {
    display: block;
    padding: 0;
}

.game-header {
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
    position: sticky;
    top: 0;
    z-index: 100;
}

.game-info {
    display: flex;
    gap: 2rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.game-controls {
    display: flex;
    gap: 1rem;
}

.game-area {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 70px);
    padding: 2rem;
}

/* ===== GAME GRID SYSTEM ===== */
.game-grid {
    display: grid;
    gap: 10px;
    margin: 2rem 0;
    padding: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Grid layouts for different levels */
.game-grid.level-1 {
    grid-template-columns: repeat(2, 120px);
    grid-template-rows: repeat(2, 120px);
}

.game-grid.level-2 {
    grid-template-columns: repeat(3, 120px);
    grid-template-rows: repeat(2, 120px);
}

.game-grid.level-3 {
    grid-template-columns: repeat(3, 120px);
    grid-template-rows: repeat(3, 120px);
}

/* Game cells - consistent square sizes */
.game-cell {
    width: 120px;
    height: 120px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: bold;
    color: transparent;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

/* Active cell states */
.game-cell.active {
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    border-color: white;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
    transform: scale(1.05);
}

/* Primary colors for cells */
.game-cell.red {
    background: linear-gradient(135deg, #ff6b6b, #ee5a52);
}

.game-cell.yellow {
    background: linear-gradient(135deg, #ffd93d, #ffb700);
    color: #333 !important;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.5);
}

.game-cell.blue {
    background: linear-gradient(135deg, #74b9ff, #0984e3);
}

/* Colorblind mode patterns */
.colorblind-mode .game-cell.red::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 5px,
        rgba(255, 255, 255, 0.3) 5px,
        rgba(255, 255, 255, 0.3) 10px
    );
    pointer-events: none;
}

.colorblind-mode .game-cell.yellow::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: repeating-linear-gradient(
        90deg,
        transparent,
        transparent 3px,
        rgba(0, 0, 0, 0.3) 3px,
        rgba(0, 0, 0, 0.3) 6px
    );
    pointer-events: none;
}

.colorblind-mode .game-cell.blue::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: radial-gradient(
        circle at 50% 50%,
        rgba(255, 255, 255, 0.3) 2px,
        transparent 2px
    );
    background-size: 15px 15px;
    pointer-events: none;
}

/* Dynamic font sizing for long words */
.game-cell {
    font-size: 1.2rem;
}

.game-cell.long-word {
    font-size: 0.9rem;
}

.game-cell.very-long-word {
    font-size: 0.7rem;
}

/* Game status */
.game-status {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 10px;
    padding: 1rem 2rem;
    margin-top: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.game-status p {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0;
}

/* ===== RESULTS SCREEN ===== */
.results-content {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 2rem;
    margin: 2rem 0;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.result-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.result-label {
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
}

.result-item span:last-child {
    color: #4ecdc4;
    font-size: 1.2rem;
    font-weight: bold;
}

/* ===== MODALS ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.3);
    max-width: 400px;
    width: 90%;
}

.modal-content h3 {
    color: #333;
    margin-bottom: 1rem;
}

.modal-content p {
    color: #666;
    margin-bottom: 1.5rem;
}

.modal-content .button-group {
    gap: 1rem;
}

.modal-content .primary-btn,
.modal-content .secondary-btn {
    font-size: 1.1rem !important;
    font-weight: 600 !important;
    min-width: 120px !important;
    padding: 12px 20px !important;
    text-transform: uppercase !important;
    letter-spacing: 1px !important;
}

.modal-content .primary-btn {
    background: linear-gradient(135deg, #ff6b6b, #ee5a52) !important;
    color: white !important;
    border: none !important;
}

.modal-content .secondary-btn {
    background: #f0f0f0 !important;
    border: 2px solid #333 !important;
    color: #333 !important;
}

/* ===== CONFETTI ANIMATION ===== */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    overflow: hidden;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #ff6b6b;
    animation: confetti-fall 3s linear forwards;
}

.confetti:nth-child(2n) { background: #4ecdc4; }
.confetti:nth-child(3n) { background: #ffe66d; }
.confetti:nth-child(4n) { background: #ff8b94; }
.confetti:nth-child(5n) { background: #95e1d3; }
.confetti:nth-child(6n) { background: #fce38a; }
.confetti:nth-child(7n) { background: #ee5a52; }
.confetti:nth-child(8n) { background: #44a08d; }

@keyframes confetti-fall {
    0% {
        transform: translateY(-100vh) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

.confetti-burst {
    animation: confetti-burst 0.6s ease-out forwards;
}

@keyframes confetti-burst {
    0% {
        transform: scale(0) rotate(0deg);
        opacity: 1;
    }
    50% {
        transform: scale(1.2) rotate(180deg);
        opacity: 1;
    }
    100% {
        transform: scale(0.8) rotate(360deg);
        opacity: 0;
    }
}

/* Fireworks effect */
.firework {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    animation: firework 1.5s ease-out forwards;
}

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

/* ===== RESPONSIVE DESIGN ===== */

/* Tablet styles */
@media (max-width: 1024px) {
    .game-grid.level-1 {
        grid-template-columns: repeat(2, 90px);
        grid-template-rows: repeat(2, 90px);
    }

    .game-grid.level-2 {
        grid-template-columns: repeat(3, 90px);
        grid-template-rows: repeat(2, 90px);
    }

    .game-grid.level-3 {
        grid-template-columns: repeat(3, 90px);
        grid-template-rows: repeat(3, 90px);
    }

    .game-cell {
        width: 90px;
        height: 90px;
        font-size: 1rem;
    }

    .game-cell.long-word {
        font-size: 0.8rem;
    }

    .game-cell.very-long-word {
        font-size: 0.6rem;
    }

    .game-title {
        font-size: 2.5rem;
    }

    .tracking-options {
        flex-direction: column;
        align-items: center;
    }

    .tracking-card {
        max-width: 100%;
        width: 100%;
    }

    .level-options {
        flex-direction: column;
        align-items: center;
    }

    .level-card {
        max-width: 100%;
        width: 100%;
    }
}

/* Mobile styles */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    .game-grid.level-1 {
        grid-template-columns: repeat(2, 70px);
        grid-template-rows: repeat(2, 70px);
    }

    .game-grid.level-2 {
        grid-template-columns: repeat(3, 70px);
        grid-template-rows: repeat(2, 70px);
    }

    .game-grid.level-3 {
        grid-template-columns: repeat(3, 70px);
        grid-template-rows: repeat(3, 70px);
    }

    .game-cell {
        width: 70px;
        height: 70px;
        font-size: 0.9rem;
    }

    .game-cell.long-word {
        font-size: 0.7rem;
    }

    .game-cell.very-long-word {
        font-size: 0.5rem;
    }

    .game-title {
        font-size: 2rem;
    }

    h2 {
        font-size: 2rem;
    }

    .button-group {
        width: 100%;
    }

    .primary-btn, .secondary-btn, .level-btn {
        width: 100%;
        max-width: 300px;
    }

    .game-header {
        flex-direction: column;
        gap: 1rem;
        padding: 10px 15px;
    }

    .game-info {
        gap: 1rem;
        font-size: 1rem;
        flex-wrap: wrap;
        justify-content: center;
    }

    .setting-item {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    .setting-item label {
        text-align: center;
        margin-bottom: 0.5rem;
    }

    .help-content {
        text-align: center;
    }

    .position-guide {
        text-align: left;
    }
}

/* Small mobile styles */
@media (max-width: 480px) {
    .game-cell {
        width: 60px;
        height: 60px;
        font-size: 0.8rem;
    }

    .game-cell.long-word {
        font-size: 0.6rem;
    }

    .game-cell.very-long-word {
        font-size: 0.45rem;
    }

    .game-grid.level-1 {
        grid-template-columns: repeat(2, 60px);
        grid-template-rows: repeat(2, 60px);
    }

    .game-grid.level-2 {
        grid-template-columns: repeat(3, 60px);
        grid-template-rows: repeat(2, 60px);
    }

    .game-grid.level-3 {
        grid-template-columns: repeat(3, 60px);
        grid-template-rows: repeat(3, 60px);
    }

    .game-title {
        font-size: 1.8rem;
    }

    .container {
        padding: 10px;
    }
}

/* Portrait vs Landscape orientation for Level 2 */
@media (orientation: portrait) {
    .game-grid.level-2.portrait {
        grid-template-columns: repeat(2, var(--cell-size));
        grid-template-rows: repeat(3, var(--cell-size));
    }
}

@media (orientation: landscape) {
    .game-grid.level-2.landscape {
        grid-template-columns: repeat(3, var(--cell-size));
        grid-template-rows: repeat(2, var(--cell-size));
    }
}

/* CSS Variables for dynamic cell sizing */
:root {
    --cell-size: 120px;
}

@media (max-width: 1024px) {
    :root {
        --cell-size: 90px;
    }
}

@media (max-width: 768px) {
    :root {
        --cell-size: 70px;
    }
}

@media (max-width: 480px) {
    :root {
        --cell-size: 60px;
    }
}

/* ===== WRITTEN EXERCISE STYLES ===== */
.written-main-layout {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 2rem;
    margin: 1rem 0;
    flex-wrap: wrap;
}

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

.written-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 10px;
    width: 400px;
    height: 400px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 20px;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.written-cell {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: bold;
    color: transparent;
    transition: all 0.3s ease;
    position: relative;
}

.written-cell.active {
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.written-cell.active.red {
    background: linear-gradient(135deg, #ff6b6b, #ee5a52);
    border-color: #ff6b6b;
}

.written-cell.active.yellow {
    background: linear-gradient(135deg, #ffe66d, #ffd93d);
    border-color: #ffe66d;
    color: #333;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
}

.written-cell.active.blue {
    background: linear-gradient(135deg, #4ecdc4, #44a08d);
    border-color: #4ecdc4;
}

.written-stats-sidebar {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 200px;
}

.exercise-stats {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 1.5rem;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

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

.stat-label {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-item span:last-child {
    color: #4ecdc4;
    font-size: 1.1rem;
    font-weight: bold;
}

.written-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin: 1.5rem 0;
    flex-wrap: wrap;
}

/* Mobile responsiveness for written exercise */
@media (max-width: 768px) {
    .written-main-layout {
        flex-direction: column;
        align-items: center;
        gap: 1.5rem;
    }
    
    .written-grid {
        width: 320px;
        height: 320px;
        padding: 15px;
        gap: 8px;
    }
    
    .written-cell {
        font-size: 1rem;
    }
    
    .written-stats-sidebar {
        min-width: 320px;
    }
    
    .exercise-stats {
        padding: 1rem;
    }
    
    .written-controls {
        flex-direction: column;
        align-items: center;
    }
}

@media (max-width: 480px) {
    .written-grid {
        width: 240px;
        height: 240px;
        padding: 10px;
        gap: 5px;
    }
    
    .written-cell {
        font-size: 0.8rem;
    }
    
    .written-stats-sidebar {
        min-width: 240px;
    }
}