.play-body {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #06131F;
  touch-action: none;
  overscroll-behavior: none;
}

#gameCanvas {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  outline: none;
}

.game-hud {
  position: fixed;
  inset: 0;
  z-index: 10;
  padding: calc(9px + env(safe-area-inset-top, 0px)) 15px 0;
  pointer-events: none;
}

.hud-row {
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: 520px;
  margin: 0 auto;
  pointer-events: none;
}

.hud-btn {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 39px;
  height: 39px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 13px;
  color: #EEF8FF;
  background: linear-gradient(180deg, rgba(20, 50, 75, 0.78), rgba(6, 20, 33, 0.82));
  box-shadow: 0 7px 16px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: auto;
  cursor: pointer;
  transition: transform 0.12s ease;
}

.hud-btn:active {
  transform: scale(0.9);
}

.hud-btn .mp-icon {
  font-size: 21px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
}

.hud-btn .icon-off {
  display: none;
}

.hud-btn.off .icon-on {
  display: none;
}

.hud-btn.off .icon-off {
  display: inline-block;
}

.mode-chip {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 39px;
  padding: 4px 12px;
  border: 1px solid rgba(255, 186, 90, 0.55);
  border-radius: 13px;
  background: linear-gradient(180deg, rgba(51, 32, 20, 0.82), rgba(15, 24, 36, 0.82));
  box-shadow: 0 7px 16px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 230, 180, 0.16);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.mode-chip b {
  color: #FFD987;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.03em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}

.mode-chip span {
  padding-left: 7px;
  border-left: 1px solid rgba(255, 214, 140, 0.3);
  color: #F1DFC9;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.hearts {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  flex: 1 1 auto;
  min-width: 0;
}

.hearts .mp-icon {
  font-size: 23px;
  color: #FF6170;
  filter: drop-shadow(0 0 6px rgba(255, 72, 92, 0.55)) drop-shadow(0 2px 2px rgba(0, 0, 0, 0.55));
  transition: color 0.18s ease, filter 0.18s ease, transform 0.18s ease;
}

.hearts .mp-icon.empty {
  color: rgba(255, 255, 255, 0.2);
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.45));
  transform: scale(0.86);
}

.hearts.beat .mp-icon:not(.empty) {
  animation: heartBeat 0.28s ease;
}

.scoreboard {
  max-width: 520px;
  margin: 7px auto 0;
  text-align: center;
  animation: scoreIn 0.5s 0.1s ease both;
}

.score-line {
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  line-height: 0.9;
}

.score-line #score {
  font-size: clamp(34px, 9.2vw, 46px);
  font-weight: 900;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #FFF7C8 0%, #FFD65A 42%, #FF9E3D 82%, #F37720 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 0 rgba(116, 47, 7, 0.85)) drop-shadow(0 6px 12px rgba(0, 0, 0, 0.55));
}

.score-line em {
  font-style: normal;
  font-size: 10.5px;
  font-weight: 800;
  color: #FFDCA0;
  letter-spacing: 0.08em;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.65);
  transform: translateY(-2px);
}

.sub-line {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 25px;
  margin-top: 5px;
  padding: 3px 10px;
  border-radius: 99px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: rgba(5, 19, 31, 0.58);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
  color: #DCEBF6;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  white-space: nowrap;
}

.stage-chip {
  color: #FFD46A;
  font-weight: 900;
}

.sep {
  width: 1px;
  height: 10px;
  background: rgba(255, 255, 255, 0.22);
}

.timer {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding-left: 7px;
  border-left: 1px solid rgba(255, 255, 255, 0.18);
  color: #FFF1D2;
}

.timer .mp-icon {
  font-size: 13px;
  color: #FFC65C;
}

