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

body {
    min-height: 100vh;
    background: linear-gradient(145deg, #fff9e8 0%, #ffe6c9 100%);
    font-family: 'Quicksand', 'Comic Neue', 'Segoe UI', cursive, sans-serif;
    color: #3b2a1f;
    position: relative;
    overflow-x: hidden;
}

#star-container {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; z-index: 0;
}
.star { position: absolute; border-radius: 50%; pointer-events: none; z-index: 0; }
@keyframes floatStar {
    0% { transform: translateY(0px) rotate(0deg); opacity: 0.3; }
    50% { transform: translateY(-12px) rotate(180deg); opacity: 0.8; }
    100% { transform: translateY(0px) rotate(360deg); opacity: 0.3; }
}

.container { max-width: 900px; margin: 0 auto; padding: 20px; position: relative; z-index: 5; }

.header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 15px 25px; background: #fff9ef; border-radius: 48px;
    border: 2px solid #ffe1aa; box-shadow: 0 12px 18px rgba(0,0,0,0.08);
    margin-bottom: 20px;
}
.header h1 { font-size: 1.3rem; font-weight: 800; color: #ff7b2c; }

.user-switch {
    display: flex; align-items: center; gap: 10px;
    cursor: pointer; padding: 8px 16px; border-radius: 30px;
    border: 2px solid #ffe1aa; background: #fff;
    transition: all 0.2s ease;
}
.user-switch:hover { border-color: #ffaa33; transform: scale(1.02); }
.user-switch .avatar { font-size: 1.5rem; }
.user-switch .name { font-weight: 700; font-size: 0.95rem; }
.user-dropdown {
    display: none; position: absolute; top: 60px; right: 20px;
    background: #fff; border-radius: 24px; border: 2px solid #ffe1aa;
    box-shadow: 0 10px 20px rgba(0,0,0,0.1); min-width: 160px;
    overflow: hidden; z-index: 100;
}
.user-dropdown.show { display: block; animation: popIn 0.3s ease; }
.user-option {
    display: flex; align-items: center; gap: 10px; padding: 14px 20px;
    cursor: pointer; transition: background 0.2s; font-weight: 600;
}
.user-option:hover { background: #fff9ef; }
.user-option.active { background: #ffe6bc; color: #ff7b2c; }
.user-option .avatar { font-size: 1.3rem; }

.tab-nav {
    display: flex; gap: 12px; margin-bottom: 20px; overflow-x: auto;
    padding: 8px 16px; background: #fff9ef; border-radius: 36px;
    border: 2px solid #ffe1aa; box-shadow: 0 8px 14px rgba(0,0,0,0.06);
    scrollbar-width: none; -ms-overflow-style: none;
}
.tab-nav::-webkit-scrollbar { display: none; }
.tab-item {
    flex: 1; min-width: 100px; padding: 12px 16px; border-radius: 24px;
    text-align: center; cursor: pointer; transition: all 0.25s ease;
    font-weight: 700; font-size: 0.92rem; display: flex;
    flex-direction: column; align-items: center; gap: 4px;
    border: 2px solid transparent;
}
.tab-item .icon { font-size: 1.2rem; margin-bottom: 2px; }
.tab-item .label { font-size: 0.8rem; }
.tab-item.active {
    background: linear-gradient(145deg, #ffd9a0, #ffb86c);
    color: #3b2a1f; border-color: #c4853a;
    box-shadow: 0 4px 0 #c4853a, 0 6px 12px rgba(255,160,51,0.2);
    transform: translateY(-2px);
}
.tab-item:not(.active) {
    background: #fff; border-color: #ffe1aa;
    color: #8b5a2b;
}
.tab-item:not(.active):hover {
    background: #fffdf0; border-color: #ffaa33;
    transform: translateY(-1px);
}

.panel { display: none; animation: fadeIn 0.3s ease; }
.panel.active { display: block; }

.stats-bar {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 14px; margin-bottom: 20px;
}
.stat-card {
    background: #fff9ef; border-radius: 36px; padding: 16px;
    text-align: center; border: 2px solid #ffe1aa;
    box-shadow: 0 8px 14px rgba(0,0,0,0.06); transition: all 0.25s ease;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 12px 18px rgba(0,0,0,0.1); }
.stat-card .icon { font-size: 1.6rem; margin-bottom: 6px; }
.stat-card .value { font-size: 1.5rem; font-weight: 800; color: #ff7b2c; }
.stat-card .label { font-size: 0.75rem; color: #8b5a2b; font-weight: 600; }

.calendar-section {
    background: #fff9ef; border-radius: 48px; padding: 22px;
    border: 2px solid #ffe1aa; box-shadow: 0 12px 18px rgba(0,0,0,0.08);
    margin-bottom: 20px;
}
.calendar-header {
    display: flex; align-items: center; justify-content: center;
    gap: 12px; margin-bottom: 16px;
}
.cal-nav-btn {
    width: 36px; height: 36px; border: none; border-radius: 50%;
    background: #fff; color: #8b5a2b; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s; box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
.cal-nav-btn:hover { background: #ffd9a0; transform: scale(1.1); }
.cal-title {
    font-size: 1.2rem; font-weight: 800; color: #ff7b2c;
    min-width: 120px; text-align: center;
}
.cal-today-btn {
    padding: 6px 14px; border: none; border-radius: 20px;
    background: linear-gradient(145deg, #ffd9a0, #ffb86c);
    color: #3b2a1f; font-weight: 700; font-size: 0.85rem;
    cursor: pointer; transition: all 0.2s;
}
.cal-today-btn:hover { transform: scale(1.05); }

.calendar-weekdays {
    display: grid; grid-template-columns: repeat(7, 1fr);
    gap: 4px; margin-bottom: 8px;
}
.cal-weekday {
    text-align: center; font-size: 0.8rem; font-weight: 700;
    color: #8b5a2b; padding: 8px 0;
}

.calendar-grid {
    display: grid; grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}
.cal-day {
    aspect-ratio: 1; min-height: 60px; border-radius: 16px;
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; cursor: pointer; transition: all 0.2s;
    background: #fff; border: 2px solid transparent;
    position: relative; padding: 4px;
}
.cal-day.empty { background: transparent; cursor: default; }
.cal-day.today { border-color: #ffaa33; background: #fff0b3; }
.cal-day.future { opacity: 0.4; cursor: default; }
.cal-day.checked { background: linear-gradient(145deg, #b8e6c1, #7dd891); border-color: #5ba86a; }
.cal-day:not(.empty):not(.future):hover { transform: scale(1.05); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.cal-day-num { font-size: 0.9rem; font-weight: 700; color: #3b2a1f; }
.cal-day.checked .cal-day-num { color: #2d5a30; }
.cal-day-min { font-size: 0.65rem; color: #5a3e2b; font-weight: 600; }
.cal-day-stamp { font-size: 0.8rem; }

.cal-summary {
    margin-top: 20px; padding-top: 16px; border-top: 2px dashed #ffe1aa;
}
.cal-summary-grid {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
}
.cal-summary-item {
    text-align: center; padding: 12px; background: #fff;
    border-radius: 16px; border: 2px solid #ffe1aa;
}
.cal-summary-item .icon { font-size: 1.2rem; margin-bottom: 4px; }
.cal-summary-item .value {
    display: block; font-size: 1.2rem; font-weight: 800; color: #ff7b2c;
}
.cal-summary-item .label {
    display: block; font-size: 0.7rem; color: #8b5a2b; font-weight: 600;
}

.section {
    background: #fff9ef; border-radius: 48px; padding: 22px;
    border: 2px solid #ffe1aa; box-shadow: 0 12px 18px rgba(0,0,0,0.08);
    margin-bottom: 20px;
}
.section-title {
    font-size: 1.1rem; font-weight: 800; color: #ff7b2c;
    margin-bottom: 16px; display: flex; justify-content: space-between; align-items: center;
}
.btn-add {
    background: linear-gradient(145deg, #ffd9a0, #ffb86c); border: none;
    padding: 8px 18px; border-radius: 24px; font-weight: 700;
    font-size: 0.85rem; color: #3b2a1f; cursor: pointer;
    box-shadow: 0 4px 0 #c4853a; transition: all 0.15s;
}
.btn-add:hover { transform: translateY(-2px); }
.btn-add:active { transform: translateY(2px); box-shadow: 0 2px 0 #c4853a; }

.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.book-card {
    background: #fff; border-radius: 32px; padding: 18px;
    text-align: center; border: 2px solid #ffe1aa;
    box-shadow: 0 6px 12px rgba(0,0,0,0.06); cursor: pointer;
    transition: all 0.25s ease; position: relative;
}
.book-card:hover { transform: translateY(-4px) scale(1.02); box-shadow: 0 10px 20px rgba(0,0,0,0.1); }
.book-card .book-icon { font-size: 2.2rem; margin-bottom: 8px; }
.book-card .book-title { font-weight: 800; font-size: 0.9rem; margin-bottom: 4px; word-break: break-all; }
.book-card .book-author { font-size: 0.72rem; color: #8b5a2b; margin-bottom: 8px; }
.book-progress { width: 100%; height: 8px; background: #f0e0cc; border-radius: 4px; overflow: hidden; }
.book-progress-bar { height: 100%; border-radius: 4px; background: linear-gradient(90deg, #ffaa33, #ff7b2c); transition: width 0.5s ease; }
.book-page-text { font-size: 0.68rem; color: #8b5a2b; margin-top: 4px; font-weight: 600; }
.book-status { position: absolute; top: 10px; right: 10px; font-size: 0.7rem; padding: 3px 8px; border-radius: 10px; font-weight: 700; }
.status-reading { background: #b8e6c1; color: #2d5a30; }
.status-finished { background: #ffe066; color: #8b6914; }
.status-want { background: #e0e0e0; color: #555; }
.card-add {
    background: #f8f4ec; border: 2px dashed #d4ba94; display: flex;
    flex-direction: column; align-items: center; justify-content: center;
    min-height: 130px;
}
.card-add i { font-size: 2rem; color: #c4853a; }
.card-add span { font-size: 0.82rem; color: #8b5a2b; font-weight: 700; margin-top: 6px; }

.checkin-panel {
    background: #fff9ef; border-radius: 48px; padding: 30px;
    border: 2px solid #ffe1aa; box-shadow: 0 12px 18px rgba(0,0,0,0.08);
}
.checkin-panel h3 { font-size: 1.2rem; font-weight: 800; color: #ff7b2c; margin-bottom: 20px; text-align: center; }

.book-selector { margin-bottom: 20px; }
.book-selector label { display: block; font-size: 0.9rem; font-weight: 700; color: #8b5a2b; margin-bottom: 8px; }
.book-selector select {
    width: 100%; padding: 14px 20px; border: 2px solid #ffe1aa; border-radius: 28px;
    font-size: 1rem; font-family: inherit; font-weight: 600;
    background: #fff; outline: none; transition: border-color 0.2s;
}
.book-selector select:focus { border-color: #ffaa33; }

.time-selector { margin-bottom: 30px; }
.time-selector label { display: block; font-size: 0.9rem; font-weight: 700; color: #8b5a2b; margin-bottom: 12px; }
.time-options { display: flex; gap: 14px; justify-content: center; }
.time-option {
    flex: 1; padding: 16px 10px; border: 2px solid #ffe1aa; border-radius: 24px;
    text-align: center; cursor: pointer; transition: all 0.25s ease;
    background: #fff; font-weight: 700; font-size: 1rem;
    color: #8b5a2b;
}
.time-option:hover { border-color: #ffaa33; transform: translateY(-2px); }
.time-option.active {
    background: linear-gradient(145deg, #ffaa33, #ff7b2c);
    color: #fff; border-color: #c45a26;
    box-shadow: 0 4px 0 #c45a26, 0 6px 12px rgba(255,123,44,0.2);
    transform: translateY(-2px);
}
.time-option .label { font-size: 0.75rem; opacity: 0.8; margin-top: 4px; }

.timer-container { margin: 30px 0; text-align: center; }
.timer-ring { position: relative; display: inline-block; margin-bottom: 20px; }
.timer-ring svg { transform: rotate(-90deg); width: 200px; height: 200px; }
.timer-ring .timer-bg { fill: none; stroke: #f0e0cc; stroke-width: 12; }
.timer-ring .timer-progress { fill: none; stroke: #ff7b2c; stroke-width: 12; stroke-linecap: round; transition: stroke-dashoffset 0.5s ease; stroke-dasharray: 565.48; stroke-dashoffset: 0; }
.timer-ring .timer-text { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 2.2rem; font-weight: 900; color: #ff7b2c; font-family: 'Courier New', monospace; }
.timer-ring.warning .timer-text { color: #FF6B6B; }
.timer-ring.blink .timer-text { animation: blink 1s infinite alternate; }
.timer-stamps {
    position: absolute; top: 65%; left: 50%; transform: translateX(-50%);
    font-size: 1rem; font-weight: 700; color: #ffaa33;
    background: rgba(255,255,255,0.9); padding: 4px 12px; border-radius: 12px;
    display: none;
}
@keyframes blink { from { opacity: 1; } to { opacity: 0.3; } }

.stamp-toast {
    position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #ffaa33, #ff8800);
    color: white; padding: 16px 32px; border-radius: 20px;
    font-size: 1.2rem; font-weight: 700; z-index: 10000;
    box-shadow: 0 8px 30px rgba(255,136,0,0.4);
    animation: stampPop 0.5s ease, stampFade 2s ease 0.5s forwards;
}
@keyframes stampPop {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    50% { transform: translate(-50%, -50%) scale(1.2); }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}
@keyframes stampFade {
    0% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -70%); }
}

.timer-status { font-size: 1rem; font-weight: 700; color: #8b5a2b; margin-bottom: 20px; }
.timer-status.running { color: #5ba86a; }
.timer-status.paused { color: #ff7b2c; }
.timer-status.done { color: #ff7b2c; }

.control-buttons { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.control-btn {
    flex: 1; min-width: 120px; padding: 14px 20px; border: none; border-radius: 28px;
    font-weight: 800; font-size: 1rem; cursor: pointer; transition: all 0.15s;
    box-shadow: 0 5px 0 rgba(0,0,0,0.2);
}
.control-btn:hover { transform: translateY(-2px); filter: brightness(1.05); }
.control-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,0.2); }
.control-btn.start { background: linear-gradient(145deg, #ffaa33, #ff7b2c); color: #fff; box-shadow: 0 5px 0 #c45a26; }
.control-btn.pause { background: linear-gradient(145deg, #ffd9a0, #ffb86c); color: #3b2a1f; box-shadow: 0 5px 0 #c4853a; }
.control-btn.resume { background: linear-gradient(145deg, #b8e6c1, #7dd891); color: #2d5a30; box-shadow: 0 5px 0 #5ba86a; }
.control-btn.end { background: linear-gradient(145deg, #FF6B6B, #ee5a52); color: #fff; box-shadow: 0 5px 0 #c4453a; }

.timer-tips { margin-top: 20px; padding: 14px 20px; background: #fff0b3; border-radius: 20px; font-size: 0.85rem; color: #8b6914; text-align: center; border: 2px solid #ffe066; }

.stamp-balance { margin-bottom: 16px; }
.stamp-card {
    display: flex; align-items: center; gap: 16px;
    background: linear-gradient(145deg, #fffdf0, #fff9e8);
    border-radius: 28px; padding: 20px;
    border: 2px solid #ffe1aa;
}
.stamp-icon { font-size: 3rem; }
.stamp-info { flex: 1; }
.stamp-label { font-size: 0.85rem; color: #8b5a2b; }
.stamp-value { font-size: 2rem; font-weight: 800; color: #ff7b2c; }
.exchange-btn {
    padding: 12px 24px; border: none; border-radius: 24px;
    background: linear-gradient(145deg, #ffaa33, #ff7b2c);
    color: #fff; font-weight: 800; font-size: 0.95rem;
    cursor: pointer; box-shadow: 0 4px 0 #c45a26;
    transition: all 0.15s;
}
.exchange-btn:hover { transform: translateY(-2px); }
.exchange-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #c45a26; }

.reward-history { max-height: 200px; overflow-y: auto; }
.reward-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px; background: #fff; border-radius: 16px;
    margin-bottom: 8px; border: 2px solid #ffe1aa;
}
.reward-date { font-size: 0.8rem; color: #8b5a2b; min-width: 80px; }
.reward-change { font-size: 1rem; font-weight: 800; min-width: 50px; }
.reward-change.positive { color: #5ba86a; }
.reward-change.negative { color: #ff6b6b; }
.reward-desc { flex: 1; font-size: 0.9rem; color: #3b2a1f; font-weight: 600; }

.achievement-grid { display: flex; gap: 14px; flex-wrap: wrap; }
.achievement-badge {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 16px 20px; border-radius: 28px; min-width: 110px;
    border: 2px solid #ffe1aa; background: #fff; transition: all 0.25s;
}
.achievement-badge.unlocked { border-color: #ffd966; background: #fffdf0; }
.achievement-badge.locked { opacity: 0.5; }
.achievement-badge .ach-icon { font-size: 2rem; }
.achievement-badge .ach-name { font-weight: 800; font-size: 0.82rem; color: #3b2a1f; }
.achievement-badge .ach-desc { font-size: 0.65rem; color: #8b5a2b; text-align: center; }

.modal-overlay {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(59,42,31,0.4); z-index: 200; justify-content: center; align-items: center;
}
.modal-overlay.show { display: flex; animation: fadeIn 0.2s ease; }
.modal-box {
    background: #fff9ef; border-radius: 40px; padding: 28px;
    border: 3px solid #ffe1aa; box-shadow: 0 20px 40px rgba(0,0,0,0.15);
    max-width: 420px; width: 90%; animation: popIn 0.3s cubic-bezier(0.68,-0.55,0.265,1.55);
}
.modal-title { font-size: 1.2rem; font-weight: 800; color: #ff7b2c; margin-bottom: 18px; }
.modal-close { float: right; cursor: pointer; font-size: 1.3rem; color: #8b5a2b; line-height: 1; }

.form-group { margin-bottom: 16px; }
.form-label {
    display: block; font-size: 0.9rem; font-weight: 700; color: #8b5a2b; margin-bottom: 8px;
    display: flex; align-items: center;
}
.form-label::after { content: ''; flex: 1; height: 2px; background: linear-gradient(90deg, #ffaa33, transparent); margin-left: 10px; border-radius: 1px; }
.form-input {
    width: 100%; padding: 16px 20px; border: 2px solid #ffe1aa; border-radius: 28px;
    font-size: 1rem; font-family: inherit; font-weight: 600;
    background: #fff; outline: none; transition: all 0.25s ease;
    box-shadow: 0 2px 0 rgba(0,0,0,0.05);
}
.form-input:focus { border-color: #ffaa33; box-shadow: 0 4px 0 rgba(255,170,51,0.2), 0 6px 12px rgba(255,170,51,0.1); transform: translateY(-1px); }
.form-input::placeholder { color: #d4ba94; font-weight: 500; }
.color-options { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.color-opt {
    width: 36px; height: 36px; border-radius: 50%; cursor: pointer;
    border: 3px solid transparent; transition: all 0.2s;
    box-shadow: 0 2px 0 rgba(0,0,0,0.1);
}
.color-opt:hover { transform: scale(1.1); }
.color-opt.selected { border-color: #3b2a1f; transform: scale(1.15); box-shadow: 0 3px 0 rgba(59,42,31,0.3); }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 20px; }
.btn-cancel, .btn-save {
    padding: 10px 24px; border-radius: 24px; font-weight: 700;
    font-size: 0.92rem; cursor: pointer; border: none; transition: all 0.15s;
}
.btn-cancel { background: #f0e0cc; color: #8b5a2b; box-shadow: 0 3px 0 rgba(139,90,43,0.3); }
.btn-save { background: linear-gradient(145deg, #ffaa33, #ff7b2c); color: #fff; box-shadow: 0 4px 0 #c45a26; }
.btn-cancel:hover, .btn-save:hover { transform: translateY(-2px); }
.btn-cancel:active, .btn-save:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,0.2); }

.day-detail-list { max-height: 250px; overflow-y: auto; }
.day-detail-item {
    padding: 14px 16px; background: #fff; border-radius: 16px;
    margin-bottom: 10px; border: 2px solid #ffe1aa;
}
.day-detail-item .book-name { font-weight: 700; color: #3b2a1f; margin-bottom: 6px; }
.day-detail-item .book-info { font-size: 0.85rem; color: #8b5a2b; }
.day-detail-summary {
    margin-top: 16px; padding: 14px; background: #fff0b3;
    border-radius: 16px; text-align: center; font-size: 0.9rem;
    color: #8b6914; line-height: 1.8;
}

.confetti-container { position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 300; }
.confetti { position: absolute; width: 10px; height: 10px; border-radius: 2px; animation: confettiFall 1.5s ease-out forwards; }
@keyframes confettiFall { 0% { transform: translateY(0) rotate(0deg) scale(1); opacity: 1; } 100% { transform: translateY(400px) rotate(720deg) scale(0); opacity: 0; } }

@keyframes popIn { 0% { opacity: 0; transform: scale(0.8); } 70% { transform: scale(1.05); } 100% { opacity: 1; transform: scale(1); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 576px) {
    .container { padding: 12px; }
    .header { padding: 12px 16px; flex-direction: column; gap: 10px; }
    .tab-nav { padding: 8px 12px; }
    .tab-item { min-width: 60px; padding: 10px 6px; font-size: 0.75rem; }
    .tab-item .icon { font-size: 1rem; }
    .tab-item .label { font-size: 0.65rem; }
    .stats-bar { grid-template-columns: repeat(2, 1fr); }
    .book-grid { grid-template-columns: repeat(2, 1fr); }
    .time-options { gap: 8px; }
    .time-option { padding: 12px 6px; font-size: 0.9rem; }
    .time-option .label { font-size: 0.65rem; }
    .timer-ring svg { width: 160px; height: 160px; }
    .timer-ring .timer-text { font-size: 1.8rem; }
    .control-buttons { flex-direction: column; }
    .control-btn { min-width: auto; }
    .modal-box { padding: 20px; }
    .form-input { padding: 14px 16px; }
    .cal-summary-grid { grid-template-columns: repeat(2, 1fr); }
    .stamp-card { flex-direction: column; text-align: center; }
}
