* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --cell: 34px;
  --bg:           #ff7a00;
  --bg-board:     #fffaf0;
  --accent:       #ffd700;
  --accent2:      #ffffff;
  --text:         #2d0000;
  --border-radius-board: 20px;
  --border-radius-cell:  50%;
  --board-border: 4px solid #ffd700;
  --cell-border:  2px solid rgba(0,0,0,0.12);
  --font-body:    'Kosugi Maru', 'Arial Rounded MT Bold', sans-serif;
  --font-title:   'Kosugi Maru', 'Arial Rounded MT Bold', sans-serif;
  --title-shadow: 3px 3px 0 #8b0000, -1px -1px 0 #8b0000;
  --board-shadow: 0 8px 40px rgba(200,50,0,0.5), 0 0 0 5px #ffd700, 0 0 0 9px #e53935;
  --n1: #1565c0; --n2: #2e7d32; --n3: #c62828; --n4: #6a1b9a;
  --n5: #e65100; --n6: #00695c; --n7: #ad1457; --n8: #37474f;
}

html, body { height: 100%; }
body {
  color: var(--text);
  font-family: var(--font-body);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100%;
  padding: 0;
  background: linear-gradient(150deg, #ffb74d 0%, #ff6d00 45%, #e64a19 100%);
  background-attachment: fixed;
}

h1 { display: none; }

/* ── App shell ── */
/* Mobile: lock to viewport height, board fills remaining space */
#app {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 520px;
  height: 100svh;
  overflow: hidden;
}

/* Desktop: let content size naturally, HUD spans full width, game content stays centered */
@media (min-width: 521px) {
  body { padding: 0; overflow-y: auto; }
  #app { height: auto; overflow: visible; max-width: 100%; }
  #hud { padding: 8px 24px; }
  #board-wrap { flex: 0 0 auto; padding: 12px 0; max-width: 520px; width: 100%; align-self: center; }
  #mini-run-bar { max-width: 520px; width: 100%; align-self: center; }
  #combo-bar { max-width: 520px; width: 100%; align-self: center; }
  #stats-panel { margin-top: 24px; max-width: 520px; width: 100%; align-self: center; }
}

/* ── Don-chan inline in mini-run-bar ── */
#don-chan-overlay {
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
  margin-left: auto;
}
#don-chan-overlay.visible { opacity: 1; }
#don-chan-overlay .don-chan {
  width: clamp(26px, 8vw, 38px);
  height: clamp(26px, 8vw, 38px);
  display: block;
}

.don-chan {
  width: 52px;
  height: 52px;
  transform-origin: bottom center;
  cursor: default;
  user-select: none;
}
.don-chan.bounce   { animation: dc-bounce   0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97); }
.don-chan.katsu    { animation: dc-katsu    0.6s cubic-bezier(0.22, 0.61, 0.36, 1); }
.don-chan.hype     { animation: dc-hype     0.8s cubic-bezier(0.22, 0.61, 0.36, 1); }
.don-chan.scared   { animation: dc-scared   0.55s ease-out; }
.don-chan.celebrate{ animation: dc-celebrate 0.7s ease-in-out infinite; }


/* ── Don-chan face animations ── */
@keyframes dc-blink {
  0%, 88%, 100% { transform: scaleY(1); }
  92%           { transform: scaleY(0.07); }
  96%           { transform: scaleY(1); }
}
@keyframes dc-look {
  0%,100% { transform: translate(0px,  0px); }
  20%     { transform: translate(1px,  0px); }
  50%     { transform: translate(0.5px,0.8px); }
  75%     { transform: translate(-0.8px,0px); }
}

/* Eyes blink continuously */
.dc-eye {
  transform-box: fill-box;
  transform-origin: center;
  animation: dc-blink 3.8s ease-in-out infinite;
}
.dc-eye-r { animation-delay: 0.05s; }

