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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #0a0a0a;
    min-height: 100vh;
    min-height: -webkit-fill-available; /* iOS Safari fix */
    padding: 0;
    margin: 0;
    color: #333;
    /* Better scrolling on mobile */
    -webkit-overflow-scrolling: touch;
    overflow-x: hidden;
}

.container {
    width: 100%;
    min-height: 100vh;
    min-height: -webkit-fill-available; /* iOS Safari fix */
    margin: 0;
    /* Better scrolling */
    overflow-x: hidden;
}

.view {
    display: none;
    background: #0a0a0a;
    min-height: 100vh;
    padding: 60px 80px;
    box-shadow: none;
    border: none;
    position: relative;
}

.view.active {
    display: block;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

h1 {
    text-align: left;
    color: #ffffff;
    margin-bottom: 48px;
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: -1px;
}

h2 {
    color: #ffffff;
    margin-bottom: 32px;
    font-size: 1.75rem;
    font-weight: 600;
}

.main-header {
    margin-bottom: 64px;
    padding-bottom: 32px;
    border-bottom: 1px solid #2a2a2a;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.header-top h1 {
    margin-bottom: 0;
}

.version-info {
    position: absolute;
    bottom: 20px;
    right: 20px;
    font-size: 0.75rem;
    color: #666;
    font-family: monospace;
}

.gold-stamp {
    position: absolute;
    bottom: 20px;
    left: 20px;
    max-width: 150px;
    height: auto;
    z-index: 10;
}

h3 {
    color: #e0e0e0;
    margin-bottom: 16px;
    font-size: 1.2rem;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: #ffffff;
    color: #0a0a0a;
}

.btn-primary:hover {
    background: #e0e0e0;
}

.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: #2a2a2a;
    color: #ffffff;
    border: 1px solid #3a3a3a;
}

.btn-secondary:hover {
    background: #3a3a3a;
    border-color: #4a4a4a;
}

.btn-danger {
    background: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-success {
    background: #27ae60;
    color: white;
}

.btn-success:hover {
    background: #229954;
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn-warning {
    background: #f39c12;
    color: #0a0a0a;
}

.btn-warning:hover {
    background: #e67e22;
}

.button-group {
    display: flex;
    gap: 16px;
    justify-content: flex-start;
    margin-bottom: 64px;
}

/* Gamepad Focus Indicator */
.gamepad-focused {
    outline: 3px solid #00d4ff !important;
    outline-offset: 3px !important;
    box-shadow: 0 0 0 1px rgba(0, 212, 255, 0.3), 0 0 20px rgba(0, 212, 255, 0.5) !important;
    position: relative;
    animation: gamepadPulse 1.5s ease-in-out infinite;
}

@keyframes gamepadPulse {
    0%, 100% {
        outline-color: #00d4ff;
        box-shadow: 0 0 0 1px rgba(0, 212, 255, 0.3), 0 0 20px rgba(0, 212, 255, 0.5);
    }
    50% {
        outline-color: #00a8cc;
        box-shadow: 0 0 0 1px rgba(0, 212, 255, 0.5), 0 0 30px rgba(0, 212, 255, 0.7);
    }
}

/* Sets List */
#bundledSetsContainer {
    margin-bottom: 48px;
}

.sets-container {
    margin-top: 0;
}

.sets-list {
    display: grid;
    gap: 20px;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.set-item {
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 12px;
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: all 0.2s ease;
    cursor: pointer;
    min-height: 140px;
}

.set-item:hover {
    border-color: #3a3a3a;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    background: #1f1f1f;
}

.set-item.bundled-set {
    border-color: #4a4a4a;
    background: #1f1f1f;
}

.bundled-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    font-size: 0.7rem;
    color: #999;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.set-info {
    flex: 1;
}

.set-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 4px;
}

.set-meta {
    font-size: 0.9rem;
    color: #999;
}

.set-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-icon {
    padding: 8px 12px;
    font-size: 0.9rem;
}

.empty-message {
    text-align: center;
    color: #666;
    padding: 40px;
    font-style: italic;
}

