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

:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --accent-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --success-gradient: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    --dark-bg: #0f0c29;
    --card-bg: rgba(255, 255, 255, 0.05);
    --card-border: rgba(255, 255, 255, 0.1);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 30px 80px rgba(0, 0, 0, 0.4);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header Styles */
.header {
    text-align: center;
    padding: 40px 20px;
    animation: fadeInDown 0.8s ease-out;
}

.title {
    font-size: 3.5rem;
    font-weight: 800;
    margin-bottom: 10px;
}

.gradient-text {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    display: block;
    animation: shimmer 3s infinite;
}

.subtitle {
    display: block;
    font-size: 1.2rem;
    font-weight: 300;
    color: var(--text-secondary);
    margin-top: 10px;
}

/* Card Styles */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    animation: fadeInUp 0.8s ease-out;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

.card h2 {
    font-size: 1.8rem;
    margin-bottom: 20px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Trainer Selection */
.trainer-selection {
    animation-delay: 0.1s;
}

.trainer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.trainer-card {
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid var(--card-border);
    border-radius: 15px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.trainer-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--primary-gradient);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 0;
}

.trainer-card:hover {
    transform: translateY(-10px) scale(1.02);
    border-color: #667eea;
    box-shadow: 0 20px 40px rgba(102, 126, 234, 0.4);
}

.trainer-card:hover::before {
    opacity: 0.1;
}

.trainer-card.active {
    border-color: #43e97b;
    background: rgba(67, 233, 123, 0.1);
    box-shadow: 0 15px 35px rgba(67, 233, 123, 0.3);
}

.trainer-card.active::before {
    background: var(--success-gradient);
    opacity: 0.2;
}

.trainer-icon {
    font-size: 3rem;
    margin-bottom: 15px;
    position: relative;
    z-index: 1;
}

.trainer-card h3 {
    font-size: 1.4rem;
    margin-bottom: 10px;
    color: var(--text-primary);
    position: relative;
    z-index: 1;
}

.trainer-card p {
    color: var(--text-secondary);
    line-height: 1.5;
    font-size: 0.95rem;
    position: relative;
    z-index: 1;
}

/* Controls Section */
.controls-section {
    animation-delay: 0.3s;
}

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

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

.input-group label {
    font-weight: 600;
    color: var(--text-secondary);
}

.number-input {
    padding: 15px;
    font-size: 1.2rem;
    border: 2px solid var(--card-border);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.number-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.3);
}