/* Pupils drift lazily */
.dc-pupil {
  transform-box: fill-box;
  transform-origin: center;
  animation: dc-look 6s ease-in-out infinite;
}
.dc-pupil-r { animation-delay: -2s; }
.dc-shine {
  transform-box: fill-box;
  transform-origin: center;
}

/* Eyebrows: only one set visible at a time */
.dc-brow { stroke: #b71c1c; stroke-width: 2.5; fill: none; stroke-linecap: round; }
.dc-brow-scared, .dc-brow-happy, .dc-brow-cry { display: none; }

/* Tears: hidden by default */
.dc-tear { display: none; }
@keyframes dc-tear-fall {
  0%   { transform: translateY(0);    opacity: 0.9; }
  100% { transform: translateY(10px); opacity: 0; }
}

/* Mouths: only one visible at a time */
.dc-mouth { display: none; }
.dc-mouth-default { display: block; }

/* ── bounce: happy squint ── */
.don-chan.bounce .dc-eye    { transform: scaleY(0.35); animation: none; }
.don-chan.bounce .dc-pupil  { transform: translateY(-1.5px); animation: none; }
.don-chan.bounce .dc-shine  { transform: translateY(-1.5px); }
.don-chan.bounce .dc-mouth-default  { display: none; }
.don-chan.bounce .dc-mouth-bounce   { display: block; }
.don-chan.bounce .dc-brow-normal    { display: none; }
.don-chan.bounce .dc-brow-happy     { display: block; }

/* ── katsu: wink + smirk for flag actions ── */
.don-chan.katsu .dc-eye-l   { transform: scaleY(1.08) scaleX(1.03); animation: none; }
.don-chan.katsu .dc-eye-r   { transform: scaleY(0.16) translateY(1.4px); animation: none; }
.don-chan.katsu .dc-pupil-l { transform: translate(-0.5px, -0.4px); animation: none; }
.don-chan.katsu .dc-pupil-r { opacity: 0; animation: none; }
.don-chan.katsu .dc-shine-l { transform: translate(-0.4px, -0.4px); }
.don-chan.katsu .dc-shine-r { opacity: 0; }
.don-chan.katsu .dc-mouth-default  { display: none; }
.don-chan.katsu .dc-mouth-bounce   { display: block; }
.don-chan.katsu .dc-brow-normal    { display: none; }
.don-chan.katsu .dc-brow-happy     { display: block; }

/* ── hype: wide-eyed excited grin for bonus moments ── */
.don-chan.hype .dc-eye    { transform: scaleY(1.18) scaleX(1.05); animation: none; }
.don-chan.hype .dc-pupil  { transform: translateY(-1.3px); animation: none; }
.don-chan.hype .dc-shine  { transform: translateY(-1.3px); }
.don-chan.hype .dc-mouth-default   { display: none; }
.don-chan.hype .dc-mouth-celebrate { display: block; }
.don-chan.hype .dc-brow-normal     { display: none; }
.don-chan.hype .dc-brow-happy      { display: block; }

/* ── scared: wide eyes, open mouth ── */
.don-chan.scared .dc-eye    { transform: scaleY(1.25) scaleX(1.05); animation: none; }
.don-chan.scared .dc-pupil  { transform: scale(0.7); animation: none; }
.don-chan.scared .dc-mouth-default  { display: none; }
.don-chan.scared .dc-mouth-scared   { display: block; }
.don-chan.scared .dc-brow-normal    { display: none; }
.don-chan.scared .dc-brow-scared    { display: block; }

/* ── celebrate: crescent squint, big smile ── */
.don-chan.celebrate .dc-eye    { transform: scaleY(0.12); animation: none; }
.don-chan.celebrate .dc-pupil  { opacity: 0; animation: none; }
.don-chan.celebrate .dc-shine  { opacity: 0; }
.don-chan.celebrate .dc-mouth-default   { display: none; }
.don-chan.celebrate .dc-mouth-celebrate { display: block; }
.don-chan.celebrate .dc-brow-normal     { display: none; }
.don-chan.celebrate .dc-brow-happy      { display: block; }

/* ── cry: sad squint, frown, tears ── */
.don-chan.cry .dc-eye    { transform: scaleY(0.18); animation: none; }
.don-chan.cry .dc-pupil  { opacity: 0; animation: none; }
.don-chan.cry .dc-shine  { opacity: 0; }
.don-chan.cry .dc-mouth-default { display: none; }
.don-chan.cry .dc-mouth-cry     { display: block; }
.don-chan.cry .dc-brow-normal   { display: none; }
.don-chan.cry .dc-brow-cry      { display: block; }
.don-chan.cry .dc-tear {
  display: block;
  transform-box: fill-box;
  transform-origin: top center;
  animation: dc-tear-fall 0.6s ease-in infinite;
}
.don-chan.cry .dc-tear-r { animation-delay: 0.3s; }

/* ── HUD: compact single row ── */
#hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 6px 12px;
  background: rgba(0,0,0,0.25);
  position: relative;
  flex-shrink: 0;
}
#hud-left, #hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
#hud-right { justify-content: flex-end; }
.hud-timer {
  font-family: 'Fredoka One', 'Kosugi Maru', sans-serif;
  font-size: 0.95rem;
  color: rgba(255,255,255,0.8);
}
.hud-timer span { color: #ffd700; }
#mode-toggle {
  display: flex;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(0,0,0,0.22);
}
.mode-btn {
  padding: 3px 9px;
  font-size: clamp(0.6rem, 2vw, 0.72rem);
  font-family: 'Fredoka One', 'Kosugi Maru', sans-serif;
  font-weight: 700;
  letter-spacing: 0.03em;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.45);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.mode-btn.active {
  background: var(--accent);
  color: var(--bg);
}
#controls-toggle {
  width: 28px; height: 28px;
  border: none;
  background: rgba(255,255,255,0.12);
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.1rem;
  color: rgba(255,255,255,0.8);
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
#controls-toggle:hover { background: rgba(255,255,255,0.22); }
#controls-panel {
  display: none;
  position: absolute;
  top: 100%;
  right: 12px;
  z-index: 200;
  grid-column: 1 / -1;
  background: rgba(30,10,0,0.92);
  border: 1px solid rgba(255,215,0,0.3);
  border-radius: 10px;
  padding: 6px;
  flex-direction: column;
  gap: 4px;
  min-width: 120px;
}
#controls-panel.open { display: flex; }
.ctrl-btn {
  padding: 6px 12px;
  border: none;
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.85);
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.8rem;
  font-family: var(--font-body);
  font-weight: bold;
  text-align: left;
  transition: background 0.12s;
}
.ctrl-btn:hover { background: rgba(255,215,0,0.18); color: #ffd700; }

/* ── Total score display (centered in HUD grid) ── */
#total-score-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
}
#score-readout {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
}
#total-score-label {
  font-family: 'Fredoka One', 'Kosugi Maru', sans-serif;
  font-size: 0.65rem;
  color: rgba(255,215,0,0.7);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