/* Editor */
.editor-header, .setup-header, .results-header {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-bottom: 48px;
    padding-bottom: 24px;
    border-bottom: 1px solid #2a2a2a;
}

.editor-header h2, .setup-header h2, .results-header h2 {
    margin: 0;
    flex: 1;
    font-size: 2rem;
}

.form-group {
    margin-bottom: 32px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #e0e0e0;
}

.form-group input[type="text"],
.form-group input[type="number"],
.select-input {
    width: 100%;
    padding: 12px;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
    background: #252525;
    color: #ffffff;
}

.select-input option {
    background: #252525;
    color: #ffffff;
}

.form-group input:focus,
.select-input:focus {
    outline: none;
    border-color: #ffffff;
    background: #2a2a2a;
}

.hint {
    display: block;
    margin-top: 4px;
    font-size: 0.85rem;
    color: #999;
}

.rounds-section {
    margin-top: 32px;
    margin-bottom: 32px;
    padding: 20px;
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 12px;
}

.rounds-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.rounds-header h3 {
    margin: 0;
    color: #ffffff;
}

.rounds-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.round-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #252525;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    color: #ffffff;
    font-weight: 500;
}

.card-round-select-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px;
    background: #252525;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
}

.card-round-select-wrapper label {
    color: #e0e0e0;
    font-weight: 500;
    font-size: 0.9rem;
    margin: 0;
}

.card-round-select-wrapper select {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #3a3a3a;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    background: #1a1a1a;
    color: #ffffff;
    cursor: pointer;
}

.card-round-select-wrapper select:focus {
    outline: none;
    border-color: #ffffff;
    background: #2a2a2a;
}


.cards-editor {
    margin-top: 48px;
}

.cards-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.cards-header-actions {
    display: flex;
    gap: 16px;
    align-items: center;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: #e0e0e0;
    font-size: 0.9rem;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #ffffff;
}

.checkbox-label input[type="checkbox"]:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.checkbox-label:has(input[type="checkbox"]:disabled) {
    cursor: not-allowed;
    opacity: 0.8;
}

.cards-list {
    display: grid;
    gap: 20px;
    max-height: calc(100vh - 400px);
    overflow-y: auto;
    padding-right: 12px;
}

.card-item {
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 12px;
    padding: 24px;
}

.card-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.card-item-number {
    font-weight: 600;
    color: #ffffff;
}

.card-item-inputs {
    display: grid;
    gap: 16px;
}

.questions-section {
    display: grid;
    gap: 12px;
}

.questions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.questions-header label {
    font-size: 0.9rem;
    color: #e0e0e0;
    font-weight: 500;
}

.questions-list {
    display: grid;
    gap: 10px;
}

.question-item {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    padding: 8px;
    border: 1px solid #e1e5e9;
    border-radius: 4px;
    background: white;
    margin-bottom: 4px;
    transition: all 0.2s ease;
}

.question-item:hover {
    border-color: #007acc;
    box-shadow: 0 2px 4px rgba(0, 122, 204, 0.1);
}

.question-item.dragging {
    opacity: 0.5;
    transform: rotate(2deg);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.question-drag-handle {
    cursor: grab;
    color: #666;
    font-size: 12px;
    line-height: 1;
    padding: 4px 8px;
    user-select: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    background: #f5f5f5;
    border-radius: 4px;
    border: 1px solid #ddd;
    margin-right: 4px;
    touch-action: none;
}

.question-drag-handle:active {
    cursor: grabbing;
    background: #e0e0e0;
}

.question-item:not(.dragging) .question-drag-handle:hover {
    background: #ebebeb;
}

.question-input-wrapper {
    flex: 1;
}

.question-input-wrapper textarea {
    width: 100%;
}

.question-placeholder {
    border: 2px dashed #007acc;
    background: rgba(0, 122, 204, 0.05);
    opacity: 0.7;
}

.question-placeholder .placeholder-text {
    color: #007acc;
    font-style: italic;
    padding: 8px 0;
    text-align: center;
}

.question-placeholder .question-drag-handle {
    color: #007acc;
}


.hints-section {
    margin-top: 16px;
}

.hints-section label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: #e0e0e0;
    font-weight: 500;
}

