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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.game-container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 30px;
    max-width: 900px;
    width: 100%;
}

.header {
    text-align: center;
    margin-bottom: 30px;
}

.header h1 {
    color: #5e60ce;
    font-size: 2.5em;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    font-size: 1.2em;
}

.stats > div {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    font-weight: bold;
}

.game-area {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 30px;
    margin-bottom: 20px;
}

.left-panel {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 180px;
}

.character-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #f8f9fa;
    border-radius: 15px;
    padding: 20px;
}

.character {
    position: relative;
    animation: idle 2s ease-in-out infinite;
}

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

.character-body {
    width: 100px;
    height: 150px;
    position: relative;
}

.character-head {
    width: 50px;
    height: 50px;
    background: #ffdbac;
    border-radius: 15px;
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    border: 3px solid #333;
    overflow: visible;
}

.character-head::before {
    content: '• •';
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 20px;
}

.character-head::after {
    content: '‿';
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 20px;
}

.character-torso {
    width: 60px;
    height: 60px;
    background: #4CAF50;
    border-radius: 10px;
    position: absolute;
    top: 45px;
    left: 50%;
    transform: translateX(-50%);
    border: 3px solid #333;
}

.character-arms {
    position: absolute;
    top: 50px;
    width: 100%;
}

.arm {
    width: 15px;
    height: 40px;
    background: #ffdbac;
    border-radius: 10px;
    position: absolute;
    border: 2px solid #333;
}

.arm.left {
    left: 10px;
    transform: rotate(-20deg);
}

.arm.right {
    right: 10px;
    transform: rotate(20deg);
}

.character-legs {
    position: absolute;
    bottom: 0;
    width: 100%;
}

.leg {
    width: 20px;
    height: 40px;
    background: #2196F3;
    border-radius: 10px;
    position: absolute;
    border: 2px solid #333;
}

.leg.left {
    left: 25px;
}

.leg.right {
    right: 25px;
}

.speech-bubble {
    background: white;
    border: 2px solid #333;
    border-radius: 20px;
    padding: 15px;
    margin-top: 20px;
    position: relative;
    font-weight: bold;
    color: #333;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.speech-bubble::before {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 10px solid white;
}

.question-area {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 25px;
}

.times-table-selector {
    text-align: center;
}

.times-table-selector h3 {
    color: #5e60ce;
    margin-bottom: 20px;
}

.table-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 25px;
}

.table-btn {
    background: #e9ecef;
    border: 3px solid #dee2e6;
    border-radius: 10px;
    padding: 15px 25px;
    font-size: 1.2em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.table-btn.active {
    background: #4CAF50;
    color: white;
    border-color: #45a049;
}

.table-btn:hover {
    transform: scale(1.05);
}

.start-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 25px;
    padding: 15px 40px;
    font-size: 1.3em;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.3s;
}

.start-btn:hover {
    transform: scale(1.1);
}

.question-display {
    text-align: center;
}

.question {
    font-size: 3em;
    color: #333;
    margin-bottom: 30px;
    font-weight: bold;
}

.answer-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    max-width: 400px;
    margin: 0 auto;
}

.answer-btn {
    background: #fff;
    border: 3px solid #5e60ce;
    border-radius: 15px;
    padding: 20px;
    font-size: 1.5em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.answer-btn:hover {
    background: #5e60ce;
    color: white;
    transform: scale(1.05);
}

.answer-btn.correct {
    background: #4CAF50;
    color: white;
    animation: bounce 0.5s;
}

.answer-btn.wrong {
    background: #f44336;
    color: white;
    animation: shake 0.5s;
}

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

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

.feedback {
    margin-top: 20px;
    font-size: 1.3em;
    font-weight: bold;
    min-height: 30px;
}

.feedback.correct {
    color: #4CAF50;
}

.feedback.wrong {
    color: #f44336;
}

.progress-area {
    margin-top: 30px;
    text-align: center;
}

.progress-bar {
    background: #e9ecef;
    border-radius: 25px;
    height: 30px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    height: 100%;
    width: 0%;
    transition: width 0.5s;
    border-radius: 25px;
}

.level {
    font-size: 1.2em;
    font-weight: bold;
    color: #5e60ce;
}

.bottom-panel {
    margin-top: 20px;
}

.achievements {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 15px;
}

.achievements h4 {
    text-align: center;
    color: #5e60ce;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.achievement-list {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.achievement {
    background: gold;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.2);
    animation: shine 2s infinite;
}

