:root {
  --amber: #8B5A2B; --sun: #FFB35C; --plaster: #EDE3CF; --shade: #3A4A6B; --red: #D83A34;
  --ink: #2a1a10; --paper: #fbf6ea; --board: #2f4a3a;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #1c140e; color: var(--ink); font-family: "Zen Maru Gothic", sans-serif; user-select: none; -webkit-user-select: none; touch-action: none; }
#c, #lines { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#lines { pointer-events: none; }
.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
.card { position: absolute; background: rgba(251, 246, 234, 0.92); border: 3px solid var(--ink); border-radius: 14px; box-shadow: 0 4px 0 rgba(42, 26, 16, 0.6); }
.hud-tl { top: 16px; left: 16px; padding: 8px 16px 10px; min-width: 150px; }
.place { font-family: "Dela Gothic One"; font-size: 56px; line-height: 1; color: var(--red); -webkit-text-stroke: 1px var(--ink); }
.place small { font-size: 22px; color: var(--ink); -webkit-text-stroke: 0; margin-left: 2px; }
.legs { display: flex; gap: 5px; margin: 6px 0 4px; }
.legs i { width: 26px; height: 10px; border-radius: 5px; border: 2px solid var(--ink); background: #fff; position: relative; }
.legs i.done { background: var(--amber); }
.legs i.now { background: var(--sun); animation: blink 0.8s infinite; }
@keyframes blink { 50% { background: #fff; } }
.time { font-family: "Dela Gothic One"; font-size: 20px; letter-spacing: 1px; }
.hud-tr { top: 16px; right: 16px; padding: 10px 14px; width: 220px; font-size: 13px; }
.hud-tr .row { display: flex; justify-content: space-between; align-items: baseline; }
.hud-tr b { font-family: "Dela Gothic One"; font-size: 20px; }
.hud-tr .mine b { font-size: 16px; color: var(--amber); }
.bar { height: 10px; border: 2px solid var(--ink); border-radius: 6px; overflow: hidden; background: #d9cfbc; margin: 3px 0 6px; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #c07a3a, #ffcf7a); transition: width .2s; }
.rag { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.ragbar { flex: 1; height: 10px; border: 2px solid var(--ink); border-radius: 6px; overflow: hidden; background: #fff; }
.ragbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #b7a98f, #6d5a42); }
.rag em { font-style: normal; font-weight: 900; font-size: 12px; min-width: 52px; text-align: right; }
.rag.warn em { color: var(--red); animation: blink2 .6s infinite; }
@keyframes blink2 { 50% { opacity: .3; } }
#map { position: absolute; right: 20px; top: 50%; transform: translateY(-40%); width: 70px; height: 300px; }

.hud-bc { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); display: flex; align-items: flex-end; gap: 18px; }
#rhythm { width: 340px; }
.track { position: relative; height: 26px; border: 3px solid var(--ink); border-radius: 14px; background: rgba(251, 246, 234, 0.9); overflow: hidden; box-shadow: 0 3px 0 rgba(42,26,16,.5); }
.track .zone { position: absolute; left: 40%; width: 20%; top: 0; bottom: 0; background: linear-gradient(90deg, transparent, rgba(255, 179, 92, .9), transparent); }
.track .zone::after { content: "◆"; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -52%); color: var(--red); font-size: 16px; }
.track .beat { position: absolute; top: 3px; bottom: 3px; width: 8px; margin-left: -4px; border-radius: 4px; background: var(--ink); left: 0; }
.track.hit { animation: hit .18s; }
@keyframes hit { 0% { transform: scale(1.06); background: #fff3c4; } 100% { transform: scale(1); } }
.feet { display: flex; justify-content: space-between; margin-top: 6px; }
.feet span { font-family: "Dela Gothic One"; font-size: 18px; width: 42px; height: 30px; border: 3px solid var(--ink); border-radius: 10px; background: #fff; text-align: center; line-height: 24px; opacity: .45; transition: all .08s; }
.feet span.next { opacity: 1; background: var(--sun); transform: translateY(-3px); }
#combo { text-align: center; min-width: 90px; color: #fff; text-shadow: 0 3px 0 var(--ink), 0 0 12px rgba(0,0,0,.5); }
#combo b { display: block; font-family: "Dela Gothic One"; font-size: 44px; line-height: 1; -webkit-text-stroke: 2px var(--ink); }
#combo span { font-weight: 900; font-size: 13px; letter-spacing: 3px; }
#combo.pop b { animation: pop .2s; }
@keyframes pop { 0% { transform: scale(1.5); color: var(--sun); } }
#wob { width: 110px; font-size: 12px; font-weight: 900; color: #fff; text-shadow: 0 2px 0 var(--ink); }
#wob div { height: 12px; border: 3px solid var(--ink); border-radius: 7px; overflow: hidden; background: rgba(255,255,255,.85); margin-top: 3px; }
#wob i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #f2b24a, #d83a34); }
#wob.danger div { animation: shake .12s infinite; }
@keyframes shake { 50% { transform: translateX(2px); } }
#speed { color: #fff; text-shadow: 0 3px 0 var(--ink); min-width: 90px; }
#speed b { font-family: "Dela Gothic One"; font-size: 34px; -webkit-text-stroke: 1.5px var(--ink); }
#speed small { font-weight: 900; margin-left: 3px; }

/* ---------- floating texts ---------- */
#popups, #labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.pop { position: absolute; transform: translate(-50%, -50%); font-family: "Dela Gothic One"; font-size: 30px; color: #fff; -webkit-text-stroke: 2px var(--ink); text-shadow: 0 4px 0 var(--ink); white-space: nowrap; animation: rise .8s ease-out forwards; }
.pop.perfect { color: var(--sun); font-size: 34px; }
.pop.good { color: #fff; font-size: 24px; }
.pop.bad { color: #9ecbff; font-size: 22px; }
.pop.big { font-size: 54px; color: var(--sun); animation: rise 1.1s ease-out forwards; }
.pop.red { color: #ff6b5e; }
@keyframes rise { 0% { opacity: 0; transform: translate(-50%, -30%) scale(1.6); } 15% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -140%) scale(.95); } }
.label { position: absolute; transform: translate(-50%, -100%); font-weight: 900; font-size: 12px; color: #fff; background: rgba(42, 26, 16, .75); padding: 1px 7px; border-radius: 8px; white-space: nowrap; }
.bubble { position: absolute; transform: translate(-50%, -100%); background: #fff; border: 3px solid var(--ink); border-radius: 16px; padding: 6px 12px; font-family: "Dela Gothic One"; font-size: 20px; color: var(--red); white-space: nowrap; animation: bub .25s ease-out; }
.bubble::after { content: ""; position: absolute; left: 50%; bottom: -12px; border: 9px solid transparent; border-top-color: var(--ink); transform: translateX(-50%); }
@keyframes bub { 0% { transform: translate(-50%, -100%) scale(.3); } 70% { transform: translate(-50%, -100%) scale(1.15); } }
.warnmark { position: absolute; transform: translate(-50%, -100%); font-family: "Dela Gothic One"; font-size: 30px; color: var(--red); -webkit-text-stroke: 2px #fff; animation: blink2 .25s infinite; }

#banner { position: fixed; left: 0; right: 0; top: 34%; text-align: center; pointer-events: none; font-family: "Dela Gothic One"; font-size: 96px; color: #fff; -webkit-text-stroke: 3px var(--ink); text-shadow: 0 7px 0 var(--ink); }
#banner.show { animation: ban .9s ease-out forwards; }
#banner.hold { animation: banIn .35s ease-out forwards; top: 9%; }
@keyframes ban { 0% { opacity: 0; transform: scale(2.2); } 18% { opacity: 1; transform: scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: scale(.9); } }
@keyframes banIn { 0% { opacity: 0; transform: scale(2); } 100% { opacity: 1; transform: scale(1); } }
#banner small { display: block; font-size: 30px; -webkit-text-stroke: 1.5px var(--ink); }

#hint { position: fixed; left: 50%; top: 18%; transform: translateX(-50%); background: var(--board); color: #f4f1e4; font-family: "Yusei Magic"; font-size: 24px; padding: 12px 26px; border-radius: 10px; border: 6px solid #8a5a34; box-shadow: 0 6px 0 rgba(0,0,0,.4); pointer-events: none; animation: hintIn .35s ease-out; text-align: center; max-width: 90vw; }
#hint kbd, .paper kbd { font-family: "Dela Gothic One"; font-size: .85em; background: #fff; color: var(--ink); border: 2px solid var(--ink); border-bottom-width: 4px; border-radius: 6px; padding: 0 7px; margin: 0 2px; }
@keyframes hintIn { 0% { opacity: 0; transform: translate(-50%, -12px); } }

/* ---------- screens ---------- */
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
#title { background: radial-gradient(ellipse at 50% 60%, rgba(0,0,0,0) 30%, rgba(20,10,4,.55) 100%); gap: 34px; animation: fadeIn .8s; }
@keyframes fadeIn { 0% { opacity: 0; } }
.logoWrap { text-align: center; }
.kicker { font-family: "Yusei Magic"; font-size: 22px; color: #fff; text-shadow: 0 2px 0 var(--ink); letter-spacing: 4px; }
.logo { font-family: "Dela Gothic One"; font-weight: 400; line-height: .95; font-size: clamp(56px, 11vw, 132px); color: var(--paper); -webkit-text-stroke: 4px var(--ink); text-shadow: 0 8px 0 var(--ink), 0 14px 30px rgba(0,0,0,.4); transform: rotate(-3deg); }
.logo span { display: block; }
.logo span:last-child { color: var(--sun); margin-left: .6em; }
.en { font-family: "Dela Gothic One"; letter-spacing: 12px; color: var(--red); -webkit-text-stroke: 1px var(--ink); font-size: 20px; margin-top: 14px; }
.tag { font-family: "Yusei Magic"; font-size: 26px; color: #fff; text-shadow: 0 3px 0 var(--ink); margin-top: 10px; }
.menu { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.menu.row { flex-direction: row; justify-content: center; }
.btn { pointer-events: auto; cursor: pointer; font-family: "Zen Maru Gothic"; font-weight: 900; font-size: 22px; color: var(--ink); background: var(--paper); border: 3px solid var(--ink); border-radius: 40px; padding: 10px 40px; min-width: 240px; box-shadow: 0 5px 0 var(--ink); transition: transform .08s, box-shadow .08s, background .15s; }
.btn small { font-size: 12px; margin-left: 10px; opacity: .6; }
.btn:hover, .btn.sel { background: #fff; transform: translateY(-2px); box-shadow: 0 7px 0 var(--ink); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn.primary { background: var(--sun); }
.vol { pointer-events: auto; font-weight: 900; color: #fff; text-shadow: 0 2px 0 var(--ink); display: flex; align-items: center; gap: 10px; }
.paper .vol { color: var(--ink); text-shadow: none; justify-content: center; margin: 8px 0 16px; }
.vol input { accent-color: var(--red); width: 160px; }
.best { font-family: "Yusei Magic"; color: #fff; text-shadow: 0 2px 0 var(--ink); font-size: 18px; min-height: 24px; }
.modal { background: rgba(20, 12, 6, .55); }
.paper { background: var(--paper); border: 4px solid var(--ink); border-radius: 18px; padding: 26px 34px; max-width: 620px; width: calc(100% - 32px); box-shadow: 0 10px 0 rgba(0,0,0,.35); text-align: center; background-image: repeating-linear-gradient(transparent 0 31px, rgba(58,74,107,.14) 31px 32px); }
.paper h2 { font-family: "Dela Gothic One"; font-weight: 400; font-size: 32px; margin-bottom: 14px; }
.paper ul { text-align: left; list-style: none; line-height: 1.7; margin-bottom: 18px; }
.paper li { margin-bottom: 8px; padding-left: 20px; position: relative; }
.paper li::before { content: "✎"; position: absolute; left: 0; color: var(--red); }
.paper li span { font-size: 14px; color: #6b5a48; }
.paper em { color: var(--red); font-style: normal; font-weight: 900; }
.paper .btn { margin: 6px auto; display: block; }

#result { background: rgba(20, 12, 6, .5); }
.sheet { position: relative; background: var(--paper); border: 4px solid var(--ink); border-radius: 18px; padding: 24px 34px; width: min(560px, calc(100% - 32px)); box-shadow: 0 12px 0 rgba(0,0,0,.35); animation: sheetIn .5s cubic-bezier(.2, 1.4, .4, 1); background-image: repeating-linear-gradient(transparent 0 31px, rgba(58,74,107,.14) 31px 32px); }
@keyframes sheetIn { 0% { transform: translateY(60px) rotate(-4deg); opacity: 0; } }
.sheet h2 { font-family: "Yusei Magic"; font-weight: 400; font-size: 26px; text-align: center; }
.sheet .rank { font-family: "Dela Gothic One"; font-size: 64px; text-align: center; color: var(--red); -webkit-text-stroke: 2px var(--ink); line-height: 1.1; }
.sheet table { width: 100%; border-collapse: collapse; margin: 6px 0 10px; font-size: 16px; }
.sheet th { text-align: left; font-weight: 700; padding: 3px 0; }
.sheet td { text-align: right; font-family: "Dela Gothic One"; }
.sheet tr.total th, .sheet tr.total td { border-top: 3px double var(--ink); padding-top: 6px; font-size: 22px; }
.standings { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.standings span { background: #fff; border: 2px solid var(--ink); border-radius: 8px; padding: 1px 8px; }
.standings span.me { background: var(--sun); }
.comment { font-family: "Yusei Magic"; text-align: center; font-size: 18px; color: var(--shade); margin: 6px 0 14px; }
.sheet .btn { min-width: 180px; padding: 10px 20px; }
.stamp { position: absolute; right: 18px; top: 14px; width: 96px; height: 96px; border: 6px solid var(--red); border-radius: 50%; color: var(--red); font-family: "Dela Gothic One"; font-size: 60px; line-height: 82px; text-align: center; transform: rotate(14deg); opacity: 0; }
.stamp.on { animation: stamp .4s cubic-bezier(.3, 1.6, .5, 1) forwards; }
@keyframes stamp { 0% { opacity: 0; transform: rotate(14deg) scale(3); } 100% { opacity: .9; transform: rotate(14deg) scale(1); } }

#fade { position: fixed; inset: 0; background: #1c140e; pointer-events: none; opacity: 0; transition: opacity .35s; }
#fade.on { opacity: 1; }

/* ---------- touch: the lower part of the screen is two feet ---------- */
html, body { -webkit-touch-callout: none; overscroll-behavior: none; }
.t-only { display: none; }
body.touch .t-only { display: block; }
body.touch .k-only { display: none; }
#touch { position: fixed; inset: 0; pointer-events: none; --zh: 38%; }
#touch .zone { position: absolute; bottom: 0; width: 50%; height: var(--zh); pointer-events: auto; touch-action: none; display: flex; align-items: flex-end; justify-content: center; padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px)); }
#zoneL { left: 0; background: linear-gradient(0deg, rgba(20,12,6,.38), rgba(20,12,6,0)); border-right: 1px dashed rgba(251,246,234,.18); }
#zoneR { right: 0; background: linear-gradient(0deg, rgba(20,12,6,.38), rgba(20,12,6,0)); }
#touch .pad { display: flex; flex-direction: column; align-items: center; gap: 2px; color: rgba(251,246,234,.75); text-shadow: 0 2px 0 rgba(42,26,16,.6); transition: transform .08s; }
#touch .pad .foot { width: 30px; height: 44px; fill: currentColor; opacity: .5; }
#zoneL .pad .foot { transform: scaleX(-1); }
#touch .pad b { font-family: "Dela Gothic One"; font-weight: 400; font-size: 22px; }
#touch .pad small { font-size: 10px; font-weight: 700; opacity: .8; max-width: 150px; text-align: center; }
#touch .zone.next .pad { color: var(--sun); transform: translateY(-4px); }
#touch .zone.next .pad .foot { opacity: 1; }
#touch .zone.on { background: linear-gradient(0deg, rgba(255,179,92,.45), rgba(255,179,92,0)); }
#touch .zone.turn { background: linear-gradient(0deg, rgba(216,58,52,.55), rgba(216,58,52,0)); }
#touch .turncue { position: absolute; left: 50%; bottom: calc(var(--zh) - 22px); transform: translateX(-50%); font-family: "Dela Gothic One"; font-size: 22px; color: #fff; -webkit-text-stroke: 1.5px var(--ink); text-shadow: 0 3px 0 var(--ink); opacity: 0; transition: opacity .1s; white-space: nowrap; }
#touch .turncue.show { opacity: 1; animation: blink2 .3s infinite; }
#touch .ripple { position: absolute; width: 90px; height: 90px; margin: -45px 0 0 -45px; border-radius: 50%; border: 4px solid var(--sun); pointer-events: none; animation: ripple .35s ease-out forwards; }
@keyframes ripple { 0% { transform: scale(.3); opacity: 1; } 100% { transform: scale(1.2); opacity: 0; } }
#touch .pz { pointer-events: auto; position: absolute; top: calc(12px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--ink); background: rgba(251,246,234,.85); font-weight: 900; color: var(--ink); }

/* touch devices: HUD sits above the feet zones */
body.touch .hud-bc { bottom: calc(38% + 10px); }
body.touch #speed, body.touch #wob { display: none; }
body.touch .hud-tl { top: calc(8px + env(safe-area-inset-top, 0px)); }
body.touch .hud-tr { top: calc(8px + env(safe-area-inset-top, 0px)); }
@media (orientation: portrait) {
  body.touch #map { display: none; }
  #title { justify-content: space-between; padding: calc(12vh + env(safe-area-inset-top, 0px)) 16px calc(8vh + env(safe-area-inset-bottom, 0px)); }
  .sheet { max-height: calc(100% - 24px); overflow-y: auto; padding: 20px 20px; }
  .sheet .rank { font-size: 52px; }
  .stamp { width: 76px; height: 76px; font-size: 46px; line-height: 64px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  #touch { --zh: 64%; }
  #touch .zone { width: 34%; }
  #zoneL { border-right: none; }
  body.touch .hud-bc { bottom: calc(4px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%) scale(.72); transform-origin: bottom center; }
  body.touch #map { display: none; }
  #touch .turncue { bottom: 90px; }
  .hud-tl, .hud-tr { transform: scale(.62) !important; }
  #map { height: 180px; }
  .logo { font-size: 58px; } .tag { font-size: 16px; } #title { gap: 10px; }
  .btn { padding: 6px 30px; font-size: 18px; }
}

@media (max-width: 760px) {
  .hud-tl { transform: scale(.72); transform-origin: top left; top: 8px; left: 8px; }
  .hud-tr { transform: scale(.72); transform-origin: top right; top: 8px; right: 8px; }
  #map { display: none; }
  .hud-bc { bottom: 8px; gap: 8px; transform: translateX(-50%) scale(.78); transform-origin: bottom center; }
  #rhythm { width: 240px; }
  #speed, #wob { display: none; }
  #banner { font-size: 60px; }
  #hint { font-size: 17px; top: 22%; }
  .tag { font-size: 18px; }
  .en { letter-spacing: 6px; font-size: 15px; }
}
@media (max-height: 500px) {
  .pop { font-size: 20px; -webkit-text-stroke: 1.5px var(--ink); }
  .pop.perfect { font-size: 22px; } .pop.good, .pop.bad { font-size: 16px; }
  .pop.big { font-size: 32px; }
  #banner { font-size: 52px; top: 24%; } #banner small { font-size: 18px; }
  #hint { font-size: 15px; top: 20%; padding: 6px 14px; }
}
.a2hs { font-size: 12px; font-weight: 700; color: #fff; text-shadow: 0 2px 0 var(--ink); text-align: center; max-width: 280px; line-height: 1.5; background: rgba(42,26,16,.55); padding: 6px 10px; border-radius: 10px; }
[hidden] { display: none !important; }
#touch .flick { position: absolute; transform: translate(-50%, -50%); font-family: "Dela Gothic One"; font-size: 40px; color: var(--sun); -webkit-text-stroke: 2px var(--ink); pointer-events: none; animation: rise .35s ease-out forwards; }
.floorBox { display: flex; align-items: baseline; gap: 8px; }
.floorBox b { font-family: "Dela Gothic One"; font-size: 24px; font-weight: 400; }
.floorBox em { font-style: normal; font-weight: 900; font-size: 13px; margin-left: auto; }
.floorBox.dusty b { color: #8d8272; } .floorBox.dusty em { color: #8d8272; }
.floorBox.ok b { color: var(--amber); }
.floorBox.shiny b { color: #e0902a; text-shadow: 0 0 10px rgba(255,210,120,.9); } .floorBox.shiny em { color: var(--red); animation: blink2 .5s infinite; }
.speedbar i { background: linear-gradient(90deg, #b9ad98, #c07a3a 50%, #ffd27a); transition: width .15s; }
#rule { position: fixed; left: 50%; bottom: 16%; transform: translateX(-50%); width: min(520px, calc(100% - 32px)); background: var(--paper); border: 4px solid var(--ink); border-radius: 16px; padding: 12px 16px; text-align: center; font-weight: 700; line-height: 1.7; box-shadow: 0 6px 0 rgba(0,0,0,.35); pointer-events: none; animation: hintIn .35s ease-out; }
#rule b { display: block; font-family: "Dela Gothic One"; font-weight: 400; color: var(--red); letter-spacing: 4px; }
#rule em { font-style: normal; color: var(--red); font-weight: 900; }
#rule .dust { color: #7d7262; } #rule .shiny { color: #d9801e; font-weight: 900; }
#rule small { color: #6b5a48; }
.tag + .sub { font-weight: 900; font-size: 16px; color: var(--sun); text-shadow: 0 2px 0 var(--ink); margin-top: 6px; }
.paper .goal { background: #fff3d6; border: 2px solid var(--ink); border-radius: 10px; padding: 8px 12px; text-align: left; margin-bottom: 12px; line-height: 1.6; }
body.touch #rule { bottom: calc(40% + 8px); }
.comeback { margin-top: 4px; font-weight: 900; font-size: 13px; color: var(--red); pointer-events: none; animation: cbGlow 1s ease-in-out infinite; }
.comeback { font-family: "Dela Gothic One"; font-weight: 400; font-size: 16px; letter-spacing: 2px; }
@keyframes cbGlow { 50% { color: #ff8a3d; text-shadow: 0 0 8px rgba(255,138,61,.7); } }
/* buttons stay one line; keyboard hints are hidden on touch devices */
.btn { white-space: nowrap; }
body.touch .btn small { display: none; }
.menu.row { gap: 10px; flex-wrap: nowrap; }
.sheet .menu.row .btn { flex: 1 1 0; min-width: 0; padding: 10px 12px; }
.sheet h2 { padding-right: 70px; padding-left: 70px; }
@media (orientation: portrait) {
  .sheet h2 { font-size: 22px; }
  .stamp { right: 10px; top: 10px; width: 64px; height: 64px; font-size: 38px; line-height: 52px; border-width: 5px; }
}
.floorBox { white-space: nowrap; }
.floorBox .lbl { flex: none; }
@media (max-width: 760px) { .floorBox b { font-size: 20px; } }
/* モップ: a real button, so it looks like one */
#mopBtn { position: fixed; left: 50%; bottom: 118px; transform: translateX(-50%); z-index: 5; display: flex; align-items: center; gap: 8px; padding: 10px 22px 10px 14px; border-radius: 40px; border: 3px solid var(--ink); background: linear-gradient(180deg, #9fd0ff, #3d7fc4); color: #fff; font-family: "Dela Gothic One"; font-size: 22px; box-shadow: 0 5px 0 var(--ink); cursor: pointer; touch-action: none; animation: mopIn .35s cubic-bezier(.3,1.6,.5,1), mopPulse 1.2s .35s ease-in-out infinite; -webkit-text-stroke: 1px var(--ink); white-space: nowrap; }
#mopBtn b { font-weight: 400; }
#mopBtn small { font-family: "Dela Gothic One"; font-size: 13px; background: #fff; color: var(--ink); -webkit-text-stroke: 0; border-radius: 5px; padding: 0 6px; }
#mopBtn:active { transform: translateX(-50%) translateY(4px); box-shadow: 0 1px 0 var(--ink); }
#mopBtn[hidden] { display: none !important; }
.mopIcon { width: 26px; height: 30px; position: relative; }
.mopIcon::before { content: ""; position: absolute; left: 11px; top: 0; width: 4px; height: 20px; background: #8a5a34; border-radius: 2px; }
.mopIcon::after { content: ""; position: absolute; left: 1px; bottom: 0; width: 24px; height: 11px; background: repeating-linear-gradient(90deg, #fff 0 3px, #d9e8f5 3px 5px); border-radius: 3px 3px 5px 5px; border: 2px solid var(--ink); box-sizing: border-box; }
@keyframes mopIn { 0% { transform: translateX(-50%) scale(.2); } 100% { transform: translateX(-50%) scale(1); } }
@keyframes mopPulse { 50% { box-shadow: 0 5px 0 var(--ink), 0 0 0 8px rgba(159,208,255,.35); } }
body.touch #mopBtn { bottom: calc(38% + 86px); }
@media (orientation: landscape) and (max-height: 500px) { body.touch #mopBtn { bottom: 70px; } }
/* status chips above the rhythm bar (the top-right card is gone: nobody looks there mid-race) */
#rhythm .chips { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 5px; pointer-events: none; }
.chip { font-family: "Dela Gothic One"; font-size: 16px; line-height: 1; color: #fff; -webkit-text-stroke: 1px var(--ink); text-shadow: 0 2px 0 var(--ink); white-space: nowrap; transition: color .15s; }
.chip.dusty { color: #cfc6b6; }
.chip.ok { color: #f0b36a; }
.chip.shiny { color: #ffd84a; font-size: 19px; animation: shinyPulse .6s ease-in-out infinite; }
@keyframes shinyPulse { 50% { text-shadow: 0 2px 0 var(--ink), 0 0 10px rgba(255,216,74,.9); } }
.ragChip { display: flex; align-items: center; gap: 5px; font-size: 14px; }
.ragChip i { width: 22px; height: 15px; border: 2px solid var(--ink); border-radius: 3px; box-shadow: inset 0 0 0 2px rgba(59,91,168,.55); }
.ragChip.warn em { color: #ff6b5e; animation: blink2 .5s infinite; }
/* ---- race-time overlays stay small: one line at the top, never over the action ---- */
#hint, #toast { position: fixed; left: 50%; top: calc(64px + env(safe-area-inset-top, 0px)); transform: translateX(-50%); max-width: calc(100% - 32px); width: max-content; padding: 6px 14px; border: none; border-radius: 20px; background: rgba(28, 20, 14, .78); color: #f4f1e4; font-family: "Zen Maru Gothic"; font-weight: 900; font-size: 15px; line-height: 1.4; text-align: center; white-space: normal; box-shadow: none; pointer-events: none; animation: hintIn .25s ease-out; }
#toast { top: calc(100px + env(safe-area-inset-top, 0px)); font-family: "Dela Gothic One"; font-weight: 400; font-size: 18px; color: var(--sun); }
#hint kbd { font-size: .8em; }
.pop.big { font-size: 26px; }
/* ---- one-hand turn button: only while a turn counts ---- */
.turnBtn { position: absolute; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 3; pointer-events: auto; touch-action: none; padding: 16px 34px; border-radius: 40px; border: 3px solid var(--ink); background: linear-gradient(180deg, #ff8a6b, #d83a34); color: #fff; font-family: "Dela Gothic One"; font-size: 24px; -webkit-text-stroke: 1px var(--ink); box-shadow: 0 5px 0 var(--ink); animation: mopIn .2s ease-out; white-space: nowrap; }
.turnBtn[hidden] { display: none !important; }
.turnBtn:active { transform: translateX(-50%) translateY(4px); box-shadow: 0 1px 0 var(--ink); }
/* mop button lives at the bottom too (moves up while the turn button is showing) */
body.touch #mopBtn { bottom: calc(22px + env(safe-area-inset-bottom, 0px)); }
body.touch #mopBtn.dodge { bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
@media (orientation: landscape) and (max-height: 500px) { body.touch #mopBtn { bottom: calc(10px + env(safe-area-inset-bottom, 0px)); } }
/* ---- small screens: everything scales with the viewport instead of overflowing ---- */
.btn { min-width: min(240px, 100%); max-width: 100%; }
.sheet .menu.row .btn { font-size: clamp(14px, 4.6vw, 22px); padding: 10px 6px; overflow: hidden; text-overflow: clip; }
.sheet { padding-left: clamp(14px, 5vw, 34px); padding-right: clamp(14px, 5vw, 34px); }
.sheet .rank { font-size: clamp(40px, 14vw, 64px); }
.sheet table { font-size: clamp(13px, 3.8vw, 16px); }
.sheet tr.total th, .sheet tr.total td { font-size: clamp(17px, 5.4vw, 22px); }
.sheet h2 { font-size: clamp(17px, 5vw, 26px); padding-left: 0; padding-right: clamp(56px, 18vw, 76px); text-align: left; }
.comment { font-size: clamp(14px, 4.2vw, 18px); }
.paper { padding: clamp(16px, 5vw, 26px) clamp(14px, 5vw, 34px); max-height: calc(100% - 24px); overflow-y: auto; }
.paper h2 { font-size: clamp(22px, 7vw, 32px); }
.paper ul { font-size: clamp(13px, 3.9vw, 16px); }
.logo { font-size: clamp(44px, 13vw, 132px); }
.tag { font-size: clamp(15px, 4.6vw, 26px); }
.tag + .sub { font-size: clamp(12px, 3.8vw, 16px); }
#hint, #toast { font-size: clamp(12px, 3.8vw, 15px); }
@media (max-width: 360px) {
  .hud-tl { transform: scale(.62); }
  .stamp { width: 56px; height: 56px; font-size: 32px; line-height: 44px; border-width: 4px; }
  #touch .pad small { display: none; }
}
@media (max-width: 480px) {
  #combo { position: absolute; left: 50%; bottom: 100%; transform: translateX(-50%); margin-bottom: 4px; min-width: 0; pointer-events: none; }
  #combo b { font-size: 30px; }
  #combo span { font-size: 10px; letter-spacing: 2px; }
  #rhythm { width: min(300px, calc(100vw - 40px)); }
}
/* short landscape phones: title logo and menu side by side so the buttons are always on screen */
@media (orientation: landscape) and (max-height: 500px) {
  #title { flex-direction: row; justify-content: center; align-items: center; gap: clamp(16px, 5vw, 48px); padding: 12px calc(16px + env(safe-area-inset-right, 0px)) 12px calc(16px + env(safe-area-inset-left, 0px)); }
  .logoWrap { max-width: 55%; }
  .kicker { font-size: 13px; }
  .logo { font-size: clamp(34px, 12vh, 60px); -webkit-text-stroke: 3px var(--ink); }
  .en { font-size: 12px; margin-top: 6px; letter-spacing: 6px; }
  .tag { font-size: 14px; margin-top: 4px; } .tag + .sub { font-size: 12px; }
  .menu { gap: 8px; }
  .menu .btn { min-width: 0; width: 200px; padding: 7px 16px; font-size: 16px; }
  .best { display: none; }
  .vol input { width: 120px; }
}
.logo { font-size: clamp(40px, min(13vw, 14vh), 132px); }
#title { gap: clamp(12px, 3.5vh, 34px); }
@media (orientation: landscape) and (max-height: 500px) { .logo { font-size: clamp(34px, 12vh, 60px); } }
@media (orientation: portrait) and (max-height: 700px) {
  #title { padding-top: calc(5vh + env(safe-area-inset-top, 0px)); padding-bottom: calc(3vh + env(safe-area-inset-bottom, 0px)); gap: 10px; }
  .best { font-size: 14px; min-height: 0; }
}
/* ---- time attack / ghost ---- */
#hud.single .place { display: none; }
.chip.gap { font-size: 17px; }
.chip.gap.ahead { color: #7ee0a0; }
.chip.gap.behind { color: #ff8b7a; }
.label.ghostLabel { background: rgba(120, 190, 240, .75); }
.soloOnly { display: none; }
#result.single tr.soloOnly { display: table-row; }
#result.single .shareBox { display: flex; }
#result.single .standings { display: none; }
#result.single tr.total { display: none; }
.shareBox { flex-direction: column; gap: 6px; margin-bottom: 12px; }
.shareBox .btn { width: 100%; min-width: 0; font-size: clamp(13px, 4vw, 17px); padding: 8px 10px; background: #bfe6ff; }
#shareOut { width: 100%; font-size: 11px; padding: 6px; border: 2px solid var(--ink); border-radius: 8px; }
.challenge { font-weight: 900; color: #fff; background: rgba(61,127,196,.85); border: 3px solid var(--ink); border-radius: 12px; padding: 6px 12px; text-align: center; max-width: 100%; }
.challenge b { font-family: "Dela Gothic One"; font-weight: 400; color: var(--sun); }
#result.single .rank { font-size: clamp(30px, 10vw, 54px); text-align: left; padding-right: clamp(56px, 18vw, 80px); }
.sheet { overflow-x: hidden; }
#title .menu .btn { font-size: clamp(15px, 4.8vw, 22px); padding-left: clamp(14px, 5vw, 40px); padding-right: clamp(14px, 5vw, 40px); }
#title .menu { max-width: calc(100vw - 32px); }
.stamp { right: 14px; top: 14px; }
/* ---- rules panel ---- */
#rulesList { display: grid; gap: 10px; margin: 6px 0 16px; }
.rule { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: 3px solid var(--ink); border-radius: 12px; background: #fff; font-weight: 900; font-size: clamp(15px, 4.4vw, 18px); cursor: pointer; text-align: left; }
.rule input { width: 26px; height: 26px; accent-color: var(--red); flex: none; }
.rule span { flex: 1; }
.rule em { font-style: normal; font-size: 13px; color: #fff; background: var(--red); border-radius: 8px; padding: 2px 8px; }
.rule input:not(:checked) ~ em { background: #8d8272; }
.rule input:not(:checked) ~ span { color: #8d8272; text-decoration: line-through; }
.paper .note { font-size: clamp(12px, 3.6vw, 14px); color: #6b5a48; margin-bottom: 8px; text-align: left; }
.rulesSummary { font-weight: 900; font-size: clamp(12px, 3.6vw, 14px); color: #fff; text-shadow: 0 2px 0 var(--ink); }
.challenge small { display: block; font-size: 12px; opacity: .9; }
.rRules { display: none; text-align: center; font-weight: 900; font-size: 13px; color: var(--shade); margin-top: -4px; }
#result.single .rRules { display: block; }
@media (orientation: landscape) and (max-height: 500px) { .rulesSummary { font-size: 11px; } }

.menuRow { display: flex; gap: 8px; width: min(340px, calc(100vw - 32px)); }
.menuRow .btn.sub { flex: 1 1 0; min-width: 0; width: auto; padding: 8px 6px; font-size: clamp(13px, 3.9vw, 17px); box-shadow: 0 4px 0 var(--ink); }
#title .menu > .btn { width: min(340px, calc(100vw - 32px)); }
@media (orientation: landscape) and (max-height: 500px) { .menuRow { width: 220px; } #title .menu > .btn { width: 220px; } .menuRow .btn.sub { font-size: 12px; padding: 6px 4px; } }
#title .menuRow .btn.sub { font-size: clamp(12px, 3.8vw, 17px); padding: 8px 4px; }
@media (orientation: landscape) and (max-height: 500px) {
  #title .menu > .btn { width: 250px; font-size: 15px; padding: 7px 10px; }
  #title .menuRow { width: 250px; }
  #title .menuRow .btn.sub { font-size: 12px; padding: 6px 2px; }
}
/* ---- ただ走る ---- */
.freeStat { display: none; font-weight: 900; font-size: 12px; margin-top: 4px; white-space: nowrap; }
#hud.free .freeStat { display: block; }
#hud.free .legs { display: none; }
#title .menu > .btn.free { background: linear-gradient(180deg, #fff3c4, #ffd27a); }
#title .menu > .btn.free small { display: inline; opacity: .7; font-size: .6em; }
body.touch #title .menu > .btn.free small { display: inline; }
/* ---- rule presets ---- */
.presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.preset { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 10px 4px; border: 3px solid var(--ink); border-radius: 12px; background: #fff; cursor: pointer; font-family: "Zen Maru Gothic"; color: var(--ink); min-width: 0; box-shadow: 0 3px 0 var(--ink); }
.preset b { font-family: "Dela Gothic One"; font-weight: 400; font-size: clamp(13px, 4vw, 17px); white-space: nowrap; }
.preset small { font-size: clamp(10px, 2.8vw, 12px); font-weight: 700; line-height: 1.3; color: #6b5a48; }
.preset.on { background: var(--sun); transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.preset.on small { color: var(--ink); }
#rulesList { gap: 6px; }
.rule { padding: 7px 12px; }
/* speed + gear readout, right above the bar */
.chip.spd { font-size: 15px; color: #f4f1e4; }
.chip.spd.warm { color: #ffd27a; }
.chip.spd.hot { color: #ff9a4a; animation: shinyPulse .45s ease-in-out infinite; }
#hud.single .chip.gap:not([hidden]) ~ .chip.spd { display: none; }
#skinList { grid-template-columns: repeat(2, 1fr); }
#skinList .preset b { font-size: clamp(12px, 3.8vw, 16px); }
/* ---- ぞうきんバトル ---- */
#title .menu > .btn.battle { background: linear-gradient(180deg, #bfe0ff, #7fb4ea); }
#mopBtn[data-item="bucket"] { background: linear-gradient(180deg, #7fc4f2, #2f7fd1); }
#mopBtn[data-item="eraser"] { background: linear-gradient(180deg, #f4f1e4, #b9ad98); color: var(--ink); -webkit-text-stroke: 0; }
#mopBtn[data-item="bucket"] .mopIcon, #mopBtn[data-item="eraser"] .mopIcon { display: none; }
.chip.item { font-size: 13px; color: #bfe6ff; }
.chip.item:empty { display: none; }

.vols { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.vols .vol input { width: clamp(80px, 26vw, 140px); }