.hints-section input.card-hint {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #3a3a3a;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    background: #252525;
    color: #ffffff;
    transition: border-color 0.2s;
}

.hints-section input.card-hint:focus {
    outline: none;
    border-color: #ffffff;
    background: #2a2a2a;
}

.hints-section input.card-hint::placeholder {
    color: #666;
}

input.card-do-not-accept,
.hints-section input.card-do-not-accept {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #3a3a3a;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    background: #252525;
    color: #ffffff;
    transition: border-color 0.2s;
    box-sizing: border-box;
    position: static !important;
    top: auto !important;
    right: auto !important;
    max-width: 100% !important;
    text-align: left !important;
    font-style: normal !important;
    z-index: auto !important;
}

input.card-do-not-accept:focus,
.hints-section input.card-do-not-accept:focus {
    outline: none;
    border-color: #ffffff;
    background: #2a2a2a;
}

input.card-do-not-accept::placeholder,
.hints-section input.card-do-not-accept::placeholder {
    color: #666;
}

.card-hints {
    position: absolute;
    top: 16px;
    right: 16px;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    font-style: italic;
    text-align: right;
    max-width: 60%;
    line-height: 1.4;
    z-index: 10;
}

/* Display element on flashcards (not input fields) */
.card-do-not-accept:not(input) {
    position: absolute;
    top: 16px;
    right: 16px;
    font-size: 0.75rem;
    color: rgba(255, 100, 100, 0.8);
    font-style: italic;
    text-align: right;
    max-width: 60%;
    line-height: 1.4;
    z-index: 10;
}

.image-input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.image-input-wrapper textarea.card-image-svg {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #3a3a3a;
    border-radius: 6px;
    font-size: 0.85rem;
    font-family: 'Courier New', monospace;
    background: #252525;
    color: #ffffff;
    resize: vertical;
    min-height: 80px;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.image-input-wrapper textarea.card-image-svg:focus {
    outline: none;
    border-color: #ffffff;
    background: #2a2a2a;
}

.image-input-wrapper input.card-image-file {
    font-size: 0.85rem;
}

.card-main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
    margin-top: 48px; /* Space for label and hint/doNotAccept at top */
    overflow: hidden;
    min-height: 0; /* Allow flex item to shrink below content size */
}

/* MC mode: use full height */
.flashcard.mc-mode .card-main-content {
    height: 100%;
}

.card-front.has-image .card-main-content,
.card-back.has-image .card-main-content {
    flex-direction: row;
    align-items: flex-start;
    gap: 24px;
    overflow: hidden;
}

.card-front.has-image .card-text-content,
.card-back.has-image .card-text-content {
    flex: 1;
    min-width: 0;
    max-width: 50%; /* Ensure text doesn't get too narrow */
    overflow: hidden;
}

.card-front.has-image .card-image,
.card-back.has-image .card-image {
    flex-shrink: 0;
    max-width: 50%; /* Ensure image doesn't take too much space */
}

.card-text-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Allow flex item to shrink */
    overflow: hidden;
}

/* MC mode: use full height */
.flashcard.mc-mode .card-text-content {
    height: 100%;
}

.card-text-content #questionText {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    word-wrap: break-word;
}

/* Ensure question is visible in MC mode */
.card-front .card-text-content {
    flex-shrink: 0; /* Don't shrink question text area */
    display: flex !important; /* Ensure it's always visible */
}

.card-front .card-text-content #questionText {
    margin-bottom: 16px; /* Space before MC options */
    overflow: hidden;
    display: block !important; /* Ensure question is always visible */
    visibility: visible !important;
    opacity: 1 !important;
}

/* Ensure MC options are fully visible and scrollable */
.card-front .mc-options-container {
    max-height: none; /* Allow all options to be visible via scrolling */
    overflow-y: visible; /* Options container itself doesn't scroll, parent does */
}

