:root {
    /* M4TH5 Brand Color Palette */
    --primary-red: #dc2626;
    --primary-red-dark: #b91c1c;
    --primary-red-light: #ef4444;
    
    --success-green: #16a34a;
    --success-green-light: #22c55e;
    
    --danger-red: #dc2626;
    --danger-red-light: #ef4444;
    
    /* M4TH5 Neutral Colors */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #333333;
    
    /* M4TH5 Background and Text */
    --bg-primary: #ffffff;
    --bg-secondary: var(--gray-50);
    --bg-main: #f5f5ff;
    --bg-accent: #fef7f7;
    
    --text-primary: #333333;
    --text-secondary: var(--gray-600);
    --text-muted: var(--gray-500);
    
    /* Component Colors */
    --border-color: var(--gray-200);
    --border-hover: var(--gray-300);
    --card-shadow: rgba(0, 0, 0, 0.1);
    --card-shadow-hover: rgba(0, 0, 0, 0.15);
    
    /* Button Colors */
    --btn-primary-bg: var(--primary-red);
    --btn-primary-hover: var(--primary-red-dark);
    --btn-secondary-bg: var(--gray-500);
    --btn-secondary-hover: var(--gray-600);
    --btn-success-bg: var(--success-green);
    --btn-success-hover: var(--success-green-light);
    --btn-danger-bg: var(--danger-red);
    --btn-danger-hover: var(--danger-red-light);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    background: var(--bg-main);
    color: var(--text-primary);
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
}

.puzzle-area {
    background: var(--bg-primary);
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 8px 32px var(--card-shadow);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 700px;
    width: 100%;
    border: 1px solid var(--border-color);
}

.puzzle-area::before {
    content: "";
    position: absolute;
    top: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: var(--primary-red);
    border-radius: 2px;
}

h1 {
    font-size: 2.2em;
    font-weight: 700;
    text-align: center;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.hidden {
    display: none !important;
}

/* ===== SELECTION SCREEN STYLES ===== */
#selection-screen {
    width: 100%;
}

.subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-size: 1.1em;
}

