/* 马善政毛笔楷书：本地化自 fonts/，不依赖 Google Fonts
   （fonts.googleapis.com 国内常不可达，会导致字体静默回退到系统黑体） */
@font-face {
    font-family: 'Ma Shan Zheng';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('./fonts/ma-shan-zheng.woff2') format('woff2');
}

/* 全局和基础样式 */
* {
	    margin: 0;
	    padding: 0;
	    box-sizing: border-box;
	}
	body {
	    font-family: 'Ma Shan Zheng', KaiTi, STKaiti, '楷体', serif; /* 引入书法字体 */
	    overflow: hidden; /* 防止滚动条 */
	    background: #000; /* 默认黑色背景 */
	}
	/* 游戏画布 */
	#gameCanvas {
	    display: block;
		width: 100vw;
        height: 100vh;
        /* dvh = 动态视口高度，避开手机地址栏/手势条，防止底部月饼盒被遮挡 */
        height: 100dvh;
        touch-action: none;
        -ms-touch-action: none;
        user-select: none;
        -webkit-user-select: none;
        /* iOS：长按画布会弹「拷贝 / 查询」气泡。出片模式正是靠**长按**退出，
           必须把它压住，否则长按被系统截胡、根本到不了我们的计时器。 */
        -webkit-touch-callout: none;
        /* 可选：防止模糊 */
        image-rendering: pixelated;
	    background: radial-gradient(ellipse at bottom, #1b2735 0%, #090a0f 100%); /* 深邃星空背景 */
	}
	/* UI层 */
	#ui {
	    position: absolute;
	    top: 0;
	    left: 0;
	    width: 100%;
	    height: 100%;
	    pointer-events: none; /* 允许点击穿透到画布 */
	    color: #fff;
	    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
	}
/* 出片模式：进入时的 3 秒提示（长按是不可见的交互，必须告知一次）。
   显隐全由 js/photo-mode.js 的 applyPhotoHint() 管：开 → 'block'，关 → 'none'。
   ★ 这里**刻意不写 display** —— 默认隐藏放在 index.html 的行内 style 上。
     若在这里写 display:none，JS 恢复时若写成清空行内（''）就会被这条顶回来。 */
#photo-hint {
    position: absolute;
    top: 14%;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 20px;
    font-size: 16px;
    letter-spacing: 1px;
    white-space: nowrap;
    color: #f7e6b4;
    background: rgba(8, 8, 12, 0.62);
    border: 1px solid rgba(240, 216, 144, 0.35);
    border-radius: 999px;
    text-shadow: 0 0 8px rgba(240, 216, 144, 0.45);
}
#score {
    position: absolute;
    top: 20px;
    left: 20px;
    font-size: 22px;
    color: #f0d890; /* 赤金色 */
    padding: 5px 14px;
    background: rgba(20, 16, 12, 0.55);
    border: 1px solid rgba(240, 216, 144, 0.45);
    border-radius: 3px;
    text-shadow: 0 0 8px rgba(240, 216, 144, 0.5);
}
	#moon-energy-container {
	    position: absolute;
	    top: 20px;
	    right: 20px;
	    text-align: right;
	}
	#moon-energy-label {
	    font-size: 20px;
	    /* ★ 与月晕金环**同源**（玩家2026-09-20：「把月华的文字颜色也修改成与月晕颜色匹配」）。
	       条是 #ffbe00 → #ffff50，文字取其中最亮的那一档 #ffff50，
	       连辉光也换成金色（原来是月白 #a0d8ef）——
	       于是「月华」这三个字、下面那条进度、画面上那圈光环，是同一套暖金。
	       ⚠ 别再退回月白：那跟金环是两套色，一眼就分家。 */
	    color: #ffff50;
	    margin-bottom: 5px;
	    text-shadow: 0 0 10px rgba(255, 190, 0, 0.85), 0 0 22px rgba(255, 222, 40, 0.45);
	}
