@font-face {
  font-family: "ZenMaru";
  src: url("../fonts/zen-maru-gothic-black-subset-perf1.woff2?v=20261130-perf1") format("woff2");
  font-weight: 900;
  font-display: swap;
}

:root {
  --broth: #2a0c07;
  --broth-2: #4a160c;
  --tomato: #e8483b;
  --orange: #ff8a3d;
  --cream: #fff3e2;
  --cream-2: #ffe1c2;
  --brown: #5b3426;
  --gold: #ffd84a;
  --pink: #ff9cc0;
  --sky: #8fdcff;
  --font: "ZenMaru", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --field-x0: 0px;
  --field-w: 100vw;
  --judge-y: 80vh;
  --view-h: 100vh;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--broth); color: var(--cream);
  font-family: var(--font); font-weight: 900;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none; user-select: none;
  overscroll-behavior: none;
}
#app { position: fixed; inset: 0; overflow: hidden; touch-action: auto; }
#field { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; display: block; touch-action: auto; }

/* v2：MV 背景。影片已預先模糊；亮度／飽和度由 rhythm-bg.js 每幀寫進 filter，空間上的壓暗畫在畫布上 */
.bg-layer {
  position: absolute; inset: 0; z-index: 0; width: 100%; height: 100%;
  object-fit: cover; pointer-events: none; visibility: hidden;
  background: var(--broth);
}
.bg-poster { filter: brightness(.5) saturate(.9); }
#app[data-bg="video"][data-screen="play"] .bg-video,
#app[data-bg="video"][data-screen="pause"] .bg-video { visibility: visible; }
#app[data-bg="video"]:not([data-screen="play"]):not([data-screen="pause"]) .bg-poster,
#app[data-bg="poster"] .bg-poster { visibility: visible; }
#app[data-bg="video"][data-bg-resuming="true"] .bg-video { visibility: hidden; }
#app[data-bg="video"][data-bg-resuming="true"] .bg-poster { visibility: visible; }
#app[data-screen="loading"] .bg-layer, #app[data-black="true"] .bg-layer { visibility: hidden !important; }
.rhythm-playing-locked { touch-action: none; overscroll-behavior: none; overflow: hidden; }
.rhythm-playing-locked img { -webkit-user-drag: none; }
.rhythm-playing-locked { -webkit-touch-callout: none; }

/* 美美：桌機站在軌道右邊；手機縮小躲在鍋緣下 */
.meimei {
  position: absolute; z-index: 2; pointer-events: none;
  left: calc(var(--field-x0) + var(--field-w) + 3vw);
  top: calc(var(--judge-y) - min(58vh, 560px) + 4vh);
  height: min(58vh, 560px); width: auto;
  transform-origin: 50% 100%;
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, .45));
  transition: opacity .3s;
  will-change: transform;
}
/* 火力階段：越高越亮（光暈是固定的，每幀只動 transform） */
.meimei[data-tier="hot"] { filter: drop-shadow(0 12px 24px rgba(0, 0, 0, .45)) drop-shadow(0 0 16px rgba(255, 150, 60, .55)); }
.meimei[data-tier="boil"] { filter: drop-shadow(0 12px 24px rgba(0, 0, 0, .45)) drop-shadow(0 0 26px rgba(255, 200, 90, .85)); }
.meimei.oops { filter: drop-shadow(0 12px 24px rgba(0, 0, 0, .45)) saturate(.75); }
#app[data-screen="title"] .meimei, #app[data-screen="result"] .meimei,
#app[data-screen="loading"] .meimei, #app[data-screen="calib"] .meimei { opacity: 0; }
@media (max-width: 1080px) and (min-width: 720px) {
  .meimei { height: min(40vh, 360px); top: calc(var(--judge-y) - min(40vh, 360px) + 3vh); left: calc(var(--field-x0) + var(--field-w) + 1vw); }
}
@media (max-width: 719px) {
  .meimei {
    left: auto; right: -8px;
    top: auto; bottom: -6px;
    height: calc(var(--view-h) - var(--judge-y) - 18px); max-height: 150px;
    opacity: .95;
  }
}

