:root {
    /* Define base palette */
    --bg-color: #0f0e1a;
    --card-bg: #1a1730;
    --text-main: #f0e6ff;
    --text-muted: #94a3b8;
    
    /* Default Accent Color */
    --accent-color: #7c3aed;
    --accent-gradient: linear-gradient(135deg, #7c3aed, #ec4899);

    /* Theme colors */
    --theme-t1: #ec4899;
    --theme-t2: #3b82f6;
    --theme-t3: #10b981;
    --theme-t4: #7c3aed;
    --theme-t5: #f59e0b;
    --theme-t6: #ef4444;
    --theme-t7: #84cc16;

    /* Semantic borders */
    --border-strength: #10b981;
    --border-weakness: #f59e0b;

    /* Sizing */
    --radius-md: 12px;
    --radius-lg: 16px;
    --btn-height: 48px;
}

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

body {
    font-family: 'Noto Sans JP', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
    /* Smooth background color transition */
    transition: background-color 0.3s ease;
}

/* Base Layout */
#app-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    min-height: 100vh;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

h1 {
    font-size: 24px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 5px;
}

.subtitle {
    font-size: 14px;
    color: var(--text-muted);
}

/* Helpers */
.hidden { display: none !important; }

/* Error Banner */
#error-banner {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid #ef4444;
    border-radius: var(--radius-md);
    padding: 15px;
    margin-bottom: 20px;
    text-align: center;
}
#retry-btn {
    margin-top: 10px;
    background: #ef4444;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
}

/* Loading Overlay */
#loading-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 14, 26, 0.9);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}
.spinner {
    width: 40px; height: 40px;
    border: 4px solid var(--card-bg);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}
@keyframes spin { 100% { transform: rotate(360deg); } }

/* Theory Intro */
.theory-intro {
    background: var(--card-bg);
    padding: 20px;
    border-radius: var(--radius-lg);
    margin-bottom: 30px;
}
.intro-lead { font-weight: 700; margin-bottom: 15px; text-align: center;}
details {
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
    padding: 10px;
}
summary {
    cursor: pointer;
    font-weight: bold;
}
.details-content { margin-top: 10px; font-size: 14px; color: var(--text-muted); }
.details-content ul { list-style: none; padding-left: 10px; }
.details-content li { margin-bottom: 5px; }

/* Theme Grid */
.theme-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 15px;
}
.theme-btn {
    background: var(--card-bg);
    color: var(--text-main);
    border: 2px solid transparent;
    padding: 15px;
    border-radius: var(--radius-lg);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
    min-height: var(--btn-height);
    display: flex;
    flex-direction: column;
}
.theme-btn:hover, .theme-btn:active {
    border-color: var(--accent-color);
    transform: translateY(-2px);
}
.theme-title { font-weight: 700; }
.theme-desc { font-size: 12px; color: var(--text-muted); margin-top: 5px; }

/* Quiz View */
.progress-bar-container {
    background: var(--card-bg);
    border-radius: 10px;
    height: 8px;
    margin-bottom: 10px;
    position: relative;
    overflow: hidden;
}
#progress-bar {
    height: 100%;
    background: var(--accent-gradient);
    width: 20%;
    transition: width 0.3s ease;
}
#progress-text {
    font-size: 12px;
    color: var(--text-muted);
    text-align: right;
    display: block;
    margin-bottom: 20px;
}
.axis-label {
    font-size: 14px;
    color: var(--accent-color);
    margin-bottom: 10px;
    font-weight: bold;
}
#question-text {
    font-size: 20px;
    margin-bottom: 25px;
    line-height: 1.4;
}
.options-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}
.option-btn {
    background: var(--card-bg);
    color: var(--text-main);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 15px 20px;
    border-radius: var(--radius-lg);
    font-size: 16px;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 56px;
}
.option-btn:hover, .option-btn:active {
    background: rgba(255,255,255,0.05);
    border-color: var(--accent-color);
}

/* Result View */
.result-header { text-align: center; margin-bottom: 30px; }
#result-type-name { font-size: 28px; margin-bottom: 10px; color: var(--accent-color); }
#result-catchcopy { font-size: 16px; font-weight: bold; }

.result-total-desc {
    background: var(--card-bg);
    padding: 20px;
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    position: relative;
}

.badges-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin: 10px 0 20px;
}
.badge {
    background: #2a2542;
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    border: 1px solid transparent;
    transition: border 0.2s;
}
.badge:hover { border-color: var(--accent-color); }
.badge-icon { font-size: 20px; display: block; margin-bottom: 5px; }
.badge-name { font-weight: bold; font-size: 14px; }
.badge-desc { font-size: 11px; color: var(--text-muted); margin-top: 4px; line-height: 1.2;}

.daily-example {
    background: rgba(255,255,255,0.05);
    padding: 15px;
    border-radius: var(--radius-md);
    margin-bottom: 25px;
    font-size: 14px;
}

/* Traits Cards */
.traits-container { display: flex; flex-direction: column; gap: 12px; margin-bottom: 25px; }
.trait-card {
    background: var(--card-bg);
    padding: 15px;
    border-radius: var(--radius-md);
    border-left: 4px solid;
}
.trait-card p { font-size: 14px; margin-top: 5px; }
.trait-icon { font-weight: bold; font-size: 14px; margin-top: 0 !important; color: white;}
.trait-card.strength { border-left-color: var(--border-strength); }
.trait-card.weakness { border-left-color: var(--border-weakness); }
.trait-card.advice { border-left-color: var(--accent-color); }