/* Tab Navigation Container */
.tabs-navigation {
    display: flex;
    overflow-x: auto;
    white-space: nowrap;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 24px;
    gap: 8px;
    padding-bottom: 2px;
    /* Hide scrollbar for cleaner look but allow scroll */
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.tabs-navigation::-webkit-scrollbar {
    display: none;
}

/* With five tabs (My Cards, AS Pure, AS Applied, A Level Pure, A Level
   Applied) this row overflows on anything narrower than a desktop window,
   worst on phones — but the scrollbar above is deliberately hidden, so
   without these there is no visual hint that "A Level Applied" is just
   scrolled off, not missing. Sticky pseudo-elements fade the edges while
   staying pinned to the scrollport as you scroll. */
.tabs-navigation::before,
.tabs-navigation::after {
    content: '';
    position: sticky;
    top: 0;
    height: 100%;
    width: 24px;
    flex: 0 0 24px;
    pointer-events: none;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.tabs-navigation::before {
    left: 0;
    margin-right: -24px;
    background: linear-gradient(to right, var(--bg-primary), transparent);
}

.tabs-navigation::after {
    right: 0;
    margin-left: -24px;
    background: linear-gradient(to left, var(--bg-primary), transparent);
}

/* Only hint at the side(s) there's more to scroll to (see setupTabFade in
   script.js) — otherwise the fade sits over the first/last tab at rest. */
.tabs-navigation.fade-left::before,
.tabs-navigation.fade-right::after {
    opacity: 1;
}

/* Individual Tab Buttons */
/* .puzzle-area caps at 700px regardless of viewport width (see below), so
   this row is never wider than that even on a wide desktop window — the
   padding/font-size here have to fit five tabs into ~636px by default,
   not just under the narrow-viewport breakpoints. */
.tab-btn {
    background: none;
    border: none;
    padding: 8px 12px;
    font-size: 0.95em;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    border-radius: 6px 6px 0 0;
}

.tab-btn:hover {
    color: var(--primary-red);
    background-color: var(--gray-50);
}

.tab-btn.active {
    color: var(--primary-red);
    border-bottom-color: var(--primary-red);
    background-color: var(--bg-accent);
}

/* Tab Content Areas */
.tab-content-container {
    position: relative;
    min-height: 200px; /* Prevent jumpiness when switching */
}

.tab-pane {
    display: none;
    animation: fadeIn 0.4s ease-out;
}

.tab-pane.active {
    display: block;
}

/* Reuse existing controls, slightly adjusted */
.panel-controls {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.select-all-category-btn {
    font-size: 0.9em;
    font-weight: 600;
    color: var(--primary-red);
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.select-all-category-btn:hover {
    background-color: var(--bg-accent);
}

/* Reuse grid */
.subcategory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); /* Slightly smaller for density */
    gap: 12px;
}

/* Reuse buttons with same logic */
.subcategory-btn {
    padding: 16px;
    font-size: 0.95em;
    font-weight: 500;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    transition: all 0.3s ease;
    text-align: center;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    height: 100%; /* Ensure uniform height in grid */
    display: flex;
    align-items: center;
    justify-content: center;
}

.subcategory-btn:hover {
    background-color: var(--bg-accent);
    border-color: var(--primary-red);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.15);
}

/* transform on the button creates a containing block for the fixed-position
   .info-bubble, clipping it under overflow:hidden — drop it while a tip
   inside this button is open (see openInfoTip in script.js). */
.subcategory-btn.tip-open {
    transform: none;
}

.subcategory-btn.selected {
    background: var(--primary-red);
    color: white;
    border-color: var(--primary-red);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

/* Start Button Container */
.start-button-container {
    display: flex;
    justify-content: center;
    padding-top: 32px;
    margin-top: 20px;
    border-top: 1px solid var(--border-color);
    width: 100%;
}

/* Start and Restart Button Styles */
#start-button, #restart-button {
    padding: 16px 32px;
    font-size: 1.1em;
    font-weight: 600;
    color: white;
    background: var(--btn-primary-bg);
    border: none;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

#start-button::before, #restart-button::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}

#start-button:hover, #restart-button:hover {
    background: var(--btn-primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(185, 28, 28, 0.4);
}

#start-button:hover::before, #restart-button:hover::before {
    left: 100%;
}

#start-button:disabled {
    background: var(--gray-400);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

#start-button:disabled::before {
    display: none;
}
/* ===== FLASHCARD SCREEN STYLES ===== */
#flashcard-screen {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.progress-container {
    width: 100%;
    margin-bottom: 24px;
}

#progress-bar {
    display: flex;
    width: 100%;
    height: 12px;
    gap: 1px;
    margin-bottom: 12px;
    border-radius: 6px;
    overflow: hidden;
    background-color: var(--gray-100);
    padding: 2px;
    background-color: #e9ecef; /* A light gray background */
    overflow: hidden; /* Ensures the inner bar has rounded corners */


}



.progress-segment {
    flex: 1;
    background-color: var(--gray-200);
    border-radius: 4px;
    transition: all 0.4s ease;
    position: relative;
    overflow: hidden;
}

.progress-segment::after {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
    transition: left 0.6s ease;
}


.progress-segment.understood {
    background: var(--success-green);
}

.progress-segment.understood::after {
    left: 100%;
}

.progress-segment.not-yet {
    background: var(--danger-red);
}

.progress-segment.not-yet::after {
    left: 100%;
}

#progress-text {
    text-align: center;
    font-size: 1em;
    font-weight: 600;
    color: var(--text-secondary);
}

.flashcard-area {
    width: 100%;
    height: 380px;
    perspective: 1200px;
    margin-bottom: 24px;
}

.flashcard {
    width: 100%; height: 100%; position: relative;
    transform-style: preserve-3d; transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    /* CRITICAL FIX FOR SWIPING: Allows vertical scroll, but handles horizontal in JS */
    touch-action: pan-y; 
    user-select: none;
    -webkit-user-select: none;
}

.flashcard.swiping {
    transition: none;
}

.flashcard.is-flipped {
    transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border: 2px solid var(--border-color);
    border-radius: 16px;
    background: var(--bg-primary);
    box-shadow: 0 8px 32px var(--card-shadow);
    font-size: 1.2em;
    transition: all 0.3s ease;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-face::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary-red);
}

