:root {
    --primary-color: #3d52d5;
    --background-color: #eef0f4;
    --text-color: #343434;
    --text-color-light: #a3a6b4;
    --danger-color: #d92525;
    --shadow-light: #ffffff;
    --shadow-dark: #d0d2d6;
}

/* Base and Anti-Pull-to-Refresh */
html, body {
    overscroll-behavior-x: none;
}
html {
    box-sizing: border-box;
}
*, *:before, *:after {
    box-sizing: inherit;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    -webkit-font-smoothing: antialiased;
    margin: 0;
    padding: 0;
    position: fixed;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    transform: translateZ(0);
    text-rendering: optimizeLegibility;
    overflow: hidden;
    touch-action: none;
    -webkit-user-drag: none;
    -ms-content-zooming: none;
    word-wrap: break-word;
    overscroll-behavior-y: none;
    -webkit-text-size-adjust: none;
    text-size-adjust: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent; 
}

.app-container {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    contain: layout size style;
}

.page {
    width: 100%;
    height: 100%;
    padding: 2rem 1rem;
    position: absolute;
    visibility: hidden;
    will-change: transform, opacity;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Center specific pages */
#resultsListPage, #page2, #page3 {
    align-items: safe center;
}

/* Claymorphism Card Style */
.card {
    background: var(--background-color);
    border-radius: 30px;
    padding: clamp(1.5rem, 5vw, 2.5rem);
    box-shadow: 8px 8px 16px var(--shadow-dark), -8px -8px 16px var(--shadow-light);
    width: 100%;
    max-width: 800px;
    margin: 2rem 0;
}
/* Remove top margin on mobile for characteristics page */
@media (max-width: 600px) {
    #page1 .card {
        margin-top: 0;
    }
}
h1, h2, h3 { font-weight: 600; text-align: center; }
h3 { text-align: left; margin: 1.5rem 0 1rem 0; border-bottom: 1px solid var(--shadow-dark); padding-bottom: 0.5rem; color: var(--text-color-light); }

/* Form & Button Elements */
input[type="text"], select {
    background: var(--background-color);
    color: var(--text-color);
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    margin-bottom: 1rem;
    font-size: 16px;
    box-shadow: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light);
}
input[type="text"]:focus, select:focus {
    outline: 2px solid var(--primary-color);
}
select option { background: #fff; color: #000; }

.button-group { display: flex; flex-wrap: wrap; gap: 0.75rem; justify-content: center; width: 100%; }
.navigation-group { margin-top: 2rem; }

button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 14px 20px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light);
}
@media (hover: hover) and (pointer: fine) {
    button:hover { 
        transform: translateY(-2px); 
        filter: brightness(1.1); 
    }
}
button:active {
    box-shadow: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light);
    transform: translateY(0);
    filter: brightness(1);
}
button.secondary-btn { background-color: var(--background-color); color: var(--text-color); }
button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: inset 2px 2px 4px var(--shadow-dark), inset -2px -2px 4px var(--shadow-light);
    transform: none;
    filter: none;
}

/* Templates, Characteristics, Results */
.templates-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; }
.template-card {
    position: relative;
    background: var(--background-color);
    padding: 1rem;
    padding-top: 2rem;
    border-radius: 12px;
    text-align: left;
    transition: all 0.2s ease;
    box-shadow: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light);
}
.template-card .template-content { cursor: pointer; }
.template-card .template-content:hover { filter: brightness(0.95); }
.delete-template-btn {
    position: absolute;
    top: 5px; right: 5px;
    background: transparent; box-shadow: none;
    padding: 0.25rem;
    color: var(--text-color-light);
}
.delete-template-btn:hover { color: var(--danger-color); }

/* Wider text box fix */
.characteristic-card {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1rem;
    align-items: center;
    background: var(--background-color);
    padding: 1rem; border-radius: 12px; margin-bottom: 1rem;
    box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light);
}
.characteristic-card .controls {
    grid-column: 1 / 2;
}
.characteristic-card .actions {
    grid-column: 2 / 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}
.characteristic-card .weight-display {
    background: linear-gradient(145deg, #4d63f0, #3d52d5);
    color: white; font-size: 24px; font-weight: bold; border-radius: 10px;
    width: 60px; height: 60px; display: flex; justify-content: center; align-items: center;
    flex-shrink: 0; box-shadow: 3px 3px 6px #2a3794, -3px -3px 6px #506dff;
}
.characteristic-card .delete-char-btn {
    padding: 0.5rem; background: transparent; border: none; color: var(--text-color-dark); opacity: 0.4; box-shadow: none;
}
.characteristic-card .delete-char-btn:hover { opacity: 1; color: var(--danger-color); }

#finalScore { font-size: 72px; font-weight: 900; color: var(--primary-color); }
.saved-result-card {
    background: var(--background-color);
    padding: 1rem; border-radius: 12px;
    box-shadow: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light);
}

/* Other minor styles */
.template-card-title, .result-card-header h4 { font-weight: 600; margin: 0 0 5px 0; }
.template-card ul, .result-card-details ul { margin: 0; padding-left: 1.2rem; font-size: 13px; opacity: 0.7; }
.page2-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }
#questionnaireCard { display: flex; flex-direction: column; align-items: center; }
.range-container { width: 100%; margin: 2rem 0 1rem 0; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 1rem; }
input[type="range"] { width: 100%; }
.range-value { margin-top: 1rem; font-size: 24px; font-weight: bold; }
.result-card-header { display: flex; justify-content: space-between; align-items: flex-start; }
.result-card-score { font-size: 2rem; font-weight: 600; color: var(--primary-color); }
.result-card-date { font-size: 0.8rem; opacity: 0.6; margin-bottom: 1rem; }
#resultDetailsContainer { text-align: left; width: 100%; margin-top: 2rem; }
#resultDetailsContainer ul { list-style: none; padding: 0; }
#resultDetailsContainer li { background: var(--background-color); box-shadow: inset 2px 2px 4px var(--shadow-dark), inset -2px -2px 4px var(--shadow-light); padding: 0.75rem; border-radius: 8px; margin-bottom: 0.5rem; }
.empty-state-text { opacity: 0.7; font-size: 14px; text-align: center; grid-column: 1 / -1; padding: 2rem 0; }
#saveConfirmation { color: var(--primary-color); font-weight: 500; }
.delete-btn { background: transparent; color: var(--danger-color); padding: 5px; flex-grow: 0; box-shadow: none; border: 1px solid transparent; }
.delete-btn:hover { border-color: var(--danger-color); }
.hidden { display: none !important; }

.update-btn {
    position: fixed;
    bottom: 20px;
    left: 0;
    right: 0;
    width: fit-content;
    margin: 0 auto;
    z-index: 1000;
    padding: 12px 20px;
    background-color: #d53d77;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    border: none;
    border-radius: 50px;
    color: white;
    font-weight: 600;
    gap: 0.75rem;
}
