/* ===========================================================
   期末考试之精囊妙计 — 儿童搞笑风格 CSS
   移动优先，适配手机端
   =========================================================== */

/* ── 基础重置 ─────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
}

body {
    font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
    background: linear-gradient(135deg, #FFF8E7 0%, #FFE4B5 50%, #FFDAB9 100%);
    min-height: 100vh;
    color: #2C3E50;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

/* ── 容器 ─────────────────────────────────────────────── */
.container {
    max-width: 500px;
    margin: 0 auto;
    padding: 20px 16px 40px;
}

/* ── 页头 ─────────────────────────────────────────────── */
.header {
    text-align: center;
    margin-bottom: 8px;
}

.title {
    font-size: 1.6rem;
    color: #E74C3C;
    text-shadow: 2px 2px 0 #F9E79F;
    letter-spacing: 1px;
}

.subtitle {
    font-size: 0.9rem;
    color: #7F8C8D;
    margin-top: 4px;
}

.bounce {
    display: inline-block;
    animation: bounce 1.5s infinite;
}

.bounce:nth-child(3) {
    animation-delay: 0.75s;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* ── 装饰横幅 ─────────────────────────────────────────── */
.deco-banner {
    text-align: center;
    padding: 6px 0;
    font-size: 1.3rem;
    overflow: hidden;
}

.deco-emoji {
    display: inline-block;
    animation: float 3s ease-in-out infinite;
    margin: 0 4px;
}

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    33%  { transform: translateY(-6px) rotate(5deg); }
    66%  { transform: translateY(-2px) rotate(-5deg); }
}

/* ── 展示卡片 ─────────────────────────────────────────── */
.display-card {
    background: #FFFFFF;
    border: 3px dashed #FFD93D;
    border-radius: 20px;
    padding: 20px 18px 16px;
    margin: 10px 0;
    box-shadow:
        0 8px 20px rgba(255, 107, 107, 0.15),
        0 2px 6px rgba(0,0,0,0.08);
    position: relative;
    transition: transform 0.3s, box-shadow 0.3s;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.display-card.pop {
    animation: cardPop 0.4s ease;
}

@keyframes cardPop {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.03); }
    100% { transform: scale(1); }
}

.card-badge {
    position: absolute;
    top: -14px;
    left: 20px;
    background: linear-gradient(135deg, #FF6B6B, #FF8C94);
    color: #FFF;
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: bold;
    box-shadow: 0 3px 8px rgba(255,107,107,0.3);
}

.card-content {
    font-size: 1.2rem;
    line-height: 1.8;
    text-align: center;
    color: #2C3E50;
    padding: 8px 0;
    word-break: break-word;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    font-size: 0.85rem;
    color: #95A5A6;
}

.card-student {
    background: #F0F3F5;
    padding: 3px 10px;
    border-radius: 10px;
}

.card-likes {
    color: #E74C3C;
}

/* ── 按钮 ─────────────────────────────────────────────── */
.btn {
    display: block;
    width: 100%;
    padding: 14px 16px;
    font-size: 1.1rem;
    font-weight: bold;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
    font-family: inherit;
    letter-spacing: 1px;
    position: relative;
    overflow: hidden;
}

.btn:active {
    transform: scale(0.95);
}

.btn-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 10px 0;
}

