/* ============================================================
   Candy Battle — 全局样式
   ============================================================ */

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #FFF5F7;
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    touch-action: none;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

/* ---- 旋转按钮（仅移动端可见） ---- */

.rotate-btn {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 10;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.85);
    box-shadow: 0 2px 8px rgba(90, 78, 107, 0.15);
    font-size: 18px;
    line-height: 40px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}

.rotate-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 14px rgba(90, 78, 107, 0.25);
}

/* 手机横屏/竖屏均显示旋转按钮 */
@media (max-width: 900px) {
    .rotate-btn {
        display: block;
    }
}

/* ---- 规则按钮 ---- */

.rules-entry {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 10;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.85);
    box-shadow: 0 2px 8px rgba(90, 78, 107, 0.15);
    font-size: 20px;
    line-height: 40px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}

.rules-entry:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 14px rgba(90, 78, 107, 0.25);
}

/* ---- 弹框遮罩 ---- */

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(90, 78, 107, 0.35);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}

.modal-overlay[hidden] {
    display: none;
}

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

/* ---- 弹框主体 ---- */

.modal-box {
    position: relative;
    width: min(520px, 90vw);
    max-height: 85vh;
    overflow-y: auto;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(90, 78, 107, 0.2);
    padding: 28px 32px 32px;
    animation: slideUp 0.25s ease;
}

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

.modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: transparent;
    font-size: 18px;
    color: #9B8FA8;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.modal-close:hover {
    background: #FFE8EC;
    color: #E06B8A;
}

.modal-box h2 {
    font-size: 22px;
    color: #5A4E6B;
    margin-bottom: 18px;
    text-align: center;
}

.rules-content h3 {
    font-size: 15px;
    color: #E06B8A;
    margin: 18px 0 8px;
}

.rules-content p {
    font-size: 14px;
    color: #5A4E6B;
    line-height: 1.7;
    margin-bottom: 6px;
}

.rules-content ul {
    padding-left: 20px;
    margin-bottom: 8px;
}

.rules-content li {
    font-size: 13px;
    color: #5A4E6B;
    line-height: 1.8;
}

.rules-content .tip {
    background: #FFF5F7;
    border-left: 3px solid #FF8FAB;
    padding: 8px 12px;
    border-radius: 0 8px 8px 0;
    font-size: 13px;
    margin: 8px 0;
}

/* ---- 移动端微调 ---- */

@media (max-width: 600px) {
    .modal-box {
        padding: 20px 18px 24px;
    }
    .modal-box h2 {
        font-size: 18px;
    }
    .rules-content h3 {
        font-size: 14px;
    }
    .rules-content p, .rules-content li {
        font-size: 12px;
    }
}

/* ---- 竖屏提示 ---- */

.rotate-hint {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    background: #FFF5F7;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    animation: fadeIn 0.3s ease;
}

.rotate-hint-content {
    padding: 24px;
}

.rotate-icon {
    font-size: 48px;
    margin-bottom: 16px;
    animation: rotatePhone 2s ease-in-out infinite;
}

@keyframes rotatePhone {
    0%, 100% { transform: rotate(0deg); }
    25%      { transform: rotate(90deg); }
    50%      { transform: rotate(90deg); }
    75%      { transform: rotate(0deg); }
}

.rotate-hint p {
    color: #5A4E6B;
    font-size: 20px;
    font-weight: bold;
    margin: 0;
}

.rotate-hint-btn {
    margin-top: 16px;
    padding: 10px 24px;
    border: none;
    border-radius: 24px;
    background: #FF8FAB;
    color: #fff;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 3px 12px rgba(255, 143, 171, 0.4);
    transition: transform 0.15s, box-shadow 0.15s;
}

.rotate-hint-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 18px rgba(255, 143, 171, 0.5);
}

.rotate-sub {
    color: #9B8FA8 !important;
    font-size: 14px !important;
    font-weight: normal !important;
    margin-top: 8px !important;
}

/* 手机竖屏时显示提示，横屏或 PC 不显示 */
@media (orientation: portrait) and (max-width: 900px) {
    .rotate-hint {
        display: flex;
    }
}
