/* KARATE RHYTHM — retro static styling */

:root {
  --paper: #0b0b12;
  --ink: #f4f4ec;
  --amber: #e0a020;
  --orange: #e0561e;
  --green: #2fbc6a;
  --violet: #8a6bd0;
  --danger: #c0303a;
  --pixel: "Courier New", "Lucida Console", monospace;
  --brush: "Zen Old Mincho", "Noto Serif JP", Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #000;
  color: var(--ink);
  font-family: var(--pixel);
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#game {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 50% 40%, #14141f 0%, #05050a 75%, #000 100%);
}

#screen {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #000;
  box-shadow: 0 0 0 2px #1c1c28, 0 0 40px rgba(0,0,0,0.8);
}

/* Subtle CRT scanlines + vignette over the whole stage */
#game::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(0,0,0,0) 0px,
      rgba(0,0,0,0) 2px,
      rgba(0,0,0,0.10) 3px
    );
  mix-blend-mode: multiply;
  z-index: 30;
}

/* ---------------- HUD ---------------- */
#hud {
  position: absolute;
  pointer-events: none;
  z-index: 20;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  /* sized + positioned by JS to match the canvas rect */
}

.hud-label {
  font-size: 0.62em;
  letter-spacing: 0.18em;
  color: var(--amber);
  opacity: 0.85;
}

.hud-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px 0;
}

.score-box, .combo-box {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}
.combo-box { align-items: flex-end; }

#score {
  font-size: 1.15em;
  font-weight: bold;
  text-shadow: 1px 1px 0 #000;
}

#combo {
  font-size: 1.0em;
  font-weight: bold;
  color: var(--green);
  text-shadow: 1px 1px 0 #000;
  min-height: 1em;
}

.center-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.level-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.0;
}
#level {
  font-size: 1.0em;
  font-weight: bold;
  color: var(--amber);
  text-shadow: 1px 1px 0 #000;
}

.strength-wrap {
  padding: 0 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.strength-bar {
  height: 12px;
  border: 2px solid #000;
  background: #2a0c0c;
  box-shadow: inset 0 0 0 1px #5a1a1a;
  overflow: hidden;
}

#strength-fill {
  height: 100%;
  width: 100%;
  background:
    repeating-linear-gradient(
      90deg,
      var(--green) 0px,
      var(--green) 7px,
      #28a25a 7px,
      #28a25a 9px
    );
  transition: width 0.18s ease-out, background 0.2s;
}

/* Boss health bar (top, opposite the strength bar) */
#boss-hud {
  position: absolute;
  top: 30px;
  right: 10px;
  width: 56%;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
#boss-hud .hud-label { color: var(--danger); }
.boss-bar {
  width: 100%;
  height: 11px;
  border: 2px solid #000;
  background: #0c0c14;
  box-shadow: inset 0 0 0 1px #3a1a1a;
  overflow: hidden;
  display: flex;
  justify-content: flex-end;
}
#boss-fill {
  height: 100%;
  width: 100%;
  background:
    repeating-linear-gradient(90deg,
      var(--danger) 0px, var(--danger) 7px, #7a1c1c 7px, #7a1c1c 9px);
  transition: width 0.15s ease-out;
}

.vict-title {
  font-family: var(--brush);
  font-weight: 900;
  font-size: clamp(1.6rem, 5.5vw, 2.8rem);
  color: var(--amber);
  text-shadow: 2px 2px 0 #000, 0 0 16px rgba(224, 160, 32, 0.55);
  margin: 0 0 0.4em;
  letter-spacing: 0.1em;
}

/* Story cut-scenes: the scene is on the canvas; this is the narration box */
#cutscene {
  position: absolute;
  inset: 0;
  z-index: 24;
  pointer-events: auto;
}
#cutscene.hidden { display: none; }
#cutscene-box {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 24px 18px 16px;
  background: linear-gradient(to top, rgba(8, 6, 12, 0.94) 55%, rgba(8, 6, 12, 0));
}
#cutscene-text {
  font-family: var(--brush);
  font-weight: 700;
  margin: 0 auto;
  max-width: 30em;
  font-size: clamp(0.95rem, 2.6vw, 1.35rem);
  line-height: 1.65;
  text-align: center;
  color: #ece4cc;
  letter-spacing: 0.04em;
  text-shadow: 1px 1px 0 #000, 0 0 18px rgba(0,0,0,0.6);
}
.cut-hint {
  display: block;
  text-align: center;
  margin-top: 0.7em;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  color: var(--amber);
  animation: cutblink 1.2s steps(2, start) infinite;
}
@keyframes cutblink { 50% { opacity: 0.25; } }
.cut-skip {
  position: absolute;
  top: 10px; right: 10px;
  font-size: 0.78rem;
  padding: 0.4em 0.9em;
  box-shadow: 3px 3px 0 #000;
}