@keyframes shine {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

.power-ups {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
}

.power-up {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    border: none;
    border-radius: 15px;
    padding: 10px 20px;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.3s;
}

.power-up:hover {
    transform: scale(1.1);
}

.power-up:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.celebration {
    animation: celebrate 1s ease-in-out;
}

@keyframes celebrate {
    0% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.5) rotate(180deg); }
    100% { transform: scale(1) rotate(360deg); }
}

.times-table-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 15px;
    padding: 10px 20px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.3s, opacity 0.3s;
    margin-top: 20px;
}

.times-table-btn:hover {
    transform: scale(1.05);
}

.times-table-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s;
}

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

.times-table-popup {
    background: white;
    border-radius: 20px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s;
}

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

.close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #f44336;
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 18px;
    cursor: pointer;
    transition: transform 0.3s;
}

.close-btn:hover {
    transform: scale(1.1);
}

#timesTableTitle {
    color: #5e60ce;
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.5em;
}

.times-table-content {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.times-table-item {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 10px;
    text-align: center;
    font-size: 1.1em;
    font-weight: bold;
    color: #333;
    border: 2px solid #dee2e6;
    transition: background 0.3s;
}

.times-table-item:hover {
    background: #e9ecef;
}

/* Compact Progress Grid Styles */
.compact-grid-container {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 15px;
}

.compact-grid-container h4 {
    text-align: center;
    color: #5e60ce;
    margin-bottom: 10px;
    font-size: 1em;
}

.compact-progress-grid {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 0.75em;
}

.grid-header-row,
.grid-row {
    display: grid;
    grid-template-columns: 20px repeat(4, 1fr);
    gap: 2px;
}

.grid-corner {
    /* Empty corner cell */
}

.grid-header {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9em;
    padding: 2px;
}

.grid-col-header {
    color: #333;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 3px;
}

.grid-col-header.table-2 {
    color: #4CAF50;
}

.grid-col-header.table-3 {
    color: #FF9800;
}

.grid-col-header.table-5 {
    color: #9C27B0;
}

.grid-col-header.table-10 {
    color: #2196F3;
}

.grid-row-header {
    color: #666;
    font-size: 0.8em;
}

.grid-cell-compact {
    aspect-ratio: 1;
    border: 1px solid #dee2e6;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    background: white;
    min-width: 20px;
    min-height: 20px;
}

.cell-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #dee2e6;
    transition: all 0.3s;
}

.grid-cell-compact.table-2 .cell-dot {
    background: rgba(76, 175, 80, 0.2);
}

.grid-cell-compact.table-3 .cell-dot {
    background: rgba(255, 152, 0, 0.2);
}

.grid-cell-compact.table-5 .cell-dot {
    background: rgba(156, 39, 176, 0.2);
}

.grid-cell-compact.table-10 .cell-dot {
    background: rgba(33, 150, 243, 0.2);
}

/* Mastery levels - progressive intensity */
.grid-cell-compact.answered-once .cell-dot {
    width: 10px;
    height: 10px;
    opacity: 0.6;
}

.grid-cell-compact.answered-once.table-2 .cell-dot {
    background: #4CAF50;
}

.grid-cell-compact.answered-once.table-3 .cell-dot {
    background: #FF9800;
}

.grid-cell-compact.answered-once.table-5 .cell-dot {
    background: #9C27B0;
}

.grid-cell-compact.answered-once.table-10 .cell-dot {
    background: #2196F3;
}

.grid-cell-compact.mastery-1 .cell-dot {
    width: 12px;
    height: 12px;
    opacity: 0.7;
}

.grid-cell-compact.mastery-1.table-2 .cell-dot {
    background: #4CAF50;
}

.grid-cell-compact.mastery-1.table-3 .cell-dot {
    background: #FF9800;
}

.grid-cell-compact.mastery-1.table-5 .cell-dot {
    background: #9C27B0;
}

.grid-cell-compact.mastery-1.table-10 .cell-dot {
    background: #2196F3;
}

.grid-cell-compact.mastery-2 .cell-dot {
    width: 14px;
    height: 14px;
    opacity: 0.85;
}

.grid-cell-compact.mastery-2.table-2 .cell-dot {
    background: #4CAF50;
    box-shadow: 0 0 3px rgba(76, 175, 80, 0.5);
}

