body {
    margin: 0;
    font-family: sans-serif;
    background: #f7f7f7;
    color: #222;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* ================= START SCREEN ================= */
.start-container {
    max-width: 500px;
    width: 90%;
    margin: 20px auto;
    padding: 20px;
    text-align: center;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    box-sizing: border-box;
}

/* 🔥 FIX 1: input overflow */
#name-input {
    width: 100%;
    display: block;
    padding: 12px;
    margin: 10px 0;
    box-sizing: border-box;
    font-size: 1rem;
    border: 1px solid #ccc;
    border-radius: 8px;
}

/* ================= DIFFICULTY ================= */
#difficulty-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

@media (max-width: 500px) {
    #difficulty-buttons {
        grid-template-columns: 1fr;
    }
}

/* ================= GAME LAYOUT ================= */
.container {
    display: flex;
    height: 100vh;
}

.left, .right {
    width: 100%;
}

@media (min-width: 700px) {
    .left {
        width: 50%;
    }

    .right {
        width: 50%;
        position: relative;
    }

    /* 🔥 PERFECT CENTER INSIDE RIGHT PANEL */
    #active-number {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }

    .game-hint {
        position: absolute;
        top: 20%;
        left: 50%;
        transform: translateX(-50%);
    }

    #skip {
        position: absolute;
        bottom: 20%;
        left: 50%;
        transform: translateX(-50%);
    }
}

/* ================= TABLE ================= */
table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

/* 🔥 FIX 4: lock column widths */
td:first-child {
    width: 60px;
}

.drop-slot {
    width: 120px; /* enough for 3 digits */
}

/* ensure consistent sizing */
td {
    border: 1px solid #e0e0e0;
    height: 45px;
    text-align: center;
    font-family: monospace;
    overflow: hidden;
    white-space: nowrap;
}

/* slot styling */
.drop-slot {
    background: #fafafa;
    cursor: pointer;
    transition: transform 0.1s;
}

.drop-slot:active {
    transform: scale(0.95);
}

/* ================= ERROR ================= */
.drop-slot.invalid {
    background: #e74c3c;
    animation: shake 0.25s;
}

@keyframes shake {
    0% { transform: translateX(0); }
    50% { transform: translateX(-4px); }
    100% { transform: translateX(4px); }
}

/* ================= ACTIVE NUMBER ================= */
#active-number {
    font-size: 2.5rem;
    padding: 25px;
    background: white;
    border-radius: 12px;
    min-width: 120px;
    text-align: center;
}

/* ================= BUTTONS ================= */
button {
    padding: 12px;
    margin: 5px;
    border-radius: 8px;
    border: 1px solid #ccc;
    cursor: pointer;
    background: white;
    transition: all 0.2s;
}

/* 🔥 FIX 2: selected always wins */
button:hover:not(.selected) {
    background: #4CAF50;
    color: white;
}

.diff-btn.selected {
    background: #4CAF50 !important;
    color: white !important;
    border: 2px solid #2e7d32;
}

/* ================= PROGRESS ================= */
#progress-fill {
    height: 6px;
    background: linear-gradient(90deg, #4CAF50, #81C784);
}

/* ================= OVERLAY ================= */
#overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;

    background: rgba(0,0,0,0.6);

    display: flex;
    justify-content: center;
    align-items: center;

    z-index: 999999; /* 🔥 MUCH higher */
}

.hidden {
    display:none !important;
}

/* ================= OVERLAY CONTENT CARD ================= */
.overlay-content {
    background: white;
    padding: 30px;
    border-radius: 16px;
    text-align: center;

    box-shadow: 0 10px 30px rgba(0,0,0,0.25);

    min-width: 250px;
    max-width: 90%;
}

/* optional: nicer spacing */
.overlay-content h2 {
    margin-top: 0;
}

.overlay-content button {
    margin: 8px;
}
/* ================= INSTRUCTIONS ================= */
.instructions-box {
    margin-top: 10px;
    padding: 15px;
    background: #f1f1f1;
    border-radius: 10px;
    text-align: left;
    animation: fadeIn 0.2s ease-in-out;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.2s ease;
}

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

/* ================= RIGHT PANEL FIXES ================= */

/* group spacing tighter */
.right-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

/* 🔥 FIX: keep right side fixed on desktop */
@media (min-width: 700px) {

    .left {
        height: 100vh;
        overflow-y: auto;
    }

    .right {
        position: fixed;
        right: 0;
        top: 0;
        width: 50%;
        height: 100vh;
        display: flex;
        justify-content: center;
        align-items: center;
    }
}

/* ================= TABLE BEHAVIOR ================= */

/* dynamic fit ONLY for easy/normal */
.fit-screen td {
    height: calc((100vh - 20px) / var(--rows));
}

/* keep consistent sizing */
td {
    height: 45px;
}

.right {
    z-index: 1;
}