/* HUD */
.hud { position: absolute; inset: 0; z-index: 5; pointer-events: none; display: none; }
#app[data-screen="play"] .hud, #app[data-screen="pause"] .hud { display: block; }
.hud-bar {
  position: absolute; top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  width: min(var(--field-w), 100vw - 16px); display: flex; align-items: center; gap: 10px;
  padding: 6px 8px 6px 14px; border-radius: 999px;
  background: rgba(20, 6, 3, .62); border: 2px solid rgba(255, 160, 90, .35);
}
.hud-song { flex: 1; display: flex; align-items: baseline; gap: 8px; font-size: 15px; white-space: nowrap; overflow: hidden; }
.hud-song b { font-size: 19px; color: var(--cream); }
.hud-song span { color: var(--cream-2); opacity: .85; }
.hud-auto { background: var(--tomato); color: #fff !important; opacity: 1 !important; border-radius: 6px; padding: 1px 6px; font-size: 12px; }
.hud-score { display: flex; align-items: baseline; gap: 6px; font-size: 22px; font-variant-numeric: tabular-nums; color: var(--gold); }
.hud-score small { font-size: 11px; color: var(--cream-2); }
.hud-pause {
  pointer-events: auto; width: 38px; height: 38px; border-radius: 50%;
  border: 2px solid rgba(255, 220, 190, .5); background: rgba(255, 240, 225, .1);
  color: var(--cream); font: inherit; font-size: 13px; cursor: pointer;
}
.hud-progress {
  position: absolute; top: calc(max(10px, env(safe-area-inset-top)) + 56px); left: 50%; transform: translateX(-50%);
  width: min(var(--field-w), 100vw - 16px); height: 5px; border-radius: 3px; background: rgba(255, 220, 190, .14); overflow: hidden;
}
.hud-progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--orange), var(--gold)); border-radius: 3px; }
/* 火力（美美的 combo 階段）：桌機放在美美腳下，手機放在鍋身左下（都不擋音符進場） */
.hud-heat {
  position: absolute; left: calc(var(--field-x0) + var(--field-w) + 3vw); top: calc(var(--judge-y) + 4vh + 14px);
  display: flex; align-items: center; gap: 5px; padding: 5px 10px; border-radius: 999px;
  background: rgba(20, 6, 3, .62); border: 2px solid rgba(255, 160, 90, .3);
  font-size: 12px; color: var(--cream-2);
}
@media (max-width: 1080px) and (min-width: 720px) {
  .hud-heat { left: calc(var(--field-x0) + var(--field-w) + 1vw); top: calc(var(--judge-y) + 3vh + 10px); }
}
@media (max-width: 719px) {
  .hud-heat { left: 10px; top: auto; bottom: max(12px, env(safe-area-inset-bottom)); }
}
.hud-heat b { font-size: 14px; color: var(--cream); margin-right: 3px; min-width: 2.2em; text-align: right; }
.hud-heat i { width: 16px; height: 6px; border-radius: 3px; background: rgba(255, 220, 190, .18); }
.hud-heat[data-tier="0"] i:nth-of-type(1),
.hud-heat[data-tier="1"] i:nth-of-type(-n+2),
.hud-heat[data-tier="2"] i:nth-of-type(-n+3),
.hud-heat[data-tier="3"] i { background: linear-gradient(90deg, var(--orange), var(--gold)); }
.hud-heat[data-tier="3"] b { color: var(--gold); text-shadow: 0 0 10px rgba(255, 150, 60, .9); }
@media (max-width: 719px) {
  #app[data-rotation="on"] .hud-heat {
    top: calc(max(10px, env(safe-area-inset-top)) + 62px); bottom: auto; left: 12px; padding: 1px 6px;
    font-size: 10px; line-height: 12px;
  }
  #app[data-rotation="on"] .hud-heat b { font-size: 12px; }
  #app[data-rotation="on"] .hud-heat i { width: 12px; height: 5px; }
  #app[data-rotation="on"] #meimei { opacity: 0; }
}
.hud-section {
  position: absolute; left: 50%; top: calc(var(--judge-y) * .17 + 40px); transform: translate(-50%, -50%) scale(.9);
  font-size: clamp(30px, 7vw, 58px); color: var(--cream); letter-spacing: .08em; white-space: nowrap;
  text-shadow: 0 4px 0 rgba(120, 30, 10, .9), 0 0 26px rgba(255, 140, 60, .8);
  opacity: 0; transition: opacity .25s, transform .25s;
}
.hud-section small { display: block; text-align: center; font-size: .38em; letter-spacing: .2em; color: var(--gold); }
.hud-section.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.hud-section.rotating {
  left: auto; right: 12px; top: 154px; max-width: 86px;
  transform: translateY(-50%) scale(.9); font-size: 18px; text-align: center;
  letter-spacing: .02em; white-space: normal;
}
.hud-section.rotating.show { transform: translateY(-50%) scale(1); }
.hud-section.rotating small { font-size: 8px; letter-spacing: .05em; }
.hud-count {
  position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%);
  font-size: clamp(56px, 14vw, 120px); color: var(--gold);
  text-shadow: 0 6px 0 rgba(120, 30, 10, .9), 0 0 30px rgba(255, 160, 60, .9);
}