#moon-energy-bar {
    /* ⚠ 真实宽度由 js/globals.js 的 syncMoonEnergyBarWidth() 在运行时设成
       「月亮边缘 → 月晕最大边缘」那段带宽
       （月亮半径 × (MOON_HALO_RADIUS_MUL − 1) = 60 × 1.8 = 108px）。
       这里这行只是 JS 没跑到时的兜底，**别当成真值**。
       max-width 是窄屏兜底：条再宽也不许顶到屏幕左边去。 */
    width: 200px;
    max-width: calc(100vw - 40px);
    height: 20px;
    border: 1px solid rgba(240, 216, 144, 0.7);
    border-radius: 2px;
    background: rgba(20, 16, 12, 0.6);
    position: relative;
}
/* 内侧第二道线：简化回纹，取代原先的荧光外发光 */
#moon-energy-bar::after {
    content: '';
    position: absolute;
    inset: 2px;
    border: 1px solid rgba(240, 216, 144, 0.22);
    pointer-events: none;
}
#moon-energy-fill {
    height: 100%;
    width: 100%;
    /* ★ 与月晕金环**同源**（玩家 2026-09-20：「把月华进度条颜色修改成与月晕颜色匹配」）。
       月晕的色阶是 rgba(255,255,80)（内档，贴着月轮）→ rgba(255,190,0)（外档）。
       条按同一个几何铺：**左端 = 月晕最外圈**（#ffbe00）、**右端 = 月亮边缘**（#ffff50）。
       于是「条还剩多少」与「光环还铺多远」不但尺度一样（见 globals.js 的条宽），
       连颜色走向都一致 —— 满格时右端那截最亮的淡金，正是贴着月轮的那一圈。
       ⚠ 别再改回靛青/月白：那跟画面上那圈金环是两套色，一眼就分家。 */
    background: linear-gradient(90deg, #ffbe00, #ffde28 55%, #ffff50);
    border-radius: 0;
    transition: width 0.3s ease-out;
    box-shadow: 0 0 8px rgba(255, 200, 0, 0.5);
}
	/* 菜单屏幕样式 */
    /* 「自动演奏」原来是画布左上角一个绝对定位的浮动面板（#auto-music-panel）。
       2026-09-18 收进月饼图鉴成了第 4 个页签，所以这里不再需要定位 ——
       只剩「控件长什么样」，位置交给图鉴面板的流式布局。
       ⚠ 别再给 #auto-music-content 加 position/top/left：它现在在面板里，不是浮层。 */
    #auto-music-content {
        padding: 6px 2px;
        text-align: center;
        font-family: 'Ma Shan Zheng', KaiTi, STKaiti, '楷体', serif;
        color: #e8dcc0;
    }
    #auto-music-content select,
    #auto-music-content button {
        height: 34px;
        border: 1px solid rgba(240, 216, 144, 0.65);
        border-radius: 6px;
        background: rgba(20, 14, 10, 0.86);
        color: #f0d890;
        font-family: 'Ma Shan Zheng', KaiTi, STKaiti, '楷体', serif;
        font-size: 16px;
    }
    #auto-music-content button {
        min-width: 96px;
        cursor: pointer;
        padding: 0 14px;
    }
    #auto-music-content button.active {
        background: #f0d890;
        color: #1c1208;
        box-shadow: 0 0 12px rgba(240, 216, 144, 0.65);
    }
    /* 四个可调项（音量 / 节拍速度 / 循环 / 自动补字）：左标签 · 中控件 · 右读数 */
    #auto-music-content .am-row {
        display: flex;
        align-items: center;
        gap: 10px;
        margin-top: 10px;
        text-align: left;
    }
    #auto-music-content .am-label {
        flex: 0 0 62px;
        font-size: 14px;
        color: #cdbb8a;
        letter-spacing: 1px;
    }
    #auto-music-content .am-val {
        flex: 0 0 52px;
        font-size: 14px;
        color: #f0d890;
        text-align: right;
        font-variant-numeric: tabular-nums;
    }
    /* 滑块：accent-color 是深色底下最省事也最稳的做法（不必重画 thumb/track）。
       高度给 34px 是为了手指好按 —— 真画出来的滑轨只有几像素，但命中区是整个盒子。 */
    #auto-music-content input[type="range"] {
        flex: 1 1 auto;
        min-width: 0;
        height: 34px;
        margin: 0;
        background: transparent;
        accent-color: #d4af37;
        cursor: pointer;
    }
    /* 行内的按钮不跟着上面那条 min-width:96px 走，让它自己撑满剩余宽度 */
    #auto-music-content .am-row button {
        flex: 1 1 auto;
        min-width: 0;
    }
	.screen {
	    position: absolute;
	    top: 0;
	    left: 0;
	    width: 100%;
	    height: 100%;
	    display: flex;
	    flex-direction: column;
	    justify-content: center;
	    align-items: center;
	    background: rgba(0, 0, 0, 0.7);
	    color: #fff;
	    text-align: center;
	    transition: opacity 0.5s;
	}
