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

:root {
    --primary-green: #2D5D3B;
    --warm-brown: #8B4513;
    --slate-gray: #4A5568;
    --classic-blue: #2B6CB0;
    --deep-purple: #7C3AED;
    --vivid-red: #DC2626;
    --text-dark: #1a1a1a;
    --text-light: #f8f9fa;
    --border-light: #e2e8f0;
    --bg-light: #f7fafc;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Hiragino Sans', 'ヒラギノ角ゴ ProN W3', 'Yu Gothic', '游ゴシック', 'Meiryo', 'メイリオ', sans-serif;
    background: linear-gradient(135deg, var(--bg-light) 0%, #ffffff 100%);
    color: var(--text-dark);
    line-height: 1.6;
    min-height: 100vh;
}

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

header {
    margin-bottom: 40px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.title-section {
    text-align: center;
    flex: 1;
}

.language-switcher {
    display: flex;
    gap: 4px;
    background: white;
    border-radius: 8px;
    padding: 4px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
}

.lang-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #6b7280;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.lang-btn:hover {
    background: rgba(107, 114, 128, 0.1);
    color: #374151;
}

.lang-btn.active {
    background: #6b7280;
    color: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #374151, #6b7280);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
}

header p {
    color: #6b7280;
    font-size: 1.1rem;
}

main {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 40px;
    align-items: start;
}

.controls {
    background: white;
    padding: 30px;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-light);
}

.input-group {
    margin-bottom: 24px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-dark);
}

#text-input {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-light);
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.2s ease;
}

#text-input:focus,
#url-input:focus {
    outline: none;
    border-color: #6b7280;
    box-shadow: 0 0 0 3px rgba(107, 114, 128, 0.1);
}

.url-input-container {
    display: flex;
    gap: 8px;
}

#url-input {
    flex: 1;
    padding: 12px;
    border: 2px solid var(--border-light);
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    transition: border-color 0.2s ease;
}

.fetch-btn {
    padding: 12px 20px;
    background: #6b7280;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.fetch-btn:hover {
    background: #374151;
}

.fetch-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.url-status {
    margin-top: 8px;
    font-size: 14px;
    min-height: 20px;
}

.url-status.loading {
    color: #6b7280;
}

.url-status.success {
    color: #16a34a;
}

.url-status.error {
    color: #dc2626;
}

.color-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.color-options {
    display: flex;
    align-items: center;
    gap: 12px;
}

.preset-colors {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    max-width: 240px;
}

.color-preset {
    width: 32px;
    height: 32px;
    border: 2px solid white;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow);
}

.color-preset:hover,
.color-preset.active {
    transform: scale(1.1);
    box-shadow: 0 0 0 3px rgba(107, 114, 128, 0.3);
}

.color-picker-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

#bg-color-picker,
#text-color-picker {
    width: 70px;
    height: 50px;
    border: 3px solid #e2e8f0;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: all 0.2s ease;
}

#bg-color-picker:hover,
#text-color-picker:hover {
    border-color: #6b7280;
    transform: scale(1.05);
}

.color-picker-label {
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s ease;
}

.color-picker-label:hover {
    color: #374151;
}

.text-color-section {
    display: flex;
    align-items: center;
    gap: 16px;
}

.text-color-presets {
    display: flex;
    gap: 8px;
}

.text-color-preset {
    width: 32px;
    height: 32px;
    border: 2px solid white;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow);
}

.text-color-preset:hover,
.text-color-preset.active {
    transform: scale(1.1);
    box-shadow: 0 0 0 3px rgba(107, 114, 128, 0.3);
}

.decoration-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.decoration-btn {
    padding: 12px 16px;
    border: 2px solid var(--border-light);
    background: white;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
    color: var(--text-dark);
}

.decoration-btn:hover {
    border-color: rgb(43, 108, 176);
    background: rgba(43, 108, 176, 0.05);
}

.decoration-btn.active {
    background: rgb(43, 108, 176);
    color: white;
    border-color: rgb(43, 108, 176);
}

.generate-btn {
    width: 100%;
    padding: 16px;
    background: rgb(43, 108, 176);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-lg);
}

.generate-btn:hover {
    background: rgba(43, 108, 176, 0.9);
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.generate-btn:active {
    transform: translateY(0);
}

.preview {
    background: white;
    padding: 30px;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-light);
    text-align: center;
}

#canvas {
    max-width: 100%;
    height: auto;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.download-btn {
    padding: 12px 24px;
    background: var(--vivid-red);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow);
}

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

@media (max-width: 768px) {
    .container {
        padding: 16px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    main {
        grid-template-columns: 1fr;
        gap: 24px;
    }
    
    .controls {
        padding: 20px;
    }
    
    .color-controls {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .color-options {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }
    
    .text-color-section {
        flex-direction: column;
        align-items: center;
        gap: 12px;
    }
    
    .decoration-options {
        grid-template-columns: 1fr;
    }
    
    .preset-colors {
        grid-template-columns: repeat(4, 1fr);
        justify-items: center;
        max-width: 200px;
        margin: 0 auto;
    }
    
    .url-input-container {
        flex-direction: column;
        gap: 12px;
    }
    
    .fetch-btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .header-content {
        flex-direction: column;
        text-align: center;
    }
    
    .title-section {
        order: 1;
    }
    
    .language-switcher {
        order: 2;
        align-self: center;
    }
    
    header h1 {
        font-size: 1.75rem;
    }
    
    .controls {
        padding: 16px;
    }
    
    .decoration-options {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .preset-colors {
        grid-template-columns: repeat(3, 1fr);
        max-width: 150px;
    }
    
    .color-preset {
        width: 28px;
        height: 28px;
    }
    
    #bg-color-picker,
    #text-color-picker {
        width: 60px;
        height: 45px;
    }
}

/* Footer Styles */
footer {
    margin-top: 60px;
    padding: 30px 0;
    border-top: 1px solid var(--border-light);
    background: linear-gradient(135deg, var(--bg-light) 0%, #ffffff 100%);
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.back-to-home {
    display: inline-flex;
    align-items: center;
    padding: 12px 20px;
    color: #6b7280;
    text-decoration: none;
    border: 2px solid var(--border-light);
    border-radius: 8px;
    background: white;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: var(--shadow);
}

.back-to-home:hover {
    color: #374151;
    border-color: #6b7280;
    background: rgba(107, 114, 128, 0.05);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.footer-info {
    color: #9ca3af;
    font-size: 14px;
    font-weight: 500;
}

@media (max-width: 768px) {
    footer {
        margin-top: 40px;
        padding: 20px 0;
    }
    
    .footer-content {
        flex-direction: column;
        text-align: center;
        gap: 16px;
    }
}

@media (max-width: 480px) {
    footer {
        margin-top: 30px;
        padding: 16px 0;
    }
    
    .back-to-home {
        padding: 10px 16px;
        font-size: 14px;
    }
}