/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-tap-highlight-color: transparent; }

body {
    font-family: 'PingFang SC', 'Microsoft YaHei', 'Hiragino Sans GB', sans-serif;
    background: #8B6914; /* dirt brown base fallback */
    background-image:
        linear-gradient(0deg,
            #8B6914 0%,
            #6B8E4A 70px,
            #6B8E4A 70px,
            #87CEEB 70px,
            #87CEEB 100%);
    min-height: 100vh;
    color: #2d1f0e;
    line-height: 1.5;
}

/* ── Main Container ── */
#app {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px;
    padding-top: 80px; /* push below sky zone */
    min-height: 100vh;
}

/* ── Loading Screen ── */
.loading-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}
.loading-text {
    font-family: 'Press Start 2P', monospace;
    font-size: 14px;
    color: #FFD700;
    text-shadow: 2px 2px 0 #8B6914;
    animation: blink 1s infinite;
}
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ── Message Card (out-of-range) ── */
.message-card {
    background: #C8A96E;
    border: 4px solid #4A3728;
    box-shadow: 6px 6px 0 #3A2718;
    padding: 32px 24px;
    text-align: center;
    margin-top: 40px;
}
.message-card .message-icon { font-size: 48px; margin-bottom: 12px; }
.message-card h2 {
    font-family: 'Press Start 2P', monospace;
    font-size: 16px;
    color: #2d1f0e;
    margin-bottom: 16px;
    line-height: 1.6;
}
.message-card p { font-size: 18px; margin: 8px 0; }
.message-sub { font-size: 14px; color: #5a4a2a; margin-top: 12px; }

/* ── Date Card ── */
.date-card {
    background: #2d1f0e;
    border: 4px solid #4A3728;
    box-shadow: 6px 6px 0 #1a0f00;
    text-align: center;
    padding: 24px 16px;
    margin-bottom: 20px;
}
.date-big {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(14px, 4vw, 20px);
    color: #FFD700;
    text-shadow: 3px 3px 0 #8B6914;
    line-height: 1.8;
    word-break: break-all;
}
.date-motivation {
    font-size: 14px;
    color: #FFFFFF;
    margin-top: 10px;
    opacity: 0.85;
    letter-spacing: 2px;
}

/* ── Section Card ── */
.section {
    background: #C8A96E;
    border: 4px solid #4A3728;
    box-shadow: 6px 6px 0 #3A2718;
    padding: 20px;
    margin-bottom: 20px;
}
.section.overdue {
    border-color: #E65100;
    /* orange-tinted for overdue */
}
.section.overdue .section-title {
    color: #BF360C;
}
.section-title {
    font-family: 'Press Start 2P', monospace;
    font-size: 12px;
    color: #2d1f0e;
    border-bottom: 3px solid #4A3728;
    padding-bottom: 10px;
    margin-bottom: 14px;
    line-height: 1.6;
}

/* ── Date Group (overdue) ── */
.date-group { margin-bottom: 12px; }
.date-group:last-child { margin-bottom: 0; }
.date-label {
    font-size: 15px;
    font-weight: bold;
    color: #E65100;
    margin: 12px 0 8px 0;
    padding: 4px 8px;
    background: rgba(230, 81, 0, 0.1);
    border-left: 4px solid #E65100;
}

/* ── Task Row ── */
.task-row {
    margin: 6px 0;
}

/* ── Custom Checkbox (Minecraft inventory slot) ── */
.check-wrapper {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 10px 12px;
    background: #B8A070;
    border: 2px solid #6B5B3E;
    transition: background 0.15s;
    -webkit-user-select: none;
    user-select: none;
    min-height: 48px; /* touch target */
}
.check-wrapper:hover {
    background: #C8B080;
}
.check-wrapper input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* The slot */
.check-box {
    width: 28px;
    height: 28px;
    min-width: 28px;
    background: #8B8B8B;
    border: 3px solid;
    border-top-color: #B8B8B8;
    border-left-color: #B8B8B8;
    border-right-color: #5A5A5A;
    border-bottom-color: #5A5A5A;
    margin-right: 14px;
    position: relative;
    transition: background 0.15s;
    image-rendering: pixelated;
}

/* Checked state */
.check-wrapper.checked .check-box {
    background: #4CAF50;
    border-top-color: #81C784;
    border-left-color: #81C784;
    border-right-color: #2E7D32;
    border-bottom-color: #2E7D32;
}

/* Pixel-art check mark using box-shadow */
.check-wrapper.checked .check-box::after {
    content: '';
    position: absolute;
    left: 8px;
    top: 4px;
    width: 8px;
    height: 14px;
    border: solid #FFFFFF;
    border-width: 0 3px 3px 0;
    transform: rotate(45deg);
    /* Add pixel-art notches */
    box-shadow:
        2px 0 0 #4CAF50,
        -2px 0 0 #4CAF50;
}

.task-label {
    font-size: 17px;
    color: #2d1f0e;
    flex: 1;
}

/* ── Submit Button ── */
.submit-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 13px;
    padding: 18px 20px;
    width: 100%;
    background: #8B8B8B;
    color: #FFFFFF;
    border: 4px solid;
    border-top-color: #B8B8B8;
    border-left-color: #B8B8B8;
    border-right-color: #5A5A5A;
    border-bottom-color: #5A5A5A;
    box-shadow: 6px 6px 0 #3A2718;
    cursor: pointer;
    text-shadow: 2px 2px 0 #3A3A3A;
    transition: all 0.1s;
    line-height: 1.8;
    letter-spacing: 1px;
    margin-bottom: 20px;
}
.submit-btn:hover:not(:disabled) {
    background: #A0A0A0;
    transform: translate(1px, 1px);
    box-shadow: 5px 5px 0 #3A2718;
}
.submit-btn:active:not(:disabled) {
    transform: translate(6px, 6px);
    box-shadow: 0 0 0 #3A2718;
}
.submit-btn:disabled {
    background: #7CB342;
    border-top-color: #AED581;
    border-left-color: #AED581;
    border-right-color: #558B2F;
    border-bottom-color: #558B2F;
    box-shadow: 6px 6px 0 #33691E;
    cursor: default;
    opacity: 0.9;
    text-shadow: 2px 2px 0 #33691E;
}