.screen h1 {
    /* 竖排右起：国风最强的视觉信号之一，纯 CSS、零风险 */
    writing-mode: vertical-rl;
    text-orientation: upright;
    font-size: clamp(32px, 8vh, 54px);
    letter-spacing: 0.18em;
    margin-bottom: 18px;
    max-height: 58vh;
    color: #f0d890;
    /* 原为双层强发光（霓虹感），改为柔和单层 */
    text-shadow: 0 0 14px rgba(240, 216, 144, 0.6);
    animation: pulse 2s infinite;
}
	.screen p {
	    font-size: 24px;
	    margin-bottom: 40px;
	    color: #a0d8ef;
	}
.screen button {
    padding: 14px 34px;
    margin: 6px 0;
    font-size: 22px;
    font-family: 'Ma Shan Zheng', KaiTi, STKaiti, '楷体', serif;
    letter-spacing: 0.16em;
    color: #f0d890;
    background: rgba(31, 27, 27, 0.85);   /* 玄底 */
    border: 2px solid #c3272b;            /* 朱砂边 */
    border-radius: 3px;                   /* 方角：印章而非胶囊 */
    cursor: pointer;
    /* 内侧一道金线形成双线边框，取代原先的荧光发光 */
    box-shadow: inset 0 0 0 1px rgba(240, 216, 144, 0.35);
    transition: transform 0.2s, background 0.2s, color 0.2s;
}
.screen button:hover {
    transform: scale(1.05);
    background: #c3272b;
    color: #fff6d8;
    box-shadow: inset 0 0 0 1px rgba(240, 216, 144, 0.5);
}
/* 菜单上的「从头开始」：样式从 .screen button 继承，这里只压小一号 ——
   它是次选，别跟「开始游戏」抢眼。显示/隐藏由 progress-save.js 控制。 */
#new-run-button {
    font-size: 16px;
    padding: 8px 20px;
    letter-spacing: 0.1em;
    border-color: rgba(195, 39, 43, 0.55);
    opacity: 0.85;
}
.hidden {
    display: none !important;
}
/* 月饼图鉴：面板开着时动态跟随月饼盒，数量变多的月饼闪一下，
   让玩家一眼看到「刚击落的那块进盒了」 */