#popup-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.popup {
  position: absolute;
  font-family: var(--brush);
  font-weight: 900;
  font-size: 1.0em;
  letter-spacing: 0.08em;
  text-shadow: 1px 1px 0 #000;
  transform: translate(-50%, -50%);
  animation: floatUp 0.7s ease-out forwards;
  white-space: nowrap;
}
.popup.perfect { color: var(--amber); text-shadow: 1px 1px 0 #000, 0 0 8px rgba(224,160,32,0.6); }
.popup.good    { color: var(--green);  text-shadow: 1px 1px 0 #000, 0 0 8px rgba(47,188,106,0.5); }
.popup.miss    { color: var(--danger); text-shadow: 1px 1px 0 #000, 0 0 8px rgba(192,48,58,0.5); }
.popup.level {
  color: var(--amber);
  font-size: 1.9em;
  letter-spacing: 0.18em;
  text-shadow: 3px 3px 0 #2a0f0a, 0 0 14px rgba(224, 160, 32, 0.65);
  animation: levelBanner 1.3s ease-out forwards;
}
/* Feint-caught: big angry red banner */
.popup.feint {
  color: var(--danger);
  font-size: 1.7em;
  letter-spacing: 0.14em;
  text-shadow: 3px 3px 0 #000, 0 0 16px rgba(192,48,58,0.7);
  animation: levelBanner 1.2s ease-out forwards;
}
/* Feint-dodged: gold float-up */
.popup.feint-dodge {
  color: var(--amber);
  font-size: 1.1em;
  letter-spacing: 0.12em;
  text-shadow: 1px 1px 0 #000, 0 0 8px rgba(224,160,32,0.6);
  animation: floatUp 1.0s ease-out forwards;
}

@keyframes levelBanner {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  15%  { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
  75%  { opacity: 1; transform: translate(-50%, -50%) scale(1.0); }
  100% { opacity: 0; transform: translate(-50%, -90%) scale(1.0); }
}

@keyframes floatUp {
  0%   { opacity: 0; transform: translate(-50%, -40%) scale(0.6); }
  20%  { opacity: 1; transform: translate(-50%, -55%) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -120%) scale(1); }
}

/* ---------------- Overlays ---------------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  background: rgba(5, 5, 10, 0.82);
  backdrop-filter: blur(1px);
}
.overlay.hidden { display: none; }

#title h1 {
  font-family: var(--brush);
  font-weight: 900;
  font-size: clamp(2rem, 7.5vw, 3.8rem);
  line-height: 0.9;
  margin: 0 0 0.2em;
  letter-spacing: 0.06em;
  color: #e8e6d4;
  text-shadow: 3px 3px 0 #b5402c, 6px 6px 0 #2a0f0a;
}
#title h1 span {
  display: block;
  color: var(--amber);
  text-shadow: 3px 3px 0 #7a2418, 6px 6px 0 #2a0f0a;
}

.tag {
  color: var(--violet);
  font-size: 0.8rem;
  margin: 0 0 1.2em;
  letter-spacing: 0.06em;
}

.how {
  list-style: none;
  padding: 0;
  margin: 0 0 1.4em;
  max-width: 30em;
  font-size: 0.82rem;
  line-height: 1.7;
  text-align: left;
  color: #cfcfd6;
}
.how b { color: var(--amber); }
.cheat-hint {
  font-size: 0.72rem;
  color: #56546a;
  letter-spacing: 0.04em;
}
.cheat-btn {
  font-family: var(--pixel);
  font-size: 0.72rem;
  color: #7a7898;
  background: rgba(255,255,255,0.05);
  border: 1px solid #3a3858;
  padding: 0.25em 0.65em;
  margin: 0 0.2em;
  cursor: pointer;
  letter-spacing: 0.08em;
  vertical-align: middle;
}
.cheat-btn:hover { background: rgba(255,255,255,0.12); color: var(--amber); border-color: var(--amber); }
.cheat-btn:active { transform: translateY(1px); }

#gameover h2 {
  font-family: var(--brush);
  font-weight: 900;
  font-size: clamp(1.6rem, 5.5vw, 2.8rem);
  color: var(--danger);
  text-shadow: 2px 2px 0 #000, 0 0 14px rgba(192,48,58,0.5);
  margin: 0 0 0.4em;
  letter-spacing: 0.1em;
}

.reached {
  color: var(--amber);
  font-size: 1rem;
  letter-spacing: 0.14em;
  margin: 0 0 1.4em;
}
.reached span {
  color: var(--ink);
  font-weight: bold;
}

.final {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5em 2em;
  margin-bottom: 1.6em;
}
.final > div {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.final span:last-child {
  font-size: 1.6em;
  font-weight: bold;
  color: var(--ink);
}

.btn {
  font-family: var(--pixel);
  font-size: 1.1rem;
  font-weight: bold;
  letter-spacing: 0.12em;
  color: #000;
  background: var(--amber);
  border: none;
  padding: 0.7em 1.6em;
  cursor: pointer;
  box-shadow: 4px 4px 0 #000;
  margin: 0.3em;
  transition: transform 0.06s, box-shadow 0.06s, background 0.1s;
}
.btn:hover { background: #f2b63a; }
.btn:active {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 #000;
}
.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}
.btn-secondary {
  background: transparent;
  color: #7a7898;
  border: 2px solid #3a3858;
  box-shadow: none;
  font-size: 0.85rem;
}
.btn-secondary:hover { background: rgba(255,255,255,0.06); color: var(--ink); border-color: #6a6888; }
.btn-secondary:active { box-shadow: none; }

.hint {
  margin-top: 1.4em;
  font-size: 0.72rem;
  color: #6a6a78;
  letter-spacing: 0.05em;
}

#mute-btn {
  position: absolute;
  bottom: 8px;
  right: 8px;
  z-index: 26;
  width: 30px;
  height: 30px;
  border: 2px solid #000;
  background: rgba(20,20,30,0.7);
  color: var(--amber);
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
}
#mute-btn.muted { color: #555; text-decoration: line-through; }

@media (max-width: 480px) {
  .how { font-size: 0.74rem; }
  .tag { font-size: 0.7rem; }
}