.card-image {
    flex-shrink: 0;
    display: none;
    justify-content: center;
    align-items: center;
    max-width: 300px;
    width: 300px;
    margin: 0;
}

.card-front.has-image .card-image,
.card-back.has-image .card-image {
    display: flex;
}

.card-image svg,
.card-image img {
    max-width: 100%;
    max-height: 300px;
    height: auto;
    display: block;
    width: auto;
}

.card-image-content {
    max-width: 100%;
    max-height: 300px;
    height: auto;
    width: auto;
}

.answer-syntax-hint {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.answer-syntax-hint small {
    font-size: 0.75rem;
    color: #999;
    font-style: italic;
}

.accepted-answers-list {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.accepted-forms-label {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 8px;
    font-style: italic;
}

.accepted-forms {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.accepted-form-item {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    border-left: 2px solid rgba(255, 255, 255, 0.3);
}

/* Multiple Choice Options */
.mc-options-container {
    width: 100%;
    margin-top: 24px;
    flex-shrink: 0; /* Prevent options from being compressed */
}

/* External MC options container (below the card) */
.mc-options-container-external {
    width: 100%;
    max-width: 700px;
    margin: 24px auto 0;
    padding: 0 32px;
}

.mc-options-study {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
    flex-shrink: 0; /* Prevent options from being compressed */
}

/* Handle odd number of options - make last one span full width if needed */
.mc-options-study .mc-option-btn:last-child:nth-child(odd) {
    grid-column: 1 / -1;
}

.mc-option-btn {
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: white;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    width: 100%;
    white-space: normal;
    word-wrap: break-word;
}

.mc-option-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
}

.mc-option-btn:active {
    transform: translateY(0);
}

.mc-result {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 16px;
    text-align: center;
}

.mc-result-correct {
    color: #4caf50;
}

.mc-result-incorrect {
    color: #f44336;
}

.mc-correct-answer {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.9);
    text-align: center;
    margin-top: 12px;
}

/* MC options in editor */
.mc-options-section {
    display: grid;
    gap: 12px;
}

.mc-options-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mc-options-header label {
    font-size: 0.9rem;
    color: #e0e0e0;
    font-weight: 500;
}

.mc-options-list {
    display: grid;
    gap: 10px;
}

.mc-option-item {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 10px;
    border: 1px solid #e1e5e9;
    border-radius: 4px;
    background: white;
}

.mc-correct-radio {
    width: 20px;
    height: 20px;
    cursor: pointer;
    flex-shrink: 0;
}

.mc-option-input {
    flex: 1;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.9rem;
}

.btn-tiny {
    padding: 6px 10px;
    font-size: 0.85rem;
    min-width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-item-inputs textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #3a3a3a;
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
    resize: vertical;
    min-height: 60px;
    transition: border-color 0.2s;
    background: #1a1a1a;
    color: #ffffff;
}

.card-item-inputs textarea:focus {
    outline: none;
    border-color: #ffffff;
    background: #252525;
}

.editor-actions {
    display: flex;
    gap: 16px;
    margin-top: 48px;
    justify-content: flex-start;
    padding-top: 32px;
    border-top: 1px solid #2a2a2a;
}

/* Study View */
.study-header {
    margin-bottom: 48px;
    padding-bottom: 24px;
    border-bottom: 1px solid #2a2a2a;
}

.progress-info {
    text-align: center;
}

#progressText {
    display: block;
    margin-bottom: 12px;
    font-weight: 600;
    color: #e0e0e0;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #2a2a2a;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #ffffff;
    transition: width 0.3s ease;
    width: 0%;
}