/* ── Fireworks Canvas ── */
.fireworks-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    cursor: pointer;
}

/* ── Congratulations Modal ── */
.congrats-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    padding: 20px;
    animation: fadeIn 0.3s ease-out;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.congrats-card {
    background: #C8A96E;
    border: 4px solid #4A3728;
    box-shadow: 8px 8px 0 #3A2718;
    padding: 32px 28px;
    text-align: center;
    max-width: 360px;
    width: 100%;
    animation: popIn 0.3s ease-out;
}
@keyframes popIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
.congrats-icon {
    font-size: 56px;
    margin-bottom: 12px;
}
.congrats-card h2 {
    font-family: 'Press Start 2P', monospace;
    font-size: 18px;
    color: #2d1f0e;
    margin-bottom: 12px;
    line-height: 1.6;
}
.congrats-card p {
    font-size: 18px;
    color: #4A3728;
    margin-bottom: 24px;
}
.mc-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 12px;
    padding: 14px 24px;
    background: #4CAF50;
    color: #FFFFFF;
    border: 3px solid;
    border-top-color: #81C784;
    border-left-color: #81C784;
    border-right-color: #2E7D32;
    border-bottom-color: #2E7D32;
    box-shadow: 4px 4px 0 #1B5E20;
    cursor: pointer;
    text-shadow: 2px 2px 0 #2E7D32;
    transition: all 0.1s;
    line-height: 1.6;
}
.mc-btn:hover {
    background: #66BB6A;
}
.mc-btn:active {
    transform: translate(4px, 4px);
    box-shadow: 0 0 0 #1B5E20;
}

/* ── Responsive ── */
@media (min-width: 768px) {
    #app { padding: 24px; padding-top: 100px; }
    .date-big { font-size: 22px; }
    .section { padding: 24px; }
    .submit-btn { font-size: 14px; }
}

/* ── Pixel-art scrollbar ── */
::-webkit-scrollbar { width: 12px; }
::-webkit-scrollbar-track { background: #8B6914; }
::-webkit-scrollbar-thumb {
    background: #C8A96E;
    border: 2px solid #4A3728;
}
::-webkit-scrollbar-thumb:hover { background: #D8B97E; }