.grid-cell-compact.mastery-2.table-3 .cell-dot {
    background: #FF9800;
    box-shadow: 0 0 3px rgba(255, 152, 0, 0.5);
}

.grid-cell-compact.mastery-2.table-5 .cell-dot {
    background: #9C27B0;
    box-shadow: 0 0 3px rgba(156, 39, 176, 0.5);
}

.grid-cell-compact.mastery-2.table-10 .cell-dot {
    background: #2196F3;
    box-shadow: 0 0 3px rgba(33, 150, 243, 0.5);
}

.grid-cell-compact.mastery-3 .cell-dot {
    width: 16px;
    height: 16px;
    opacity: 1;
}

.grid-cell-compact.mastery-3.table-2 .cell-dot {
    background: #4CAF50;
    box-shadow: 0 0 5px rgba(76, 175, 80, 0.7);
}

.grid-cell-compact.mastery-3.table-3 .cell-dot {
    background: #FF9800;
    box-shadow: 0 0 5px rgba(255, 152, 0, 0.7);
}

.grid-cell-compact.mastery-3.table-5 .cell-dot {
    background: #9C27B0;
    box-shadow: 0 0 5px rgba(156, 39, 176, 0.7);
}

.grid-cell-compact.mastery-3.table-10 .cell-dot {
    background: #2196F3;
    box-shadow: 0 0 5px rgba(33, 150, 243, 0.7);
}

.grid-cell-compact.mastery-4 .cell-dot {
    width: 18px;
    height: 18px;
    opacity: 1;
    animation: pulse 2s ease-in-out infinite;
}

.grid-cell-compact.mastery-4.table-2 .cell-dot {
    background: #4CAF50;
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.9);
}

.grid-cell-compact.mastery-4.table-3 .cell-dot {
    background: #FF9800;
    box-shadow: 0 0 8px rgba(255, 152, 0, 0.9);
}

.grid-cell-compact.mastery-4.table-5 .cell-dot {
    background: #9C27B0;
    box-shadow: 0 0 8px rgba(156, 39, 176, 0.9);
}

.grid-cell-compact.mastery-4.table-10 .cell-dot {
    background: #2196F3;
    box-shadow: 0 0 8px rgba(33, 150, 243, 0.9);
}

.grid-cell-compact:hover .cell-dot {
    transform: scale(1.2);
}

/* Mastery Legend */
.mastery-legend {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #dee2e6;
}

.legend-title {
    font-size: 0.8em;
    color: #666;
    margin-bottom: 5px;
    text-align: center;
}

.mastery-indicators {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 5px;
}

.mastery-indicator {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 0.7em;
    color: #666;
}

.dot-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #dee2e6;
    display: inline-block;
}

.dot-indicator.answered-once {
    background: #81C784;
    opacity: 0.6;
}

.dot-indicator.mastery-1 {
    background: #66BB6A;
    opacity: 0.7;
}

.dot-indicator.mastery-2 {
    background: #4CAF50;
    opacity: 0.85;
}

.dot-indicator.mastery-3 {
    background: #43A047;
}

.dot-indicator.mastery-4 {
    background: #388E3C;
    box-shadow: 0 0 4px rgba(56, 142, 60, 0.8);
}

/* Sparkle Animation */
@keyframes sparkle {
    0% {
        transform: scale(0) rotate(0deg);
        opacity: 1;
    }
    50% {
        transform: scale(1.5) rotate(180deg);
        opacity: 0.8;
    }
    100% {
        transform: scale(0) rotate(360deg);
        opacity: 0;
    }
}

.sparkle {
    position: absolute;
    width: 30px;
    height: 30px;
    pointer-events: none;
    z-index: 100;
}

.sparkle::before,
.sparkle::after {
    content: '✨';
    position: absolute;
    font-size: 20px;
    animation: sparkle 1s ease-out;
}

.sparkle::after {
    animation-delay: 0.2s;
    left: 10px;
    top: 10px;
}