.card-container {
    perspective: 1000px;
    margin-bottom: 48px;
    min-height: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.flashcard {
    width: 100%;
    max-width: 700px;
    height: 450px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s;
    cursor: pointer;
    margin: 0 auto;
}

/* Disable card clicking in MC mode - cursor only, pointer events handled in JS */
.flashcard.mc-mode {
    cursor: default;
}

/* Re-enable pointer events for MC option buttons */
.mc-options-container-external .mc-option-btn {
    cursor: pointer;
}

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

.flashcard.slide-out {
    animation: slideOut 0.6s ease-out forwards;
}

.flashcard.slide-in {
    animation: slideIn 0.6s ease-out forwards;
}

@keyframes slideOut {
    from {
        transform: translateY(0) rotateY(0deg);
        opacity: 1;
    }
    to {
        transform: translateY(100vh) rotateY(0deg);
        opacity: 1;
    }
}

@keyframes slideIn {
    from {
        transform: translateY(-100vh) rotateY(0deg);
        opacity: 0;
    }
    to {
        transform: translateY(0) rotateY(0deg);
        opacity: 1;
    }
}

.card-front,
.card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 16px;
    padding: 32px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

/* All cards have no scrollbars - overflow is hidden on all card elements */

.card-front {
    background: #0a0a0a;
    color: white;
    border: 2px solid #ffffff;
}

.card-back {
    background: #1a1a1a;
    color: white;
    transform: rotateY(180deg);
    border: 2px solid #ffffff;
}

.card-label {
    position: absolute;
    top: 16px;
    left: 32px;
    font-size: 0.9rem;
    opacity: 0.9;
    margin-bottom: 0;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    z-index: 10;
}


.card-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    line-height: 1.6;
    text-align: center;
    word-wrap: break-word;
    overflow: hidden;
    min-height: 0; /* Allow flex item to shrink */
}

/* MC mode specific: left align content */
.flashcard.mc-mode .card-content {
    align-items: flex-start;
    justify-content: flex-start;
    text-align: left;
    padding: 16px;
    width: 100%;
}


.study-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.answer-buttons {
    display: flex;
    gap: 16px;
    width: 100%;
    max-width: 400px;
}

.answer-buttons .btn {
    flex: 1;
    padding: 16px;
    font-size: 1.1rem;
}

.hint-button {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    width: 100%;
    max-width: 400px;
}

.points-display {
    font-size: 0.9rem;
    color: #e0e0e0;
    font-weight: 600;
}

/* Results View */
.results-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 24px;
    margin-bottom: 48px;
    max-width: 900px;
}

