body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    margin: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    padding: 20px;
}

.container {
    position: relative;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 40px;
    max-width: 900px;
    width: 100%;
}

h1 {
    text-align: center;
    color: #667eea;
    margin-bottom: 10px;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 20px;
}

.level-info {
    text-align: center;
    flex: 1;
    min-width: 200px;
}

.level-name {
    font-size: 24px;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 5px;
}

.level-letters {
    font-size: 14px;
    color: #666;
    font-family: monospace;
    background: #f5f5f5;
    padding: 8px 12px;
    border-radius: 8px;
}

.kb-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.kb-row {
    display: flex;
    gap: 4px;
}

.kb-key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 30px;
    padding: 0;
    border-radius: 5px;
    border: 1px solid #ccc;
    background: #e8e8e8;
    color: #aaa;
    font-size: 13px;
    font-family: monospace;
    font-weight: 600;
}

.kb-key.kb-active {
    background: #667eea;
    border-color: #5568d3;
    color: white;
}

.kb-key.kb-wide {
    padding: 0 6px;
    font-size: 11px;
    color: #999;
}

.kb-key.kb-space {
    min-width: 240px;
}

.stats {
    display: flex;
    gap: 30px;
    justify-content: center;
    flex-wrap: wrap;
}

.stat {
    text-align: center;
}

.stat-value {
    font-size: 32px;
    font-weight: bold;
    color: #667eea;
}

.stat-label {
    font-size: 12px;
    color: #999;
    text-transform: uppercase;
    margin-top: 5px;
}

.exercise-section {
    background: #f9f9f9;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
}

.cursor-position-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    color: #555;
    background: #f0f4ff;
    border: 1px solid #c5d0f5;
    border-radius: 8px;
    padding: 8px 14px;
    margin-bottom: 10px;
}

.cursor-pos-label {
    color: #667eea;
    font-weight: 700;
    font-family: 'Segoe UI', sans-serif;
    margin-right: 2px;
}

.cursor-pos-value {
    font-weight: 700;
    color: #333;
    min-width: 28px;
    text-align: right;
}

.cursor-pos-sep {
    color: #aaa;
}

.cursor-pos-total {
    color: #888;
    min-width: 28px;
}

.cursor-pos-current {
    margin-left: 12px;
    font-size: 18px;
    font-weight: 700;
    color: #667eea;
    background: rgba(102, 126, 234, 0.12);
    border-radius: 4px;
    padding: 2px 10px;
    min-width: 30px;
    text-align: center;
    letter-spacing: 2px;
}

.display-container {
    font-size: 30px;
    font-family: 'Courier New', monospace;
    text-align: center;
    margin: 20px 0;
    line-height: 1;
    cursor: text;
    padding: 22px 20px;
    border-radius: 8px;
    background: white;
    border: 2px solid #667eea;
    transition: all 0.2s;
}

.display-container:focus-within {
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
    border-color: #764ba2;
}

.display-rows {
    overflow-x: auto;
    padding-bottom: 4px;
    width: max-content;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
}

.exercise-block + .exercise-block {
    margin-top: 48px;
}

.exercise-line,
.typed-line {
    display: grid;
    grid-template-columns: repeat(var(--line-char-count), var(--char-width, 30px));
    justify-content: start;
    column-gap: 0;
    min-height: 42px;
    width: max-content;
    max-width: 100%;
}

.exercise-line {
    color: #333;
    font-weight: 500;
    align-items: center;
    margin-bottom: 10px;
}

.typed-line {
    min-height: 48px;
    align-items: center;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 2px dashed #ddd;
}

.char {
    display: inline-block;
    width: var(--char-width, 30px);
    text-align: center;
    line-height: 1;
}

.char.cursor-active {
    background: rgba(80, 170, 255, 0.28);
    border-radius: 999px;
    box-shadow: 0 0 0 8px rgba(80, 170, 255, 0.28);
}

.char.correct {
    color: #27ae60;
    font-weight: bold;
}

.char.wrong {
    color: #e74c3c;
    background: #ffe6e6;
    padding: 2px 4px;
    border-radius: 2px;
    font-weight: bold;
}

.char.corrected {
    color: #8a6d00;
    background: #fff3b0;
    padding: 2px 4px;
    border-radius: 2px;
    font-weight: bold;
}

.char.empty {
    color: #bbb;
}

#text-input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

.buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 30px;
}

button {
    padding: 12px 24px;
    font-size: 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #e0e0e0;
    color: #333;
}

.btn-secondary:hover {
    background: #d0d0d0;
}

.message {
    text-align: center;
    font-size: 18px;
    margin: 20px 0;
    padding: 15px;
    border-radius: 8px;
    display: none;
}

.message.success {
    background: #d4edda;
    color: #155724;
    display: block;
}

.message.unlock {
    background: #fff3cd;
    color: #856404;
    display: block;
}