.card-back {
    transform: rotateY(180deg);
    background: var(--gray-100);
}

.card-content-wrapper {
    width: 90%;
    text-align: center;
    padding: 20px;
    line-height: 1.4;
    /* Ensure consistent positioning */
    position: relative;
}

/* Fix KaTeX math alignment */
.card-content-wrapper .katex {
    vertical-align: baseline !important;
}

.card-content-wrapper .katex-display {
    margin: 0.5em 0 !important;
}

/* For inline math expressions */
.card-content-wrapper .katex-html {
    vertical-align: baseline;
}

/* Ensure fractions align properly */
.katex .frac-line {
    vertical-align: middle;
}

.interaction-buttons {
    display: flex;
    gap: 24px;
    margin-bottom: 24px;
}

.interaction-buttons button {
    width: 80px;
    height: 80px;
    font-size: 2.2em;
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.interaction-buttons button::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transition: all 0.3s ease;
    transform: translate(-50%, -50%);
}

.interaction-buttons button:hover::before {
    width: 100%;
    height: 100%;
}

.interaction-buttons button:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.interaction-buttons button:active {
    transform: translateY(-2px) scale(0.98);
}

#cross-button {
    background: var(--btn-danger-bg);
}

#cross-button:hover {
    background: var(--btn-danger-hover);
}

#tick-button {
    background: var(--btn-success-bg);
}

#tick-button:hover {
    background: var(--success-green-light);
}

#end-session-button {
    background: var(--btn-secondary-bg);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

#end-session-button:hover {
    background: var(--btn-secondary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ===== COMPLETION SCREEN STYLES ===== */
#completion-screen {
    text-align: center;
    padding: 40px 20px;
}

#completion-screen h2 {
    color: var(--success-green);
    font-size: 2.5em;
    margin-bottom: 16px;
    font-weight: 700;
}

#completion-screen p {
    margin-bottom: 32px;
    font-size: 1.2em;
    color: var(--text-secondary);
}

#completion-screen p.completion-next-due {
    margin-top: -20px;
    font-size: 0.95em;
    color: var(--text-muted);
}

#completion-screen p.completion-next-due:empty {
    display: none;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .puzzle-area {
        padding: 20px;
        margin: 10px;
    }

    h1 {
        font-size: 1.8em;
    }

    .subcategory-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 10px;
    }
    
    .flashcard-area {
        height: 320px;
    }
    
    .card-face {
        font-size: 1.1em;
    }
    
    .interaction-buttons button {
        width: 70px;
        height: 70px;
        font-size: 2em;
    }
    
    #start-button, #restart-button {
        padding: 14px 28px;
        font-size: 1em;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    .puzzle-area {
        padding: 16px;
    }

    h1 {
        font-size: 1.6em;
    }

    .tab-btn {
        padding: 6px 10px;
        font-size: 0.85em;
    }

    .subcategory-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .accordion-header {
        padding: 16px;
    }
    
    .accordion-panel {
        padding: 0 16px;
    }
    
    .flashcard-area {
        height: 280px;
    }
    
    .interaction-buttons {
        gap: 16px;
    }
    
    .interaction-buttons button {
        width: 60px;
        height: 60px;
        font-size: 1.8em;
    }
}

/* ===== ANIMATIONS ===== */
@keyframes slideInFromTop {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.puzzle-area {
    animation: slideInFromTop 0.6s ease-out;
}

.flashcard {
    animation: fadeIn 0.4s ease-out;
}



/* ===== ROTATE WARNING STYLES ===== */
#rotate-warning-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

#rotate-warning-overlay:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

.rotate-warning-box {
    background: var(--bg-primary);
    padding: 32px;
    border-radius: 16px;
    text-align: center;
    max-width: 320px;
    color: var(--text-secondary);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

#rotate-warning-overlay:not(.hidden) .rotate-warning-box {
    transform: scale(1);
}

.rotate-warning-box svg {
    color: var(--primary-red);
    margin-bottom: 16px;
}

.rotate-warning-box h3 {
    color: var(--text-primary);
    font-size: 1.4em;
    margin-bottom: 8px;
}

.rotate-warning-box p {
    margin-bottom: 24px;
    line-height: 1.5;
}

#rotate-warning-continue-btn {
    padding: 12px 24px;
    font-size: 1em;
    font-weight: 600;
    color: white;
    background: var(--btn-primary-bg);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

#rotate-warning-continue-btn:hover {
    background: var(--btn-primary-hover);
    transform: translateY(-2px);
}