#total-score {
  font-family: 'Fredoka One', 'Kosugi Maru', sans-serif;
  font-size: 1.6rem;
  color: #ffd700;
  font-variant-numeric: tabular-nums;
  text-shadow: 2px 2px 0 #8b0000, -1px -1px 0 #8b0000;
  line-height: 1.1;
}
#score-bonus-tray {
  position: absolute;
  left: calc(100% + 6px);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  min-width: 42px;
  min-height: 30px;
}
.bonus-card {
  width: 38px;
  height: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 2px solid rgba(255, 244, 197, 0.9);
  background: linear-gradient(145deg, #fff5b8 0%, #ffc83d 56%, #f39c12 100%);
  box-shadow: 0 4px 10px rgba(138, 72, 0, 0.35), inset 0 1px 0 rgba(255,255,255,0.55);
  color: #6a2200;
  text-shadow: 0 1px 0 rgba(255,255,255,0.45);
  font-family: 'Fredoka One', 'Kosugi Maru', sans-serif;
  transform: rotate(-5deg);
}
.bonus-card-top {
  font-size: 0.34rem;
  letter-spacing: 0.1em;
  line-height: 1;
}
.bonus-card-main {
  font-size: 0.8rem;
  line-height: 1;
}
.bonus-card.life-card .bonus-card-main {
  letter-spacing: 0.04em;
}
.bonus-card-wrapper {
  position: relative;
  display: flex;
  align-items: flex-end;
}
.bonus-card-count {
  font-family: 'Fredoka One', 'Kosugi Maru', sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  color: #ffd700;
  text-shadow: 1px 1px 0 #8b5e00, -1px -1px 0 #8b5e00;
  line-height: 1;
  margin-left: 2px;
  margin-bottom: 3px;
}
.bonus-fly-card {
  position: fixed;
  left: 0;
  top: 0;
  margin: 0;
  pointer-events: none;
  z-index: 9006;
}

#message {
  font-size: 1rem;
  font-weight: bold;
  color: var(--accent2);
  font-family: var(--font-body);
  text-shadow: 1px 1px 0 rgba(0,0,0,0.3);
  margin-bottom: 6px;
  min-height: 22px;
  text-align: center;
}