@keyframes mcPop {
    0%   { transform: scale(0.55); filter: brightness(2.4); }
    55%  { transform: scale(1.14); filter: brightness(1.5); }
    100% { transform: scale(1);    filter: brightness(1); }
}
.mc-pop {
    animation: mcPop 0.55s ease-out;
}
/* 连击显示 */
#combo-display {
    position: absolute;
    top: 55px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 36px;
    color: #ff6b35;
    text-shadow: 0 0 20px #ff6b35, 0 0 40px #ff4500;
    animation: comboPulse 0.3s ease-out;
    pointer-events: none;
    z-index: 50;
    white-space: nowrap;
}
#combo-display .combo-num {
    font-size: 48px;
    font-weight: bold;
}
#combo-display .combo-mult {
    font-size: 22px;
    color: #f0d890;
}
@keyframes comboPulse {
    0% { transform: translateX(-50%) scale(0.5); opacity: 0; }
    50% { transform: translateX(-50%) scale(1.2); opacity: 1; }
    100% { transform: translateX(-50%) scale(1); opacity: 1; }
}
/* 波次显示 */
#wave-display {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 18px;
    color: #a0d8ef;
    text-shadow: 0 0 10px #a0d8ef;
    pointer-events: none;
    z-index: 50;
    text-align: center;
}
#wave-display .wave-label {
    font-size: 14px;
    opacity: 0.7;
}
/* 里程碑弹窗 */
#milestone-display {
    position: absolute;
    top: 35%;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 60;
    text-align: center;
}
#milestone-display .milestone-text {
    font-size: 32px;
    color: #FFD700;
    text-shadow: 0 0 25px #FFD700, 0 0 50px #FF8C00;
    animation: milestoneShow 2s ease-out forwards;
    white-space: nowrap;
}
#milestone-display .milestone-desc {
    font-size: 18px;
    color: #f0d890;
    text-shadow: 0 0 15px #f0d890;
    animation: milestoneShow 2s ease-out forwards;
    animation-delay: 0.2s;
    opacity: 0;
}
@keyframes milestoneShow {
    0% { transform: scale(0.3); opacity: 0; }
    15% { transform: scale(1.1); opacity: 1; }
    85% { transform: scale(1); opacity: 1; }
    100% { transform: scale(1.2); opacity: 0; }
}
/* 最终统计 */
#final-stats {
    font-size: 16px;
    color: #a0d8ef;
    line-height: 1.8;
}
#final-stats span {
    color: #f0d890;
    font-weight: bold;
}
#high-score-display {
    font-size: 18px;
    color: #FFD700;
    text-shadow: 0 0 10px #FFD700;
    margin-bottom: 20px;
}
	@keyframes pulse {
	    0%, 100% { transform: scale(1); }
	    50% { transform: scale(1.05); }
	}
/* 落款朱砂印：菜单与结算页的收尾点缀 */
.seal {
    margin-top: 20px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    writing-mode: vertical-rl;
    text-orientation: upright;
    font-size: 15px;
    letter-spacing: 0.08em;
    color: #fff6d8;
    background: #c3272b;
    border-radius: 3px;
    opacity: 0.88;
    box-shadow: 0 0 0 2px rgba(195, 39, 43, 0.3);
    user-select: none;
}

/* ============================================================
   结算成诗：竖排五绝
   竖排用 writing-mode: vertical-rl —— 块级子元素会从右往左依次排成列，
   所以 DOM 顺序是「诗题 → 首句 → … → 末句」，视觉上诗题正好在最右。
   ============================================================ */