.stat-card {
    background: #252525;
    color: white;
    padding: 24px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    border: 1px solid #3a3a3a;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.stat-label {
    font-size: 0.9rem;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.cards-results-container {
    margin-top: 48px;
    margin-bottom: 32px;
}

.cards-results-container h3 {
    color: #ffffff;
    margin-bottom: 24px;
    font-size: 1.5rem;
}

.cards-results-list {
    display: grid;
    gap: 16px;
    max-height: 600px;
    overflow-y: auto;
    padding-right: 12px;
}

.cards-results-list::-webkit-scrollbar {
    width: 8px;
}

.cards-results-list::-webkit-scrollbar-track {
    background: #1a1a1a;
    border-radius: 4px;
}

.cards-results-list::-webkit-scrollbar-thumb {
    background: #3a3a3a;
    border-radius: 4px;
}

.cards-results-list::-webkit-scrollbar-thumb:hover {
    background: #4a4a4a;
}

.card-result-item {
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 12px;
    padding: 20px;
    transition: all 0.2s ease;
}

.card-result-item:hover {
    border-color: #3a3a3a;
    background: #1f1f1f;
}

.card-result-item.correct {
    border-left: 4px solid #27ae60;
}

.card-result-item.wrong {
    border-left: 4px solid #e74c3c;
}

.card-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.card-result-number {
    font-weight: 600;
    color: #ffffff;
    font-size: 1rem;
}

.card-result-badge {
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card-result-badge.correct {
    background: rgba(39, 174, 96, 0.2);
    color: #27ae60;
    border: 1px solid rgba(39, 174, 96, 0.3);
}

.card-result-badge.wrong {
    background: rgba(231, 76, 60, 0.2);
    color: #e74c3c;
    border: 1px solid rgba(231, 76, 60, 0.3);
}

.card-result-content {
    display: grid;
    gap: 12px;
}

.card-result-question,
.card-result-answer {
    color: #e0e0e0;
    line-height: 1.6;
}

.card-result-question strong,
.card-result-answer strong {
    color: #ffffff;
    font-weight: 600;
    margin-right: 8px;
}

.results-actions {
    display: flex;
    gap: 16px;
    justify-content: flex-start;
    padding-top: 32px;
    border-top: 1px solid #2a2a2a;
}

.setup-content {
    max-width: 500px;
    margin: 0;
}

/* Scrollbar styling */
.cards-list::-webkit-scrollbar {
    width: 8px;
}

.cards-list::-webkit-scrollbar-track {
    background: #1a1a1a;
    border-radius: 4px;
}

.cards-list::-webkit-scrollbar-thumb {
    background: #3a3a3a;
    border-radius: 4px;
}

.cards-list::-webkit-scrollbar-thumb:hover {
    background: #4a4a4a;
}

/* Responsive */
@media (max-width: 1200px) {
    .view {
        padding: 40px 60px;
    }
}

/* Tablet and smaller desktop */
@media (max-width: 768px) {
    .view {
        padding: 32px 40px;
    }
    
    h1 {
        font-size: 2.5rem;
        margin-bottom: 32px;
    }
    
    .header-top {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .header-top h1 {
        margin-bottom: 0;
    }
    
    .button-group {
        flex-direction: column;
        gap: 12px;
    }
    
    .sets-list {
        grid-template-columns: 1fr;
    }
    
    .set-item {
        min-height: auto;
    }
    
    .flashcard {
        height: 350px;
    }
    
    .results-content {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile optimizations */
@media (max-width: 600px) {
    /* Safe area insets for devices with notches (iPhone X+) */
    @supports (padding: max(0px)) {
        .view {
            padding-left: max(16px, env(safe-area-inset-left));
            padding-right: max(16px, env(safe-area-inset-right));
            padding-top: max(20px, env(safe-area-inset-top));
            padding-bottom: max(80px, env(safe-area-inset-bottom));
        }
        
        .button-group {
            padding-left: max(0px, env(safe-area-inset-left));
            padding-right: max(0px, env(safe-area-inset-right));
        }
    }
    
    /* Prevent zoom on inputs (iOS Safari) */
    input[type="text"],
    input[type="number"],
    select,
    textarea {
        font-size: 16px !important;
    }
    
    .view {
        padding: 20px 16px;
        min-height: 100vh;
        padding-bottom: 80px; /* Extra space for mobile navigation */
        padding-bottom: calc(80px + env(safe-area-inset-bottom)); /* With safe area */
    }
    
    /* Typography */
    h1 {
        font-size: 1.75rem;
        margin-bottom: 24px;
        line-height: 1.2;
    }
    
    h2 {
        font-size: 1.5rem;
        margin-bottom: 24px;
    }
    
    .editor-header h2, 
    .setup-header h2, 
    .results-header h2,
    .study-header h2 {
        font-size: 1.25rem;
    }
    
    h3 {
        font-size: 1.1rem;
        margin-bottom: 12px;
    }
    
    /* Header adjustments */
    .main-header {
        margin-bottom: 32px;
        padding-bottom: 24px;
    }
    
    .header-top {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        margin-bottom: 16px;
    }
    
    .header-top h1 {
        font-size: 1.75rem;
        margin-bottom: 0;
    }
    
    /* Buttons - Touch-friendly sizes (min 44x44px) */
    .btn {
        padding: 14px 24px;
        font-size: 1rem;
        min-height: 44px;
        min-width: 44px;
        touch-action: manipulation; /* Remove tap delay */
        -webkit-tap-highlight-color: rgba(255, 255, 255, 0.3);
    }
    
    .btn-primary {
        font-weight: 600;
    }
    
    .btn-small {
        padding: 10px 16px;
        font-size: 0.9rem;
        min-height: 40px;
    }
    
    .btn-tiny {
        padding: 8px 12px;
        font-size: 0.85rem;
        min-height: 36px;
        min-width: 36px;
    }
    
    .button-group {
        flex-direction: column;
        gap: 12px;
        margin-bottom: 32px;
    }
    
    /* Sets list */
    .sets-list {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .set-item {
        min-height: auto;
        padding: 16px;
    }
    
    .set-item .set-actions {
        flex-direction: column;
        gap: 8px;
        margin-top: 12px;
    }
    
    .set-item .set-actions .btn {
        width: 100%;
    }
    
    /* Form inputs - Touch-friendly */
    input[type="text"],
    input[type="number"],
    select,
    textarea {
        padding: 12px 16px;
        font-size: 16px;
        min-height: 44px;
        border-radius: 8px;
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
    }
    
    select {
        background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
        background-repeat: no-repeat;
        background-position: right 12px center;
        background-size: 20px;
        padding-right: 40px;
    }
    
    .form-group {
        margin-bottom: 20px;
    }
    
    .form-group label {
        display: block;
        margin-bottom: 8px;
        font-size: 0.95rem;
        font-weight: 500;
    }
    
    .checkbox-label {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px;
        cursor: pointer;
        min-height: 44px;
        touch-action: manipulation;
    }
    
    .checkbox-label input[type="checkbox"] {
        width: 20px;
        height: 20px;
        min-width: 20px;
        min-height: 20px;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    
    /* Editor */
    .editor-header,
    .setup-header {
        margin-bottom: 24px;
        padding-bottom: 16px;
        border-bottom: 1px solid #2a2a2a;
    }
    
    .editor-header .btn,
    .setup-header .btn {
        margin-bottom: 0;
    }
    
    .cards-editor {
        margin-bottom: 24px;
    }
    
    .cards-header {
        margin-bottom: 20px;
    }
    
    .card-item {
        padding: 16px;
        margin-bottom: 16px;
    }
    
    .card-item-header {
        margin-bottom: 16px;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .card-item-inputs {
        gap: 16px;
    }
    
    .questions-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .questions-header button {
        width: 100%;
    }
    
    .hints-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .hints-header button {
        width: 100%;
    }
    
    /* Flashcard - Optimized for mobile */
    .card-container {
        min-height: 300px;
        margin-bottom: 32px;
        padding: 0 8px;
    }
    
    .flashcard {
        width: 100%;
        max-width: 100%;
        height: auto;
        min-height: 280px;
        max-height: 60vh;
        cursor: pointer;
        touch-action: manipulation;
    }
    
    .card-front,
    .card-back {
        padding: 24px 20px;
    }
    
    .card-content {
        font-size: 1.1rem;
        line-height: 1.6;
        overflow: hidden;
    }
    
    .card-main-content {
        overflow: hidden;
    }
    
    .card-text-content {
        overflow: hidden;
    }
    
    .card-front.has-image .card-text-content,
    .card-back.has-image .card-text-content {
        max-width: 100%; /* Full width on mobile when image is present */
    }
    
    .card-label {
        position: absolute;
        top: 12px;
        left: 20px;
        font-size: 0.85rem;
        margin-bottom: 0;
    }
    
    .card-hints {
        font-size: 0.85rem;
        margin-bottom: 12px;
    }
    
    .card-do-not-accept {
        font-size: 0.85rem;
        margin-bottom: 12px;
    }
    
    .card-main-content {
        margin-top: 44px; /* Space for label and hint/doNotAccept at top on mobile */
    }
    
    .card-main-content {
        flex-direction: column !important;
        gap: 16px;
        margin-top: 44px; /* Space for label and hint/doNotAccept at top on mobile */
    }
    
    .card-image {
        width: 100%;
        max-width: 100%;
        margin: 0;
    }
    
    .card-image svg,
    .card-image img {
        max-height: 200px;
    }
    
    /* Study actions - Mobile optimized */
    .study-actions {
        gap: 16px;
        width: 100%;
        padding: 0 8px;
    }
    
    .answer-buttons {
        flex-direction: column;
        gap: 12px;
        width: 100%;
        max-width: 100%;
    }
    
    .answer-buttons .btn {
        flex: 1;
        width: 100%;
        padding: 16px 24px;
        font-size: 1.1rem;
        font-weight: 600;
        min-height: 56px; /* Large touch target */
    }
    
    #flipCardBtn {
        width: 100%;
        max-width: 100%;
        padding: 16px 24px;
        font-size: 1.1rem;
        min-height: 56px;
    }
    
    .hint-button {
        width: 100%;
        max-width: 100%;
    }
    
    .hint-button .btn {
        width: 100%;
        padding: 14px 24px;
        min-height: 48px;
    }
    
    /* Progress bar */
    .progress-info {
        margin-bottom: 24px;
    }
    
    .progress-bar {
        height: 8px;
        margin-top: 8px;
    }
    
    /* Results */
    .results-content {
        grid-template-columns: 1fr;
        gap: 16px;
        margin-bottom: 24px;
    }
    
    .stat-card {
        padding: 20px;
    }
    
    .stat-value {
        font-size: 2rem;
    }
    
    .cards-results-container {
        margin-bottom: 24px;
    }
    
    .card-result-item {
        padding: 16px;
        margin-bottom: 12px;
    }
    
    .card-result-header {
        margin-bottom: 12px;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    /* Version info - Hide on very small screens */
    .version-info {
        font-size: 0.65rem;
        bottom: 12px;
        right: 12px;
    }
    
    .gold-stamp {
        bottom: 12px;
        left: 12px;
        max-width: 100px;
    }
    
    /* Editor actions */
    .editor-actions {
        flex-direction: column;
        gap: 12px;
        position: sticky;
        bottom: 0;
        background: #0a0a0a;
        padding: 16px 0;
        margin-top: 24px;
        border-top: 1px solid #2a2a2a;
    }
    
    .editor-actions .btn {
        width: 100%;
    }
    
    .results-actions {
        flex-direction: column;
        gap: 12px;
        margin-top: 24px;
    }
    
    .results-actions .btn {
        width: 100%;
    }
    
    /* Hide gamepad focus indicator on mobile (not needed) */
    .gamepad-focused {
        outline: none !important;
        box-shadow: none !important;
        animation: none !important;
    }
    
    /* Better touch targets for set actions */
    .set-actions {
        gap: 8px;
    }
    
    .set-actions .btn {
        flex: 1;
        min-width: 0;
    }
    
    /* Answer syntax hint - smaller on mobile */
    .answer-syntax-hint {
        font-size: 0.8rem;
        padding: 12px;
    }
    
    .answer-syntax-hint small {
        display: block;
        margin-bottom: 4px;
        line-height: 1.4;
    }
    
    /* Accepted answers list - better mobile layout */
    .accepted-answers-list {
        margin-top: 16px;
    }
    
    .accepted-forms-label {
        font-size: 0.85rem;
        margin-bottom: 8px;
    }
    
    .accepted-forms {
        gap: 8px;
    }
    
    .accepted-form-item {
        font-size: 0.9rem;
        padding: 8px 12px;
    }
}

/* Mode Selection Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: #1a1a1a;
    border: 2px solid #ffffff;
    border-radius: 12px;
    padding: 32px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    color: white;
}

.modal-content h2 {
    margin-top: 0;
    margin-bottom: 16px;
    color: white;
}

.modal-content p {
    margin-bottom: 24px;
    color: #e0e0e0;
}

.modal-buttons {
    display: flex;
    gap: 16px;
    justify-content: center;
}

.modal-buttons .btn {
    flex: 1;
    padding: 16px 24px;
    font-size: 1.1rem;
    min-width: 140px;
}

@media (max-width: 768px) {
    .modal-content {
        padding: 24px;
        width: 85%;
    }
    
    .modal-buttons {
        flex-direction: column;
    }
    
    .modal-buttons .btn {
        width: 100%;
    }
}