.message.info {
    background: #d1ecf1;
    color: #0c5460;
    display: block;
}

.levels-section,
.skill-scale-section,
.stats-section,
.collection-section {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 2px solid #e0e0e0;
}

.levels-section h2,
.skill-scale-section h2,
.stats-section h2,
.collection-section h2 {
    color: #667eea;
    margin-bottom: 20px;
}

.ss-wrap {
    position: relative;
    padding-bottom: 12px;
}

.ss-bar {
    display: flex;
    border-radius: 10px;
    overflow: hidden;
    height: 64px;
}

.ss-segment {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: opacity 0.2s;
}

.ss-segment.ss-active {
    outline: 3px solid #333;
    outline-offset: -3px;
    z-index: 1;
}

.ss-name {
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.35);
}

.ss-thresh {
    font-size: 10px;
    color: rgba(255,255,255,0.85);
    text-shadow: 0 1px 2px rgba(0,0,0,0.35);
}

.ss-marker {
    position: absolute;
    bottom: 0;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
}

.ss-marker-pin {
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-bottom: 10px solid #1e293b;
}

.ss-marker-bubble {
    background: #1e293b;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 6px;
    white-space: nowrap;
    margin-bottom: 2px;
}

.hs-formula {
    font-size: 12px;
    font-weight: 400;
    color: #999;
    margin-left: 10px;
}

.stats-empty {
    color: #aaa;
    font-style: italic;
    font-size: 13px;
}

#stats-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
}

.hs-level-block {
    flex: 1 1 220px;
    min-width: 200px;
}

.hs-level-name {
    font-size: 13px;
    font-weight: 700;
    color: #667eea;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.hs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.hs-table thead th {
    color: #999;
    text-align: left;
    padding: 3px 6px;
    border-bottom: 1px solid #e0e0e0;
    font-weight: 600;
    white-space: nowrap;
}

.hs-table tbody td {
    padding: 4px 6px;
    border-bottom: 1px solid #f0f0f0;
    white-space: nowrap;
}

.hs-table tr.hs-first td {
    font-weight: 700;
    color: #333;
}

