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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    /* Prevent pull-to-refresh and overscroll on mobile */
    overscroll-behavior: none;
    touch-action: pan-y;
}

body.dragging {
    overflow: hidden;
    touch-action: none;
}

.container {
    max-width: 500px;
    width: 100%;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 30px;
    max-height: 95vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 10px;
    font-size: 28px;
}

.instructions {
    text-align: center;
    color: #666;
    font-size: 14px;
    margin-bottom: 20px;
    line-height: 1.6;
}

.game-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
}

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

.info-label {
    font-size: 12px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-value {
    font-size: 24px;
    font-weight: bold;
    color: #667eea;
    margin-top: 5px;
}

.timer {
    font-family: 'Courier New', monospace;
}

.current-guess {
    margin-bottom: 20px;
}

.guess-label {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
    text-align: center;
}

/* Number pool section */
.number-pool {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.pool-label {
    font-size: 12px;
    font-weight: 600;
    color: #666;
    margin-bottom: 10px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pool-container {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    min-height: 70px;
}

.number-tile {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    cursor: grab;
    user-select: none;
    transition: transform 0.2s, opacity 0.2s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    /* Make touch more responsive */
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

.number-tile:active {
    cursor: grabbing;
}

.number-tile.dragging {
    opacity: 0.3;
}

.number-tile.used {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

/* Floating drag indicator */
.drag-ghost {
    position: fixed;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    pointer-events: none;
    z-index: 9999;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    transform: translate(-50%, -50%) scale(1.2);
    opacity: 0.95;
}

/* Platform section */
.platform {
    background: #fff;
    padding: 20px;
    border: 3px dashed #ddd;
    border-radius: 10px;
    margin-bottom: 20px;
}

.platform-label {
    font-size: 12px;
    font-weight: 600;
    color: #666;
    margin-bottom: 10px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.platform-slots {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.slot {
    width: 60px;
    height: 60px;
    background: #f8f9fa;
    border: 2px dashed #ddd;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    color: white;
    transition: all 0.15s;
    position: relative;
    /* Make touch more responsive */
    -webkit-tap-highlight-color: transparent;
}

.slot.empty {
    color: #ccc;
}

.slot.filled {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: 2px solid #667eea;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.slot.drag-over {
    background: #4caf50;
    border-color: #4caf50;
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(76, 175, 80, 0.5);
}

.slot .remove-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 20px;
    height: 20px;
    background: #f44336;
    color: white;
    border-radius: 50%;
    font-size: 14px;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 2px solid white;
}

.slot.filled:hover .remove-btn {
    display: flex;
}

.submit-btn {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.submit-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

.submit-btn:active:not(:disabled) {
    transform: translateY(0);
}

.submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.history {
    margin-top: 30px;
}

.history-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 10px;
    transition: background 0.2s;
}

.history-title:hover {
    background: #e9ecef;
}

.history-toggle {
    font-size: 20px;
    transition: transform 0.3s;
}

.history-toggle.collapsed {
    transform: rotate(-180deg);
}

.history-content {
    max-height: 300px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.history-item {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 10px;
    animation: slideIn 0.3s ease-out;
    text-align: center;
}

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

.attempt-number {
    font-size: 12px;
    color: #999;
    margin-bottom: 8px;
}

.feedback-text {
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.feedback-correct {
    color: #4caf50;
}

.game-over {
    text-align: center;
    padding: 30px;
    background: #f8f9fa;
    border-radius: 10px;
    margin-top: 20px;
}

.game-over-title {
    font-size: 28px;
    font-weight: bold;
    margin-bottom: 15px;
}

.game-over-title.win {
    color: #4caf50;
}

.game-over-title.lose {
    color: #f44336;
}

.game-over-stats {
    margin: 20px 0;
    padding: 20px;
    background: white;
    border-radius: 10px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 16px;
}

.stat-label {
    color: #666;
}

.stat-value {
    font-weight: 600;
    color: #333;
}

.share-btn {
    padding: 12px 30px;
    background: #4caf50;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
    margin-bottom: 10px;
}

.share-btn:hover {
    transform: translateY(-2px);
}

.reset-btn {
    padding: 12px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
}

.reset-btn:hover {
    transform: translateY(-2px);
}

.share-message {
    margin-top: 10px;
    color: #4caf50;
    font-size: 14px;
    font-weight: 600;
}

/* Popup Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background: white;
    border-radius: 20px;
    padding: 40px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease-out;
}

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

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

    .container {
        padding: 20px;
    }

    .number-tile,
    .slot {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }

    .drag-ghost {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }

    .pool-container {
        gap: 8px;
    }

    h1 {
        font-size: 24px;
    }

    .info-value {
        font-size: 20px;
    }

    .game-info {
        padding: 10px;
    }

    .number-pool,
    .platform {
        padding: 15px;
    }

    .instructions {
        font-size: 13px;
    }
}

@media (max-width: 340px) {
    .pool-container {
        max-width: 180px;
        margin: 0 auto;
    }
}