.btn-random {
    background: linear-gradient(135deg, #FF6B6B, #FF8C94);
    color: #FFF;
    box-shadow: 0 4px 12px rgba(255,107,107,0.4);
}

.btn-sequential {
    background: linear-gradient(135deg, #4ECDC4, #6DD5CF);
    color: #FFF;
    box-shadow: 0 4px 12px rgba(78,205,196,0.4);
}

.btn-like {
    background: linear-gradient(135deg, #FFE66D, #F0C040);
    color: #2C3E50;
    box-shadow: 0 4px 12px rgba(255,230,109,0.5);
}

.btn-ranking {
    background: linear-gradient(135deg, #A8E6CF, #7ECFB0);
    color: #2C3E50;
    box-shadow: 0 4px 12px rgba(168,230,207,0.5);
}

.btn-submit {
    background: linear-gradient(135deg, #FF9A76, #FFB88C);
    color: #FFF;
    margin-top: 12px;
    box-shadow: 0 4px 12px rgba(255,154,118,0.4);
    font-size: 1rem;
}

/* ── Toast ────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: linear-gradient(135deg, #2C3E50, #34495E);
    color: #FFF;
    padding: 14px 28px;
    border-radius: 30px;
    font-size: 1rem;
    font-weight: bold;
    box-shadow: 0 8px 30px rgba(0,0,0,0.25);
    z-index: 1001;
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275),
                opacity 0.3s;
    white-space: nowrap;
    max-width: 90vw;
    text-align: center;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* ── 弹窗 ─────────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.open {
    display: flex;
}

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

.modal {
    background: #FFF;
    border-radius: 20px;
    width: 100%;
    max-width: 440px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 12px 40px rgba(0,0,0,0.2);
    animation: slideUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 2px dashed #F0F3F5;
}

.modal-header h2 {
    font-size: 1.2rem;
    color: #E74C3C;
}

.modal-close {
    background: #F0F3F5;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1rem;
    cursor: pointer;
    color: #7F8C8D;
    transition: background 0.2s;
}

.modal-close:active {
    background: #E0E4E8;
}

.modal-body {
    padding: 20px;
}

/* ── 排行榜 ───────────────────────────────────────────── */
.ranking-table {
    font-size: 0.9rem;
}

.ranking-header {
    display: grid;
    grid-template-columns: 32px 48px 1fr 42px;
    gap: 6px;
    padding: 8px 0;
    font-weight: bold;
    color: #7F8C8D;
    border-bottom: 2px solid #F0F3F5;
    font-size: 0.8rem;
}

.ranking-row {
    display: grid;
    grid-template-columns: 32px 48px 1fr 42px;
    gap: 6px;
    padding: 10px 0;
    border-bottom: 1px solid #F5F6F8;
    align-items: center;
}

.ranking-row:nth-child(1) .col-rank { color: #F1C40F; font-size: 1.2rem; }
.ranking-row:nth-child(2) .col-rank { color: #BDC3C7; font-size: 1.1rem; }
.ranking-row:nth-child(3) .col-rank { color: #E67E22; font-size: 1rem; }

.col-content {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.col-likes {
    color: #E74C3C;
    font-weight: bold;
}

.ranking-empty {
    text-align: center;
    color: #BDC3C7;
    padding: 40px 0;
    font-size: 1.1rem;
}

/* ── 表单 ─────────────────────────────────────────────── */
.form-label {
    display: block;
    font-weight: bold;
    margin: 16px 0 6px;
    font-size: 0.95rem;
}

.form-textarea {
    width: 100%;
    padding: 14px;
    border: 2px solid #F0F3F5;
    border-radius: 14px;
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.2s;
    background: #FAFBFC;
    -webkit-appearance: none;
}

.form-textarea:focus {
    outline: none;
    border-color: #FF6B6B;
}

.char-count {
    text-align: right;
    font-size: 0.8rem;
    color: #BDC3C7;
    margin-top: 4px;
}

.form-select {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid #F0F3F5;
    border-radius: 14px;
    font-size: 1rem;
    font-family: inherit;
    background: #FAFBFC;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237F8C8D' stroke-width='2' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

.form-select:focus {
    outline: none;
    border-color: #FF6B6B;
}

.btn-submit-tip {
    width: 100%;
    margin-top: 18px;
    background: linear-gradient(135deg, #FF9A76, #FF6B6B);
    color: #FFF;
    box-shadow: 0 4px 12px rgba(255,107,107,0.4);
}

.form-hint {
    text-align: center;
    font-size: 0.8rem;
    color: #BDC3C7;
    margin-top: 10px;
}

/* ── 访问统计 ─────────────────────────────────────────── */
.stats-bar {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 20px;
    padding: 12px 16px;
    background: rgba(255,255,255,0.6);
    border-radius: 16px;
    font-size: 0.8rem;
    color: #7F8C8D;
    flex-wrap: wrap;
}

.stats-bar strong {
    color: #E74C3C;
}

/* ── 响应式 ───────────────────────────────────────────── */
@media (min-width: 480px) {
    .container {
        padding: 30px 24px 50px;
    }
    .title {
        font-size: 1.8rem;
    }
    .card-content {
        font-size: 1.3rem;
    }
    .btn {
        font-size: 1.15rem;
    }
}

@media (min-width: 768px) {
    .container {
        padding: 40px 32px 60px;
    }
    .btn-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}
