/* ===================================
   Reset and Base Styles
   =================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #fafafa;
    padding: 0;
    margin: 0;
}

main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px 40px;
}

/* ===================================
   Header Styles
   =================================== */

header {
    background: linear-gradient(135deg, #667eea 0%, #8fa2e0 100%);
    color: white;
    padding: 10px 20px 10px;
    text-align: center;
    margin-bottom: 40px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

header h1 {
    font-size: 2.5em;
    font-weight: 600;
    margin-bottom: 10px;
    letter-spacing: -0.5px;
}

.subtitle {
    font-size: 1.1em;
    opacity: 1;  /* Full opacity for better visibility */
    font-weight: 400;  /* Slightly bolder for better readability */
    margin-top: 10px;
    color: white;  /* Explicit white color like the title */
}

/* ===================================
   Typography
   =================================== */

h1 {
    text-align: center;
    margin-bottom: 0;
}

h2 {
    color: #2c3e50;
    font-size: 1.8em;
    font-weight: 600;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 3px solid #667eea;
    display: inline-block;
}

h3 {
    color: #34495e;
    font-size: 1.3em;
    font-weight: 600;
    margin-bottom: 10px;
}

p {
    margin-bottom: 15px;
    color: #555;
}

a {
    color: inherit;
    text-decoration: none;
}

/* ===================================
   Section Styles
   =================================== */

.intro {
    background: white;
    padding: 30px 40px;
    border-radius: 8px;
    margin-bottom: 50px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.intro h2 {
    margin-top: 0;
}

.intro p {
    font-size: 1.05em;
    line-height: 1.7;
}

.mode-selection {
    margin-top: 25px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.mode-selection ul {
    margin: 15px 0 15px 25px;
}

.mode-selection li {
    margin-bottom: 10px;
    line-height: 1.7;
}

.mode-selection a {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
}

.mode-selection a:hover {
    text-decoration: underline;
}

.mode-selection em {
    color: #28a745;
    font-weight: 500;
}

/* Progress summary in gallery */
.progress-summary {
    margin-top: 25px;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #8fa2e0 100%);
    border-radius: 8px;
    color: white;
}

.progress-stats {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.progress-label {
    font-weight: 600;
    font-size: 1.1rem;
}

.progress-numbers {
    font-size: 1rem;
    opacity: 0.95;
}

.progress-bar-mini {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 5px;
}

.progress-fill-mini {
    height: 100%;
    background: white;
    transition: width 0.3s ease;
}

.level-section {
    margin-bottom: 60px;
}

.level-section h2 {
    margin-bottom: 30px;
}

/* ===================================
   Challenge Gallery (TurtleChallenges.html)
   =================================== */

.level-section > div {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 0;
}

figure {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin: 0;
    display: inline-block;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
    position: relative;
}

figure:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

/* Completed challenge cards */
a.completed figure {
    background: linear-gradient(135deg, #f5fdf8 0%, #e8f5e9 100%);
    border: 1px solid #c8e6c9;
}

a.completed figure:hover {
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.25);
}

/* Completion badge */
.completion-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #4caf50;
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    z-index: 5;
}

.reviewed-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: #3b82f6;
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    z-index: 5;
    cursor: help;
}

.reviewed-badge svg {
    width: 12px;
    height: 12px;
}

.needs-review-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: #f59e0b;
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    z-index: 5;
    cursor: help;
}

figure img {
    width: 140px;
    height: 140px;
    object-fit: contain;
    display: block;
}

figcaption {
    text-align: center;
    font-weight: 600;
    margin-top: 12px;
    color: #34495e;
    font-size: 0.95em;
}

/* ===================================
   Challenge Details (TurtleInstructions.html)
   =================================== */

.challenge {
    background: white;
    padding: 30px;
    margin-bottom: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 30px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.2s ease;
}

.challenge:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.challenge img {
    width: 200px;
    min-width: 200px;
    height: 200px;
    object-fit: contain;
    border-radius: 6px;
    padding: 10px;
    background: #fafafa;
}

.description {
    flex: 1;
    margin: 0;
}

.description p {
    margin-bottom: 10px;
}

.description p:last-child {
    margin-bottom: 0;
}

/* ===================================
   Hints Section
   =================================== */

.show {
    background-color: #f8f9ff;
    border-left: 3px solid #667eea;
    padding: 15px 20px;
    margin-top: 15px;
    border-radius: 4px;
    display: none;
}

.show li {
    margin-bottom: 8px;
    color: #555;
}

.arrow {
    border: solid #667eea;
    border-width: 0 2px 2px 0;
    display: inline-block;
    padding: 4px;
    transform: rotate(45deg);
    margin: 0 5px;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.arrow:hover {
    border-color: #764ba2;
}

/* ===================================
   Login System Styles
   =================================== */

.auth-buttons {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.login-btn, .logout-btn {
    background: white;
    color: #667eea;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.login-btn:hover, .logout-btn:hover {
    background: #f0f0f0;
    transform: translateY(-1px);
}

.logout-btn {
    background: #fff5f5;
    color: #dc3545;
}

.logout-btn:hover {
    background: #ffe0e3;
}

/* Modal styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    color: #2c3e50;
    border: none;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 20px;
}

.tab-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.tab-btn {
    flex: 1;
    padding: 10px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.tab-btn:hover:not(.active) {
    background: #f8f9fa;
}

.tab-content {
    padding: 10px 0;
}

.name-input, .key-input, .generated-key-input {
    width: 100%;
    padding: 10px;
    margin: 10px 0;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
}

.name-input:focus, .key-input:focus {
    border-color: #667eea;
    outline: none;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: #667eea;
    color: white;
    width: 100%;
    margin-top: 10px;
}

.btn-primary:hover {
    background: #5567d8;
}

.key-display-box {
    display: flex;
    gap: 10px;
    margin: 20px 0;
}

.generated-key-input {
    flex: 1;
    font-family: monospace;
    font-size: 18px;
    font-weight: bold;
    background: #f8f9fa;
}

.btn-copy {
    background: #28a745;
    color: white;
    padding: 10px 20px;
    white-space: nowrap;
}

.btn-copy:hover {
    background: #218838;
}

.success-message {
    color: #28a745;
    font-weight: 600;
    font-size: 1.1em;
    margin-bottom: 15px;
}

.key-warning {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
    padding: 10px;
    border-radius: 6px;
    margin-top: 15px;
    font-size: 0.9em;
}

.modal-compact {
    max-width: 400px;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-warning {
    background: #dc3545;
    color: white;
}

.btn-warning:hover {
    background: #c82333;
}

/* ===================================
   Responsive Design
   =================================== */

@media only screen and (max-width: 768px) {
    header h1 {
        font-size: 2em;
    }

    .subtitle {
        font-size: 1em;
    }

    .intro {
        padding: 20px 25px;
    }

    .challenge {
        flex-direction: column;
        padding: 20px;
    }

    .challenge img {
        width: 100%;
        max-width: 250px;
        min-width: auto;
    }

    .description {
        width: 100%;
    }

    figure {
        padding: 15px;
    }
}

@media only screen and (min-width: 880px) {
    .challenge img {
        width: 220px;
        min-width: 220px;
        height: 220px;
    }
}

@media only screen and (min-width: 1200px) {
    .challenge img {
        width: 240px;
        min-width: 240px;
        height: 240px;
    }
}
