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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    overflow: hidden;
    background: linear-gradient(135deg, #4682b4 0%, #ffffff 100%);
    width: 100vw;
    height: 100vh;
    position: fixed;
}

#memoryCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    touch-action: none;
}

.form-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.form-container.visible {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: all !important;
}

.form-container.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.form-card {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 500px;
    position: relative;
    animation: slideUp 0.4s ease;
}

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

.form-card h1 {
    font-size: 28px;
    margin-bottom: 20px;
    color: #333;
    text-align: center;
}

#memoryForm {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#memoryInput {
    width: 100%;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 16px;
    font-family: inherit;
    resize: none;
    transition: border-color 0.3s ease;
    -webkit-appearance: none;
}

#memoryInput:focus {
    outline: none;
    border-color: #87ceeb;
}

.char-count {
    text-align: right;
    font-size: 12px;
    color: #999;
    margin-top: -10px;
}

button[type="submit"] {
    background: linear-gradient(135deg, #d4a574 0%, #c8956d 100%);
    color: white;
    border: none;
    padding: 15px;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    -webkit-appearance: none;
    -webkit-tap-highlight-color: transparent;
}

button[type="submit"]:active {
    transform: scale(0.95);
}

button[type="submit"]:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.toggle-form {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #f0f0f0;
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.toggle-form:active {
    background: #e0e0e0;
}

.add-memory-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f4d03f 0%, #e6c547 100%);
    color: #333;
    border: none;
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 999;
    transition: transform 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.add-memory-btn:active {
    transform: scale(0.9);
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .form-card {
        padding: 25px;
        width: 95%;
        max-height: 90vh;
        overflow-y: auto;
    }

    .form-card h1 {
        font-size: 24px;
    }

    #memoryInput {
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .add-memory-btn {
        bottom: 20px;
        right: 20px;
        width: 55px;
        height: 55px;
    }
}

/* Instruction text */
.instruction-text {
    position: fixed;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    color: #333;
    font-size: 18px;
    font-weight: 500;
    text-align: center;
    z-index: 1001;
    background: rgba(255, 255, 255, 0.8);
    padding: 12px 24px;
    border-radius: 25px;
    backdrop-filter: blur(10px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0.5s ease;
    text-shadow: none;
}

.instruction-text.visible {
    opacity: 1;
    visibility: visible;
}

/* Loading indicator */
.loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 18px;
    z-index: 2000;
    text-align: center;
}

.loading::after {
    content: '...';
    animation: dots 1.5s infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}
