:root {
  color-scheme: light;
  --deep: #084451;
  --ink: #123f49;
  --foam: #f3fffa;
  --sand: #fff0c9;
  --coral: #ef7957;
  --left: max(12px, calc(env(safe-area-inset-left) + 8px));
  --right: max(12px, calc(env(safe-area-inset-right) + 8px));
  --top: max(12px, calc(env(safe-area-inset-top) + 6px));
  --bottom: max(12px, calc(env(safe-area-inset-bottom) + 6px));
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--deep);
  color: var(--foam);
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}
[hidden] { display: none !important; }
#view, .screen { position: fixed; inset: 0; }
#view { width: 100%; height: 100%; display: block; }
.svg-defs { position: absolute; pointer-events: none; }
button {
  font: inherit;
  font-weight: 800;
  color: #542a23;
  background: linear-gradient(170deg, #fff3cd, #ffba85);
  min-height: 44px;
  border: 1px solid #fff7dd;
  border-radius: 27px 27px 17px 17px / 29px 29px 15px 15px;
  padding: 9px 20px;
  box-shadow: 0 3px 0 #bc654e, inset 0 1px 0 #fff8e3;
  cursor: pointer;
}
button:active:not(:disabled) { translate: 0 2px; }
button:focus-visible { outline: 3px solid #ffce6f; outline-offset: 3px; }
button.ghost {
  background: #dcefe6;
  color: #164953;
  border-color: #a8d4c9;
  box-shadow: 0 2px 0 #a0c8be, inset 0 1px 0 #f7fff9;
}

.screen {
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: max(16px, var(--top)) max(16px, var(--right)) max(20px, var(--bottom)) max(16px, var(--left));
  text-align: center;
  background: rgba(6, 45, 58, .59);
}
#loading {
  z-index: 15;
  isolation: isolate;
  overflow: auto;
  padding-bottom: max(32px, var(--bottom));
  background: #082d44;
}
.loading-sea {
  position: fixed;
  z-index: -1;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 43% -7%, #97dfc9 0, #278a91 23%, transparent 68%),
    linear-gradient(164deg, #196779, #0c4c62 45%, #08263c 85%);
}
.loading-rays {
  position: absolute;
  inset: 0 -12% 12%;
  background: conic-gradient(from 139deg at 42% -13%,
    transparent, #ddfff13b 5deg, transparent 12deg 16deg, #c8ffe53d 22deg,
    transparent 28deg 33deg, #e5ffc73d 36deg, transparent 42deg 47deg,
    #ceffec38 53deg, transparent 60deg 64deg, #c7ffeb2b 70deg, transparent 77deg);
  mask-image: linear-gradient(#000, #0009 40%, transparent);
  transform-origin: 42% 0;
  animation: ray-sway 7s ease-in-out infinite alternate;
}
@keyframes ray-sway { to { transform: translateX(4%) rotate(-6deg); opacity: .58; } }
.loading-school {
  position: absolute;
  top: 29%;
  left: 10%;
  width: clamp(62px, 14vw, 154px);
  color: #073c51;
  opacity: .36;
  animation: fish-cross 28s -6s linear infinite;
}
.loading-school.far {
  top: 19%;
  left: 75%;
  width: clamp(44px, 10vw, 112px);
  opacity: .24;
  transform: scaleX(-1);
  animation: fish-cross-back 32s -9s linear infinite;
}
@keyframes fish-cross {
  from { transform: translate3d(-30vw, 4vh, 0); }
  to { transform: translate3d(94vw, -5vh, 0); }
}
@keyframes fish-cross-back {
  from { transform: translate3d(29vw, 0, 0) scaleX(-1); }
  to { transform: translate3d(-94vw, 9vh, 0) scaleX(-1); }
}
.loading-floor { position: absolute; inset: auto 0 0; width: 100%; height: 44%; }
.loading-kelp { position: absolute; bottom: 0; width: clamp(86px, 21vw, 276px); color: #0d5660; }
.loading-kelp.left { left: -2%; }
.loading-kelp.right { right: -3%; scale: -1 1; color: #0b4353; }
.loading-bubbles { position: absolute; inset: 0; }
.loading-bubbles i, .brand-bubbles i {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--size);
  aspect-ratio: 1;
  border: 1px solid #dbfff2a8;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 25%, #edfff3b3 0 9%, transparent 23%);
}
.loading-bubbles i {
  opacity: .48;
  animation: bubble-rise 11s var(--delay) linear infinite;
}
@keyframes bubble-rise {
  0% { transform: translate3d(0, 10vh, 0); opacity: 0; }
  16%, 68% { opacity: .64; }
  53% { transform: translate3d(16px, -36vh, 0); }
  100% { transform: translate3d(-6px, -78vh, 0); opacity: 0; }
}

.loading-layout {
  width: min(100%, 550px);
  margin: auto;
  display: grid;
  gap: clamp(18px, 3.4vh, 30px);
}
.brand-mark { width: max-content; margin-inline: auto; transform-origin: top left; }
.brand-motion { animation: brand-drift 5.2s ease-in-out infinite; }
.brand-shrimp {
  display: block;
  width: clamp(142px, 46vw, 199px);
  aspect-ratio: 158 / 96;
  margin: 0 auto -1px;
  overflow: visible;
  filter: drop-shadow(0 4px 0 #702d36a3);
}
.logo {
  margin: 0;
  color: #fff5d5;
  font-size: clamp(40px, 18.2vw, 79px);
  line-height: 1.12;
  font-weight: 1000;
  letter-spacing: .015em;
  white-space: nowrap;
  -webkit-text-stroke: clamp(4px, .7vw, 8px) #d45d44;
  paint-order: stroke fill;
  text-shadow: 0 .07em 0 #913d3a, 0 .12em .16em #062b3ca6;
}
.shrimp-tail {
  transform-box: fill-box;
  transform-origin: 15% 52%;
  animation: var(--shrimp-tail-animation, shrimp-flick 4.9s ease-in-out infinite);
}
.shrimp-glint {
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  animation: shrimp-glint 4.9s ease-in-out infinite;
}
@keyframes brand-drift {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-6px) rotate(1deg); }
}
@keyframes shrimp-flick {
  0%, 20%, 36%, 100% { transform: rotate(0); }
  25% { transform: rotate(-27deg); }
  30% { transform: rotate(8deg); }
}
@keyframes shrimp-glint {
  0%, 25%, 47%, 100% { opacity: 0; transform: translateX(-5px) scale(.48); }
  35% { opacity: .95; transform: translateX(4px) scale(1); }
}

#load-route { --load-distance: -100%; position: relative; height: 79px; }
.load-road {
  position: absolute;
  inset: 41px 0 0;
  border: 1px solid #ffe7b4c9;
  border-radius: 48% 36% 14px 14px / 14px 12px 14px 14px;
  background:
    radial-gradient(ellipse at 4px 7px, #93604c70 0 1px, transparent 2px) 0 55% / 23px 17px,
    radial-gradient(ellipse at 9px 8px, #fff5cdbf 0 1px, transparent 2px) 0 75% / 34px 20px,
    linear-gradient(#f1d39c, #d9a777);
  box-shadow: inset 0 2px 0 #fff2bf, inset 0 -4px 0 #b78363, 0 5px 0 #06283c91;
}
.load-lane {
  position: absolute;
  inset: auto 30px 17px;
  height: 5px;
  border-radius: 4px;
  background: #855e51a6;
}
.load-lane::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  width: 9px;
  height: 9px;
  border: 2px solid #fff1c7;
  border-radius: 50%;
  background: #986b56;
  translate: -50% -50%;
}
#load-bar {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #b8f1d2, #fff1aa 70%, #fff4d0);
  box-shadow: 0 0 7px #fff7c0c2;
}
.load-flag { position: absolute; z-index: 1; right: -25px; bottom: 2px; width: 34px; }
.load-position {
  position: absolute;
  inset: auto 0 5px;
  height: 1px;
  transform: translateX(var(--load-distance));
  transition: transform .36s ease-out;
  pointer-events: none;
}
.load-runner {
  --shrimp-tail-animation: runner-curl .98s ease-in-out infinite;
  position: absolute;
  right: 0;
  bottom: 0;
  width: clamp(56px, 14vw, 78px);
  translate: 40% 0;
  animation: runner-hop .98s ease-in-out infinite;
}
.load-runner svg { display: block; width: 100%; overflow: visible; }
@keyframes runner-hop {
  0%, 100% { transform: translateY(2px) scaleY(.91) rotate(4deg); }
  43% { transform: translateY(-20px) rotate(-10deg); }
  78% { transform: translateY(-4px) rotate(5deg); }
}
@keyframes runner-curl {
  0%, 100% { transform: rotate(-28deg); }
  45% { transform: rotate(12deg); }
}
.load-status {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 12px;
  margin-top: 12px;
  padding-inline: 4px;
  line-height: 1.55;
}
#load-text { margin: 0; text-align: left; font-size: 14px; font-weight: 800; overflow-wrap: anywhere; }
#load-percent { color: #fff1b9; font-size: 16px; font-weight: 900; font-variant-numeric: tabular-nums; }
.load-hint {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
  min-height: 62px;
  padding: 9px 14px;
  border: 1px solid #baf6e54d;
  border-radius: 12px 16px 16px 12px;
  background: #082c40bf;
  color: #e4fff8;
  text-align: left;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
  box-shadow: inset 0 1px 0 #d4fff019;
}
.load-hint-label { padding: 4px 9px; border-radius: 9px; background: #b0f5dc; color: #103f49; white-space: nowrap; }
#load-hint { margin: 0; }

#title {
  isolation: isolate;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: #6eb7ae #0e5363;
  background:
    radial-gradient(ellipse at 49% 44%, transparent 36%, #06263f29 72%, #042438a1 100%),
    linear-gradient(180deg, #032c4640 0, transparent 28% 70%, #041c318f 100%);
}
.title-layout { width: min(100%, 448px); margin: auto; display: grid; gap: clamp(38px, 8vh, 76px); }
.title-hero { position: relative; }
#title:not(.from-loading) .title-hero { animation: title-rise .65s cubic-bezier(.2, .65, .25, 1) both; }
.sub {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .65em;
  margin: 16px 0 0;
  color: #fff5d8;
  font-size: clamp(15px, 4.35vw, 20px);
  font-weight: 900;
  letter-spacing: .07em;
  text-shadow: 0 2px 3px #092c3e, 0 0 12px #092c3e;
}
.sub::before, .sub::after {
  content: "";
  flex: 0 1 36px;
  height: 1px;
  background: linear-gradient(90deg, transparent, #f5ffdf);
  box-shadow: 0 1px 1px #11425299;
}
.sub::after { scale: -1 1; }
.from-loading .sub { animation: title-rise .45s .29s ease-out both; }
.brand-bubbles { position: absolute; inset: -8% 5% 9%; pointer-events: none; }
.brand-bubbles i { opacity: 0; animation: brand-bubble 1.15s var(--delay) ease-out both; }
.brand-bubbles i:nth-child(1) { --x: 12%; --y: 44%; --size: 17px; --delay: .04s; }
.brand-bubbles i:nth-child(2) { --x: 24%; --y: 26%; --size: 9px; --delay: .14s; }
.brand-bubbles i:nth-child(3) { --x: 39%; --y: 17%; --size: 6px; --delay: .05s; }
.brand-bubbles i:nth-child(4) { --x: 81%; --y: 43%; --size: 13px; --delay: .1s; }
.brand-bubbles i:nth-child(5) { --x: 91%; --y: 28%; --size: 7px; --delay: .2s; }
@keyframes brand-bubble {
  0% { transform: translateY(32px) scale(.5); opacity: 0; }
  28% { opacity: .85; }
  100% { transform: translateY(-50px) scale(1.13); opacity: 0; }
}
@keyframes title-rise {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}
.stage-picker {
  padding: 15px 13px 13px;
  border: 1px solid #c6ffec70;
  border-radius: 24px 24px 19px 19px;
  background: linear-gradient(145deg, #103e51e8, #062b3eeb);
  box-shadow: 0 12px 24px #0526354d, inset 0 1px 0 #e7fff233;
  animation: title-rise .46s .23s ease-out both;
}
.stage-picker h2 {
  margin: 0 0 11px;
  color: #ecfff4;
  text-align: left;
  font-size: 17px;
  letter-spacing: .04em;
}
#course-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
#course-list li { min-width: 0; animation: title-rise .4s .33s ease-out both; }
#course-list li:nth-child(2) { animation-delay: .42s; }
#course-list li:nth-child(3) { animation-delay: .51s; }
#course-list button {
  position: relative;
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) 12px;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 85px;
  padding: 0 9px 0 0;
  text-align: left;
  color: var(--ink);
  background: var(--stage-paper, #fff0cb);
  border: 1px solid #fff7ddba;
  border-radius: 14px 17px 17px 13px;
  box-shadow: 0 2px 0 #083747;
  overflow: hidden;
}
#course-list button:not(:disabled) {
  background: linear-gradient(120deg, #fff9e5, var(--stage-paper) 54%, #fff8df);
  border-color: #fff2d0;
  box-shadow: 0 3px 0 #9a664c, 0 5px 10px #051e2e6b, inset 0 1px 0 #fffdf5;
  transition: transform .18s ease-out;
}
#course-list button:not(:disabled)::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(110deg, transparent 36%, #fffdf19e 49%, transparent 61%);
  animation: course-shine 6.2s 1s ease-in-out infinite;
}
@keyframes course-shine {
  0% { transform: translateX(-92%); opacity: 0; }
  6%, 13% { opacity: .54; }
  20%, 100% { transform: translateX(92%); opacity: 0; }
}
@media (hover: hover) {
  #course-list button:not(:disabled):hover { transform: translateY(-3px); }
}
#course-list button:focus-visible:not(:disabled) { transform: translateY(-3px); }
#course-list button:active:not(:disabled) { transform: none; }
#course-list button:disabled { cursor: default; }
#course-list .sand { --stage-paper: #fff0cb; --stage-sky: linear-gradient(#36a3ba, #8adac4 68%, #f8d598); }
#course-list .grass { --stage-paper: #ffe2d3; --stage-sky: linear-gradient(#885985, #e68e8a 60%, #f6b481); }
#course-list .rock { --stage-paper: #e1ebfa; --stage-sky: linear-gradient(#172f58, #425987 75%, #697aa0); }
.course-art { position: relative; align-self: stretch; background: var(--stage-sky, #298d9b); }
.stage-art { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.course-copy { display: grid; gap: 4px; padding-block: 9px; }
.course-copy .name { font-size: clamp(14px, 4.35vw, 18px); line-height: 1.22; font-weight: 900; }
.course-copy .desc { font-size: 12px; line-height: 1.45; font-weight: 600; }
.course-tags { display: flex; flex-wrap: wrap; gap: 3px 4px; }
[data-gimmick="current"] { --tag-color: #125b75; --tag-bg: #d9f4f8; }
[data-gimmick="vent"] { --tag-color: #17645b; --tag-bg: #def6ed; }
[data-gimmick="jelly"] { --tag-color: #594781; --tag-bg: #eee9fb; }
[data-gimmick="moray"] { --tag-color: #75452d; --tag-bg: #f4e4d3; }
[data-gimmick="grass"] { --tag-color: #305d3e; --tag-bg: #e6f1d7; }
.course-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 5px;
  border: 1px solid currentColor;
  border-radius: 6px;
  background: var(--tag-bg, #edf6ed);
  color: var(--tag-color, #265863);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}
.gimmick-icon {
  flex: none;
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.course-copy .time {
  width: fit-content;
  padding: 1px 7px;
  border-radius: 7px 9px 8px 7px;
  background: #b9554820;
  color: #78392b;
  font-size: 10px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}
.course-cue { width: 9px; height: 9px; border: solid #28727b; border-width: 2px 2px 0 0; transform: rotate(45deg); }
/* ロック中の ステージ：少し 灰色に（押しても 始まらない） */
#course-list li.locked button { filter: grayscale(1) brightness(.87); opacity: .86; cursor: default; }
#course-list li.locked button:active { transform: none; }
.locked .course-cue { position: relative; margin-top: 4px; width: 11px; height: 9px; border: 1.5px solid #476175; border-radius: 2px; transform: none; }
.locked .course-cue::before { content: ""; position: absolute; inset: -6px 1px auto; height: 5px; border: 1.5px solid #476175; border-bottom: 0; border-radius: 5px 5px 0 0; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 11px; }
.row button.ghost { padding-inline: 8px; color: #effff7; background: #1d5a69; border-color: #a8e4d578; box-shadow: 0 2px 0 #082f3f, inset 0 1px 0 #a0e2d44d; font-size: 13px; }
#btn-sound { display: flex; align-items: center; justify-content: center; gap: 7px; }
.sound-icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[aria-pressed="true"] .sound-muted, [aria-pressed="false"] .sound-waves { display: none; }

.card {
  width: min(440px, 100%);
  max-height: 100%;
  margin: auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 24px clamp(14px, 5vw, 24px) 19px;
  border: 1px solid #fff6db;
  border-radius: 30px 25px 27px 24px;
  background: radial-gradient(ellipse 125% 50px at 34% 0, #bce8dc 95%, transparent 100%) top / 100% 13px no-repeat, linear-gradient(155deg, #fbfff1, #f9ebcd 94%);
  color: var(--ink);
  box-shadow: 0 4px 0 #0a4054a6;
}
.card h2 { margin: 0 0 10px; color: #174f59; font-size: clamp(22px, 6vw, 31px); line-height: 1.25; }
.card ul { text-align: left; padding-left: 1.3em; margin: 8px 0; font-size: 13px; line-height: 1.55; }
.card li { margin-block: 5px; }
.card ul li::marker { color: #168675; }
.keys { margin: 10px 0; font-size: 12px; color: #335b62; }
#howto { z-index: 12; }
#howto .card { display: flex; flex-direction: column; overflow: hidden; padding: 0; text-align: left; }
.howto-body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 23px 18px 6px; }
#howto-start { flex: none; margin: 6px 18px 17px; }
.howto-stage { margin: 0 0 4px; color: #29646c; font-size: 13px; font-weight: 800; }
.card .howto-list { margin-block: 9px 12px; }
.card .howto-gimmicks { display: grid; gap: 5px; padding: 0; margin: 0; list-style: none; }
.howto-gimmicks li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  padding: 5px 8px;
  border-radius: 8px;
  background: var(--tag-bg, #edf6ed);
  font-size: 12px;
  line-height: 1.5;
}
.howto-gimmicks .gimmick-icon { width: 17px; height: 17px; color: var(--tag-color); }
.howto-gimmicks b { color: var(--tag-color, #265863); margin-inline-end: .55em; }
.phone {
  position: relative;
  width: min(230px, 100%);
  height: 94px;
  margin: 8px auto 10px;
  overflow: hidden;
  border: 2px solid #86c5ba;
  border-radius: 23px 19px 24px 18px;
  background:
    radial-gradient(ellipse 100% 16px at 70% 100%, #d6bf89 96%, transparent),
    linear-gradient(150deg, #358f96, #165a6c);
}
.phone-shrimp { position: absolute; left: 50%; top: 45%; width: 58px; height: 41px; transform: translate(-50%, -50%); animation: diagram-shrimp 4s ease-in-out infinite; }
.finger { position: absolute; left: 50%; top: 45%; width: 20px; height: 20px; margin: -10px; border: 1px solid #fff; border-radius: 50%; background: #edfff4a6; box-shadow: 0 0 0 4px #dbfff445; transform: translateY(23px); animation: diagram-finger 4s ease-in-out infinite; }
.arr { position: absolute; color: #e6fff5; font-size: 16px; font-weight: 900; line-height: 1; }
.arr.up { top: 4px; left: 50%; translate: -50% 0; }
.arr.down { bottom: 3px; left: 50%; translate: -50% 0; }
.arr.left { left: 9px; top: 45%; translate: 0 -50%; }
.arr.right { right: 9px; top: 45%; translate: 0 -50%; }
@keyframes swim { to { transform: translateY(-7px) rotate(-4deg); } }
@keyframes diagram-finger { 0%, 100% { transform: translate(0, 23px); } 25% { transform: translate(-46px, 23px); } 50% { transform: translate(46px, 23px); } 75% { transform: translate(0, 2px); } }
@keyframes diagram-shrimp { 0%, 100% { transform: translate(-50%, -50%); } 25% { transform: translate(calc(-50% - 46px), -50%); } 50% { transform: translate(calc(-50% + 46px), -50%); } 75% { transform: translate(-50%, calc(-50% - 21px)); } }

#pause .card, #result .card { width: min(330px, 100%); }
#pause button, #result button { display: block; width: 100%; margin-top: 9px; }
#pause h2 { margin-bottom: 14px; }
.result-shell { display: block; width: 48px; height: 39px; margin: 0 auto 7px; color: #f2a273; }
#result.winner .result-shell { width: 72px; height: 57px; color: #ffc555; filter: drop-shadow(0 2px 0 #c57842); }
#res-place { color: #14757b; font-size: clamp(54px, 16vw, 79px); font-weight: 1000; line-height: 1; margin: 10px 0 17px; font-variant-numeric: tabular-nums; }
#res-place small { font-size: .39em; margin-left: .12em; }
#result.winner #res-place { color: #a3402e; text-shadow: 0 2px 0 #ffca6f; }
#result.eaten #res-title { font-size: clamp(18px, 5.3vw, 23px); }
#result.eaten #res-place { margin-bottom: 0; }
#res-note { margin: 4px 0 17px; color: #37616b; font-size: 13px; font-weight: 700; }

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; font-variant-numeric: tabular-nums; }
.hud-chip {
  width: max-content;
  padding: 5px 9px;
  border: 1px solid #c0fcf17a;
  border-radius: 13px 11px 14px 9px;
  background: #083e4cc2;
  color: #f0fff8;
}
.hud-rank { position: absolute; top: var(--top); left: var(--left); min-width: 65px; }
#place { line-height: 1; font-weight: 900; }
#place b { display: inline-block; font-size: clamp(31px, 9vw, 42px); color: #fff5d5; }
#place.p1 b { color: #ffce71; }
#place span { font-size: 13px; margin-left: 2px; }
#alive { margin-top: 3px; color: #c9eee7; font-size: 10px; font-weight: 800; white-space: nowrap; }
.hud-course { position: absolute; top: var(--top); right: var(--right); display: flex; align-items: flex-start; gap: 6px; }
.hud-distance { min-width: 104px; text-align: right; }
#lapbox { display: grid; gap: 1px; }
#lapbox span { color: #c9eee7; font-size: 10px; font-weight: 700; line-height: 1; }
#dist { font-size: 19px; line-height: 1; white-space: nowrap; }
.hud-distance.sprint { border-color: #ffdf8ca3; }
.hud-distance.sprint #dist, .hud-distance.sprint #distance-label { color: #ffe28d; }
#timer { color: #c9eee7; font-size: 10px; margin-top: 2px; }
#btn-pause {
  width: 44px;
  height: 44px;
  padding: 0;
  border-color: #c2fff48a;
  border-radius: 47% 54% 48% 50%;
  background: linear-gradient(148deg, #dcfff4cf, #94dcccbd 75%);
  box-shadow: inset 0 1px 0 #fff9;
  display: grid;
  place-items: center;
  pointer-events: auto;
}
#btn-pause span { width: 12px; height: 13px; border: solid #125665; border-width: 0 4px; border-radius: 2px; }
#progress { position: absolute; top: calc(var(--top) + 58px); left: 50%; translate: -50% 0; width: min(345px, calc(100% - var(--left) - var(--right))); height: auto; }
.hud-jump { position: absolute; bottom: var(--bottom); left: var(--left); }
#gauges { min-width: 101px; }
.gauge-label { color: #def6eb; margin-bottom: 2px; font-size: 10px; font-weight: 800; }
#gauges.ready .gauge-label { color: #ffe7a2; }
#boost-pips { display: flex; gap: 4px; }
#boost-pips i { position: relative; display: block; width: 24px; height: 18px; color: #7baea8; }
#boost-pips svg { position: absolute; inset: 0; width: 100%; height: 100%; }
#boost-pips svg + svg { color: #ffd57e; clip-path: inset(0 calc(100% - var(--f, 0%)) 0 0); }
#charge { position: absolute; bottom: calc(100% + 4px); left: 0; width: 101px; height: 14px; overflow: hidden; opacity: 0; border: 1px solid #b3f1e2a8; border-radius: 8px; background: #083e4cdd; transition: opacity .12s; }
#charge.on { opacity: 1; }
#charge-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, #29958c, #449685 70%, #ad664d); }
#charge.full #charge-fill { background: #ac5c46; }
#charge span { position: absolute; inset: 0; color: #fff9dc; font-size: 9px; font-weight: 900; text-align: center; line-height: 12px; }
#speed { position: absolute; right: var(--right); bottom: var(--bottom); }
#speed b { font-size: 17px; line-height: 1; }
#speed span { color: #c9eee7; margin-left: 3px; font-size: 9px; }
#ink, #speedlines, #tags { position: absolute; inset: 0; }
#ink { background: radial-gradient(ellipse at 50% 54%, #21152b80, #160f20ed 77%); opacity: 0; transition: opacity .3s; }
#speedlines { opacity: 0; background: repeating-conic-gradient(from 0deg at 50% 55%, transparent 0deg 11deg, #d6fdff48 11deg 11.5deg); mask-image: radial-gradient(ellipse, transparent 65%, #000); }
#tags .me { position: absolute; left: 0; top: 0; width: 14px; height: 11px; }
#tags .me::before, #tags .me::after { content: ""; position: absolute; inset: 0; clip-path: polygon(0 0, 100% 0, 50% 100%); background: #573e2e; }
#tags .me::after { inset: 1px 2px 2px; background: #ffda73; }

.threat-bounds { position: absolute; inset: calc(var(--top) + 94px) calc(var(--right) + 8px) calc(var(--bottom) + 48px) calc(var(--left) + 8px); }
#threat-arrow, #threat-mark { position: absolute; left: 0; top: 0; }
#threat-arrow i {
  position: relative;
  display: block;
  width: 25px;
  height: 22px;
  animation: threat-pulse .62s ease-in-out infinite alternate;
}
#threat-arrow i::before, #threat-arrow i::after {
  content: "";
  position: absolute;
  inset: 0;
  clip-path: polygon(0 24%, 49% 24%, 49% 0, 100% 50%, 49% 100%, 49% 76%, 0 76%);
  background: #fff3df;
}
#threat-arrow i::after { inset: 4px 3px; background: #d52d3f; }
#threat-mark {
  display: grid;
  place-items: center;
  width: 21px;
  height: 21px;
  border: 1.5px solid #fff3df;
  border-radius: 50%;
  background: #ad2435;
  color: #fff3df;
  font-size: 16px;
  font-weight: 950;
  line-height: 1;
}
@keyframes threat-pulse { to { transform: scale(1.16); } }

.race-effect { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
#current-effect, #stun-effect { opacity: 0; }
#current-effect::before, #current-effect::after {
  content: "";
  position: absolute;
  inset: 25% auto 22% -11%;
  width: 42%;
  background:
    linear-gradient(90deg, transparent, #a7f4ffd9, transparent) 18% 14% / 73% 2px,
    linear-gradient(90deg, transparent, #80e8ffbd, transparent) 46% 37% / 63% 2px,
    linear-gradient(90deg, transparent, #bcfbffe0, transparent) 5% 61% / 91% 1px,
    linear-gradient(90deg, transparent, #80e8ffbd, transparent) 44% 87% / 75% 3px;
  background-repeat: no-repeat;
  transform: skewY(-7deg);
}
#current-effect::after { inset: 29% -11% 17% auto; transform: skewY(7deg); }
#stun-effect { background: radial-gradient(ellipse at center, transparent 66%, #ffca36a6); }
#finish-bubbles { position: fixed; z-index: 9; }
.race-bubble {
  position: absolute;
  width: var(--size);
  height: var(--size);
  border: 1.5px solid var(--bubble-color);
  border-radius: 50%;
  background: radial-gradient(circle at 33% 28%, #fffdf4 0 8%, transparent 14%);
  opacity: 0;
  animation: rise var(--duration) ease-out var(--delay);
}
@keyframes rise {
  0% { opacity: 0; transform: scale(.6); }
  18% { opacity: .95; }
  67% { opacity: .74; }
  100% { opacity: 0; transform: translate(var(--drift), var(--rise)) scale(1.12); }
}

#msg, .popup, #tip {
  position: absolute;
  left: 50%;
  translate: -50% 0;
  width: max-content;
  max-width: calc(100% - var(--left) - var(--right));
  text-align: center;
  font-weight: 850;
}
#msg {
  top: calc(var(--top) + 110px);
  padding: 5px 12px;
  color: #104f59;
  background: #e4fff1ed;
  border: 1px solid #fffee6;
  border-radius: 14px 17px 14px 12px;
  opacity: 0;
  font-size: clamp(13px, 4vw, 18px);
  transition: opacity .16s;
}
#msg.on { opacity: 1; }
#msg.warn {
  padding-left: 27px;
  color: #fff4ed;
  background: #a62d38;
  border-color: #ffd4b5;
  animation: danger .63s ease-in-out infinite alternate;
}
#msg.warn::before { content: "!"; position: absolute; left: 9px; top: 50%; translate: 0 -50%; color: #a62d38; width: 13px; height: 14px; line-height: 14px; border-radius: 50%; background: #ffe6b8; font-size: 10px; }
#msg.caution { background: #ffe4c4ec; color: #683626; border-color: #fff4db; }
@keyframes danger { from { transform: scale(1); } to { transform: scale(1.035); background: #be4047; } }
.popup {
  top: calc(var(--top) + 147px);
  padding: 4px 9px;
  color: #53351e;
  background: #fff0beec;
  border-radius: 12px 9px 14px 10px;
  opacity: 0;
  font-size: 13px;
}
#msg.current, #msg.vent, .popup.current, .popup.vent { background: #dcfaffed; color: #164e60; }
#msg.hit, .popup.hit { background: #fff0beed; color: #643f10; }
#count {
  position: absolute;
  top: 34%;
  left: 50%;
  translate: -50% -10%;
  display: grid;
  place-items: center;
  width: 98px;
  height: 92px;
  border: 2px solid #ebfff5db;
  border-radius: 49% 53% 49% 52%;
  color: #f8fff3;
  background: radial-gradient(ellipse at 26% 18%, #effff1b3 0 6%, transparent 9%), radial-gradient(ellipse at 34% 34%, #50bdaab3, #157d90dc 77%);
  box-shadow: inset 0 -3px 0 #bbffeb66;
  font-size: 61px;
  font-weight: 950;
  text-shadow: 0 2px 0 #0c5466;
}
#count.go { width: 172px; height: 76px; color: #fff6c4; font-size: 29px; }
#count i { position: absolute; inset: -8px; border-radius: 50%; border: 2px solid #eafff3; opacity: 0; }
#count i::before, #count i::after { content: ""; position: absolute; width: 10px; height: 10px; border: 1px solid #eafff3; border-radius: 50%; }
#count i::before { left: -3px; top: 4px; }
#count i::after { right: -5px; bottom: 7px; width: 6px; height: 6px; }
#tip { top: calc(34% + 100px); padding: 5px 8px; border-radius: 10px; background: #064554cc; color: #fff6d0; font-size: 12px; }

#touch { position: fixed; inset: 0; z-index: 4; touch-action: none; }
#touch-hint {
  position: absolute;
  left: 50%;
  bottom: calc(var(--bottom) + 70px);
  translate: -50% 0;
  width: max-content;
  max-width: calc(100% - var(--left) - var(--right));
  padding: 4px 8px;
  border-radius: 9px 13px 11px 12px;
  background: #064554b3;
  color: #f2fff8;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  pointer-events: none;
  transition: opacity .4s;
}
#touch-hint.off { opacity: 0; }

@media (min-width: 760px) {
  .title-layout { width: min(100%, 1120px); grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: clamp(32px, 6vw, 78px); align-items: center; }
  .brand-shrimp { width: clamp(204px, 24vw, 285px); }
  .logo { font-size: clamp(63px, 8.75vw, 112px); }
  .sub { font-size: clamp(17px, 2vw, 22px); }
  .stage-picker { padding: 18px; }
  #course-list button { grid-template-columns: clamp(66px, 7vw, 92px) minmax(0, 1fr) 15px; min-height: 86px; }
  #progress { left: 50%; translate: -50% 0; top: calc(var(--top) + 6px); width: min(340px, 35vw); }
  #msg { top: calc(var(--top) + 48px); }
  .popup { top: calc(var(--top) + 87px); }
  .threat-bounds { inset-block-start: calc(var(--top) + 73px); }
}

@media (max-height: 510px) and (orientation: landscape) {
  .title-layout { gap: clamp(20px, 5vw, 50px); padding-block: 2px 5px; }
  .loading-layout { gap: 12px; }
  .brand-shrimp { width: min(174px, 30vw); }
  .logo { font-size: clamp(45px, 8.3vw, 76px); }
  .stage-picker { padding-block: 9px; }
  #course-list button { min-height: 71px; }
  #progress { left: 50%; translate: -50% 0; top: calc(var(--top) + 4px); width: min(300px, 34vw); }
  #msg { top: calc(var(--top) + 41px); }
  .popup { top: calc(var(--top) + 74px); }
  #count { top: 35%; width: 81px; height: 75px; font-size: 48px; }
  #count.go { width: 150px; height: 66px; font-size: 26px; }
  #tip { top: calc(35% + 79px); }
  .threat-bounds { inset-block-start: calc(var(--top) + 73px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .stage-picker button:not(:disabled):is(:hover, :focus-visible, :active) { transform: none !important; translate: none; }
}

/* 加速リングを くぐった 瞬間：水色の 光が 画面の ふちから 広がって 消える */
#ringflash { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: radial-gradient(ellipse at 50% 55%, rgba(170,250,255,0) 35%, rgba(120,235,255,.55) 75%, rgba(220,255,255,.85) 100%); }
#ringflash.on { animation: ringflash .6s ease-out; }
@keyframes ringflash { 0% { opacity: 1; transform: scale(1.06); } 100% { opacity: 0; transform: scale(1); } }