/* Genre Tabs */
.genre-tabs, .axis-tabs, .tone-tabs, .category-tabs {
    display: flex; gap: 8px; margin-bottom: 15px;
    overflow-x: auto;
    padding-bottom: 5px;
}
.genre-tabs::-webkit-scrollbar, .axis-tabs::-webkit-scrollbar, .category-tabs::-webkit-scrollbar { display: none; }
.genre-tab, .axis-tab, .tone-tab, .category-tab {
    background: var(--card-bg);
    color: var(--text-main);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
}
.genre-tab.active, .axis-tab.active, .tone-tab.active, .category-tab.active {
    background: var(--accent-color);
    border-color: var(--accent-color);
    font-weight: bold;
}
.genre-content {
    background: var(--card-bg);
    padding: 15px;
    border-radius: var(--radius-md);
    font-size: 14px;
    margin-bottom: 25px;
}

/* Compatibility */
.compatibility-container { margin-bottom: 30px; }
.compatibility-container ul { list-style: none; padding-left: 0; margin: 10px 0 20px; }
.compatibility-container li { margin-bottom: 8px; font-size: 14px; background: var(--card-bg); padding: 10px; border-radius: 8px;}
.hard-type-title { color: #f59e0b; margin-top: 15px;}

/* Buttons / Actions */
.action-btn {
    width: 100%;
    background: var(--accent-gradient);
    color: white;
    border: none;
    padding: 15px;
    border-radius: var(--radius-lg);
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 10px;
    min-height: var(--btn-height);
}
.action-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.secondary-btn {
    width: 100%;
    background: transparent;
    color: var(--text-main);
    border: 1px solid rgba(255,255,255,0.2);
    padding: 15px;
    border-radius: var(--radius-lg);
    font-size: 16px;
    cursor: pointer;
    min-height: var(--btn-height);
    margin-top: 10px;
}
.axis-guide-btn {
    width: 100%;
    background: rgba(255,255,255,0.05);
    color: var(--text-main);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 15px;
    border-radius: var(--radius-md);
    margin-bottom: 30px;
    cursor: pointer;
}

/* Tool Sections */
.tool-section {
    background: rgba(0,0,0,0.2);
    padding: 20px;
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    border: 1px solid rgba(255,255,255,0.05);
}
.tool-section h3 { font-size: 18px; margin-bottom: 15px; }

textarea, select {
    width: 100%;
    background: var(--card-bg);
    color: var(--text-main);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 12px;
    border-radius: 8px;
    font-size: 16px; /* 16px prevents iOS zoom */
    font-family: inherit;
    margin-bottom: 10px;
}
textarea { resize: vertical; min-height: 80px; }

.prompt-controls {
    display: flex; gap: 10px; margin-bottom: 10px;
}
.prompt-controls select { flex: 2; margin-bottom: 0;}
#img-lang-btn {
    flex: 1; min-width: 60px;
    background: var(--card-bg);
    border: 1px solid rgba(255,255,255,0.2);
    color: white; border-radius: 8px; cursor: pointer;
}

.result-box {
    margin-top: 15px;
    background: rgba(0,0,0,0.3);
    padding: 15px;
    border-radius: 8px;
    position: relative;
}
.result-box p { font-size: 14px; margin-bottom: 15px;}
.copy-btn {
    position: absolute;
    bottom: 10px; right: 10px;
    background: rgba(255,255,255,0.1);
    border: none; color: white;
    padding: 5px 10px; border-radius: 4px;
    font-size: 12px; cursor: pointer;
}

.bottom-actions { margin-top: 40px; display: flex; flex-direction: column; gap: 15px; }
.share-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.share-actions button, .share-actions a {
    text-align: center;
    background: var(--card-bg);
    color: white; border: 1px solid rgba(255,255,255,0.2);
    padding: 12px; border-radius: 8px; text-decoration: none;
    font-size: 14px; display: block;
}

/* Modals */
.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex; justify-content: center; align-items: center;
    z-index: 2000; padding: 20px;
}
.modal-content {
    background: var(--card-bg);
    width: 100%; max-width: 400px;
    padding: 25px; border-radius: var(--radius-lg);
    position: relative; max-height: 80vh; overflow-y: auto;
}
.modal-large { max-width: 500px; }
.close-modal {
    position: absolute; top: 15px; right: 15px;
    font-size: 24px; cursor: pointer; opacity: 0.7;
}

.axis-cards-container { display: flex; flex-direction: column; gap: 10px; }
.axis-card {
    background: rgba(255,255,255,0.05); padding: 15px; border-radius: 8px; border-left: 3px solid transparent;
}
.axis-card h4 { margin-bottom: 5px; display: flex; align-items: center; justify-content: space-between;}
.axis-card.highlight { border-color: var(--accent-color); background: rgba(124, 58, 237, 0.1); }
.you-badge { font-size: 10px; background: var(--accent-color); padding: 2px 6px; border-radius: 10px; }

/* Animations */
.fade-in { animation: fadeIn 0.3s forwards; opacity: 0; }
.slide-in { animation: slideIn 0.5s forwards; opacity: 0; transform: translateY(10px); }
.fade-in-delay { animation: fadeIn 0.8s forwards; opacity: 0; }
@keyframes fadeIn { to { opacity: 1; } }
@keyframes slideIn { to { opacity: 1; transform: translateY(0); } }
