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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f8f9fa;
    color: #333;
    line-height: 1.6;
}

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

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.1em;
    opacity: 0.9;
}

.main-content {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 20px;
    margin-bottom: 20px;
    align-items: start;
}

.sidebar {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

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

.timer-display {
    font-size: 3em;
    font-weight: bold;
    color: #667eea;
    margin: 20px 0;
    font-variant-numeric: tabular-nums;
}

.record-button {
    background: #667eea;
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.2em;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    width: 100%;
}

.record-button:hover {
    background: #764ba2;
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
}

.record-button.active {
    background: #e53e3e;
}

.timer-option {
    margin-top: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.timer-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.timer-option label {
    cursor: pointer;
    font-size: 0.9em;
    color: #666;
}

.pen-selector {
    margin-bottom: 20px;
}

.tool-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

.tool-section h3 {
    margin-bottom: 15px;
    color: #555;
}

.tool-buttons {
    display: flex;
    gap: 10px;
    flex-direction: column;
}

.tool-button {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    border: 2px solid #e0e0e0;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1em;
    color: #333;
}

.tool-button:hover {
    border-color: #999;
    background: #f8f9fa;
    transform: translateY(-2px);
}

.tool-button.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.tool-icon {
    font-size: 1.3em;
}

.eraser-button:hover {
    border-color: #ffa07a;
    background: #fff5f0;
}

.eraser-button.active {
    background: #ffa07a;
    color: white;
    border-color: #ffa07a;
}

.clear-button:hover {
    border-color: #e53e3e;
    background: #ffebeb;
}

.clear-button:active {
    background: #e53e3e;
    color: white;
    border-color: #e53e3e;
}

.pen-selector h3 {
    margin-bottom: 15px;
    color: #555;
}

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

.pen-item {
    display: flex;
    align-items: center;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.pen-item:hover {
    background: #f8f9fa;
    transform: translateX(5px);
}

.pen-item.selected {
    border-color: #667eea;
    background: #f0f4ff;
}

.pen-color {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    margin-right: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.pen-name-input {
    flex: 1;
    padding: 5px 10px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    font-size: 0.9em;
    background: transparent;
    transition: all 0.2s ease;
}

.pen-name-input:focus {
    outline: none;
    border-color: #667eea;
    background: white;
}

.pen-item.selected .pen-name-input {
    font-weight: 600;
}

.add-pen-button {
    width: 100%;
    margin-top: 15px;
    padding: 10px;
    background: #f0f0f0;
    border: 2px dashed #ccc;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #666;
}

.add-pen-button:hover {
    background: #e8e8e8;
    border-color: #999;
    color: #333;
}

.pen-delete {
    margin-left: 5px;
    color: #999;
    cursor: pointer;
    font-size: 1.2em;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.pen-item:hover .pen-delete {
    opacity: 1;
}

.pen-delete:hover {
    color: #e53e3e;
}

.grid-area {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.grid-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.grid-info {
    display: flex;
    gap: 20px;
    font-size: 1.1em;
}

.grid-container {
    position: relative;
    width: 100%;
    height: 500px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    background: repeating-linear-gradient(
        0deg,
        #f8f9fa,
        #f8f9fa 24px,
        #e0e0e0 24px,
        #e0e0e0 25px
    ),
    repeating-linear-gradient(
        90deg,
        #f8f9fa,
        #f8f9fa 24px,
        #e0e0e0 24px,
        #e0e0e0 25px
    );
}

.grid-square {
    position: absolute;
    width: 25px;
    height: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0;
}

.grid-square.eraser-mode {
    cursor: crosshair;
}

.grid-square.filled {
    opacity: 1;
    animation: fillAnimation 0.5s ease-out;
}

.grid-square.next-to-fill {
    border: 2px solid #667eea;
    background: rgba(102, 126, 234, 0.1);
    animation: pulse 1.5s infinite;
    opacity: 1;
    cursor: pointer;
}

.grid-square.next-to-fill:hover {
    background: rgba(102, 126, 234, 0.2);
    transform: scale(1.1);
}

.grid-instruction {
    text-align: center;
    margin-top: 10px;
    color: #666;
    font-size: 0.9em;
}

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

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(102, 126, 234, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0);
    }
}

.stats-section {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

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

.stat-card {
    text-align: center;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.stat-value {
    font-size: 2em;
    font-weight: bold;
    color: #667eea;
}

.stat-label {
    color: #666;
    margin-top: 5px;
}

.sound-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #667eea;
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5em;
    transition: all 0.3s ease;
}

.sound-toggle:hover {
    transform: scale(1.1);
}

.sound-toggle.muted {
    background: #999;
}

@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .timer-display {
        font-size: 2.5em;
    }
    
    .grid-container {
        height: 400px;
    }
}