/* 全黑半拍：瞬間全黑，不做淡入淡出 */
.blackout { position: absolute; inset: 0; z-index: 50; background: #000; opacity: 0; pointer-events: none; }
.blackout.on { opacity: 0; } /* Compatibility element must never cover play controls. */

/* 各畫面 */
.screen { position: absolute; inset: 0; z-index: 10; display: none; }
#app[data-screen="loading"] #screen-loading,
#app[data-screen="title"] #screen-title,
#app[data-screen="calib"] #screen-calib,
#app[data-screen="pause"] #screen-pause,
#app[data-screen="result"] #screen-result { display: flex; }

.screen-loading { align-items: center; justify-content: center; flex-direction: column; gap: 18px; padding: 18px; text-align: center; background: var(--broth); }
.screen-loading .btn-row { justify-content: center; margin: 0; animation: reveal-loading-actions 0s 12s backwards; }
.screen-loading[data-load-failed] .btn-row { animation: none; }
@keyframes reveal-loading-actions { from { visibility: hidden; } }
.loader { display: flex; gap: 10px; }
.loader span { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--cream-2); animation: bub 1s infinite ease-in-out; }
.loader span:nth-child(2) { animation-delay: .15s; } .loader span:nth-child(3) { animation-delay: .3s; }
@keyframes bub { 0%, 100% { transform: translateY(0); opacity: .4; } 50% { transform: translateY(-14px); opacity: 1; } }