.timer b {
  font-size: 10.5px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.timer.urgent {
  color: #FF7A84;
  animation: timerPulse 0.9s ease-in-out infinite;
}

.timer.urgent .mp-icon {
  color: #FF7A84;
}

.grow {
  display: block;
  width: 150px;
  height: 5px;
  margin: 6px auto 0;
  border-radius: 99px;
  background: rgba(5, 19, 30, 0.6);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

.grow span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #FF8A3D, #FFD45C);
  box-shadow: 0 0 9px rgba(255, 185, 70, 0.8);
  transition: width 0.35s ease;
}

/* intro ---------------------------------------------------------------- */

.intro {
  position: fixed;
  inset: 0;
  z-index: 32;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(ellipse at 50% 45%, rgba(4, 16, 26, 0.42), rgba(2, 8, 14, 0.78));
  pointer-events: none;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.intro.out {
  opacity: 0;
  visibility: hidden;
}

.intro-card {
  width: min(84vw, 300px);
  padding: 22px 22px 18px;
  border-radius: 24px;
  border: 1.5px solid rgba(255, 190, 96, 0.5);
  background:
    radial-gradient(120% 100% at 50% 0%, rgba(255, 151, 62, 0.18), transparent 60%),
    linear-gradient(180deg, #1B3B55 0%, #0A1E31 100%);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 0 40px rgba(255, 138, 61, 0.14);
  text-align: center;
  animation: introPop 0.55s cubic-bezier(0.16, 0.9, 0.25, 1.1) both;
}

.intro-kicker {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 99px;
  background: rgba(255, 171, 70, 0.15);
  border: 1px solid rgba(255, 190, 100, 0.35);
  color: #FFD88D;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.intro-card strong {
  display: block;
  margin-top: 10px;
  color: #FFF4D0;
  font-size: 29px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-shadow: 0 2px 0 rgba(104, 44, 5, 0.7), 0 6px 16px rgba(0, 0, 0, 0.5);
}

.intro-card p {
  margin: 7px 0 0;
  color: #C3D8E8;
  font-size: 12px;
  line-height: 1.5;
}

.intro-start {
  display: block;
  margin-top: 15px;
  color: #FFB557;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  animation: startPulse 1.1s ease-in-out infinite;
}

/* transient banners ---------------------------------------------------- */

.banner {
  position: fixed;
  left: 50%;
  top: calc(168px + env(safe-area-inset-top, 0px));
  z-index: 26;
  min-width: 180px;
  max-width: 86vw;
  padding: 10px 20px;
  border-radius: 16px;
  border: 1.5px solid rgba(255, 204, 116, 0.55);
  background: linear-gradient(180deg, rgba(41, 32, 24, 0.94), rgba(11, 24, 37, 0.94));
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.13);
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, -10px) scale(0.94);
  pointer-events: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.banner.show {
  animation: bannerIn 1.7s ease both;
}

.banner b {
  display: block;
  color: #FFE39A;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.03em;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.banner small {
  display: block;
  margin-top: 2px;
  color: #BBD0E0;
  font-size: 10.5px;
  letter-spacing: 0.03em;
}

.combo {
  position: fixed;
  right: 18px;
  top: calc(176px + env(safe-area-inset-top, 0px));
  z-index: 25;
  padding: 6px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 196, 90, 0.35);
  background: rgba(9, 24, 38, 0.7);
  color: #FFD86A;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.55);
  opacity: 0;
  transform: scale(0.7);
  pointer-events: none;
}

.combo.show {
  animation: comboPop 0.9s ease both;
}

/* controls ------------------------------------------------------------- */

.joystick {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 12;
  width: 104px;
  height: 104px;
  margin: -52px 0 0 -52px;
  opacity: 0;
  transform: scale(0.86);
  transition: opacity 0.12s ease, transform 0.12s ease;
  pointer-events: none;
}

.joystick.active {
  opacity: 1;
  transform: scale(1);
}

.joy-base {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid rgba(255, 190, 100, 0.5);
  background: radial-gradient(circle at 50% 50%, rgba(255, 172, 74, 0.17), rgba(4, 17, 28, 0.12) 68%, transparent 72%);
  box-shadow: 0 0 26px rgba(255, 140, 50, 0.2), inset 0 0 24px rgba(255, 180, 80, 0.12);
}

.joy-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border-radius: 50%;
  border: 2px solid rgba(255, 237, 190, 0.9);
  background: radial-gradient(circle at 35% 28%, #FFF0BE 0%, #FFB34F 42%, #F0761E 78%, #B84E10 100%);
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.45), 0 0 18px rgba(255, 150, 55, 0.55), inset 0 2px 3px rgba(255, 255, 255, 0.55);
  will-change: transform;
}