/* ===== ACCESSIBILITY IMPROVEMENTS ===== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus states for accessibility */
button:focus-visible {
    outline: 2px solid var(--primary-red);
    outline-offset: 2px;
}

.subcategory-btn:focus-visible {
    outline: 2px solid var(--primary-red);
    outline-offset: 2px;
}

.accordion-header:focus-visible {
    outline: 2px solid var(--primary-red);
    outline-offset: -2px;
}

.card-content-wrapper .katex {
    line-height: 1.2; /* Reset line-height to prevent global styles from interfering */
    font-size: 1.1em; /* Slightly increase font size for better clarity in fractions */
    vertical-align: middle; /* Improves alignment with surrounding text */
}

/* Fix KaTeX math alignment */
.card-content-wrapper .katex {
    vertical-align: baseline !important;
}

.card-content-wrapper .katex-display {
    margin: 0.5em 0 !important;
}

/* For inline math expressions */
.card-content-wrapper .katex-html {
    vertical-align: baseline;
}


/* Main container for the instruction card content */
.instruction-card-content {
  font-weight: 500;
  text-align: center;
  padding: 20px;
}

/* Style for the top line of text */
.main-instruction {
  font-size: 1.2em;
  margin-bottom: 25px;
  color: #333;
}

/* Container for the two swipe instruction lines */
.swipe-instructions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px; /* Creates space between the two instruction lines */
}

/* Styles for a single swipe instruction line (icon + text) */
.swipe-instruction {
  display: flex;
  align-items: center;
  justify-content: flex-start; /* Aligns items to the start */
  width: 90%; /* Adjust width as needed */
  max-width: 400px;
}

/* The circular container for the arrow icon */
.icon-container {
  width: 36px;
  height: 36px;
  border-radius: 50%; /* Makes it a circle */
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 15px; /* Space between icon and text */
  flex-shrink: 0; /* Prevents the circle from being squashed */
}

/* The arrow itself, created with a border */
.arrow {
  border-color: white; /* Arrow is now white */
  border-style: solid;
  border-width: 0 3px 3px 0; /* Creates the > shape */
  display: inline-block;
  padding: 4px;
}

/* --- Color and Direction Logic --- */

/* Right Swipe (Green) */
.swipe-right .icon-container {
  background-color: #28a745; /* Solid green background */
}
.swipe-right .arrow {
  transform: rotate(-45deg); /* Points the arrow to the right */
}

/* Left Swipe (Red) */
.swipe-left .icon-container {
  background-color: #dc3545; /* Solid red background */
}
.swipe-left .arrow {
  transform: rotate(135deg); /* Points the arrow to the left */
}
/* --- THIS IS THE FIX --- */
.katex .frac-line {
    position: relative !important;
    top: 0.2em; /* tweak this value until the bar sits where you want */
}
/* ===== MY CARDS, FAVOURITES, DECKS ===== */
/* Topic buttons carry a second line: card count, or "known / total" once
   the topic has been revised. */
.subcategory-btn {
    flex-direction: column;
    gap: 4px;
}

.topic-meta {
    font-size: 0.78em;
    font-weight: 400;
    color: var(--text-muted);
}

.subcategory-btn.selected .topic-meta {
    color: rgba(255, 255, 255, 0.85);
}

/* Share / delete controls on a saved deck's button. Spans, not buttons —
   a button inside a button is not valid HTML. */
.deck-tools {
    position: absolute;
    top: 4px;
    right: 4px;
    display: flex;
    gap: 2px;
    opacity: 0.55;
}

.subcategory-btn:hover .deck-tools,
.subcategory-btn:focus-within .deck-tools {
    opacity: 1;
}

.deck-tool {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
}

.deck-tool:hover {
    background: rgba(0, 0, 0, 0.08);
}

.deck-tool.delete-deck {
    font-size: 20px;
}