.screen-title, .screen-result {
  align-items: center; justify-content: center; gap: 2vw; padding: 24px;
  background: radial-gradient(120% 90% at 30% 70%, rgba(255, 120, 50, .28), rgba(30, 8, 5, .82) 60%), rgba(30, 8, 5, .55);
  overflow-y: auto; touch-action: pan-y pinch-zoom;
}
.title-art, .result-art { flex: 0 1 auto; display: flex; justify-content: center; }
.title-art img, .result-art img { height: min(78vh, 680px); width: auto; filter: drop-shadow(0 18px 30px rgba(0, 0, 0, .5)); animation: sway 2.4s infinite ease-in-out; transform-origin: 50% 100%; }
@keyframes sway { 0%, 100% { transform: rotate(-1.5deg) translateY(0); } 50% { transform: rotate(1.5deg) translateY(-8px); } }
.title-panel { width: min(520px, 100%); display: flex; flex-direction: column; gap: 14px; }
.screen-title { align-items: flex-start; }
.title-art { align-self: center; }
.title-panel { flex-shrink: 0; margin-block: auto; }
.title-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hub-return { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; white-space: nowrap; }
.song-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.song-choice { min-height: 66px; min-width: 0; padding: 11px 12px; border: 2px solid rgba(255, 220, 190, .25); border-radius: 16px; background: rgba(20, 6, 3, .4); color: var(--cream); font: inherit; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.song-choice b { font-size: 21px; line-height: 1.4; overflow-wrap: anywhere; }
.song-choice small { color: var(--cream-2); font-size: 12px; line-height: 1.4; }
.song-choice[aria-checked="true"] { border-color: var(--gold); background: rgba(255, 200, 90, .14); }
.song-choice:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.song-special-choice { margin: 10px 0 14px; text-decoration: none; border-color: rgba(255, 200, 90, .65); background: rgba(255, 200, 90, .08); }
.song-special-choice b { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 20px; }
.song-special-tag { color: var(--gold); font-size: 11px; line-height: 1.5; letter-spacing: .04em; }
.song-heat { margin-top: 12px; }
.logo.logo-long { font-size: clamp(40px, 7vw, 72px); letter-spacing: 0; }
#app[data-screen="play"], #app[data-screen="play"] #field { touch-action: none; overscroll-behavior: none; }
.song-current { padding: 18px 22px 20px; border: 2px solid var(--orange); border-radius: 22px; background: rgba(255, 138, 61, .1); }
.song-status { display: flex; align-items: center; gap: 7px; margin: 0 0 8px; color: var(--gold); font-size: 13px; }
.song-status span { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 9px rgba(255, 216, 74, .45); }
.song-soon { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.song-locked { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; min-width: 0; padding: 13px 6px 12px; border: 2px solid rgba(255, 220, 190, .18); border-radius: 16px; background: rgba(20, 6, 3, .4); color: var(--cream-2); font: inherit; text-align: center; opacity: 1; }
.song-locked b { font-size: 17px; line-height: 1.4; overflow-wrap: anywhere; }
.song-locked small { font-size: 12px; line-height: 1.4; color: #e3b79a; }
.song-lock { position: relative; display: block; width: 13px; height: 11px; margin-top: 5px; border: 2px solid #e3b79a; border-radius: 3px; }
.song-lock::before { content: ""; position: absolute; width: 7px; height: 7px; left: 1px; top: -8px; border: 2px solid #e3b79a; border-bottom: 0; border-radius: 6px 6px 0 0; }
.eyebrow { margin: 0; color: var(--gold); font-size: 15px; letter-spacing: .14em; }
.logo {
  margin: 0; font-size: clamp(64px, 10vw, 112px); line-height: 1; letter-spacing: .06em;
  color: var(--cream);
  text-shadow: 0 6px 0 #b8331f, 0 12px 0 rgba(60, 14, 6, .9), 0 0 40px rgba(255, 130, 50, .6);
}
.logo small { display: block; margin-top: 18px; font-size: 15px; letter-spacing: .1em; color: var(--cream-2); text-shadow: none; opacity: .85; }
.diff-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.diff {
  font: inherit; color: var(--cream); cursor: pointer; text-align: left;
  padding: 12px 12px 10px; border-radius: 18px;
  background: rgba(255, 240, 225, .07); border: 3px solid rgba(255, 220, 190, .22);
  display: flex; flex-direction: column; gap: 4px; transition: transform .12s, border-color .12s, background .12s;
}
.diff b { font-size: 22px; }
.diff b small { margin-left: 6px; padding: 1px 6px; border-radius: 6px; font-size: 11px; vertical-align: middle; background: var(--sky); color: var(--broth); }
.diff .stars { color: var(--gold); letter-spacing: 2px; font-size: 14px; }
.diff .meta { font-size: 12px; color: var(--cream-2); opacity: .9; line-height: 1.5; }
.diff .best { font-size: 11px; color: var(--pink); min-height: 1em; }
.diff-list:has(> :nth-child(4)) { gap: 6px; }
.diff-list:has(> :nth-child(4)) .diff { padding: 9px 8px 8px; }
.diff-list:has(> :nth-child(4)) .diff .meta { font-size: 11px; }
.diff[aria-checked="true"] { border-color: var(--orange); background: rgba(255, 138, 61, .22); transform: translateY(-2px); }
.btn {
  font: inherit; font-size: 16px; color: var(--cream); cursor: pointer;
  padding: 10px 18px; border-radius: 999px;
  background: rgba(255, 240, 225, .1); border: 2px solid rgba(255, 220, 190, .4);
}
.btn:disabled { opacity: .4; cursor: default; }
.btn-main {
  font-size: 22px; padding: 14px 24px; color: #fff; border: 0;
  background: linear-gradient(180deg, #ff6a4d, var(--tomato));
  box-shadow: 0 6px 0 #9c2416, 0 10px 24px rgba(232, 72, 59, .45);
}
.btn-main:active { transform: translateY(4px); box-shadow: 0 2px 0 #9c2416; }
.btn-small { font-size: 14px; padding: 7px 14px; }
.btn:focus-visible, .diff:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.settings { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-radius: 18px; background: rgba(20, 6, 3, .45); }
.set-row { display: flex; align-items: center; gap: 12px; font-size: 15px; }
.set-row > span { width: 2.6em; color: var(--cream-2); }
.set-row input[type=range] { flex: 1; accent-color: var(--orange); }
.set-row output { width: 5.2em; text-align: right; font-variant-numeric: tabular-nums; color: var(--gold); }
.set-toggles { flex-wrap: wrap; gap: 14px; }
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.chk input { accent-color: var(--orange); width: 18px; height: 18px; }
.hint { margin: 0; font-size: 13px; color: var(--cream-2); opacity: .8; line-height: 1.6; }
kbd { display: inline-block; min-width: 1.6em; padding: 0 5px; margin: 0 2px; border-radius: 6px; border: 2px solid rgba(255, 220, 190, .5); text-align: center; font-family: inherit; font-size: 12px; }

.screen-card { align-items: center; justify-content: center; background: rgba(20, 6, 3, .72); padding: 20px; }
.card {
  width: min(460px, 100%); padding: 22px 22px 20px; border-radius: 26px;
  background: linear-gradient(180deg, rgba(90, 30, 14, .95), rgba(46, 14, 7, .95));
  border: 3px solid rgba(255, 170, 110, .45); box-shadow: 0 20px 50px rgba(0, 0, 0, .5);
}
.card h2 { margin: 0 0 10px; font-size: 28px; color: var(--cream); }
.card p { font-size: 15px; line-height: 1.7; color: var(--cream-2); }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
#btn-calib-clear[hidden], #calib-setting-status[hidden] { display: none; }
.calib-pad.btn { display: block; width: 100%; min-height: 76px; touch-action: none; }
.calib-pad:disabled { opacity: .58; }
.calib-dots { display: flex; gap: 10px; justify-content: center; margin: 16px 0; }
.calib-dots i { width: 22px; height: 22px; border-radius: 50%; border: 3px solid rgba(255, 220, 190, .4); }
.calib-dots i.hit { background: var(--gold); border-color: var(--gold); }
.calib-result { text-align: center; font-size: 18px !important; color: var(--gold) !important; min-height: 1.7em; }

.result-card { width: min(470px, 100%); }
.res-head { display: flex; align-items: center; gap: 18px; margin: 6px 0 10px; }
.rank {
  font-size: 92px; line-height: 1; color: var(--gold); width: 1.1em; text-align: center;
  text-shadow: 0 6px 0 #b8331f, 0 0 30px rgba(255, 160, 60, .8);
}
.res-score { font-size: 44px; font-variant-numeric: tabular-nums; color: var(--cream); }
.badges { display: flex; gap: 6px; flex-wrap: wrap; min-height: 24px; }
.badges span { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--tomato); color: #fff; }
.badges span.ap { background: linear-gradient(90deg, #ffb13d, #ff5d8f); }
.res-table { width: 100%; border-collapse: collapse; font-size: 17px; }
.res-table th { text-align: left; font-weight: 900; color: var(--cream-2); padding: 4px 0; }
.res-table td { text-align: right; font-variant-numeric: tabular-nums; color: var(--cream); }
.res-table tr.j-perfect th { color: var(--gold); } .res-table tr.j-great th { color: var(--pink); }
.res-table tr.j-good th { color: var(--sky); } .res-table tr.j-miss th { color: #b8a49b; }
.result-card .hint { margin-top: 8px; }

.debug { position: absolute; left: 8px; bottom: 8px; z-index: 60; margin: 0; padding: 6px 8px; font: 11px/1.4 ui-monospace, Menlo, monospace; color: #9f9; background: rgba(0, 0, 0, .7); pointer-events: none; }

@media (max-width: 719px) {
  .screen-title, .screen-result { flex-direction: column; justify-content: flex-start; gap: 6px; padding: 14px 14px 24px; }
  .title-art img, .result-art img { height: 24vh; }
  .title-panel { margin-block: 0; }
  .song-current { padding: 14px 17px 17px; }
  .song-locked b { font-size: 15px; }
  .logo { font-size: 64px; } .logo small { margin-top: 12px; font-size: 13px; }
  .diff { padding: 9px 9px 8px; } .diff b { font-size: 19px; }
  .btn-main { font-size: 20px; }
  .keys-hint { display: none; }
  .hud-song { font-size: 13px; } .hud-song b { font-size: 16px; } .hud-score { font-size: 19px; }
  .rank { font-size: 76px; } .res-score { font-size: 36px; }
}
@media (prefers-reduced-motion: reduce) {
  .title-art img, .result-art img, .loader span { animation: none; }
}

/* 長按／撈麵：長音符說明（手機也顯示） */
.long-hint { margin-top: 4px; color: var(--gold); opacity: .92; }
.long-hint[hidden] { display: none; }

/* Follow the browser's current viewport instead of stretching a stale canvas. */
@supports (height: 100dvh) { #app { bottom: auto; height: 100dvh; } }
@media (min-width: 720px) and (max-width: 1023px) {
  .screen-title, .screen-result { flex-direction: column; align-items: center; justify-content: flex-start; }
  .title-art img, .result-art img { height: min(20vh, 220px); max-width: 100%; object-fit: contain; }
  .title-panel { width: min(640px, 100%); margin-block: 0; }
}

/* Keep the HUD and the moving portrait outside the note field on phones. */
.meimei-side {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.hud-pause {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
}

@media (max-width: 719px), (max-height: 500px) and (orientation: landscape) {
  #app {
    --play-head: calc(env(safe-area-inset-top) + 57px);
    --play-foot: calc(env(safe-area-inset-bottom) + 53px);
  }

  #field {
    inset: var(--play-head) env(safe-area-inset-right) var(--play-foot) env(safe-area-inset-left);
    width: calc(100% - env(safe-area-inset-left) - env(safe-area-inset-right));
    height: calc(100% - var(--play-head) - var(--play-foot));
  }

  .hud-bar {
    top: env(safe-area-inset-top);
    width: min(720px, calc(100% - max(8px, env(safe-area-inset-left)) - max(8px, env(safe-area-inset-right))));
    min-height: 48px;
    padding: 0 6px 0 12px;
  }

  .hud-progress {
    top: calc(var(--play-head) - 5px);
    width: min(720px, calc(100% - max(8px, env(safe-area-inset-left)) - max(8px, env(safe-area-inset-right))));
    height: 3px;
  }

  .meimei-side {
    inset: auto 0 0;
    height: var(--play-foot);
    overflow: hidden;
  }

  .meimei {
    inset: auto max(9px, env(safe-area-inset-right)) env(safe-area-inset-bottom) auto;
    width: 65px;
    height: 49px;
    object-fit: contain;
    object-position: bottom right;
  }

  .hud-heat,
  #app[data-rotation="on"] .hud-heat {
    inset: auto auto calc(env(safe-area-inset-bottom) + 13px) max(8px, env(safe-area-inset-left));
    padding: 3px 6px;
    font-size: 10px;
  }

  .hud-heat i { width: 7px; }

  .hud-section,
  .hud-section.rotating {
    inset: auto 73px calc(env(safe-area-inset-bottom) + 4px) 114px;
    max-width: none;
    min-height: 40px;
    display: grid;
    align-content: center;
    font-size: 15px;
    line-height: 1.25;
    letter-spacing: .02em;
    text-align: center;
    white-space: normal;
    transform: none;
  }

  .hud-section.show,
  .hud-section.rotating.show { transform: none; }
  .hud-section small,
  .hud-section.rotating small { font-size: 10px; }

  .btn, .diff, .chk, .song-choice, .set-row:has(input[type="range"]) { min-height: 44px; }
  .set-row input[type="range"] { min-height: 44px; }
  .screen { padding-inline: max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-right)); }
  .screen-title, .screen-result {
    padding-block: max(10px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-bottom));
  }
}

@media (max-width: 719px) and (orientation: portrait) {
  .title-art { display: none; }
  .title-panel { gap: 7px; }
  .song-list, .song-soon { gap: 6px; }
  .song-choice { padding: 5px 9px; gap: 1px; line-height: 1.2; }
  .song-choice b { font-size: 16px; }
  .song-special-choice { margin: 0; }
  .song-current {
    padding: 9px clamp(76px, 24vw, 112px) 9px 13px;
    background-image: url('../img/meimei-cape.png');
    background-size: auto calc(100% - 12px);
    background-position: right 12px center;
    background-repeat: no-repeat;
  }
  .song-heat, .logo small { margin-top: 6px; }
  .logo, .logo.logo-long { font-size: clamp(30px, 8vw, 49px); }
  .song-locked { padding: 8px 4px 5px; gap: 2px; }
  .song-locked b { font-size: 12px; }
  .song-locked small { font-size: 10px; }
  .diff-list { gap: 5px; }
  .diff, .diff-list:has(> :nth-child(4)) .diff { padding: 5px 6px; gap: 1px; border-width: 2px; }
  .diff b { font-size: 16px; }
  .diff .stars { font-size: 12px; }
  .diff .meta, .diff-list:has(> :nth-child(4)) .diff .meta { font-size: 10px; }
  .btn-main { padding-block: 9px; }
}

@media (max-height: 500px) and (orientation: landscape) {
  #app { --play-foot: calc(env(safe-area-inset-bottom) + 45px); }
  .meimei { height: 43px; }
  .hud-section, .hud-section.rotating { min-height: 34px; }
  .screen-title, .screen-result { flex-direction: row; align-items: flex-start; justify-content: center; }
  .title-art, .result-art { position: sticky; top: 0; align-self: flex-start; }
  .title-art img, .result-art img { height: min(52svh, 240px); }
  .title-panel { width: min(520px, 68%); }
  .screen-card { overflow-y: auto; align-items: safe center; }
}
