:root {
    --bg-color: #f4f7f6;
    --primary-color: #3a6073;
    --accent-color: #3a7bd5;
    --piece-color: #ffffff;
    --text-color: #2c3e50;
    --success-color: #10b981;
    --border-color: #e2e8f0;
    --light-bg: #f8fafc;
    --card-bg: #ffffff;
    --pool-bg: #e8eef4;
    --link-blue: #2563eb;
}

body.dark-mode {
    --bg-color: #0f172a;
    --primary-color: #93c5fd;
    --accent-color: #60a5fa;
    --piece-color: #1e293b;
    --text-color: #e2e8f0;
    --success-color: #34d399;
    --border-color: #334155;
    --light-bg: #1e293b;
    --card-bg: #1e293b;
    --pool-bg: #0f172a;
    --link-blue: #60a5fa;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    line-height: 1.45;
    transition: background-color 0.3s, color 0.3s;
}

.container {
    width: 100%;
    max-width: 600px;
    background: var(--card-bg);
    padding: 18px;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    transition: background-color 0.3s;
}

h1 {
    text-align: center;
    color: var(--primary-color);
    font-size: 22px;
    margin: 0 0 6px;
    font-weight: 700;
}

.subtitle {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 20px;
    text-align: center;
}
.sub-line1 { font-size: 16px; font-weight: 600; color: var(--primary-color); }
.sub-line2 { font-size: 15px; font-weight: 500; color: #718096; }
body.dark-mode .sub-line2 { color: #94a3b8; }

.hidden { display: none !important; }

.setup-zone, .game-zone {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.version-select-container {
    background: var(--light-bg);
    border: 1px solid var(--border-color);
    padding: 12px 14px;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

#versionSelect {
    padding: 9px 12px;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    font-size: 15px;
    color: var(--text-color);
    background: var(--card-bg);
    cursor: pointer;
    min-width: 160px;
    flex: 1;
}

.volume-container {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 14px;
    background: var(--light-bg);
}

.volume-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.verse-grid { display: flex; flex-direction: column; gap: 8px; }

.verse-item {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 13px 12px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    min-height: 52px;
}
.verse-item:hover { background: var(--light-bg); }
.verse-item.mastered { border-left: 5px solid var(--success-color); }

.status-badge {
    font-size: 12px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 20px;
    background: #e2e8f0;
    color: #64748b;
    white-space: nowrap;
}
body.dark-mode .status-badge { background: #334155; color: #94a3b8; }
.verse-item.mastered .status-badge { background: #d1fae5; color: #065f46; }
body.dark-mode .verse-item.mastered .status-badge { background: #064e3b; color: #6ee7b7; }

.reward-item {
    margin-top: 10px;
    padding: 14px;
    border-radius: 10px;
    text-align: center;
    font-weight: 700;
    font-size: 14px;
    user-select: none;
}
.reward-item.locked {
    background: var(--light-bg);
    border: 1px dashed var(--border-color);
    color: #94a3b8;
    cursor: not-allowed;
}
.reward-item.unlocked {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border: 2px solid #f59e0b;
    color: #b45309;
    cursor: pointer;
}
body.dark-mode .reward-item.unlocked {
    background: linear-gradient(135deg, #78350f, #92400e);
    color: #fde68a;
}
.reward-item.unlocked .devotional-blue { color: var(--link-blue); }

/* Options button – gray */
.btn-options {
    background: #e2e8f0 !important;
    color: var(--text-color) !important;
}
body.dark-mode .btn-options {
    background: #334155 !important;
    color: #e2e8f0 !important;
}

.btn-download {
    display: block;
    width: 100%;
    text-align: center;
    background: linear-gradient(135deg, #059669, #10b981);
    color: white !important;
    border: none;
    padding: 14px 16px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.text-link-btn {
    display: block;
    text-align: center;
    margin-top: 14px;
    color: var(--accent-color);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    width: 100%;
    font-family: inherit;
}
.text-link-btn:hover { text-decoration: underline; }

button {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
    border: none;
    padding: 14px 16px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    width: 100%;
    font-family: inherit;
}
button:active { transform: scale(0.98); }

.control-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.btn-hint { background: #e2e8f0 !important; color: var(--text-color) !important; }
body.dark-mode .btn-hint { background: #334155 !important; color: #e2e8f0 !important; }

.btn-back-main {
    background: linear-gradient(135deg, #2563eb, #3b82f6) !important;
    color: white !important;
}

/* Custom verse Back button – gray */
.btn-custom-back {
    background: #e2e8f0 !important;
    color: var(--text-color) !important;
    margin-top: 8px;
}
body.dark-mode .btn-custom-back {
    background: #334155 !important;
    color: #e2e8f0 !important;
}

.custom-bottom-back {
    margin-top: 4px;
}

.verse-header {
    text-align: center;
    font-weight: 700;
    color: var(--primary-color);
    font-size: 17px;
}

.pool-title, .drop-title {
    font-size: 13px;
    font-weight: 700;
    color: #718096;
    margin-bottom: 2px;
}
body.dark-mode .pool-title,
body.dark-mode .drop-title { color: #94a3b8; }

.hint-text { font-weight: 500; font-size: 12px; color: #94a3b8; }

.word-pool, .drop-zone {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
    min-height: 110px;
    border-radius: 12px;
    align-content: flex-start;
}
.drop-zone {
    border: 2px solid var(--border-color);
    background: var(--card-bg);
    gap: 6px 4px;
}
.word-pool {
    background: var(--pool-bg);
    border: 2px dashed #94a3b8;
}

.word-piece {
    background-color: var(--piece-color);
    border: 2px solid var(--border-color);
    padding: 11px 15px;
    border-radius: 12px;
    cursor: pointer;
    user-select: none;
    font-weight: 500;
    font-size: 16px;
    min-height: 44px;
    display: flex;
    align-items: center;
}
.drop-zone .word-piece {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 2px 3px !important;
    border-radius: 0 !important;
    min-height: auto !important;
    font-size: 17px;
}

.word-piece.insert-target {
    outline: 3px solid #0ea5e9;
    background: #e0f2fe !important;
}
body.dark-mode .word-piece.insert-target { background: #0c4a6e !important; }

.insert-controls {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 6px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
body.dark-mode .insert-controls { background: #0c4a6e; border-color: #0369a1; }

.insert-label { font-size: 13px; font-weight: 600; color: #0369a1; }
body.dark-mode .insert-label { color: #7dd3fc; }

.insert-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.move-row {
    display: grid;
    grid-template-columns: 48px 1fr 48px;
    gap: 8px;
    align-items: center;
}

.btn-insert {
    background: linear-gradient(135deg, #0ea5e9, #0284c7) !important;
    padding: 10px 8px !important;
    font-size: 14px !important;
}
.btn-cancel-insert {
    background: #e2e8f0 !important;
    color: #334155 !important;
    padding: 10px 12px !important;
    font-size: 14px !important;
}
body.dark-mode .btn-cancel-insert { background: #334155 !important; color: #e2e8f0 !important; }

.btn-move {
    background: #cbd5e1 !important;
    color: #1e293b !important;
    padding: 10px 0 !important;
    font-size: 18px !important;
    font-weight: 700 !important;
    min-width: 48px;
}
body.dark-mode .btn-move {
    background: #475569 !important;
    color: #e2e8f0 !important;
}

.success-message {
    text-align: center;
    padding: 18px;
    background: #d1fae5;
    color: #065f46;
    border-radius: 12px;
    font-weight: 700;
    font-size: 17px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
body.dark-mode .success-message { background: #064e3b; color: #6ee7b7; }

.success-nav { display: flex; flex-direction: column; gap: 10px; }
.success-second-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.btn-next {
    background: linear-gradient(135deg, var(--success-color), #059669) !important;
}
.btn-retry {
    background: #94a3b8 !important;
    color: white !important;
}
.btn-back-menu {
    background: linear-gradient(135deg, #2563eb, #3b82f6) !important;
    color: white !important;
}

.puzzle-status {
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: #64748b;
    margin-top: 8px;
    padding: 8px;
}
body.dark-mode .puzzle-status { color: #94a3b8; }
.puzzle-status.mastered { color: var(--success-color); }

/* Modals */
.modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.55);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
    z-index: 1000;
    padding: 16px;
}
.modal.open { opacity: 1; pointer-events: auto; }

.modal-content {
    background: var(--card-bg);
    padding: 24px 20px;
    border-radius: 16px;
    max-width: 520px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0,0,0,0.18);
    max-height: 88vh;
    overflow-y: auto;
    color: var(--text-color);
}

.modal-content h3 { margin-top: 0; color: var(--primary-color); font-size: 18px; }

.btn-close-modal {
    margin-top: 12px;
    background: #e2e8f0 !important;
    color: var(--text-color) !important;
}
body.dark-mode .btn-close-modal { background: #334155 !important; }

/* Options */
.options-content { text-align: left; }
.options-content h3 { text-align: center; }

.option-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.field-label {
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 4px;
    display: block;
}

textarea, input[type="text"] {
    width: 100%;
    padding: 13px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 16px;
    font-family: inherit;
    color: var(--text-color);
    background: var(--card-bg);
    margin-bottom: 12px;
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #cbd5e1;
    transition: .3s;
    border-radius: 28px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}
input:checked + .slider { background-color: var(--accent-color); }
input:checked + .slider:before { transform: translateX(24px); }

/* Music */
.music-controls {
    background: var(--light-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 0;
}
.music-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 10px 0;
    text-align: center;
    color: var(--primary-color);
}
.music-buttons { display: flex; flex-direction: column; gap: 8px; }
.music-second-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.btn-music {
    padding: 10px 6px !important;
    font-size: 13px !important;
    background: linear-gradient(135deg, #64748b, #475569) !important;
}
.btn-play { background: linear-gradient(135deg, #10b981, #059669) !important; }
.btn-pause { background: linear-gradient(135deg, #ef4444, #dc2626) !important; }

.select-song-btn {
    display: block;
    width: 100%;
    margin-top: 10px;
    background: none;
    border: none;
    color: var(--accent-color);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    padding: 6px;
}
.select-song-btn:hover { text-decoration: underline; }

.song-subtitle {
    font-size: 14px;
    font-weight: 400;
    color: #64748b;
    margin: -6px 0 14px;
    text-align: center;
}
body.dark-mode .song-subtitle { color: #94a3b8; }

.song-list { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.song-option {
    background: var(--light-bg) !important;
    color: var(--text-color) !important;
    border: 1px solid var(--border-color) !important;
    padding: 14px !important;
    font-size: 15px !important;
    text-align: center !important;
}

/* Options Sections */
.options-section {
    margin: 14px 0;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
}
.section-header {
    background: var(--light-bg);
    padding: 12px 14px;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    color: var(--primary-color);
}
.section-header.left-align {
    text-align: left;
}
.section-content {
    padding: 14px;
    font-size: 14px;
    line-height: 1.5;
}
.lang-desc { margin-bottom: 12px; color: #64748b; }
body.dark-mode .lang-desc { color: #94a3b8; }

.instruction-text {
    font-size: 13px;
    color: #64748b;
    margin: 8px 0 10px;
    font-style: italic;
    text-align: center;
}
body.dark-mode .instruction-text { color: #94a3b8; }

/* Expand / Collapse buttons – borderless, left-aligned, light gray */
.btn-expand-all {
    display: block;
    width: auto;
    margin: 0 0 14px 0;
    padding: 4px 0 !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    background: transparent !important;
    color: #94a3b8 !important;
    border: none !important;
    text-align: left !important;
    cursor: pointer;
}
body.dark-mode .btn-expand-all {
    color: #64748b !important;
}

.divider {
    height: 1px;
    background: var(--border-color);
    margin: 12px 0;
}

/* Hebrew / Greek headers */
.lang-header {
    padding: 10px 12px;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    border-radius: 8px;
    margin: 8px 0 10px;
    text-align: center;
}
.hebrew-header,
.greek-header {
    background: #dbeafe;
    color: #1e40af;
}
body.dark-mode .hebrew-header,
body.dark-mode .greek-header {
    background: #1e3a5f;
    color: #93c5fd;
}

.lang-subcontent {
    padding: 4px 0 8px;
}

/* Individual verse dropdowns */
.verse-dropdown {
    margin: 4px 0 8px;
}
.verse-title {
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    padding: 6px 0;
    color: #64748b;
}
body.dark-mode .verse-title {
    color: #94a3b8;
}
.verse-body {
    padding: 6px 0 14px;
    font-size: 13.5px;
    line-height: 1.55;
}
.verse-body.hidden {
    display: none;
}
.verse-body .orig {
    font-size: 15px;
    display: block;
    margin: 4px 0;
    direction: rtl;
}
.english-line {
    margin-top: 10px;
    font-size: 13px;
    color: var(--text-color);
}

/* Latest Updates */
.updates-date {
    text-align: left;
    font-weight: 400;
    color: var(--text-color);
    margin: 0;
}

/* Reset section */
.reset-desc {
    font-size: 13.5px;
    line-height: 1.5;
    margin-bottom: 12px;
    color: var(--text-color);
}
.btn-reset {
    background: linear-gradient(135deg, #ef4444, #dc2626) !important;
    margin-bottom: 8px;
}
.hint-toggle {
    font-weight: 600;
    font-size: 14px;
    color: var(--primary-color);
    cursor: pointer;
    padding: 6px 0;
}
.hint-content {
    font-size: 13.5px;
    line-height: 1.55;
    padding: 8px 0 4px;
    color: var(--text-color);
}
.hint-content p { margin: 0 0 10px; }

/* Hint */
.hint-phrase {
    font-size: 18px;
    font-weight: 400;
    color: var(--primary-color);
    margin: 12px 0;
    font-style: italic;
}

.btn-see-full {
    background: linear-gradient(135deg, #10b981, #059669) !important;
    margin-bottom: 12px;
    font-size: 14px !important;
    padding: 10px !important;
}
.btn-see-full.hide-mode {
    background: linear-gradient(135deg, #3b82f6, #2563eb) !important;
}

.full-verse {
    font-size: 16px;
    line-height: 1.6;
    text-align: center;
    font-style: italic;
    background: var(--light-bg);
    padding: 14px;
    border-radius: 10px;
    margin-bottom: 12px;
}

/* Devotional */
.reward-content h2.devotional-title {
    color: var(--link-blue) !important;
    margin-bottom: 10px;
    font-size: 19px;
    text-align: center;
}

.reward-content .divider {
    height: 1px;
    background: var(--border-color);
    margin: 16px 0;
}

.devotional-heading {
    text-align: center;
    font-size: 18px;
    font-weight: 700;
    color: var(--primary-color);
    margin: 8px 0 16px;
}

.devotional-body p {
    text-align: left;
    font-size: 15.5px;
    line-height: 1.65;
    margin-bottom: 14px;
}

.verse-ref {
    color: var(--link-blue);
    font-weight: 600;
}

.reward-content .closing {
    font-weight: 600;
    color: var(--primary-color);
}

.devotional-verse-select {
    margin: 8px 0 16px;
    text-align: left;
}
.devotional-verse-select label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
}
#devotionalVerseSelect {
    width: 100%;
    padding: 11px 12px;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    font-size: 15px;
    background: var(--card-bg);
    color: var(--text-color);
    margin-bottom: 10px;
}
.devotional-verse-display {
    background: var(--light-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 14px;
    font-size: 15px;
    line-height: 1.55;
    margin-top: 8px;
    text-align: center;
    font-style: italic;
}
.devotional-verse-display strong {
    display: block;
    margin-bottom: 6px;
    font-style: normal;
}

/* Mobile */
@media (max-width: 480px) {
    body { padding: 10px; }
    .container { padding: 14px; }
    h1 { font-size: 20px; }
    .sub-line1 { font-size: 15px; }
    .sub-line2 { font-size: 14px; }
    .insert-buttons { grid-template-columns: 1fr 1fr; }
    .move-row { grid-template-columns: 44px 1fr 44px; }
}