.mine-shared,
.mine-resume {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    margin-bottom: 16px;
    border-radius: 10px;
    background: var(--bg-accent);
    border: 1px solid #fecaca;
}

.mine-shared-actions {
    display: flex;
    gap: 8px;
}

.mini-btn {
    padding: 8px 16px;
    font-size: 0.9em;
    font-weight: 600;
    border-radius: 8px;
    border: 1px solid var(--border-hover);
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.mini-btn:hover {
    border-color: var(--primary-red);
}

.mini-btn.primary {
    background: var(--btn-primary-bg);
    border-color: var(--btn-primary-bg);
    color: white;
}

.mini-btn.primary:hover {
    background: var(--btn-primary-hover);
}

/* "What's this?" tooltip on Cards to work on / Favourites. Tap-to-toggle
   (via JS) rather than a native title, so it works on touch too. */
.info-tip {
    position: relative;
    display: inline-flex;
    vertical-align: middle;
    margin-left: 4px;
}

.info-tip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--border-color);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
}

.subcategory-btn.selected .info-tip-icon {
    background: rgba(255, 255, 255, 0.3);
    color: white;
}

/* position: fixed, not absolute — .subcategory-btn has overflow: hidden
   (for the deck-tools/card-corner treatment elsewhere), which clipped an
   absolutely-positioned bubble before it could escape the button. top/left
   are set from the icon's real screen position in JS on open. */
.info-bubble {
    display: none;
    position: fixed;
    z-index: 50;
    width: 240px;
    max-width: 60vw;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--text-primary);
    color: var(--bg-primary);
    font-size: 0.8em;
    font-weight: 400;
    line-height: 1.4;
    text-align: left;
    white-space: normal;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.info-tip.open .info-bubble {
    display: block;
}

.mine-empty,
.mine-account {
    margin-top: 16px;
    font-size: 0.92em;
    color: var(--text-muted);
    text-align: center;
}

.mine-account a {
    color: var(--primary-red);
}

/* Start row: the deck-save button sits beside Start, styled like End Session. */
.start-button-container {
    gap: 12px;
    flex-wrap: wrap;
}

#save-deck-button {
    background: var(--btn-secondary-bg);
    color: white;
    border: none;
    padding: 16px 24px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

#save-deck-button:hover {
    background: var(--btn-secondary-hover);
    transform: translateY(-2px);
}

#save-deck-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 16px;
}

#save-deck-form[hidden] {
    display: none;
}

#save-deck-form label {
    font-weight: 600;
    color: var(--text-secondary);
}

#save-deck-form input {
    flex: 1 1 200px;
    max-width: 320px;
    padding: 10px 14px;
    font: inherit;
    border: 2px solid var(--border-color);
    border-radius: 8px;
}

#save-deck-form input:focus {
    outline: none;
    border-color: var(--primary-red);
}

#save-deck-form button {
    padding: 10px 18px;
    font: inherit;
    font-weight: 600;
    border-radius: 8px;
    border: 1px solid var(--border-hover);
    background: var(--bg-primary);
    cursor: pointer;
}

#save-deck-form button[type="submit"] {
    background: var(--btn-primary-bg);
    border-color: var(--btn-primary-bg);
    color: white;
}

/* Favourite star, over the card's top-right corner. It sits outside
   .flashcard, so tapping it neither flips nor drags the card. */
.flashcard-area {
    position: relative;
}

#fav-button {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    padding: 6px;
    border-radius: 50%;
    border: none;
    background: none;
    color: var(--gray-400);
    cursor: pointer;
    transition: color 0.2s ease, transform 0.2s ease;
}

#fav-button:hover {
    color: #f59e0b;
    transform: scale(1.1);
}

#fav-button.on {
    color: #f59e0b;
}

#fav-button.on svg path {
    fill: currentColor;
}

/* Completion screen actions. */
.completion-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}

#retry-missed-button {
    padding: 16px 32px;
    font-size: 1.1em;
    font-weight: 600;
    color: white;
    background: var(--btn-secondary-bg);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

#retry-missed-button:hover {
    background: var(--btn-secondary-hover);
    transform: translateY(-2px);
}

#completion-nudge:empty {
    display: none;
}
