/* 字体（随项目一起放在 fonts/，SIL Open Font License 1.1，见 fonts/OFL-*.txt）：
   英文 Fredoka（圆润可爱、易读）；日文 M PLUS Rounded 1c（同样圆润的日文字体，粗细与 Fredoka 搭配）。
   英文字母用 Fredoka，日文字符自动落到 M PLUS Rounded 1c。 */
@font-face { font-family: "Fredoka"; src: url("../fonts/Fredoka.ttf") format("truetype"); font-weight: 300 700; font-display: swap; }
@font-face { font-family: "M PLUS Rounded 1c"; src: url("../fonts/MPLUSRounded1c-Bold.ttf") format("truetype"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "M PLUS Rounded 1c"; src: url("../fonts/MPLUSRounded1c-ExtraBold.ttf") format("truetype"); font-weight: 800 900; font-display: swap; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #F3DDD1; overflow: hidden; font-family: "Fredoka", "M PLUS Rounded 1c", "Arial Rounded MT Bold", "Hiragino Maru Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif; }
#stage { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: block; }

/* 画布上的 DOM 层：和画布同一个范围（main.js fit 设定位置；--k = 画布缩放比例，1920 宽时 = 1）*/
#stage-ui { position: fixed; pointer-events: none; --u: calc(var(--k, 1) * 1px); }
#start-screen { position: absolute; inset: 0; }
#start-screen[hidden] { display: none; }
#start-screen > * { pointer-events: auto; }

/* START：画面中央下方（title_screen_preview 的位置），可点击、有键盘焦点 */
#btn-start { position: absolute; left: 50%; top: 91%; transform: translate(-50%, -50%); width: calc(560 * var(--u)); padding: 0; background: none; border-radius: 999px; transition: transform 0.12s; }
#btn-start img { display: block; width: 100%; pointer-events: none; }
#btn-start:hover { transform: translate(-50%, -50%) scale(1.04); filter: none; }
#btn-start:active { transform: translate(-50%, -50%) scale(0.97); }
#btn-start:focus-visible { outline: 4px solid #fff; outline-offset: 2px; }
#start-note { position: absolute; left: 50%; top: 100%; transform: translateX(-50%); white-space: nowrap; font-size: max(11px, calc(18 * var(--u))); color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35); }

/* 两侧角落的小操作区（在水面上）*/
.op { position: absolute; bottom: 1.2%; width: 20%; display: flex; flex-direction: column; gap: calc(6 * var(--u)); font-size: max(11px, calc(15 * var(--u))); }
.op-left { left: 1%; }
.op-right { right: 1%; }
.card { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; gap: calc(4 * var(--u)) calc(8 * var(--u)); align-items: center; padding: calc(8 * var(--u)) calc(10 * var(--u)); border-radius: calc(16 * var(--u)); background: rgba(255, 255, 255, 0.86); border: 2px solid #d7d7d7; color: #245B91; }
.card .st { grid-column: 1 / -1; font-size: max(10px, calc(13 * var(--u))); color: #445; min-height: 1.3em; }
.card button { background: #258ACB; padding: calc(4 * var(--u)) calc(10 * var(--u)); font-size: inherit; }
.card .btns { display: flex; gap: calc(6 * var(--u)); justify-content: flex-end; }
.card button.usb { background: #7d8a96; }
.m5zero { background: #2e9d57; padding: calc(5 * var(--u)) calc(10 * var(--u)); font-size: inherit; }
.m5zero[hidden] { display: none; }
#debug button:disabled { opacity: 0.4; cursor: not-allowed; }
#btn-start:disabled { filter: grayscale(0.8) opacity(0.55); cursor: not-allowed; transform: translate(-50%, -50%); }
.card[data-src="serial"] { background: rgba(227, 246, 233, 0.95); border-color: #2e9d57; }
.card[data-src="sim"] { background: rgba(255, 240, 222, 0.95); border-color: #e8892b; }
.card[data-src="lost"] { background: rgba(253, 229, 229, 0.95); border-color: #d64545; }
.pid, .hint { margin: 0; padding: calc(4 * var(--u)) calc(10 * var(--u)); border-radius: calc(12 * var(--u)); background: rgba(255, 255, 255, 0.8); color: #6a5a4c; font-size: max(10px, calc(13 * var(--u))); }
.pid { display: flex; gap: 8px; align-items: center; }
.pid input { flex: 1; min-width: 0; font: inherit; padding: 2px 8px; border: 2px solid #d7d7d7; border-radius: 10px; }
.warn { color: #c0392b; }
.warn[hidden] { display: none; }
button { font: inherit; cursor: pointer; border: 0; border-radius: 12px; padding: 8px 14px; background: #F25C8E; color: #fff; }
button:hover { filter: brightness(1.08); }
#lang { position: fixed; right: 98px; top: 10px; height: 36px; display: flex; align-items: center; gap: 2px; padding: 0 6px; border-radius: 18px; background: rgba(0, 0, 0, 0.25); color: rgba(255, 255, 255, 0.8); font-size: 14px; }
#lang button { background: none; padding: 4px 6px; font-size: 14px; color: rgba(255, 255, 255, 0.75); border-radius: 10px; }
#lang button.on { background: rgba(255, 255, 255, 0.9); color: #245B91; font-weight: bold; }
#save-note { align-self: center; color: #fff; font-size: 16px; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4); }
/* 暂停按钮（位置由 main.js 放在语言切换的左边）+ 暂停画面 */
#btn-pause { position: fixed; right: 230px; top: 10px; width: 36px; height: 36px; padding: 0; border-radius: 50%; background: rgba(0, 0, 0, 0.25); font-size: 16px; color: #fff; opacity: 0.75; }
#btn-pause:hover { opacity: 1; }
#btn-pause[hidden], #pause-screen[hidden], #pause-confirm[hidden] { display: none; }
#pause-screen { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; background: rgba(20, 40, 60, 0.45); }
/* 排行榜（暂停画面同样的卡片样式）*/
#board { position: fixed; inset: 0; z-index: 25; display: flex; align-items: center; justify-content: center; background: rgba(20, 40, 60, 0.45); }
#board[hidden] { display: none; }
.board-card { min-width: min(560px, 90vw); }
.board-card .board-note { margin: -6px 0 14px; font-size: 14px; color: #7A93AD; }
#board-list { list-style: none; margin: 0 0 18px; padding: 0; max-height: 56vh; overflow-y: auto; text-align: left; }
#board-list li { display: grid; grid-template-columns: 44px 1fr auto 110px; gap: 10px; align-items: center; padding: 8px 12px; border-radius: 14px; font-size: 20px; }
#board-list li:nth-child(odd) { background: rgba(255, 255, 255, 0.8); }
#board-list li.me { background: #FFE3EC; font-weight: 700; }
#board-list li.empty { display: block; text-align: center; color: #7A93AD; }
#board-list .rk { font-weight: 900; color: #F25C8E; text-align: center; }
#board-list .pt { font-weight: 900; color: #245B91; }
#board-list .dt { font-size: 14px; color: #7A93AD; text-align: right; }
.board-btn { align-self: flex-end; background: #FFB84D; padding: calc(5 * var(--u)) calc(12 * var(--u)); font-size: inherit; }
#end-screen button.ghost { background: #FFB84D; }
.pause-card { min-width: 340px; max-width: 90vw; padding: 26px 34px; border-radius: 28px; background: #FFF8F0; text-align: center; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); color: #245B91; }
.pause-card h2 { margin: 0 0 18px; font-size: 40px; font-weight: 700; letter-spacing: 1px; }
.pause-card p { margin: 18px 0 12px; font-size: 18px; color: #445; }
.pause-row { display: flex; gap: 12px; justify-content: center; }
.pause-row button { font-size: 20px; padding: 10px 26px; border-radius: 24px; background: #3E9BE0; }
.pause-row button.ghost { background: #E3EAF1; color: #245B91; }
.pause-row button.pink { background: #F25C8E; }
#btn-mute { position: fixed; right: 54px; top: 10px; width: 36px; height: 36px; padding: 0; border-radius: 50%; background: rgba(0, 0, 0, 0.25); font-size: 18px; opacity: 0.6; }
#btn-mute:hover { opacity: 1; }
@media (prefers-reduced-motion: reduce) { #btn-start { transition: none; } }

#end-screen { position: fixed; left: 0; right: 0; bottom: 4vh; display: flex; justify-content: center; gap: 16px; }
#end-screen[hidden] { display: none; }
#end-screen button { font-size: 22px; padding: 10px 28px; border-radius: 30px; background: #258ACB; }
#end-screen button.pink { background: #F25C8E; }

#btn-gear { position: fixed; right: 10px; top: 10px; width: 36px; height: 36px; padding: 0; border-radius: 50%; background: rgba(0, 0, 0, 0.25); font-size: 20px; opacity: 0.5; }
#btn-gear:hover { opacity: 1; }
#debug { position: fixed; right: 10px; top: 54px; width: 470px; max-height: calc(100vh - 64px); overflow: auto; background: rgba(250, 250, 250, 0.96); border-radius: 14px; padding: 10px 14px; font-size: 13px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3); font-family: "Yu Gothic UI", "Meiryo", sans-serif; }
#debug[hidden] { display: none; }
#debug h3 { margin: 4px 0 8px; display: flex; justify-content: space-between; align-items: center; }
#debug h3 button { background: #999; padding: 2px 10px; }
#debug section { border-top: 1px solid #ddd; padding: 6px 0; }
#debug .row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 4px 0; }
#debug .row button { padding: 4px 10px; font-size: 13px; background: #4b6c8a; }
#debug .small { font-size: 12px; color: #555; }
#debug input[type=number] { width: 54px; }
#debug input[type=range] { flex: 1; }
