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

[x-cloak] {
    display: none !important;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem 1rem;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
}

main {
    max-width: 800px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.welcome {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.welcome h2 {
    color: #667eea;
    margin-bottom: 1rem;
}

.welcome p {
    margin-bottom: 0.5rem;
    color: #666;
}

footer {
    text-align: center;
    padding: 2rem 1rem;
    color: #666;
    margin-top: 4rem;
}

/* Game Container Styles */
.game-container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    overflow: hidden;
}

/* Puzzle Header */
.puzzle-header {
    padding: 1.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.puzzle-title {
    font-size: 1.5rem;
    margin: 0;
}

/* Puzzle Description */
.puzzle-description {
    background: rgba(255, 255, 255, 0.95);
    padding: 1rem;
    margin: 1rem 0;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.description-text,
.survey-description-text {
    line-height: 1.6;
}

.description-text p,
.survey-description-text p {
    margin-bottom: 1rem;
}

.description-text p:last-child,
.survey-description-text p:last-child {
    margin-bottom: 0;
}

.description-text ul,
.description-text ol,
.survey-description-text ul,
.survey-description-text ol {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.description-text li,
.survey-description-text li {
    margin-bottom: 0.5rem;
}

.description-text h1,
.description-text h2,
.description-text h3,
.survey-description-text h1,
.survey-description-text h2,
.survey-description-text h3 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.description-text code,
.survey-description-text code {
    background: #f5f5f5;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: monospace;
}

.description-text pre,
.survey-description-text pre {
    background: #f5f5f5;
    padding: 1rem;
    border-radius: 4px;
    overflow-x: auto;
    margin-bottom: 1rem;
}

/* Section Styles */
.peaks-section,
.shelf-section {
    border-bottom: 1px solid #e0e0e0;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: #f9f9f9;
    cursor: pointer;
    user-select: none;
}

.section-header h3 {
    margin: 0;
    font-size: 1.2rem;
}

.peak-indicator {
    background: #e0e0e0;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
}

.peak-indicator.full {
    background: #4caf50;
    color: white;
}

.collapse-toggle {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    transition: transform 0.3s;
}

.collapsed .collapse-toggle {
    transform: rotate(-90deg);
}

.section-content {
    padding: 1.5rem;
}

.collapsed .section-content {
    display: none;
}

/* Peaks List */
.peaks-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.peak-slot {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 50px;
    transition: background 0.2s;
}

.peak-slot.drag-over {
    background: rgba(102, 126, 234, 0.1);
    border-radius: 8px;
}

.rank-number {
    background: #667eea;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
}

.drop-zone {
    flex: 1;
    border: 2px dashed #ccc;
    border-radius: 8px;
    padding: 0.75rem;
    text-align: center;
    color: #999;
    font-style: italic;
}

.peak-item {
    flex: 1;
    background: white;
    border: 2px solid #667eea;
    border-radius: 8px;
    padding: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    cursor: move;
    transition: box-shadow 0.2s, transform 0.1s;
    /* Prevent text selection during touch drag */
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    /* Improve touch experience */
    touch-action: none;
}

.peak-item.dragging {
    opacity: 0.4;
}

.peak-item.drag-ghost {
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.6);
    transform: scale(1.05) rotate(2deg);
    opacity: 0.95;
    transition: none;
}

.peak-item:hover {
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.peak-item .choice-text {
    flex: 1;
    font-weight: 500;
}

.boot-button {
    background: #ff5252;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.2s;
}

.boot-button:hover {
    background: #e64545;
}

/* Check Button */
.check-button {
    width: 100%;
    background: #4caf50;
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.check-button:hover:not(:disabled) {
    background: #45a049;
}

.check-button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Guess History */
.guess-history {
    margin-top: 1.5rem;
}

.guess-counter {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.guesses {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.guess-result {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    background: #f9f9f9;
    border-radius: 6px;
}

.guess-number {
    font-weight: 500;
    min-width: 70px;
}

.guess-squares {
    display: flex;
    gap: 0.5rem;
}

.guess-square {
    width: 32px;
    height: 32px;
    border-radius: 4px;
}

.guess-square.correct {
    background: #4caf50;
}

.guess-square.wrong-position {
    background: #ffc107;
}

.guess-square.incorrect {
    background: #333;
}

.game-message {
    padding: 1rem;
    border-radius: 6px;
    font-weight: 600;
    text-align: center;
    margin-top: 0.5rem;
}

.game-message.win {
    background: #e8f5e9;
    color: #2e7d32;
}

.game-message.lose {
    background: #ffebee;
    color: #c62828;
}

/* Share Button */
.share-container {
    margin-top: 1rem;
    text-align: center;
}

.share-button {
    background: #667eea;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.share-button:hover {
    background: #5568d3;
}

.share-button:active {
    transform: scale(0.98);
}

.share-feedback {
    margin-top: 0.5rem;
    color: #2e7d32;
    font-weight: 500;
    font-size: 0.875rem;
}

.correct-answer-reveal {
    padding: 0.75rem;
    background: #f5f5f5;
    border-radius: 6px;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

/* Shelf List */
.shelf-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.shelf-item {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

.shelf-item .choice-text {
    flex: 1;
}

.shelf-item.disabled {
    opacity: 0.4;
    pointer-events: none;
    background: #f5f5f5;
}

.shelf-item.disabled .choice-text {
    color: #999;
    text-decoration: line-through;
}

.pick-button {
    background: #667eea;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.2s;
}

.pick-button:hover {
    background: #5568d3;
}

/* Hidden utility class */
.hidden {
    display: none !important;
}

/* Survey Section */
.survey-section {
    border-top: 2px solid #667eea;
    margin-top: 2rem;
}

.survey-section .section-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.survey-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.survey-title {
    font-size: 1.5rem;
    color: #667eea;
    margin: 0;
}

/* Survey Description */
.survey-description {
    background: rgba(102, 126, 234, 0.1);
    padding: 1rem;
    margin: 1rem 0;
    border-radius: 8px;
    border: 1px solid rgba(102, 126, 234, 0.2);
}

.survey-peaks-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.survey-shelf-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.submit-survey-button {
    width: 100%;
    background: #667eea;
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.submit-survey-button:hover:not(:disabled) {
    background: #5568d3;
}

.submit-survey-button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.survey-result {
    padding: 1.5rem;
    background: #e8f5e9;
    color: #2e7d32;
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
    margin-top: 1rem;
}

.game-result {
    padding: 1.5rem;
    border-radius: 8px;
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    margin-top: 1rem;
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

@media (max-width: 768px) {
    header h1 {
        font-size: 1.5rem;
    }
    
    .welcome {
        padding: 1.5rem;
    }

    .puzzle-title {
        font-size: 1.2rem;
    }

    .section-content {
        padding: 1rem;
    }

    .peak-item,
    .shelf-item {
        font-size: 0.9rem;
    }

    .boot-button,
    .pick-button {
        padding: 0.4rem 0.75rem;
        font-size: 0.85rem;
    }

    .survey-title {
        font-size: 1.2rem;
    }

    .game-result {
        font-size: 1.2rem;
        padding: 1rem;
    }
}
