:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --bg-gradient-start: #f3f4f6;
    --bg-gradient-end: #e5e7eb;
    --card-bg: #ffffff;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --shadow-soft: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-strong: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
    font-family: var(--font-family);
    background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

header {
    width: 100%;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-soft);
    position: sticky;
    top: 0;
    z-index: 10;
}

h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(to right, var(--primary-color), var(--primary-hover));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.btn {
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
    background: var(--primary-color);
    color: white;
}

.btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    transform: none;
    opacity: 0.5;
}

.btn.secondary {
    background: white;
    color: var(--text-main);
    border: 1px solid #e5e7eb;
}

.btn.secondary:hover {
    background: #f9fafb;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 600px;
    padding: 2rem;
    gap: 2rem;
}

.card-container {
    perspective: 1000px;
    width: 100%;
    max-width: 400px;
    height: 300px;
    cursor: pointer;
}

.card {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 1.5rem;
    box-shadow: var(--shadow-strong);
}

.card.flipped {
    transform: rotateY(180deg);
}

.card-front,
.card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--card-bg);
    border-radius: 1.5rem;
    padding: 2rem;
    text-align: center;
}

.card-back {
    transform: rotateY(180deg);
    background: #fff;
    /* Could differ if needed */
}

#word-front,
#word-back {
    font-size: var(--dynamic-font-size, 2.5rem);
    font-weight: 700;
    margin-bottom: 1rem;
    word-break: keep-all;
    overflow-wrap: break-word;
    white-space: normal;
    max-width: 100%;
    line-height: 1.2;
}

.hint {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: auto;
}

/* Comment Section Styles */
.comment-section {
    margin-top: 0.75rem;
    padding: 0.75rem 1rem;
    background: #f3f4f6;
    border-radius: 0.5rem;
    max-width: 100%;
}

#word-comment {
    font-size: 0.95rem;
    font-style: italic;
    color: var(--text-muted);
    line-height: 1.4;
}

.navigation {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    background: white;
    padding: 0.75rem 1.5rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-soft);
}

#progress {
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    font-weight: 500;
}

footer {
    padding: 1rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

#error-message {
    color: #ef4444;
}

@media (max-width: 480px) {

    #word-front,
    #word-back {
        font-size: 2rem;
    }

    .card-container {
        height: 250px;
    }
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(4px);
}

.modal {
    background: white;
    padding: 2rem;
    border-radius: 1rem;
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-strong);
}

.modal h2 {
    margin-bottom: 1rem;
    color: var(--text-main);
}

.modal p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.input-group input {
    padding: 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    font-size: 1rem;
    width: 100%;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.link {
    color: var(--primary-color);
    text-decoration: none;
}

.link:hover {
    text-decoration: underline;
}

/* Settings Button */
.settings-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    color: var(--text-muted);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-btn:hover {
    background-color: #f3f4f6;
    color: var(--text-main);
}

/* Setup Wizard Styles */
.setup-wizard {
    width: 100%;
    max-width: 500px;
    background: white;
    padding: 2rem;
    border-radius: 1.5rem;
    box-shadow: var(--shadow-strong);
    text-align: center;
}

.step h2 {
    margin-bottom: 1rem;
    color: var(--text-main);
}

.step p {
    color: var(--text-muted);
    margin-bottom: 2rem;
    line-height: 1.5;
}

.wizard-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    width: 100%;
}

.wizard-actions .btn {
    flex: 1;
}

.hint-text {
    margin-top: 1.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

#step-1-next {
    width: 100%;
}

/* Ensure #app-content takes full width when visible to center its children */
#app-content {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

#app-content.hidden {
    display: none;
}

/* Utility - Must be last to override others */
.hidden {
    display: none !important;
}