.hs-rank  { width: 24px; text-align: center; color: #aaa; }
.hs-score { font-weight: 700; color: #667eea; }
.hs-speed, .hs-acc { color: #555; }
.hs-date  { color: #aaa; font-size: 11px; }

.levels-grid,
.dino-grid {
    display: grid;
    gap: 10px;
}

.levels-grid {
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
}

.dino-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.dino-collection-sections {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.dino-rarity-section {}

.dino-rarity-heading {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 12px;
    padding: 6px 14px;
    border-radius: 8px;
    display: inline-block;
}

.rarity-common    { background: #e8e8e8; color: #444; }
.rarity-rare      { background: #cce4ff; color: #1a5fa8; }
.rarity-epic      { background: #e8d5ff; color: #6b21a8; }
.rarity-legendary { background: #fff0cc; color: #92500a; }

.dino-rarity-empty {
    color: #aaa;
    font-style: italic;
    margin: 0;
}

.level-button {
    padding: 15px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
    font-weight: 600;
}

.level-button.unlocked {
    border-color: #667eea;
    color: #667eea;
    background: #f0f4ff;
}

.level-button.unlocked:hover {
    background: #667eea;
    color: white;
}

.level-button.locked {
    opacity: 0.5;
    cursor: not-allowed;
    color: #999;
}

.level-button.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.collection-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    color: #666;
    font-weight: 600;
    flex-wrap: wrap;
}

.latest-unlock {
    color: #667eea;
}

.dino-card {
    min-height: 148px;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: white;
    padding: 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    position: relative;
}

.dino-extra-star {
    position: absolute;
    top: 6px;
    right: 8px;
    font-size: 14px;
    color: #f59e0b;
    line-height: 1;
    pointer-events: none;
}

.dino-card.unlocked {
    border-color: #27ae60;
    background: #f0fff6;
    cursor: pointer;
}

.dino-card.unlocked:hover {
    border-color: #667eea;
    box-shadow: 0 4px 14px rgba(102, 126, 234, 0.18);
    transform: translateY(-1px);
}

.dino-card.locked {
    color: #999;
    background: #f7f7f7;
}

.dino-image-wrap {
    height: 86px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
}

.dino-image {
    max-width: 100%;
    max-height: 86px;
    object-fit: contain;
}

.dino-placeholder {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: #e5e5e5;
    color: #aaa;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
}

.dino-name {
    font-weight: 700;
    line-height: 1.2;
}

.dino-rarity {
    color: #777;
    font-size: 12px;
    text-transform: uppercase;
}

.dino-info-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(20, 24, 38, 0.58);
    padding: 24px;
}

.dino-info-overlay.visible {
    display: flex;
}

.dino-info-modal {
    position: relative;
    width: min(1480px, 96vw);
    height: 92vh;
    max-height: 92vh;
    overflow: auto;
    border: 2px solid #667eea;
    border-radius: 8px;
    background: #fbfbff;
    padding: 24px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
}

.dino-info-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    padding: 0;
    background: #667eea;
    color: white;
    font-size: 24px;
    line-height: 1;
}

.dino-info-close:hover {
    background: #5568d3;
}

.dino-info-header {
    display: flex;
    align-items: center;
    gap: 22px;
    margin-bottom: 22px;
    padding-right: 44px;
}

.dino-info-header img {
    width: 220px;
    height: 160px;
    object-fit: contain;
    flex: 0 0 auto;
    border-radius: 8px;
    background: white;
    border: 1px solid #e2e2e2;
}

.dino-info-card-img {
    width: 100px;
    height: 100px;
}

.dino-info-header h3 {
    color: #667eea;
    font-size: 28px;
    margin: 0 0 6px;
}

.dino-info-source {
    color: #777;
    font-size: 13px;
    font-weight: 600;
}

.dino-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.dino-info-stat {
    background: white;
    border: 1px solid #e2e2e2;
    border-radius: 8px;
    padding: 10px;
}

.dino-info-label {
    color: #777;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.dino-info-value {
    color: #333;
    font-weight: 700;
}

.dino-info-section {
    margin-top: 16px;
}

.dino-info-section h4 {
    color: #667eea;
    margin: 0 0 8px;
}

.dino-info-section p {
    margin: 0;
    line-height: 1.5;
}

.dino-info-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 18px;
    padding-right: 44px;
}

.dino-info-tab {
    background: #e9edff;
    color: #667eea;
    border: 2px solid #cfd6ff;
    border-radius: 8px;
    padding: 10px 14px;
}

.dino-info-tab.active {
    background: #667eea;
    border-color: #667eea;
    color: white;
}

.dino-tab-panel {
    display: none;
}

.dino-tab-panel.active {
    display: block;
}

.dinosaur-pictures-clean {
    margin-top: 0;
}

.dinosaur-pictures-clean h4 {
    color: #667eea;
    margin: 0 0 10px;
}

.dinosaur-pictures-status {
    color: #777;
    font-weight: 600;
    padding: 14px 0;
}

.dinosaur-pictures-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.dinosaur-pictures-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #667eea;
    color: white;
    border-radius: 8px;
    padding: 10px 14px;
    font-weight: 700;
    text-decoration: none;
}

.dinosaur-pictures-action:hover {
    background: #5568d3;
}

.extra-locked {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 60px 20px;
    text-align: center;
    color: #555;
}

.extra-locked-icon {
    font-size: 48px;
}

.extra-unlock-btn {
    padding: 14px 28px;
    font-size: 16px;
}

.dino-globe-wrap {
    margin-bottom: 20px;
}

.dino-globe-wrap h4 {
    color: #667eea;
    margin: 0 0 10px;
}

.dino-globe-iframe {
    width: 100%;
    height: 400px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #000;
}

.dinosaur-pictures-srcdoc-frame {
    width: 100%;
    height: calc(92vh - 170px);
    min-height: 620px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: white;
}

.completion-meter {
    background: #e0e0e0;
    height: 8px;
    border-radius: 4px;
    margin: 15px 0;
    overflow: hidden;
}

.completion-bar {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    width: 0%;
    transition: width 0.3s;
}

@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 20px;
    }

    .display-container {
        font-size: 26px;
        padding: 14px;
        --char-width: 26px;
    }

    .dino-info-overlay {
        padding: 12px;
    }

    .dino-info-modal {
        padding: 18px;
    }

    .dino-info-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .dino-info-header img {
        width: 100%;
        height: 190px;
    }
}

/* Profile widget */
.profile-widget {
    position: absolute;
    top: 16px;
    right: 20px;
    z-index: 20;
}

.profile-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--profile-color, #667eea);
    color: white;
    font-size: 15px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Segoe UI', sans-serif;
    box-shadow: 0 2px 6px rgba(0,0,0,0.18);
    transition: transform 0.15s, box-shadow 0.15s;
}
.profile-avatar:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 10px rgba(0,0,0,0.22);
}

.profile-panel {
    position: absolute;
    right: 0;
    top: 42px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    border: 1px solid #e8e8e8;
    padding: 6px;
    min-width: 130px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.profile-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border: none;
    background: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-family: 'Segoe UI', sans-serif;
    color: #333;
    text-align: left;
    width: 100%;
    transition: background 0.1s;
}
.profile-option:hover { background: #f5f5f5; }
.profile-option-active { font-weight: 700; }

.profile-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--profile-color, #667eea);
    flex-shrink: 0;
}

.profile-check {
    margin-left: auto;
    color: var(--profile-color, #667eea);
    font-size: 13px;
    visibility: hidden;
}
.profile-option-active .profile-check { visibility: visible; }
