/* ... Previous styles ... */
body {
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: #0f0f0f;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: #fff;
}

canvas {
  display: block;
  background-image: url("https://coresg-normal.trae.ai/api/ide/v1/text_to_image?prompt=Destroyed%20Shibuya%20city%20background%20at%20night%2C%20anime%20style%2C%20rubble%2C%20dark%20atmosphere%2C%20ruins&image_size=landscape_16_9");
  background-size: cover;
  background-position: center;
}

.game-ui {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none; /* Let clicks pass through to canvas if needed, though we use keyboard */
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

header {
  padding: 20px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.hp-container {
  display: flex;
  align-items: center;
  gap: 20px;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}

.character-info {
  display: flex;
  align-items: center;
  gap: 15px;
  flex: 1;
}

.character-info.enemy {
  flex-direction: row-reverse;
  text-align: right;
}

.avatar {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
  object-fit: cover;
}

.status-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.bar-container {
  width: 100%;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 4px;
  overflow: hidden;
  position: relative; /* For absolute positioning of text */
}

.hp-container-inner {
  height: 20px;
}

.mp-container-inner {
  height: 10px;
}

.hp-bar {
  height: 100%;
  background: linear-gradient(90deg, #4caf50, #8bc34a);
  width: 100%;
  transition: width 0.2s;
  box-shadow: 0 0 5px rgba(76, 175, 80, 0.5);
}

#enemy-hp {
  background: linear-gradient(90deg, #e53935, #ff5252);
  box-shadow: 0 0 5px rgba(229, 57, 53, 0.5);
}

.mp-bar {
  height: 100%;
  background: linear-gradient(90deg, #2196f3, #64b5f6);
  width: 100%;
  transition: width 0.2s;
  box-shadow: 0 0 5px rgba(33, 150, 243, 0.5);
}

#enemy-mp {
  background: linear-gradient(90deg, #9c27b0, #ba68c8); /* Purple MP for enemies */
}

.bar-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 0.8rem;
  font-weight: bold;
  text-shadow: 1px 1px 2px black;
  z-index: 2;
  white-space: nowrap;
  line-height: 1;
}

.mp-container-inner .bar-text {
  font-size: 0.6rem;
}

.name-text {
  font-size: 1rem;
  text-shadow: 1px 1px 2px black;
  font-weight: bold;
}

.vs {
  font-size: 2.5rem;
  font-weight: bold;
  color: #ffd700;
  font-style: italic;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
}

.back-btn {
  pointer-events: auto;
  color: #aaa;
  text-decoration: none;
  font-size: 0.9rem;
  border: 1px solid #555;
  padding: 5px 10px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.5);
  transition: all 0.3s;
}

.back-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* New Skill Bar Styles */
.skill-bar {
  padding: 20px;
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 20px;
}

.skill-slot {
  position: relative;
  width: 60px;
  height: 60px;
  background: rgba(0, 0, 0, 0.6);
  border: 2px solid #555;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: all 0.2s;
}

.skill-slot.movement-hint {
  width: 100px;
  border-color: #888;
}

.key-hint {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.8rem;
  border: 1px solid #666;
  font-weight: bold;
}

.skill-icon {
  font-size: 1.2rem;
  font-weight: bold;
  z-index: 1;
}

.attack-icon {
  color: #ff5252;
}
.special-icon {
  color: #e040fb;
}
.beam-icon {
  color: #2196f3;
  text-shadow: 0 0 5px #2196f3;
}
.heal-icon {
  color: #4caf50;
  text-shadow: 0 0 5px #4caf50;
}
.domain-icon {
  color: #40c4ff;
  text-shadow: 0 0 5px #40c4ff;
}

.skill-cd {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 0%;
  background: rgba(0, 0, 0, 0.8);
  border-radius: 6px;
  transition: height 0.1s linear;
  z-index: 2;
}

.skill-cost {
  position: absolute;
  bottom: -20px;
  font-size: 0.7rem;
  color: #64b5f6;
  font-weight: bold;
  text-shadow: 1px 1px 1px black;
}

#game-over-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  pointer-events: auto;
  z-index: 100;
}

#game-over-screen.hidden {
  display: none;
}

#game-over-screen h1 {
  font-size: 4rem;
  margin-bottom: 20px;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
}