.button-group {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

/* Button Styles */
.btn {
    padding: 15px 30px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    color: white;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

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

.btn-primary {
    background: var(--primary-gradient);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover {
    box-shadow: 0 15px 40px rgba(102, 126, 234, 0.6);
}

.btn-secondary {
    background: var(--secondary-gradient);
    box-shadow: 0 10px 30px rgba(240, 147, 251, 0.4);
}

.btn-secondary:hover {
    box-shadow: 0 15px 40px rgba(240, 147, 251, 0.6);
}

.btn-accent {
    background: var(--accent-gradient);
    box-shadow: 0 10px 30px rgba(79, 172, 254, 0.4);
}

.btn-accent:hover {
    box-shadow: 0 15px 40px rgba(79, 172, 254, 0.6);
}

.current-value {
    margin-top: 20px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.2rem;
}

.value-display {
    font-size: 2rem;
    font-weight: bold;
    background: var(--success-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Abacus Styles */
.abacus-section {
    animation-delay: 0.5s;
}

.abacus-card {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
}

.abacus-container {
    display: flex;
    justify-content: center;
    padding: 40px 20px;
}

.abacus {
    display: flex;
    gap: 15px;
    background: rgba(0, 0, 0, 0.3);
    padding: 30px;
    border-radius: 15px;
    box-shadow: inset 0 5px 20px rgba(0, 0, 0, 0.5);
}

.column {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.column-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 5px;
    font-weight: 600;
}

.rod {
    width: 6px;
    height: 300px;
    background: linear-gradient(180deg, #4a5568, #2d3748);
    border-radius: 3px;
    position: relative;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.divider {
    position: absolute;
    width: 30px;
    height: 3px;
    background: var(--primary-gradient);
    left: 50%;
    transform: translateX(-50%);
    top: 80px;
    border-radius: 2px;
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.5);
}

.bead {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: var(--secondary-gradient);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 10;
}

.bead:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 25px rgba(240, 147, 251, 0.6);
}

.bead:active {
    transform: scale(0.95);
}

.bead.active {
    background: var(--success-gradient);
    box-shadow: 0 5px 25px rgba(67, 233, 123, 0.6);
}

.top-beads, .bottom-beads {
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.top-beads {
    top: 10px;
}

.bottom-beads {
    bottom: 10px;
}

.hint-text {
    text-align: center;
    margin-top: 20px;
    color: var(--text-secondary);
}

.hint-text p {
    margin: 5px 0;
}

/* Tutorial Section */
.tutorial-section {
    animation-delay: 0.7s;
}

.tutorial-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.tutorial-item {
    background: rgba(0, 0, 0, 0.2);
    padding: 25px;
    border-radius: 15px;
    border: 1px solid var(--card-border);
    transition: all 0.3s ease;
}

.tutorial-item:hover {
    background: rgba(0, 0, 0, 0.3);
    transform: translateY(-5px);
}

.step-number {
    width: 50px;
    height: 50px;
    background: var(--primary-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 15px;
}

.tutorial-item h3 {
    font-size: 1.3rem;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.tutorial-item p {
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Practice Section */
.practice-section {
    animation-delay: 0.9s;
}

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

.challenge {
    background: rgba(0, 0, 0, 0.3);
    padding: 40px;
    border-radius: 15px;
    margin-bottom: 20px;
}

.challenge h3 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: var(--text-secondary);
}

.challenge-number {
    font-size: 4rem;
    font-weight: bold;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 20px 0;
    animation: pulse 2s infinite;
}

.challenge button {
    margin: 10px;
}

.result-message {
    padding: 20px;
    border-radius: 10px;
    font-size: 1.2rem;
    font-weight: 600;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.result-message.success {
    background: rgba(67, 233, 123, 0.2);
    border: 2px solid #43e97b;
    color: #43e97b;
    animation: successPulse 0.5s ease;
}

.result-message.error {
    background: rgba(245, 87, 108, 0.2);
    border: 2px solid #f5576c;
    color: #f5576c;
    animation: shake 0.5s ease;
}

/* Flash Anzan Trainer Styles */
.flash-anzan-section {
    animation-delay: 0.3s;
}

.flash-settings {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setting-group label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.flash-select {
    padding: 12px 15px;
    font-size: 1rem;
    border: 2px solid var(--card-border);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.flash-select:hover {
    border-color: #667eea;
}

.flash-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.3);
}

.flash-display {
    min-height: 300px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin: 30px 0;
    position: relative;
    overflow: hidden;
}

.flash-display::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--primary-gradient);
    opacity: 0.05;
    z-index: 0;
}

.flash-number {
    font-size: 6rem;
    font-weight: bold;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 1;
}

.flash-progress {
    font-size: 1.2rem;
    color: var(--text-secondary);
    font-weight: 600;
    z-index: 1;
}

.flash-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 20px 0;
}

.flash-answer {
    background: rgba(0, 0, 0, 0.3);
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    margin: 20px 0;
}

.flash-answer h3 {
    color: var(--text-primary);
    margin-bottom: 20px;
    font-size: 1.4rem;
}

.flash-input {
    padding: 15px;
    font-size: 1.5rem;
    border: 2px solid var(--card-border);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-primary);
    text-align: center;
    width: 100%;
    max-width: 300px;
    margin: 0 auto 20px;
    display: block;
    transition: all 0.3s ease;
}

.flash-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 30px rgba(102, 126, 234, 0.4);
}

.flash-result {
    padding: 25px;
    border-radius: 15px;
    margin: 20px 0;
    font-size: 1.2rem;
    font-weight: 600;
    text-align: center;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.flash-result.success {
    background: rgba(67, 233, 123, 0.2);
    border: 2px solid #43e97b;
    color: #43e97b;
    animation: successPulse 0.5s ease;
}

.flash-result.error {
    background: rgba(245, 87, 108, 0.2);
    border: 2px solid #f5576c;
    color: #f5576c;
    animation: shake 0.5s ease;
}

.result-success, .result-error {
    line-height: 1.8;
}

.result-success small, .result-error small {
    display: block;
    margin-top: 8px;
    font-size: 0.9rem;
    opacity: 0.9;
}

.flash-stats {
    background: rgba(0, 0, 0, 0.3);
    padding: 25px;
    border-radius: 15px;
    margin-top: 30px;
}

.flash-stats h3 {
    color: var(--text-primary);
    margin-bottom: 20px;
    text-align: center;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
}

.stat-item {
    background: rgba(0, 0, 0, 0.3);
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    border: 1px solid var(--card-border);
    transition: all 0.3s ease;
}

.stat-item:hover {
    transform: translateY(-5px);
    border-color: #667eea;
}

.stat-label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 10px;
}

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: bold;
    background: var(--success-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Footer */
.footer {
    text-align: center;
    padding: 30px;
    color: var(--text-secondary);
    margin-top: 40px;
}

/* Animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes shimmer {
    0%, 100% {
        filter: brightness(1);
    }
    50% {
        filter: brightness(1.3);
    }
}

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

@keyframes successPulse {
    0% {
        transform: scale(0.9);
        opacity: 0;
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

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

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .title {
        font-size: 2.5rem;
    }

    .trainer-grid {
        grid-template-columns: 1fr;
    }

    .trainer-card {
        padding: 25px;
    }

    .trainer-icon {
        font-size: 2.5rem;
    }

    .abacus {
        gap: 10px;
        padding: 20px;
        overflow-x: auto;
    }

    .bead {
        width: 30px;
        height: 30px;
    }

    .rod {
        height: 250px;
    }

    .tutorial-grid {
        grid-template-columns: 1fr;
    }

    .button-group {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .challenge-number {
        font-size: 3rem;
    }

    .flash-number {
        font-size: 4rem;
    }

    .flash-settings {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 10px;
    }

    .card {
        padding: 20px;
    }

    .title {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1rem;
    }
}