/* Armor System Styles */
.armor-container {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.armor-piece {
    position: absolute;
    transition: all 0.5s ease;
}

/* Helmet */
.armor-piece.helmet {
    width: 60px;
    height: 60px;
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #silver 0%, #gray 50%, #silver 100%);
    border-radius: 20px 20px 15px 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    border: 3px solid #333;
}

.armor-piece.helmet::before {
    content: '';
    position: absolute;
    width: 50px;
    height: 25px;
    background: linear-gradient(90deg, #FFD700, #FFA500);
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 5px;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.2);
}

.armor-piece.helmet.level-high {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 50%, #FFD700 100%);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
}

/* Chestplate */
.armor-piece.chestplate {
    width: 70px;
    height: 70px;
    top: 40px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #8B7355 0%, #654321 50%, #8B7355 100%);
    border-radius: 15px;
    box-shadow: 0 3px 15px rgba(0, 0, 0, 0.4);
    border: 3px solid #333;
}

.armor-piece.chestplate::before {
    content: '⚔️';
    position: absolute;
    font-size: 30px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.armor-piece.chestplate.level-high {
    background: linear-gradient(135deg, #C0C0C0 0%, #808080 50%, #C0C0C0 100%);
    box-shadow: 0 0 25px rgba(192, 192, 192, 0.8);
}

/* Gauntlets */
.armor-piece.gauntlets::before,
.armor-piece.gauntlets::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 45px;
    background: linear-gradient(135deg, #4B0082 0%, #8A2BE2 50%, #4B0082 100%);
    border-radius: 10px;
    border: 2px solid #333;
    top: 45px;
}

.armor-piece.gauntlets::before {
    left: 5px;
    transform: rotate(-20deg);
}

.armor-piece.gauntlets::after {
    right: 5px;
    transform: rotate(20deg);
}

.armor-piece.gauntlets.level-high::before,
.armor-piece.gauntlets.level-high::after {
    background: linear-gradient(135deg, #FFD700 0%, #FF6347 50%, #FFD700 100%);
    box-shadow: 0 0 15px rgba(255, 99, 71, 0.6);
}

/* Boots */
.armor-piece.boots::before,
.armor-piece.boots::after {
    content: '';
    position: absolute;
    width: 25px;
    height: 25px;
    background: linear-gradient(135deg, #1E90FF 0%, #4169E1 50%, #1E90FF 100%);
    border-radius: 8px 8px 12px 12px;
    border: 2px solid #333;
    bottom: -5px;
}

.armor-piece.boots::before {
    left: 20px;
}

.armor-piece.boots::after {
    right: 20px;
}

.armor-piece.boots.level-high::before,
.armor-piece.boots.level-high::after {
    background: linear-gradient(135deg, #FF1493 0%, #FF69B4 50%, #FF1493 100%);
    box-shadow: 0 0 20px rgba(255, 20, 147, 0.7);
}

/* Glow effect for high levels */
@keyframes armorGlow {
    0%, 100% {
        filter: brightness(1) drop-shadow(0 0 10px currentColor);
    }
    50% {
        filter: brightness(1.3) drop-shadow(0 0 20px currentColor);
    }
}

.armor-piece.glowing {
    animation: armorGlow 2s ease-in-out infinite;
}

/* Level indicator enhancements */
.level {
    font-size: 1.4em;
    font-weight: bold;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.level.high-level {
    animation: pulse 2s ease-in-out infinite;
}

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

/* Row/Column complete animation */
@keyframes lineComplete {
    0% {
        background: linear-gradient(90deg, transparent, gold, transparent);
        background-size: 200% 100%;
        background-position: -100% 0;
    }
    100% {
        background-position: 100% 0;
    }
}

.line-complete {
    animation: lineComplete 1s ease-out;
}

/* Hair Growth System */
.character-hair {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
    top: 0;
    left: 0;
}

/* Hair stages - starts with no hair (bald) */
.character-hair.hair-0 {
    /* Bald - no hair */
}

.character-hair.hair-1::before {
    content: '';
    position: absolute;
    width: 35px;
    height: 10px;
    background: #654321;
    top: 2px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 50% 50% 0 0;
    border: 1px solid #4a3018;
}

.character-hair.hair-2::before {
    content: '';
    position: absolute;
    width: 42px;
    height: 15px;
    background: #654321;
    top: -2px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 50% 50% 0 0;
    border: 1px solid #4a3018;
}

.character-hair.hair-3::before {
    content: '';
    position: absolute;
    width: 48px;
    height: 20px;
    background: #654321;
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 50% 50% 0 0;
    border: 1px solid #4a3018;
}

.character-hair.hair-4::before,
.character-hair.hair-4::after {
    content: '';
    position: absolute;
    background: #8B4513;
}

.character-hair.hair-4::before {
    width: 50px;
    height: 20px;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 50% 50% 0 0;
}

.character-hair.hair-4::after {
    width: 10px;
    height: 15px;
    top: 5px;
    left: -3px;
    border-radius: 50%;
}

.character-hair.hair-5::before,
.character-hair.hair-5::after {
    content: '';
    position: absolute;
    background: #8B4513;
}

.character-hair.hair-5::before {
    width: 50px;
    height: 25px;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 50% 50% 0 0;
}

.character-hair.hair-5::after {
    width: 15px;
    height: 20px;
    top: 5px;
    left: -5px;
    border-radius: 50%;
}

/* Longer hair stages */
.character-hair.hair-6::before {
    content: '';
    position: absolute;
    width: 55px;
    height: 30px;
    background: linear-gradient(135deg, #8B4513, #A0522D);
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 50% 50% 0 0;
    box-shadow: 0 5px 10px rgba(139, 69, 19, 0.3);
}

.character-hair.hair-7::before {
    content: '';
    position: absolute;
    width: 60px;
    height: 35px;
    background: linear-gradient(135deg, #8B4513, #A0522D);
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 50% 50% 20% 20%;
    box-shadow: 0 8px 15px rgba(139, 69, 19, 0.4);
}

.character-hair.hair-8::before,
.character-hair.hair-8::after {
    content: '';
    position: absolute;
    background: linear-gradient(135deg, #8B4513, #A0522D);
}

.character-hair.hair-8::before {
    width: 130%;
    height: 40px;
    top: -22px;
    left: -15%;
    border-radius: 50% 50% 30% 30%;
    box-shadow: 0 10px 20px rgba(139, 69, 19, 0.4);
}

.character-hair.hair-8::after {
    width: 25px;
    height: 35px;
    top: 10px;
    left: -10px;
    border-radius: 0 0 50% 50%;
}

/* Epic long hair */
.character-hair.hair-9::before {
    content: '';
    position: absolute;
    width: 140%;
    height: 50px;
    background: linear-gradient(135deg, #8B4513, #D2691E, #A0522D);
    top: -25px;
    left: -20%;
    border-radius: 50% 50% 40% 40%;
    box-shadow: 0 12px 25px rgba(139, 69, 19, 0.5);
}

.character-hair.hair-10::before {
    content: '';
    position: absolute;
    width: 150%;
    height: 60px;
    background: linear-gradient(135deg, #FFD700, #FFA500, #FF8C00);
    top: -30px;
    left: -25%;
    border-radius: 50% 50% 45% 45%;
    box-shadow: 0 15px 30px rgba(255, 215, 0, 0.6);
    animation: epicHair 3s ease-in-out infinite;
}

@keyframes epicHair {
    0%, 100% {
        transform: translateY(0) scale(1);
    }
    50% {
        transform: translateY(-2px) scale(1.02);
    }
}

/* Enhanced hair effects and animations */
.character-hair.hair-growing {
    animation: hairGrowth 1s ease-out;
}

@keyframes hairGrowth {
    0% {
        transform: scale(0.95);
        filter: brightness(1.5);
    }
    50% {
        transform: scale(1.1);
        filter: brightness(1.3) hue-rotate(10deg);
    }
    100% {
        transform: scale(1);
        filter: brightness(1);
    }
}

/* Sparkle effect for high-level hair */
.character-hair.hair-sparkle::before {
    animation: sparkleEffect 2s ease-in-out infinite;
}

@keyframes sparkleEffect {
    0%, 100% {
        filter: brightness(1) drop-shadow(0 0 5px rgba(255, 215, 0, 0.5));
    }
    25% {
        filter: brightness(1.2) drop-shadow(0 0 10px rgba(255, 215, 0, 0.8));
    }
    50% {
        filter: brightness(1.4) drop-shadow(0 0 15px rgba(255, 215, 0, 1));
    }
    75% {
        filter: brightness(1.2) drop-shadow(0 0 10px rgba(255, 215, 0, 0.8));
    }
}

/* Legendary hair - ultimate achievement */
.character-hair.hair-legendary::before {
    animation: legendaryHair 3s ease-in-out infinite, rainbowShift 5s linear infinite;
    box-shadow: 
        0 0 20px rgba(255, 215, 0, 0.8),
        0 0 40px rgba(255, 105, 180, 0.6),
        0 0 60px rgba(138, 43, 226, 0.4);
}

@keyframes legendaryHair {
    0%, 100% {
        transform: translateX(-50%) translateY(0) scale(1);
    }
    25% {
        transform: translateX(-50%) translateY(-3px) scale(1.05);
    }
    50% {
        transform: translateX(-50%) translateY(-5px) scale(1.08);
    }
    75% {
        transform: translateX(-50%) translateY(-3px) scale(1.05);
    }
}

@keyframes rainbowShift {
    0% {
        filter: hue-rotate(0deg) brightness(1.2);
    }
    50% {
        filter: hue-rotate(180deg) brightness(1.4);
    }
    100% {
        filter: hue-rotate(360deg) brightness(1.2);
    }
}

/* Additional intermediate hair stages for smoother progression */
.character-hair.hair-6::before {
    width: 55px;
    height: 30px;
    background: linear-gradient(135deg, #8B4513, #A0522D, #8B4513);
}

.character-hair.hair-7::before {
    width: 60px;
    height: 35px;
    background: linear-gradient(135deg, #8B4513, #CD853F, #A0522D);
    box-shadow: 0 5px 10px rgba(139, 69, 19, 0.3);
}

.character-hair.hair-8::before {
    width: 65px;
    height: 40px;
    background: linear-gradient(135deg, #A0522D, #D2691E, #8B4513);
    box-shadow: 0 8px 15px rgba(139, 69, 19, 0.4);
}

.character-hair.hair-9::before {
    width: 70px;
    height: 45px;
    background: linear-gradient(135deg, #D2691E, #DEB887, #CD853F);
    box-shadow: 0 10px 20px rgba(222, 184, 135, 0.5);
}

.character-hair.hair-10::before {
    width: 75px;
    height: 50px;
    background: linear-gradient(135deg, #FFD700, #FFA500, #FF8C00, #FFD700);
    box-shadow: 
        0 12px 25px rgba(255, 215, 0, 0.6),
        inset 0 -5px 10px rgba(255, 140, 0, 0.3);
    animation: epicHair 3s ease-in-out infinite;
}

/* Hair Progress Indicator */
.hair-progress {
    margin-top: 15px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    text-align: center;
}

.hair-level-text {
    font-size: 0.9em;
    font-weight: bold;
    color: #5e60ce;
    margin-bottom: 8px;
}

.hair-progress-bar {
    width: 100%;
    height: 20px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.hair-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #8B4513, #D2691E, #FFD700);
    transition: width 0.5s ease-out;
    border-radius: 10px;
    position: relative;
    overflow: hidden;
}

.hair-progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* Mobile styles - Touch-friendly and responsive */

/* Custom viewport height for mobile (handles keyboard) */
:root {
    --vh: 1vh;
}

/* Pressed state for touch feedback */
.answer-btn.pressed,
.table-btn.pressed,
.power-up.pressed {
    transform: scale(0.95);
    opacity: 0.8;
}

/* Small mobile devices (phones) */
@media (max-width: 480px) {
    body {
        padding: 10px;
        min-height: calc(var(--vh, 1vh) * 100);
    }
    
    .game-container {
        padding: 15px;
        border-radius: 15px;
    }
    
    .header h1 {
        font-size: 1.5em;
        margin-bottom: 10px;
    }
    
    .stats {
        gap: 10px;
        flex-wrap: wrap;
        font-size: 0.9em;
    }
    
    .stats > div {
        padding: 8px 12px;
        min-width: 80px;
    }
    
    /* Make character smaller on mobile */
    .character-container {
        width: 80px;
        height: 80px;
    }
    
    .character {
        width: 60px;
        height: 60px;
    }
    
    .speech-bubble {
        font-size: 0.8em;
        padding: 8px;
        max-width: 150px;
    }
    
    /* Larger touch targets for answer buttons */
    .answer-btn {
        min-height: 60px;
        font-size: 1.3em;
        padding: 15px;
    }
    
    /* 2x2 grid maintained but larger */
    .answer-options {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        max-width: 100%;
    }
    
    .question {
        font-size: 2.2em;
        margin-bottom: 20px;
    }
    
    /* Power-ups in horizontal scroll if needed */
    .power-ups {
        display: flex;
        gap: 10px;
        overflow-x: auto;
        padding: 10px 0;
        -webkit-overflow-scrolling: touch;
    }
    
    .power-up {
        min-width: 80px;
        min-height: 50px;
        padding: 10px;
        font-size: 0.9em;
    }
    
    /* Table buttons with better touch targets */
    .table-btn {
        min-height: 50px;
        min-width: 60px;
        padding: 12px 20px;
        font-size: 1.1em;
    }
    
    /* Start button prominent */
    .start-btn {
        padding: 15px 30px;
        font-size: 1.2em;
        min-height: 50px;
    }
    
    /* Compact progress grid */
    .compact-progress-grid {
        font-size: 0.6em;
        max-width: 100px;
    }
    
    .grid-cell-compact {
        min-width: 16px;
        min-height: 16px;
    }
    
    .cell-dot {
        width: 5px;
        height: 5px;
    }
    
    /* Full screen modal on mobile */
    .times-table-popup {
        width: 95%;
        height: 90vh;
        max-height: none;
        padding: 15px;
    }
    
    .times-table-content {
        grid-template-columns: 1fr;
        font-size: 1.1em;
    }
    
    .close-btn {
        width: 44px;
        height: 44px;
        font-size: 1.5em;
    }
    
    /* Hide less important elements */
    .achievement-list {
        max-height: 60px;
        overflow-y: auto;
    }
}

/* Standard mobile (larger phones) */
@media (max-width: 768px) {
    body {
        padding: 15px;
    }
    
    .game-container {
        padding: 20px;
    }
    
    .game-area {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    /* Stack panels vertically on mobile */
    .left-panel {
        order: 2;
        max-width: 100%;
        margin: 0 auto;
    }
    
    .question-area {
        order: 1;
    }
    
    /* Maintain 2x2 grid but responsive */
    .answer-options {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        max-width: 350px;
        margin: 0 auto;
    }
    
    .answer-btn {
        min-height: 55px;
        font-size: 1.4em;
    }
    
    .header h1 {
        font-size: 1.8em;
    }
    
    .question {
        font-size: 2.5em;
    }
    
    /* Better modal for tablets */
    .times-table-popup {
        width: 90%;
        max-width: 500px;
    }
    
    .times-table-content {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Progress grid adjustments */
    .compact-progress-grid {
        font-size: 0.65em;
    }
    
    .grid-cell-compact {
        min-width: 18px;
        min-height: 18px;
    }
    
    .cell-dot {
        width: 6px;
        height: 6px;
    }
}

/* Landscape orientation for phones */
@media (max-width: 768px) and (orientation: landscape) {
    body {
        padding: 10px;
    }
    
    .game-container {
        padding: 15px;
    }
    
    .game-area {
        grid-template-columns: 200px 1fr;
        gap: 15px;
    }
    
    .left-panel {
        order: 1;
    }
    
    .question-area {
        order: 2;
    }
    
    .header h1 {
        font-size: 1.5em;
        margin-bottom: 10px;
    }
    
    .stats {
        gap: 15px;
    }
    
    .question {
        font-size: 2em;
        margin-bottom: 15px;
    }
    
    .answer-options {
        grid-template-columns: repeat(2, 1fr);
        max-width: 300px;
    }
    
    .answer-btn {
        min-height: 45px;
        padding: 12px;
    }
    
    /* Smaller character in landscape */
    .character-container {
        width: 70px;
        height: 70px;
    }
    
    .character {
        width: 50px;
        height: 50px;
    }
}

/* Touch-specific improvements */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects on touch devices */
    .answer-btn:hover,
    .table-btn:hover,
    .power-up:hover {
        transform: none;
        background: inherit;
        color: inherit;
    }
    
    /* Add active states for touch feedback */
    .answer-btn:active,
    .table-btn:active,
    .power-up:active,
    .start-btn:active {
        transform: scale(0.95);
        opacity: 0.9;
    }
    
    /* Ensure minimum touch target size (44x44px) */
    button, .btn, a {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Disable text selection on interactive elements */
    .answer-btn,
    .table-btn,
    .power-up,
    .start-btn {
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }
    
    /* Smooth scrolling for touch */
    * {
        -webkit-overflow-scrolling: touch;
    }
}

/* Prevent zoom on input focus (iOS) */
@media (max-width: 768px) {
    input, select, textarea {
        font-size: 16px !important;
    }
}

/* High resolution displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Sharper borders and shadows for retina displays */
    .answer-btn,
    .table-btn,
    .power-up {
        border-width: 2px;
    }
}