#board {
  display: inline-grid;
  gap: 4px;
  background: var(--bg-board);
  padding: 12px;
  border-radius: var(--border-radius-board);
  border: var(--board-border);
  box-shadow: var(--board-shadow);
  user-select: none;
  transition: all 0.3s;
}

.cell {
  width: var(--cell);
  height: var(--cell);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--cell) * 0.43);
  font-weight: bold;
  border-radius: var(--border-radius-cell);
  border: var(--cell-border);
  cursor: pointer;
  transition: background 0.08s, transform 0.1s;
  font-family: var(--font-body);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.cell.hidden {
  background: radial-gradient(circle at 35% 30%, #ff6b6b, #c0392b 70%);
  box-shadow: 0 3px 8px rgba(0,0,0,0.3), inset 0 1px 4px rgba(255,180,150,0.35);
}

@media (hover: hover) {
  .cell.hidden:hover {
    background: radial-gradient(circle at 35% 30%, #ff8e8e, #e04040 70%);
    transform: scale(1.12);
    box-shadow: 0 5px 12px rgba(0,0,0,0.35);
  }
}
.cell.revealed {
  background: radial-gradient(circle at 35% 30%, #fffde7, #fff9c4 70%);
  cursor: default;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.08);
}

@keyframes reveal-pop {
  0%   { transform: scale(0.45); opacity: 0; }
  55%  { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1);    opacity: 1; }
}
.cell.reveal-pop {
  animation: reveal-pop 0.18s ease-out forwards;
}

.cell.flagged {
  background: radial-gradient(circle at 35% 30%, #74b9ff, #0984e3 70%);
  font-size: calc(var(--cell) * 0.52);
  box-shadow: 0 3px 8px rgba(9,132,227,0.4), inset 0 1px 4px rgba(180,220,255,0.4);
}

.cell.mine-hit {
  background: radial-gradient(circle at 35% 30%, #ff7675, #d63031 70%);
  box-shadow: 0 0 20px rgba(214,48,49,0.8) !important;
}

.cell.mine-revealed {
  background: radial-gradient(circle at 35% 30%, #ffe0e0, #ffb3b3 70%);
  cursor: default;
}

.cell.mine-defused {
  background: radial-gradient(circle at 35% 30%, #fff9c4, #ffd700 70%) !important;
  box-shadow: 0 0 16px rgba(255,215,0,0.8), inset 0 1px 4px rgba(255,255,200,0.5) !important;
}

.n1 { color: var(--n1); }
.n2 { color: var(--n2); }
.n3 { color: var(--n3); }
.n4 { color: var(--n4); }
.n5 { color: var(--n5); }
.n6 { color: var(--n6); }
.n7 { color: var(--n7); }
.n8 { color: var(--n8); }

/* ── Stats panel ── */
#stats-panel {
  margin-top: 28px;
  width: 100%;
  max-width: 520px;
}

#stats-panel h2 {
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#stats-panel h2 button {
  font-size: 0.7rem;
  padding: 2px 10px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-body);
  opacity: 0.6;
}
#stats-panel h2 button:hover { opacity: 1; }

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.stats-table th {
  color: var(--accent);
  text-align: left;
  padding: 4px 8px;
  border-bottom: 1px solid var(--accent);
  opacity: 0.7;
  font-weight: normal;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
}

.stats-table td {
  padding: 5px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.stats-table td:first-child { color: var(--accent); font-weight: bold; }
.stats-table td.best { color: var(--accent2); }

/* ── Board wrapper (fills remaining flex space) ── */
#board-wrap {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px;
  -webkit-overflow-scrolling: touch;
}



/* ── Responsive ── */

/* Fluid sizing via clamp (applies at all widths) */
#total-score       { font-size: clamp(1.2rem, 5vw, 1.6rem); }
.hud-timer         { font-size: clamp(0.72rem, 3vw, 0.95rem); }
.mr-step           { width: clamp(26px, 8vw, 38px); height: clamp(26px, 8vw, 38px); font-size: clamp(0.38rem, 1.4vw, 0.52rem); }

/* Phones (≤ 520px) */
@media (max-width: 520px) {
  #hud              { padding: 5px 10px; }
  #mini-run-bar     { padding: 5px 10px; gap: 6px; margin-bottom: 4px; }
  #mini-run-label   { font-size: 0.6rem; }
  #mini-run-timer   { font-size: 0.85rem; }

  #stats-panel { margin-top: 16px; }
  #stats-panel h2 { font-size: 0.85rem; }
  .stats-table { font-size: 0.7rem; }
  .stats-table th, .stats-table td { padding: 3px 4px; }
}

/* Very small phones (≤ 375px) */
@media (max-width: 375px) {
  #hud              { padding: 4px 8px; }
  #mini-run-bar     { padding: 4px 8px; gap: 4px; }
  #mini-run-timer   { font-size: 0.75rem; }
  .stats-table      { font-size: 0.62rem; }
}

/* ── Taiko Animation Keyframes ── */
@keyframes dc-bounce {
  0%   { transform: scale(1,   1  ) translateY(0);    }
  20%  { transform: scale(1.2, 0.8) translateY(6px);  }
  50%  { transform: scale(0.9, 1.2) translateY(-18px);}
  75%  { transform: scale(1.1, 0.9) translateY(4px);  }
  100% { transform: scale(1,   1  ) translateY(0);    }
}
@keyframes dc-katsu {
  0%   { transform: scale(1) translateY(0) rotate(0deg); }
  20%  { transform: scale(1.1, 0.92) translateY(4px) rotate(-8deg); }
  45%  { transform: scale(0.96, 1.08) translateY(-11px) rotate(10deg); }
  70%  { transform: scale(1.04, 0.98) translateY(2px) rotate(-4deg); }
  100% { transform: scale(1) translateY(0) rotate(0deg); }
}
@keyframes dc-hype {
  0%   { transform: scale(1) translateY(0) rotate(0deg); }
  25%  { transform: scale(1.12, 0.92) translateY(6px) rotate(-4deg); }
  50%  { transform: scale(0.98, 1.12) translateY(-14px) rotate(4deg); }
  75%  { transform: scale(1.08, 0.95) translateY(2px) rotate(-2deg); }
  100% { transform: scale(1) translateY(0) rotate(0deg); }
}
@keyframes dc-scared {
  0%,100%{ transform: scale(1)    rotate(0deg);   }
  15%    { transform: scale(1.3)  rotate(-12deg); }
  30%    { transform: scale(0.9)  rotate( 12deg); }
  50%    { transform: scale(1.1)  rotate(-8deg);  }
  70%    { transform: scale(0.95) rotate( 6deg);  }
  85%    { transform: scale(1.05) rotate(-3deg);  }
}
@keyframes dc-celebrate {
  0%,100%{ transform: scale(1)   translateY(0)    rotate(-6deg); }
  50%    { transform: scale(1.2) translateY(-14px) rotate(6deg); }
}
@keyframes tk-ripple {
  0%   { transform: translate(-50%,-50%) scale(0);   opacity: 0.85; }
  100% { transform: translate(-50%,-50%) scale(5.5); opacity: 0;    }
}
@keyframes tk-popup {
  0%   { transform: translate(-50%,  0px) scale(0.2); opacity: 1; }
  25%  { transform: translate(-50%, -12px) scale(1.5); opacity: 1; }
  65%  { transform: translate(-50%, -38px) scale(1.1); opacity: 1; }
  100% { transform: translate(-50%, -70px) scale(0.8); opacity: 0; }
}
@keyframes tk-shake {
  0%,100%{ transform: translate(0,0) rotate(0deg); }
  10%    { transform: translate(-10px,-2px) rotate(-1.5deg); }
  20%    { transform: translate( 10px, 2px) rotate( 1.5deg); }
  30%    { transform: translate(-8px,  0)   rotate(-1deg);   }
  40%    { transform: translate( 8px,  0)   rotate( 1deg);   }
  50%    { transform: translate(-5px,  1px); }
  60%    { transform: translate( 5px, -1px); }
  70%    { transform: translate(-3px,  0); }
  80%    { transform: translate( 3px,  0); }
  90%    { transform: translate(-1px,  0); }
}
@keyframes tk-flash {
  0%,100%{ opacity: 0;    }
  25%    { opacity: 0.55; }
  60%    { opacity: 0.2;  }
}
@keyframes tk-banner {
  0%  { transform: translate(-50%,-50%) scale(0.1) rotate(-15deg); opacity: 0; }
  55% { transform: translate(-50%,-50%) scale(1.25) rotate(4deg);  opacity: 1; }
  75% { transform: translate(-50%,-50%) scale(0.95) rotate(-1deg); opacity: 1; }
  88% { transform: translate(-50%,-50%) scale(1)    rotate(0deg);  opacity: 1; }
  100%{ transform: translate(-50%,-50%) scale(2)    rotate(0deg);  opacity: 0; }
}

/* ── Combo / Rhythm bar ── */
#combo-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 4px 12px;
  font-size: clamp(0.72rem, 2.5vw, 0.9rem);
  font-family: var(--font-body);
  min-height: 32px;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}
#bomb-counter {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-family: 'Fredoka One', 'Kosugi Maru', sans-serif;
  font-size: clamp(0.78rem, 2.8vw, 1rem);
  color: rgba(255, 255, 255, 0.85);
  white-space: nowrap;
  line-height: 1;
}
#bomb-counter span {
  color: #ffd700;
}
#combo-count {
  font-weight: bold;
  color: var(--accent);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  flex-shrink: 1;
  min-width: 0;
}
.rhythm-label {
  font-weight: 900;
  font-size: clamp(0.65rem, 2.2vw, 0.85rem);
  padding: 2px 8px;
  border-radius: 12px;
  background: rgba(255,255,255,0.12);
  text-align: center;
  white-space: nowrap;
  transition: background 0.3s, color 0.3s;
  color: var(--text);
  flex-shrink: 1;
  min-width: 0;
}
#energy-bar-wrap {
  flex: 0 1 120px;
  min-width: 40px;
  max-width: 120px;
  height: 10px;
  background: rgba(0,0,0,0.3);
  border-radius: 5px;
  overflow: hidden;
  flex-shrink: 1;
}
#energy-bar {
  height: 100%;
  width: 0%;
  background: #ffd700;
  border-radius: 5px;
  transition: width 0.2s ease-out, background 0.3s;
}
#combo-score {
  font-family: 'Fredoka One', 'Kosugi Maru', sans-serif;
  font-size: clamp(0.82rem, 2.5vw, 1rem);
  color: #ffd700;
  white-space: nowrap;
  text-align: right;
  font-variant-numeric: tabular-nums;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.5);
  flex-shrink: 0;
}

