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

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            background: #FFD4A3;
            color: #2C2C2C;
            min-height: 100vh;
            overflow-x: hidden;
        }

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

        .header {
            text-align: center;
            padding: 40px 20px;
        }

        .nav {
            display: flex;
            justify-content: center;
            gap: 30px;
            margin-bottom: 30px;
            font-size: 14px;
            text-transform: uppercase;
            letter-spacing: 1px;
        }

        .nav-item {
            cursor: pointer;
            color: #666;
            transition: color 0.3s;
        }

        .nav-item.active {
            color: #FF8C00;
            font-weight: 600;
        }

        .title {
            font-size: 4rem;
            font-weight: 700;
            color: #2C2C2C;
            margin-bottom: 10px;
            line-height: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 20px;
        }

        .cat-logo {
            height: 120px;
            width: auto;
            object-fit: contain;
            filter: drop-shadow(0 4px 10px rgba(255, 140, 0, 0.3));
        }

        .subtitle {
            font-size: 1.1rem;
            color: #666;
            margin-bottom: 25px;
        }

        .credits {
            display: inline-block;
            background: linear-gradient(135deg, #FF8C00, #FFA500);
            color: white;
            padding: 12px 24px;
            border-radius: 30px;
            font-weight: 600;
            margin-bottom: 20px;
            box-shadow: 0 4px 15px rgba(255, 140, 0, 0.3);
        }

        .btn {
            background: linear-gradient(135deg, #FF8C00, #FFA500);
            color: white;
            border: none;
            border-radius: 30px;
            padding: 14px 35px;
            font-size: 1rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s;
            box-shadow: 0 4px 15px rgba(255, 140, 0, 0.3);
        }

        .btn:hover {
            background: linear-gradient(135deg, #E67E00, #FF9500);
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(255, 140, 0, 0.4);
        }

        .btn:disabled {
            background: #CCC;
            cursor: not-allowed;
        }

        .section {
            background: white;
            border: 2px solid #2C2C2C;
            border-radius: 20px;
            padding: 25px;
            margin-bottom: 20px;
        }

        .input-area {
            width: 100%;
            background: #FFF4E6;
            border: 2px solid #2C2C2C;
            border-radius: 12px;
            padding: 15px;
            font-size: 1rem;
            font-family: inherit;
            resize: vertical;
            min-height: 80px;
            margin-bottom: 15px;
        }

        .input-area:focus {
            outline: none;
            border-color: #FF8C00;
        }

        .controls {
            display: flex;
            gap: 10px;
            margin-bottom: 15px;
            flex-wrap: wrap;
        }

        .controls .btn {
            flex: 1 1 140px;
        }

        .tap-zone {
            background: #FFF;
            border: 2px solid #2C2C2C;
            border-radius: 20px;
            padding: 50px 30px;
            text-align: center;
            cursor: pointer;
            user-select: none;
            transition: all 0.2s;
            margin: 30px 0;
        }

        .tap-zone:active {
            transform: scale(0.98);
            background: #F5F1E8;
        }

        .tap-count {
            font-size: 4rem;
            font-weight: 900;
            color: #2C2C2C;
            margin-bottom: 10px;
        }

        .tap-text {
            font-size: 1rem;
            color: #666;
        }

        .progress {
            height: 8px;
            background: #E5E5E5;
            border-radius: 10px;
            overflow: hidden;
            margin-top: 20px;
        }

        .progress-bar {
            height: 100%;
            background: linear-gradient(90deg, #FF8C00, #FFA500);
            transition: width 0.3s;
        }

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

        .card {
            background: white;
            border: 2px solid #2C2C2C;
            border-radius: 16px;
            padding: 25px;
        }

        .card-title {
            font-size: 1.5rem;
            font-weight: 700;
            margin-bottom: 15px;
            border-bottom: 3px solid #2C2C2C;
            padding-bottom: 10px;
        }

        .checkbox-group {
            display: flex;
            align-items: center;
            gap: 10px;
            cursor: pointer;
            margin: 15px 0;
        }

        .repeat-container {
            position: relative;
        }

        .repeat-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            background: #FFF4E6;
            border: 2px solid #2C2C2C;
            border-radius: 12px;
            padding: 8px 12px;
            cursor: pointer;
            transition: all 0.3s;
            white-space: nowrap;
        }

        .repeat-header:hover {
            background: #FFC999;
            transform: translateY(-1px);
        }

        .repeat-menu {
            position: absolute;
            right: 0;
            top: calc(100% + 6px);
            z-index: 10;
            width: max-content;
            display: flex;
            flex-direction: column;
            gap: 8px;
            margin-top: 10px;
            padding: 10px;
            background: white;
            border: 2px solid #2C2C2C;
            border-radius: 12px;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
        }

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

        .repeat-option {
            background: white;
            border: 2px solid #2C2C2C;
            border-radius: 20px;
            padding: 8px 16px;
            font-size: 0.9rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s;
            color: #666;
            text-align: left;
        }

        .repeat-option:hover {
            background: #FFC999;
            transform: translateY(-1px);
        }

        .repeat-option.active {
            color: #FF8C00;
            border-color: #FF8C00;
            background: rgba(255, 140, 0, 0.12);
        }

        .checkbox {
            width: 24px;
            height: 24px;
            border: 2px solid #2C2C2C;
            border-radius: 4px;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.3s;
        }

        .checkbox.checked {
            background: linear-gradient(135deg, #FF8C00, #FFA500);
            border-color: #FF8C00;
        }

        .checkbox.checked::after {
            content: '✓';
            color: white;
            font-weight: bold;
        }

        .speed-btn {
            background: white;
            border: 2px solid #2C2C2C;
            border-radius: 20px;
            padding: 8px 16px;
            font-size: 0.9rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s;
        }

        .speed-btn:hover {
            background: #FFC999;
            transform: translateY(-1px);
        }

        .speed-btn.active {
            background: linear-gradient(135deg, #FF8C00, #FFA500);
            color: white;
            border-color: #FF8C00;
        }

        .speed-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            background: #FFF4E6;
            border: 2px solid #2C2C2C;
            border-radius: 12px;
            padding: 8px 12px;
            cursor: pointer;
            transition: all 0.3s;
            white-space: nowrap;
        }

        .speed-header:hover {
            background: #FFC999;
            transform: translateY(-1px);
        }

        .speed-menu {
            display: flex;
            gap: 8px;
            margin-top: 10px;
            padding: 10px;
            background: white;
            border: 2px solid #2C2C2C;
            border-radius: 12px;
            flex-wrap: wrap;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
        }

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

        .sidebar-btn {
            position: fixed;
            top: 20px;
            right: 20px;
            width: 50px;
            height: 50px;
            background: linear-gradient(135deg, #FF8C00, #FFA500);
            border: none;
            border-radius: 50%;
            color: white;
            font-size: 1.3rem;
            cursor: pointer;
            z-index: 1001;
            transition: transform 0.3s;
            box-shadow: 0 4px 15px rgba(255, 140, 0, 0.3);
        }

        .sidebar-btn:hover {
            transform: scale(1.1);
            box-shadow: 0 6px 20px rgba(255, 140, 0, 0.4);
        }

        .sidebar {
            position: fixed;
            top: 0;
            right: -400px;
            width: 400px;
            height: 100vh;
            background: white;
            border-left: 3px solid #2C2C2C;
            z-index: 1000;
            transition: right 0.3s;
            overflow-y: auto;
            padding: 80px 30px 30px;
        }

        .sidebar.open {
            right: 0;
        }

        .sidebar-section {
            margin-bottom: 35px;
        }

        .sidebar-section:last-of-type {
            margin-bottom: 0;
        }

        .sidebar-account {
            display: flex;
            flex-direction: column;
            gap: 12px;
            font-size: 0.95rem;
            color: #555;
        }

        .sidebar-text {
            line-height: 1.5;
        }

        .full-width {
            width: 100%;
        }

        .sidebar-user {
            display: flex;
            flex-direction: column;
            gap: 6px;
        }

        .sidebar-user-name {
            font-weight: 600;
        }

        .sidebar-user-email {
            font-size: 0.85rem;
            color: #777;
            word-break: break-word;
        }

        .sidebar-user-sync {
            font-size: 0.8rem;
            color: #2368B5;
        }

        .sidebar-credits {
            background: #FFF4E6;
            border: 2px solid #2C2C2C;
            border-radius: 12px;
            padding: 12px 16px;
            font-weight: 600;
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 15px;
        }

        .credit-actions {
            display: flex;
            flex-direction: column;
            gap: 10px;
        }

        .sidebar-label {
            font-size: 0.85rem;
            color: #777;
        }

        .sidebar-select {
            width: 100%;
            border: 2px solid #2C2C2C;
            border-radius: 12px;
            padding: 10px 12px;
            background: white;
            font-size: 0.95rem;
        }

        .sidebar-input {
            width: 100%;
            border: 2px solid #2C2C2C;
            border-radius: 12px;
            padding: 10px 12px;
            font-size: 0.95rem;
            background: #FFF;
        }

        .sidebar-note {
            font-size: 0.8rem;
            color: #555;
            margin-top: 4px;
        }

        .sidebar-empty {
            font-size: 0.9rem;
            color: #888;
            line-height: 1.5;
        }

        /* Game mode */
        .game-layout {
            display: flex;
            flex-wrap: wrap;
            gap: 20px;
        }

        .game-settings {
            flex: 1 1 320px;
        }

.game-board {
    flex: 1 1 320px;
    display: flex;
    align-items: stretch;
    justify-content: center;
}

.game-message-input {
    height: 42px;
    min-height: 42px;
    max-height: 42px;
    resize: none;
    overflow-y: auto;
}

@media (max-width: 768px) {
    .game-settings,
    .game-board {
        flex: 1 1 100%;
        max-width: 100%;
    }

    .game-canvas-wrapper {
        max-width: 100%;
    }

    #gameCanvas {
        width: 100%;
        height: auto;
       }
    }

@media (max-width: 768px) {
    .game-settings,
    .game-board {
        flex: 1 1 100%;
        max-width: 100%;
    }
}

@media (max-width: 600px) {
    .game-canvas-wrapper {
        max-width: 100%;
    }

    #gameCanvas {
        width: 100%;
        height: 70vh;
    }
}

        .game-controls {
            display: flex;
            gap: 10px;
            margin-top: 10px;
            flex-wrap: wrap;
        }

        .game-controls .btn.secondary {
            background: white;
            color: #2C2C2C;
            border: 2px solid #2C2C2C;
            box-shadow: none;
        }

        .game-controls .btn.secondary:hover {
            background: #FFE4CC;
            transform: translateY(-2px);
        }

        .game-tip {
            font-size: 0.85rem;
            color: #666;
            margin-top: 12px;
        }

        .game-status {
            display: flex;
            align-items: center;
            gap: 12px;
            margin-top: 15px;
            flex-wrap: wrap;
        }

        .game-status-text {
            font-size: 0.85rem;
            color: #444;
            flex: 1 1 160px;
        }

.game-canvas-wrapper {
    position: relative;
    width: 100%;
    max-width: 540px;
    margin: 0 auto;
    border: 2px solid #2C2C2C;
    border-radius: 20px;
    overflow: hidden;
    background: #2C2C2C;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

        #gameCanvas {
            display: block;
            width: 100%;
        }

        .game-message {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background: linear-gradient(135deg, #FF8C00, #FFA500);
            color: white;
            padding: 15px 25px;
            border-radius: 20px;
            text-align: center;
            display: none;
            z-index: 10;
            font-size: 1.1rem;
            font-weight: 600;
            box-shadow: 0 4px 15px rgba(255, 140, 0, 0.4);
        }

@media (max-width: 768px) {
    .game-settings,
    .game-board {
        flex: 1 1 100%;
    }

    .game-controls {
        justify-content: stretch;
    }

    .game-controls .btn,
    .game-controls .btn.secondary {
        flex: 1 1 auto;
    }
}

        .history-list {
            display: flex;
            flex-direction: column;
            gap: 12px;
            margin-top: 15px;
        }

        .history-item {
            border: 2px solid #2C2C2C;
            border-radius: 14px;
            padding: 15px;
            background: #FFF9F0;
        }

        .history-item-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 10px;
        }

        .history-item-title {
            font-weight: 600;
        }

        .history-item-type {
            font-size: 0.85rem;
            color: #8A5A23;
        }

        .history-meta {
            font-size: 0.85rem;
            color: #666;
            margin-bottom: 12px;
            line-height: 1.4;
        }

        .history-actions {
            display: flex;
            gap: 8px;
            flex-wrap: wrap;
        }

        .btn.secondary {
            background: #F5F1E8;
            color: #2C2C2C;
            box-shadow: none;
            border: 2px solid #2C2C2C;
        }

        .btn.secondary:hover {
            background: #FFE2BF;
            transform: none;
        }

        .btn.secondary.danger {
            border-color: #C74B4B;
            color: #C74B4B;
        }

        .btn.secondary.danger:hover {
            background: #FCE4E4;
            color: #A43A3A;
        }

        .overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.5);
            z-index: 999;
            opacity: 0;
            visibility: hidden;
            transition: all 0.3s;
        }

        .overlay.show {
            opacity: 1;
            visibility: visible;
        }

        .story-card {
            background: #F5F1E8;
            border: 2px solid #2C2C2C;
            border-radius: 12px;
            padding: 20px;
            margin-bottom: 15px;
        }

        .story-author {
            font-weight: 700;
            margin-bottom: 8px;
        }

        .story-content {
            color: #555;
            line-height: 1.5;
            margin-bottom: 10px;
        }

        .popup {
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%) scale(0);
            background: linear-gradient(135deg, #FF8C00, #FFA500);
            color: white;
            padding: 30px 50px;
            border-radius: 20px;
            font-size: 1.5rem;
            font-weight: 700;
            z-index: 2000;
            transition: transform 0.3s;
            box-shadow: 0 10px 30px rgba(255, 140, 0, 0.4);
        }

        .btn.recording {
            background: linear-gradient(135deg, #FF4444, #FF6666);
            animation: pulse 1.5s infinite;
        }

        .popup.show {
            transform: translate(-50%, -50%) scale(1);
        }

        .login-modal {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.7);
            z-index: 3000;
            display: flex;
            justify-content: center;
            align-items: center;
            backdrop-filter: blur(5px);
        }

        .login-modal.hidden {
            display: none;
        }

        .login-box {
            background: white;
            border: 3px solid #2C2C2C;
            border-radius: 20px;
            padding: 40px;
            max-width: 400px;
            width: 90%;
            text-align: center;
        }

        .login-title {
            font-size: 2rem;
            font-weight: 900;
            color: #2C2C2C;
            margin-bottom: 10px;
        }

        .login-subtitle {
            color: #666;
            margin-bottom: 25px;
            font-size: 0.95rem;
        }

        .login-input {
            width: 100%;
            background: #FFF4E6;
            border: 2px solid #2C2C2C;
            border-radius: 12px;
            padding: 15px;
            font-size: 1rem;
            font-family: inherit;
            margin-bottom: 15px;
        }

        .login-input:focus {
            outline: none;
            border-color: #FF8C00;
            box-shadow: 0 0 10px rgba(255, 140, 0, 0.2);
        }

        .login-btn {
            width: 100%;
            margin-bottom: 10px;
        }

        .skip-btn {
            background: white;
            border: 2px solid #2C2C2C;
            color: #2C2C2C;
            box-shadow: none;
        }

        .skip-btn:hover {
            background: #FFE4CC;
            box-shadow: none;
        }

        .user-info {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            font-size: 0.9rem;
            color: #666;
            margin-bottom: 8px;
        }

        .cloud-badge {
            background: #E8F5FF;
            color: #2368B5;
            font-size: 0.75rem;
            padding: 3px 8px;
            border-radius: 999px;
            border: 1px solid #2368B5;
            text-transform: uppercase;
            letter-spacing: 0.02em;
        }

        .logout-link {
            color: #FF8C00;
            text-decoration: underline;
            cursor: pointer;
            font-size: 0.85rem;
        }

        .hidden {
            display: none;
        }

        #timerMode {
            display: flex;
            flex-direction: column;
            gap: 25px;
        }

        #timerMode.hidden {
            display: none;
        }

        #timerMode .panel {
            background: white;
            border: 2px solid #2C2C2C;
            border-radius: 20px;
            padding: 20px;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
        }

        #timerPanel {
            padding: 15px 20px;
        }

        #planningPanel {
            padding-top: 25px;
            padding-bottom: 25px;
        }

        .panel-title {
            font-size: 1.3rem;
            font-weight: 600;
            margin-bottom: 15px;
            color: #2C2C2C;
            text-align: center;
        }

        .timer-container {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 15px;
        }

        .timer-display {
            font-size: 2.5rem;
            font-weight: 700;
            text-align: center;
            color: #FF8C00;
            min-width: 110px;
        }

        .timer-controls {
            display: flex;
            gap: 10px;
            flex-wrap: wrap;
            justify-content: center;
        }

        .timer-result {
            font-size: 1.1rem;
            font-weight: 600;
            text-align: center;
            margin: 15px 0 0;
            color: #2C2C2C;
        }

        .practice-actions {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
            margin-top: 20px;
        }

        .practice-actions .btn {
            flex: 1 1 150px;
        }

        .option-row {
            display: flex;
            align-items: center;
            margin-bottom: 20px;
            gap: 15px;
        }

        .option-label {
            flex: 1;
            font-size: 1.05rem;
            font-weight: 500;
        }

        .option-input {
            width: 110px;
            background: #FFF4E6;
            border: 2px solid #2C2C2C;
            border-radius: 12px;
            padding: 8px 12px;
            font-size: 1rem;
            text-align: center;
        }

        .option-input:focus {
            outline: none;
            border-color: #FF8C00;
        }

        .option-group {
            margin-top: 20px;
        }

        .radio-group {
            display: flex;
            justify-content: space-around;
            margin: 20px 0;
            gap: 10px;
        }

        .radio-label {
            display: flex;
            align-items: center;
            gap: 10px;
            cursor: pointer;
            font-weight: 500;
        }

        .radio-custom {
            width: 20px;
            height: 20px;
            border: 2px solid #2C2C2C;
            border-radius: 50%;
            position: relative;
        }

        .radio-custom::after {
            content: '';
            width: 10px;
            height: 10px;
            background: #FF8C00;
            border-radius: 50%;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            opacity: 0;
            transition: opacity 0.2s;
        }

        .radio-input {
            display: none;
        }

        .radio-input:checked + .radio-custom::after {
            opacity: 1;
        }

        .countdown {
            font-size: 2.5rem;
            font-weight: 700;
            text-align: center;
            margin: 20px 0;
            color: #FF8C00;
            display: none;
        }

        .timer-progress {
            width: 100%;
            height: 10px;
            background: #FFF4E6;
            border-radius: 6px;
            overflow: hidden;
            margin: 15px 0;
        }

        .timer-progress-fill {
            height: 100%;
            background: linear-gradient(90deg, #FF8C00, #FFA500);
            width: 0%;
            transition: width 1s linear;
        }

        #timeSection,
        #countSection {
            display: none;
        }


        @media (max-width: 768px) {
            .title {
                font-size: 3rem;
            }

            .cat-logo {
                height: 90px;
            }

            .sidebar {
                width: 100%;
                right: -100%;
            }

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

            .timer-container {
                flex-direction: column;
            }

            .timer-display {
                font-size: 2rem;
            }

            .option-row {
                flex-direction: column;
                align-items: flex-start;
                width: 100%;
            }

            .option-input {
                width: 100%;
            }
        }
@media (max-width: 768px) {
    .game-settings,
    .game-board {
        flex: 1 1 100%;
        max-width: 100%;
    }
}

@media (max-width: 600px) {
    .game-canvas-wrapper {
        max-width: 100%;
    }
    #gameCanvas {
        width: 100%;
        height: auto;
    }
}
@media (max-width: 600px) {
    .game-canvas-wrapper {
        max-width: 100%;
    }
    #gameCanvas {
        width: 100%;
        height: auto;
    }
}