#settlement-poem {
    display: inline-block;
    margin: 4px auto 16px;
    padding: 14px 18px 12px;
    background: rgba(20, 16, 12, 0.62);
    border: 1px solid rgba(212, 175, 55, 0.45);
    border-radius: 4px;
    max-width: 92%;
}
#settlement-poem.hidden { display: none; }
.sp-body {
    writing-mode: vertical-rl;
    text-orientation: upright;
    height: 150px;
    margin: 0 auto;
    color: #f5ebd2;
    font-size: 21px;
    line-height: 1.14;
    letter-spacing: 0.05em;
    text-shadow: 0 0 10px rgba(240, 216, 144, 0.35);
}
/* 竖排下 margin-left 就是「与左边那一列之间的间距」 */
.sp-title {
    font-size: 17px;
    color: #f0d890;
    margin-left: 14px;
}
.sp-line { margin-left: 8px; }
.sp-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    font-size: 13px;
    color: #c9b98a;
}
.sp-grade { color: #f0d890; }
.sp-slips { color: #e08a86; }
.over-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ============================================================
   广寒宫
   ============================================================ */
#guanghan-screen {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.82);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 12px;
}
#guanghan-screen.hidden { display: none; }
.gh-panel {
    width: min(94vw, 520px);
    max-height: 88vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: #2c1810;
    border: 3px solid #d4af37;
    border-radius: 12px;
    padding: 16px;
    box-sizing: border-box;
    box-shadow: 0 0 30px rgba(212, 175, 55, 0.45);
}
.gh-head {
    margin: 0 0 10px;
    color: #f0d890;
    text-align: center;
    font-size: 22px;
    letter-spacing: 6px;
    font-weight: 400;
}
.gh-purse {
    display: flex;
    justify-content: center;
    gap: 18px;
    margin-bottom: 12px;
    font-size: 15px;
    color: #f5ebd2;
}
.gh-cur b { color: #f0d890; font-size: 18px; }
.gh-ico {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 5px;
    border-radius: 50%;
}
.gh-ico-slip { background: #f5ebd2; }
.gh-ico-cake { background: #d4af37; }
.gh-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.gh-tab {
    flex: 1;
    padding: 9px 4px;
    min-height: 40px;
    background: rgba(240, 216, 144, 0.08);
    color: #c9b98a;
    border: 1px solid rgba(212, 175, 55, 0.35);
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.gh-tab-on {
    background: rgba(240, 216, 144, 0.22);
    color: #f0d890;
    border-color: #d4af37;
}
.gh-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}
.gh-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 6px;
    min-height: 98px;
    background: rgba(20, 16, 12, 0.6);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 8px;
    color: #e8dcc0;
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.gh-card.gh-equipped {
    background: rgba(240, 216, 144, 0.14);
    border-color: #d4af37;
}
.gh-card.gh-poor { opacity: 0.5; }
.gh-card.gh-sel { outline: 1px solid #f0d890; }
.gh-swatch {
    display: block;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid;
}
.gh-swatch-robe { border-radius: 50% 50% 42% 42%; }
/* 诗帛材质：色板做成**竖直长条**（帛本来就是竖的），而不是圆形 ——
   一眼就能和「服饰 / 月面皮肤」那两类圆色板区分开。 */
.gh-swatch-silk {
    width: 20px;
    height: 34px;
    border-radius: 3px;
}
.gh-name { color: #f0d890; font-size: 15px; }
.gh-cost { font-size: 12px; opacity: 0.72; }
.gh-state { font-size: 12px; opacity: 0.6; }
.gh-slip {
    grid-column: 1 / -1;
    align-items: flex-start;
    text-align: left;
}
.gh-slip-title { color: #f0d890; font-size: 15px; }
.gh-slip-text { font-size: 13px; line-height: 1.5; opacity: 0.85; }
.gh-empty {
    grid-column: 1 / -1;
    padding: 24px 8px;
    text-align: center;
    font-size: 13px;
    line-height: 1.8;
    opacity: 0.6;
}
.gh-detail {
    margin-top: 12px;
    padding: 10px 12px;
    min-height: 58px;
    background: rgba(20, 16, 12, 0.5);
    border: 1px solid rgba(212, 175, 55, 0.25);
    border-radius: 8px;
    color: #c9b98a;
    font-size: 13px;
    line-height: 1.7;
}
.gh-d-title { color: #f0d890; font-size: 16px; }
.gh-d-text { color: #e8dcc0; }
.gh-d-meta { font-size: 12px; opacity: 0.65; }
.gh-hint { opacity: 0.6; }
.gh-foot { margin-top: 14px; text-align: center; }
#close-guanghan {
    padding: 10px 28px;
    min-height: 44px;
    background: #8B4513;
    color: white;
    border: 2px solid #d4af37;
    border-radius: 8px;
    font-family: inherit;
    font-size: 17px;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