#game-over-screen button {
  padding: 15px 40px;
  font-size: 1.5rem;
  background: #6200ea;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.2s;
}

#game-over-screen button:hover {
  transform: scale(1.1);
  background: #7c4dff;
}

.game-over-buttons {
  display: flex;
  gap: 20px;
}

.game-btn {
  min-width: 200px;
}

/* Cutscene Styles */
#cutscene-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: black;
  z-index: 200;
  display: flex;
  justify-content: center;
  align-items: center;
  animation: flash 0.2s;
}

#cutscene-overlay.hidden {
  display: none;
}

.cutscene-content {
  text-align: center;
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

#cutscene-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.6;
  animation: zoomIn 2s ease-out;
}

#cutscene-text {
  position: relative;
  font-size: 5rem;
  color: white;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.8);
  margin: 0;
  z-index: 2;
  font-family: "KaiTi", "Microsoft YaHei", serif;
  animation: slideUp 0.5s ease-out;
}

#cutscene-subtext {
  position: relative;
  font-size: 3rem;
  color: #ffd700;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
  margin-top: 20px;
  z-index: 2;
  font-family: "KaiTi", "Microsoft YaHei", serif;
  animation: slideUp 0.5s ease-out 0.3s backwards;
}

@keyframes flash {
  0% {
    background: white;
  }
  100% {
    background: black;
  }
}

@keyframes zoomIn {
  0% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes slideUp {
  0% {
    opacity: 0;
    transform: translateY(50px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Mobile Controls */
#mobile-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
  display: none;
}

#mobile-controls.visible {
  display: block;
}

/* Joystick Area */
.joystick-area {
  position: absolute;
  bottom: 40px;
  left: 40px;
  width: 140px;
  height: 140px;
  pointer-events: auto;
}

.joystick-base {
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  position: relative;
  backdrop-filter: blur(2px);
}

.joystick-stick {
  width: 50px;
  height: 50px;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.6);
}

/* Skill Buttons Container */
.mobile-skills {
  position: absolute;
  bottom: 30px;
  right: 30px;
  width: 280px;
  height: 280px;
  pointer-events: none; /* Let clicks pass through empty space */
}

/* Base Button Style */
.mobile-btn {
  position: absolute;
  border-radius: 50%;
  color: white;
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  user-select: none;
  touch-action: manipulation;
  pointer-events: auto;
  border: 2px solid rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(4px);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  transition: transform 0.1s;
}

.mobile-btn:active {
  transform: scale(0.92);
  filter: brightness(1.2);
}

/* Specific Button Layout (Ergonomic Arc) */

/* Attack (J) - Largest, bottom-right anchor */
.attack-btn {
  width: 90px;
  height: 90px;
  bottom: 10px;
  right: 10px;
  background: radial-gradient(circle at 30% 30%, rgba(244, 67, 54, 0.8), rgba(198, 40, 40, 0.9));
  font-size: 1.8rem;
  z-index: 10;
}

/* Blue/Beam (U) - Above Attack */
.beam-btn {
  width: 65px;
  height: 65px;
  bottom: 110px;
  right: 20px;
  background: radial-gradient(circle at 30% 30%, rgba(33, 150, 243, 0.8), rgba(21, 101, 192, 0.9));
  font-size: 1.2rem;
}

/* Purple/Special (K) - Left of Attack */
.special-btn {
  width: 65px;
  height: 65px;
  bottom: 20px;
  right: 110px;
  background: radial-gradient(circle at 30% 30%, rgba(224, 64, 251, 0.8), rgba(156, 39, 176, 0.9));
  font-size: 1.2rem;
}

/* Heal (I) - Farther arc */
.heal-btn {
  width: 55px;
  height: 55px;
  bottom: 110px;
  right: 100px;
  background: radial-gradient(circle at 30% 30%, rgba(76, 175, 80, 0.8), rgba(46, 125, 50, 0.9));
  font-size: 1rem;
}

/* Domain (L) - Ultimate, distinct position (Top) */
.domain-btn {
  width: 50px;
  height: 50px;
  bottom: 180px;
  right: 60px;
  background: radial-gradient(circle at 30% 30%, rgba(64, 196, 255, 0.8), rgba(2, 119, 189, 0.9));
  font-size: 0.9rem;
  border-color: rgba(255, 255, 255, 0.6);
}

/* Cooldown Overlay for Mobile */
.mobile-btn::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  clip-path: inset(0 0 100% 0); /* Reveal from bottom */
  transition: clip-path 0.1s linear;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .controls-hint {
    display: none;
  } /* Hide PC hints on mobile */
  #mobile-controls {
    display: block;
  }
  .skill-bar {
    display: none;
  } /* Hide bottom skill bar to save space, or make it smaller */

  .hp-container {
    padding: 0 10px;
    max-width: 100%;
  }

  .avatar {
    width: 50px;
    height: 50px;
  }

  .vs {
    font-size: 1.5rem;
  }

  /* Make skill bar smaller and top positioned if needed, or just hide */
}
/* Transparent Overlay Mode */
#narrator-overlay.transparent-mode {
    background: transparent;
    justify-content: center; /* Center screen */
    align-items: center;
    padding-top: 0;
    pointer-events: none;
}