#total-score.pop {
  animation: score-pop 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}
#score-bonus-tray.pop .bonus-card {
  animation: bonus-card-pop 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}
@keyframes score-pop {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.45); }
  65%  { transform: scale(0.92); }
  100% { transform: scale(1); }
}
@keyframes bonus-card-pop {
  0%   { transform: rotate(-5deg) scale(1); }
  45%  { transform: rotate(-1deg) scale(1.16); }
  100% { transform: rotate(-5deg) scale(1); }
}
/* ── Mini-run challenge bar (Taiko style) ── */
#mini-run-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  margin-bottom: 10px;
  padding: 7px 16px 7px 12px;
  background: linear-gradient(135deg, rgba(0,0,0,0.55) 0%, rgba(30,10,0,0.45) 100%);
  border-radius: 999px;
  border: 2.5px solid rgba(255,215,0,0.5);
  box-shadow: 0 2px 12px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.08);
  font-family: var(--font-body);
  transition: border-color 0.3s, background 0.3s;
  flex-shrink: 0;
}
#mini-run-bar.complete {
  border-color: #ffd700;
  background: linear-gradient(135deg, rgba(180,120,0,0.35) 0%, rgba(80,40,0,0.35) 100%);
  box-shadow: 0 2px 18px rgba(255,215,0,0.35), inset 0 1px 0 rgba(255,255,255,0.1);
}
#mini-run-label {
  font-weight: 900;
  font-size: 0.68rem;
  color: #ffd700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.6);
  flex-shrink: 0;
}
#mini-run-steps {
  display: flex;
  align-items: center;
  gap: 5px;
}
/* Each note is a Taiko-style circle */
.mr-step {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 0.52rem;
  letter-spacing: -0.01em;
  text-align: center;
  line-height: 1.1;
  color: #fff;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.55);
  flex-shrink: 0;
  position: relative;
  transition: opacity 0.2s, transform 0.15s, box-shadow 0.2s;
  border: 2.5px solid rgba(255,255,255,0.2);
}
/* DON = red filled drum face */
.mr-step.don-step {
  background: radial-gradient(circle at 35% 28%, #ff6b6b, #c0392b 75%);
  box-shadow: 0 3px 10px rgba(192,57,43,0.6), inset 0 1px 4px rgba(255,180,150,0.3);
}
/* KATSU = blue rim hit */
.mr-step.katsu-step {
  background: radial-gradient(circle at 35% 28%, #74b9ff, #0984e3 75%);
  box-shadow: 0 3px 10px rgba(9,132,227,0.6), inset 0 1px 4px rgba(150,210,255,0.3);
}
.mr-step.done {
  opacity: 0.38;
  transform: scale(0.88);
}
.mr-step.done::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: rgba(255,255,255,0.9);
  text-shadow: 1px 1px 0 rgba(0,0,0,0.4);
}
.mr-step.active {
  opacity: 1;
  animation: mr-pulse 0.5s ease-in-out infinite alternate;
}
#mini-run-bar.critical .mr-step.active {
  animation-duration: 0.18s;
}
.mr-step.pending { opacity: 0.25; }
.mr-arrow {
  color: rgba(255,215,0,0.4);
  font-size: 0.7rem;
  flex-shrink: 0;
}
@keyframes mr-pulse {
  from { transform: scale(1);    }
  to   { transform: scale(1.18); box-shadow: 0 0 16px 4px currentColor; }
}
#mini-run-timer {
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  font-size: 1rem;
  color: #ffd700;
  min-width: 28px;
  text-align: right;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.5);
  transition: color 0.3s;
  flex-shrink: 0;
}
#mini-run-timer.urgent {
  color: #ff2d55;
}
.visually-hidden-content {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.stats-streak-best { opacity: 0.5; }
/* ── Fever glow pulse on board ── */
@keyframes fever-pulse {
  0%, 100% { box-shadow: 0 8px 40px rgba(200,50,0,0.5), 0 0 0 5px #ffd700, 0 0 0 9px #e53935; }
  50%       { box-shadow: 0 8px 60px rgba(255,80,0,0.85), 0 0 0 6px #ff2d55, 0 0 0 13px #ffd700, 0 0 55px #ff6b00; }
}
body.fever #board { animation: fever-pulse 0.7s ease-in-out infinite; }

/* ── Level splash ── */
#level-splash {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  pointer-events: none;
  font-family: 'Fredoka One', 'Kosugi Maru', sans-serif;
  font-weight: 900;
  background: rgba(0,0,0,0.55);
  opacity: 0;
  transition: opacity 0.25s;
}
#level-splash.show {
  display: flex;
  animation: splash-in 1.4s ease forwards;
}
.splash-title {
  font-size: clamp(2rem, 9vw, 4.5rem);
  color: #ff6b6b;
  text-shadow: 3px 3px 0 #5a0000, -2px -2px 0 #5a0000, 2px -2px 0 #5a0000, -2px 2px 0 #5a0000;
  letter-spacing: 0.05em;
}
.splash-level {
  font-size: clamp(3rem, 14vw, 7rem);
  color: #ffd700;
  text-shadow: 5px 5px 0 #8b0000, -3px -3px 0 #8b0000, 3px -3px 0 #8b0000, -3px 3px 0 #8b0000;
}
@keyframes splash-in {
  0%   { opacity: 0; transform: scale(0.4); }
  18%  { opacity: 1; transform: scale(1.08); }
  30%  { transform: scale(1); }
  75%  { opacity: 1; }
  100% { opacity: 0; transform: scale(1); }
}

/* ── Game-over splash ── */
#gameover-splash {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: rgba(0,0,0,0.68);
}
#gameover-splash.show {
  display: flex;
  animation: gameover-anim 0.4s ease forwards;
}
@keyframes gameover-anim {
  0%   { opacity: 0; transform: scale(0.88); }
  70%  { opacity: 1; transform: scale(1.03); }
  100% { opacity: 1; transform: scale(1); }
}
#gameover-splash .don-chan {
  width: 110px;
  height: 110px;
}
#gameover-text {
  font-family: 'Fredoka One', 'Kosugi Maru', sans-serif;
  font-size: clamp(2.2rem, 10vw, 4.5rem);
  font-weight: 900;
  color: #ff5252;
  text-shadow: 4px 4px 0 #5a0000, -2px -2px 0 #5a0000, 2px -2px 0 #5a0000, -2px 2px 0 #5a0000;
}
#gameover-restart {
  font-family: 'Fredoka One', 'Kosugi Maru', sans-serif;
  font-size: 1.6rem;
  font-weight: 900;
  color: #ffd700;
  background: #e53935;
  border: none;
  border-radius: 14px;
  padding: 8px 36px;
  cursor: pointer;
  box-shadow: 3px 3px 0 #8b0000, 0 0 16px rgba(229,57,53,0.5);
  text-shadow: 1px 1px 0 #8b0000;
  margin-top: 8px;
}
#gameover-restart:hover { background: #ff5252; box-shadow: 3px 3px 0 #8b0000, 0 0 24px rgba(229,57,53,0.9); }