.hint {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  z-index: 11;
  transform: translateX(-50%);
  padding: 7px 14px;
  border-radius: 99px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(4, 16, 27, 0.56);
  color: #D9E9F4;
  font-size: 11px;
  letter-spacing: 0.03em;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.hint.hide {
  opacity: 0;
}

/* full screen fx ------------------------------------------------------- */

.fx-vignette {
  position: fixed;
  inset: 0;
  z-index: 6;
  background: radial-gradient(ellipse at 50% 48%, transparent 48%, rgba(2, 8, 14, 0.34) 78%, rgba(1, 5, 9, 0.62) 100%);
  pointer-events: none;
}

.fx-flash {
  position: fixed;
  inset: 0;
  z-index: 21;
  opacity: 0;
  background: radial-gradient(circle at 50% 50%, rgba(255, 62, 62, 0) 22%, rgba(255, 40, 46, 0.62) 100%);
  mix-blend-mode: screen;
  pointer-events: none;
}

/* modals --------------------------------------------------------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom, 0px));
  background: rgba(2, 9, 16, 0.68);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: maskFade 0.22s ease both;
}

.modal[hidden] {
  display: none;
}

.panel {
  width: 100%;
  max-width: 344px;
  max-height: 88dvh;
  overflow-y: auto;
  padding: 22px 20px 18px;
  border-radius: 26px;
  border: 1.5px solid rgba(255, 196, 104, 0.28);
  background:
    radial-gradient(130% 60% at 50% 0%, rgba(255, 149, 56, 0.14), transparent 62%),
    linear-gradient(180deg, #1B3D58 0%, #0A1E31 100%);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.62), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  text-align: center;
  animation: panelIn 0.36s cubic-bezier(0.16, 0.9, 0.25, 1.08) both;
}

.panel-kicker {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 99px;
  background: rgba(255, 173, 70, 0.14);
  border: 1px solid rgba(255, 195, 105, 0.3);
  color: #FFD991;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.09em;
}

.panel h2 {
  margin: 10px 0 0;
  color: #FFF3D0;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 0 rgba(88, 39, 7, 0.6), 0 6px 16px rgba(0, 0, 0, 0.45);
}

.panel-desc {
  margin: 7px 0 20px;
  color: #B7CDDD;
  font-size: 12px;
  line-height: 1.5;
}

.panel [hidden] {
  display: none !important;
}

.panel .btn-primary,
.panel .btn-secondary,
.panel .btn-ghost {
  display: block;
  width: 100%;
  height: 48px;
  margin-top: 9px;
  border-radius: 15px;
  border: 0;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}

.panel .btn-primary:active,
.panel .btn-secondary:active,
.panel .btn-ghost:active {
  transform: scale(0.975);
  filter: brightness(1.07);
}

.btn-primary {
  color: #3B2207;
  background: linear-gradient(180deg, #FFE47E 0%, #FFB24D 48%, #F27B22 100%);
  box-shadow: 0 8px 20px rgba(242, 123, 34, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.65), inset 0 -2px 0 rgba(155, 69, 10, 0.45);
}

.btn-secondary {
  color: #FFF2DD;
  background: linear-gradient(180deg, #B061F5 0%, #8237CF 100%);
  box-shadow: 0 8px 20px rgba(120, 45, 190, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.3), inset 0 -2px 0 rgba(61, 15, 107, 0.45);
}

.btn-ghost {
  color: #D7E7F3;
  background: rgba(255, 255, 255, 0.08) !important;
  border: 1px solid rgba(255, 255, 255, 0.14) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.pause-panel .panel-desc {
  margin-bottom: 18px;
}

/* results -------------------------------------------------------------- */

.result-panel {
  padding-top: 20px;
}

.result-score {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  margin: 6px 0 2px;
}

.result-score span {
  font-size: 48px;
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #FFF7C8, #FFD45C 50%, #FF9A3A);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 0 rgba(110, 44, 6, 0.8)) drop-shadow(0 7px 14px rgba(0, 0, 0, 0.45));
}

.result-score em {
  font-style: normal;
  color: #FFD894;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.09em;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 13px 0 4px;
  padding: 11px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.result-grid > div {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.result-grid > div + div::before {
  content: "";
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 1px;
  background: rgba(255, 255, 255, 0.12);
}

.result-grid b {
  color: #F4E7CF;
  font-size: 15px;
  font-weight: 900;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.result-grid span {
  color: #8FA9BC;
  font-size: 9.5px;
  letter-spacing: 0.03em;
}

.new-record {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 10px auto 2px;
  padding: 3px 11px;
  border-radius: 99px;
  border: 1px solid rgba(255, 210, 90, 0.45);
  background: rgba(255, 172, 55, 0.14);
  color: #FFDE7C;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.05em;
  animation: recordGlow 1.6s ease-in-out infinite;
}

.new-record .mp-icon {
  font-size: 14px;
}

.new-record[hidden] {
  display: none;
}

/* animations ----------------------------------------------------------- */

@keyframes scoreIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes heartBeat {
  0%, 100% { transform: scale(1); }
  35% { transform: scale(1.28); }
  70% { transform: scale(0.94); }
}

@keyframes timerPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

@keyframes introPop {
  from { opacity: 0; transform: scale(0.86) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes startPulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

@keyframes bannerIn {
  0% { opacity: 0; visibility: hidden; transform: translate(-50%, -12px) scale(0.9); }
  12% { opacity: 1; visibility: visible; transform: translate(-50%, 0) scale(1); }
  78% { opacity: 1; visibility: visible; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; visibility: hidden; transform: translate(-50%, -8px) scale(0.97); }
}

@keyframes comboPop {
  0% { opacity: 0; transform: scale(0.5) rotate(-6deg); }
  22% { opacity: 1; transform: scale(1.12) rotate(2deg); }
  52% { opacity: 1; transform: scale(1) rotate(0); }
  100% { opacity: 0; transform: scale(0.92) translateY(-8px); }
}

@keyframes maskFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes panelIn {
  from { opacity: 0; transform: scale(0.9) translateY(16px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes recordGlow {
  0%, 100% { box-shadow: 0 0 0 rgba(255, 200, 70, 0); }
  50% { box-shadow: 0 0 18px rgba(255, 200, 70, 0.28); }
}

@media (max-height: 700px) {
  .score-line #score { font-size: 34px; }
  .scoreboard { margin-top: 3px; }
  .banner { top: calc(145px + env(safe-area-inset-top, 0px)); }
  .intro-card { padding: 17px 18px 14px; }
  .intro-card strong { font-size: 24px; }
  .panel { padding: 18px 16px 14px; }
  .panel h2 { font-size: 21px; }
  .result-score span { font-size: 40px; }
  .panel .btn-primary, .panel .btn-secondary, .panel .btn-ghost { height: 44px; margin-top: 7px; }
}

@media (max-height: 600px) {
  .hud-row { gap: 6px; }
  .hearts .mp-icon { font-size: 19px; }
  .sub-line { margin-top: 2px; }
  .grow { margin-top: 3px; }
  .hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