#narrator-overlay.transparent-mode .narrator-text {
    transform: scale(1);
    background: transparent;
    padding: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#narrator-overlay.transparent-mode p {
    font-size: 2.5rem;
    margin: 10px 0;
    color: #fff;
    /* Heavy stroke effect */
    text-shadow: 
        -2px -2px 0 #000,  
        2px -2px 0 #000,
        -2px 2px 0 #000,
        2px 2px 0 #000,
        0 0 10px #ff0000; /* Red glow */
    opacity: 0;
    animation: slowFadeIn 1s forwards;
    font-family: 'KaiTi', 'Microsoft YaHei', serif;
}

#narrator-overlay.transparent-mode h1 {
    font-size: 5rem;
    margin: 20px 0;
    color: #ff0000;
    text-shadow: 
        -3px -3px 0 #000,  
        3px -3px 0 #000,
        -3px 3px 0 #000,
        3px 3px 0 #000,
        0 0 20px #000;
    opacity: 0;
    animation: slowFadeIn 1s forwards;
    font-family: 'KaiTi', 'Microsoft YaHei', serif;
    letter-spacing: 10px;
}

@keyframes slowFadeIn {
    from { opacity: 0; transform: scale(1.1); filter: blur(5px); }
    to { opacity: 1; transform: scale(1); filter: blur(0); }
}

#narrator-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 90;
  pointer-events: none;
}

#narrator-overlay.hidden {
  display: none;
}

.narrator-text {
  text-align: center;
  color: #fff;
  font-family: "KaiTi", "Microsoft YaHei", serif; /* Use a serif font for dramatic effect */
}

.narrator-text p {
  font-size: 2rem;
  margin: 10px 0;
  opacity: 0;
  animation: fadeIn 1s forwards;
}

.narrator-text h1 {
  font-size: 3.5rem;
  margin: 20px 0;
  opacity: 0;
  color: #03dac6; /* Electric blue/teal for Kashimo */
  text-shadow: 0 0 20px rgba(3, 218, 198, 0.8);
  animation: fadeIn 1s forwards;
}

.narrator-text .line-1 {
  animation-delay: 0.5s;
}
.narrator-text .line-2 {
  animation-delay: 2s;
}
.narrator-text .line-3 {
  animation-delay: 3.5s;
}
.narrator-text .line-4 {
  animation-delay: 5s;
}
.narrator-text .line-5 {
  animation-delay: 6s;
  font-size: 5rem;
  letter-spacing: 10px;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Loading Screen */
#loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #000;
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #fff;
  flex-direction: column;
  transition: opacity 0.5s ease-out;
}

#loading-screen.hidden {
  display: none;
}

.loading-content {
  text-align: center;
}

.loading-content h1 {
  font-family: "KaiTi", "Microsoft YaHei", serif;
  font-size: 3rem;
  margin-bottom: 20px;
  text-shadow: 0 0 10px #2196f3;
}

.progress-bar-container {
  width: 300px;
  height: 10px;
  background: #333;
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 10px;
  margin-left: auto;
  margin-right: auto;
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #2196f3, #e040fb);
  transition: width 0.2s;
}

#loading-text {
  font-family: monospace;
  color: #888;
}
