/* OFFICE RAGE THEME - REBELLIOUS POP ART */
/* CSS for Stuck Projectiles */
.stuck-projectile {
  position: absolute;
  width: 40px;
  /* Adjust based on asset */
  pointer-events: none;
  filter: drop-shadow(2px 2px 2px rgba(0, 0, 0, 0.3));
  z-index: 20;
}

.btn-icon {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.4);
  transform: scale(1.1);
}

:root {
  /* Palette */
  --c-yellow: #facc15;
  /* Volt Yellow */
  --c-black: #0f172a;
  /* Deep Slate */
  --c-white: #ffffff;
  --c-pink: #ec4899;
  /* Hot Pink - Attack */
  --c-green: #a3e635;
  /* Toxic Green - Boss */
  --c-red: #ef4444;
  /* Danger */

  /* Fonts */
  --font-display: "Impact", "Arial Black", sans-serif;
  --font-body: "Courier New", monospace;
  /* Raw, document feel */

  /* Effects */
  --shadow-hard: 4px 4px 0px var(--c-black);
  --border-thick: 4px solid var(--c-black);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--c-yellow);
  /* Ben-Day Dots Pattern */
  background-image: radial-gradient(var(--c-black) 10%, transparent 11%);
  background-size: 20px 20px;
  color: var(--c-black);
  font-family: var(--font-body);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem;
  overflow-x: hidden;
  /* Prevent horizontal scroll on mobile */
}

#app {
  width: 100%;
  max-width: 800px;
  height: 90vh;
  /* Changed from min-height: 600px to viewport based */
  min-height: 600px;
  max-height: 900px;
  background: var(--c-white);
  border: var(--border-thick);
  position: relative;
  box-shadow: 12px 12px 0px rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
}

/* --- COMMON UTILS --- */
.hidden {
  display: none !important;
}

.btn {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 1px;
  border: var(--border-thick);
  background: var(--c-white);
  padding: 1rem 2rem;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.1s;
  position: relative;
}

.btn:active {
  transform: translate(2px, 2px);
  box-shadow: none !important;
}

.btn.primary {
  background: var(--c-black);
  color: var(--c-yellow);
  box-shadow: var(--shadow-hard);
}

.btn.primary:hover {
  background: #333;
  color: #fff;
}

.btn.ghost {
  box-shadow: 2px 2px 0px var(--c-black);
  background: var(--c-white);
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
}

/* --- VIEW: HOME --- */
#view-home {
  flex: 1;
  /* Ensure it takes full height */
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 2rem;
  background: repeating-linear-gradient(45deg,
      var(--c-yellow),
      var(--c-yellow) 10px,
      #fff 10px,
      #fff 20px);
  width: 100%;
}



.title {
  font-family: var(--font-display);
  font-size: clamp(3rem, 10vw, 5rem);
  /* Responsive font size */
  margin: 0 0 3rem 0;
  line-height: 1;
  text-shadow: 4px 4px 0px var(--c-white), 8px 8px 0px var(--c-black);
  transform: rotate(-3deg);
  background: var(--c-white);
  padding: 1rem;
  border: var(--border-thick);
  box-shadow: var(--shadow-hard);
}

/* --- VIEW: SELECT --- */
#view-select {
  flex: 1;
  padding: 2rem;
  background: var(--c-white);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  /* Allow scrolling for files */
}

.files-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.5rem;
  padding: 1rem 0;
  width: 100%;
}

.file-folder {
  border: var(--border-thick);
  background: #f0f0f0;
  padding: 0;
  position: relative;
  cursor: pointer;
  height: 140px;
  transition: transform 0.2s;
  text-align: left;
}

.file-folder:hover {
  transform: rotate(-2deg) scale(1.05);
  z-index: 10;
  box-shadow: var(--shadow-hard);
  background: var(--c-white);
}

.file-tab {
  background: var(--c-black);
  color: var(--c-white);
  display: inline-block;
  padding: 0.25rem 0.5rem;
  font-family: var(--font-display);
  font-size: 0.8rem;
  position: absolute;
  top: -24px;
  left: -2px;
  border: var(--border-thick);
  border-bottom: none;
}

.file-content {
  padding: 1rem;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.file-name {
  font-family: var(--font-display);
  font-size: 1.1rem;
  text-align: center;
  line-height: 1.2;
}

.stamp {
  position: absolute;
  bottom: 5px;
  right: 5px;
  color: var(--c-red);
  font-family: var(--font-display);
  border: 2px solid var(--c-red);
  padding: 0.1rem 0.3rem;
  transform: rotate(-15deg);
  font-size: 0.7rem;
  opacity: 0;
  background: rgba(255, 255, 255, 0.8);
  pointer-events: none;
  transition: opacity 0.2s;
}

.file-folder:hover .stamp {
  opacity: 1;
}

.select-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

/* --- VIEW: GAME (COMIC PANEL LAYOUT) --- */
#view-game {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: relative;
}

/* TOP PANEL: BOSS AREA */
.panel-boss {
  flex: 3;
  /* More space for boss */
  background: var(--c-green);
  position: relative;
  overflow: hidden;
  border-bottom: var(--border-thick);
  display: flex;
  align-items: flex-end;
  /* Align boss to bottom of this panel */
  justify-content: center;

  /* Speed lines background */
  background-image: repeating-conic-gradient(var(--c-white) 0 15deg, transparent 15deg 30deg);
  background-color: #a3e635;
  background-blend-mode: overlay;
  padding-bottom: 0;
}

.boss-visual-wrapper {
  position: relative;
  z-index: 2;
  transition: transform 0.1s;
  height: 90%;
  display: flex;
  align-items: flex-end;
}

.boss-img {
  max-height: 100%;
  width: auto;
  object-fit: contain;
  filter: grayscale(100%) contrast(120%);
  transition: filter 0.3s;
}

.boss-img.hit {
  filter: grayscale(0%) sepia(100%) hue-rotate(-50deg) saturate(500%);
}

/* SPEECH BUBBLE - MOVED AND RESIZED */
.speech-bubble {
  position: absolute;
  top: 60px;
  /* Moved down to avoid top buttons */
  left: 20px;
  width: 50%;
  /* Constrain width */
  max-width: 300px;
  background: var(--c-white);
  border: var(--border-thick);
  padding: 1.5rem;
  z-index: 20;
  /* Higher than boss */
  filter: drop-shadow(4px 4px 0px rgba(0, 0, 0, 0.5));
}

/* Speech bubble tail */
.speech-bubble::after {
  content: '';
  position: absolute;
  bottom: -15px;
  right: 20px;
  /* Tail on right side pointing to boss */
  width: 0;
  height: 0;
  border-left: 15px solid transparent;
  border-right: 0px solid transparent;
  border-top: 15px solid var(--c-black);
}

.speech-bubble-inner {
  font-weight: bold;
  font-size: clamp(0.9rem, 2vw, 1.1rem);
  line-height: 1.4;
  font-style: italic;
  word-break: break-word;
}

/* EGO METER (HP) - FIXED TRUNCATION */
.ego-meter-container {
  position: absolute;
  top: 80px;
  /* Moved down to avoid Exit Fight button overlap */
  right: 20px;
  width: 40px;
  height: 200px;
  border: var(--border-thick);
  background: var(--c-white);
  z-index: 10;
  display: flex;
  flex-direction: column-reverse;
}

.ego-label {
  position: absolute;
  top: -30px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--c-black);
  color: var(--c-white);
  font-weight: bold;
  font-family: var(--font-display);
  font-size: 1rem;
  padding: 2px 5px;
  white-space: nowrap;
}

.ego-fill {
  width: 100%;
  background: var(--c-black);
  transition: height 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.ego-fill.danger {
  background: var(--c-red);
  animation: pulse 0.2s infinite;
}

/* MIDDLE PANEL: VS SEPARATOR */
.vs-line {
  height: 0px;
  border-top: var(--border-thick);
  position: relative;
  z-index: 30;
}

.vs-badge {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) rotate(-5deg);
  background: var(--c-red);
  color: var(--c-white);
  font-family: var(--font-display);
  font-size: 2rem;
  padding: 0.5rem 1rem;
  border: var(--border-thick);
  box-shadow: 4px 4px 0px rgba(0, 0, 0, 0.5);
}

/* BOTTOM PANEL: PLAYER CONTROL */
.panel-player {
  flex: 2;
  background: #333;
  background-image:
    linear-gradient(45deg, #444 25%, transparent 25%),
    linear-gradient(-45deg, #444 25%, transparent 25%);
  background-size: 20px 20px;
  padding: 1rem;
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: center;
}

/* ENDING CARD MODAL */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(5px);
}

.ending-card {
  position: relative;
  width: 90%;
  max-width: 400px;
  background: #fff;
  border: var(--border-thick);
  box-shadow: 10px 10px 0px var(--c-black);
  transform: rotate(-2deg);
  padding: 0;
  display: flex;
  flex-direction: column;
  animation: cardSlideIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes cardSlideIn {
  from {
    transform: translateY(100vh) rotate(10deg);
  }

  to {
    transform: rotate(-2deg);
  }
}

.card-header {
  background: var(--c-black);
  color: #fff;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: var(--border-thick);
}

.card-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  letter-spacing: 1px;
}

.card-date {
  font-family: var(--font-body);
  font-size: 0.8rem;
  color: var(--c-yellow);
}

.card-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  background-image: radial-gradient(#ddd 10%, transparent 11%);
  background-size: 10px 10px;
}

.boss-portrait {
  width: 120px;
  height: 120px;
  border: var(--border-thick);
  background: #fff;
  margin-bottom: 1rem;
  overflow: hidden;
  border-radius: 50%;
  box-shadow: 4px 4px 0px var(--c-black);
}

.boss-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.result-info {
  text-align: center;
}

#end-title {
  font-family: var(--font-display);
  font-size: 2rem;
  margin: 0 0 0.5rem 0;
  text-transform: uppercase;
}

#end-desc {
  font-family: var(--font-body);
  font-size: 0.95rem;
  /* Slightly smaller for stories */
  line-height: 1.5;
  margin: 0;
  text-align: left;
  /* Better for stories */
  max-height: 200px;
  overflow-y: auto;
  /* Scroll if too long */
  width: 100%;
}

.card-stamp {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: rotate(-15deg) translateY(-50%);
  font-family: var(--font-display);
  font-size: 3rem;
  color: var(--c-red);
  border: 5px solid var(--c-red);
  padding: 0.5rem 1rem;
  opacity: 0.8;
  mask-image: url('data:image/svg+xml;utf8,<svg ...>');
  /* Optional grunge */
  pointer-events: none;
  animation: stampIn 0.3s 0.5s backwards;
}

@keyframes stampIn {
  from {
    transform: rotate(-15deg) scale(3);
    opacity: 0;
  }

  to {
    transform: rotate(-15deg) scale(1);
    opacity: 0.8;
  }
}

.card-actions {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  background: #eee;
  border-top: var(--border-thick);
  justify-content: center;
}

.action-card {
  flex: 1;
  max-width: 300px;
  background: var(--c-white);
  border: var(--border-thick);
  height: 100%;
  padding: 1rem;
  position: relative;
  cursor: pointer;
  transition: transform 0.1s;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.action-card:hover:not(.disabled) {
  /* transform: translateY(-5px) rotate(1deg); REMOVED for stability */
  box-shadow: 5px 5px 0px var(--c-pink);
  z-index: 10;
}

.action-card.disabled {
  opacity: 0.6;
  filter: grayscale(100%);
  pointer-events: none;
}

.action-label {
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--c-black);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
}

.action-text {
  font-size: 1.3rem;
  /* Increased from 0.9rem */
  line-height: 1.4;
  flex-grow: 1;
  font-weight: 600;
  margin-bottom: 0.5rem;
  word-break: break-word;
}

.action-cost {
  align-self: flex-end;
  background: var(--c-pink);
  color: white;
  padding: 0.2rem 0.5rem;
  font-weight: bold;
  transform: rotate(-3deg);
  border: 2px solid black;
  border: 2px solid black;
  font-size: 0.9rem;
  display: none;
  /* Hidden as requested */
}

/* EXIT FIGHT BUTTON FIX */
#btn-back-select {
  background: var(--c-white);
  border: var(--border-thick);
  top: 10px;
  right: 10px;
  /* Moved to Right to avoid overlap with speech bubble/files */
  left: auto !important;
  padding: 0.5rem;
}

/* PROGRESS */
.turn-counter {
  position: absolute;
  bottom: 0;
  right: 0;
  background: var(--c-yellow);
  border-top: var(--border-thick);
  border-left: var(--border-thick);
  padding: 0.5rem 1rem;
  font-family: var(--font-display);
  font-size: 1rem;
  z-index: 50;
}

/* ANIMATIONS */
@keyframes pulse {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.05);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes shake {

  0%,
  100% {
    transform: rotate(0deg);
  }

  25% {
    transform: rotate(calc(-1 * var(--shake-intensity, 3deg)));
  }

  75% {
    transform: rotate(var(--shake-intensity, 3deg));
  }
}

.card-shake {
  animation: cardShake 0.2s ease-in-out;
}

@keyframes cardShake {

  0%,
  100% {
    transform: rotate(0deg);
  }

  25% {
    transform: rotate(-2deg);
  }

  75% {
    transform: rotate(2deg);
  }
}

.screen-shake {
  animation: shake 0.3s cubic-bezier(.36, .07, .19, .97) both;
}

.damage-pop {
  position: absolute;
  font-family: var(--font-display);
  font-size: 3rem;
  color: var(--c-pink);
  text-shadow: 3px 3px 0 #000;
  transform: rotate(-10deg);
  pointer-events: none;
  z-index: 100;
  animation: popOut 0.8s forwards;
}

@keyframes popOut {
  0% {
    transform: scale(0.5) rotate(-10deg);
    opacity: 0;
  }

  20% {
    transform: scale(1.5) rotate(-10deg);
    opacity: 1;
  }

  100% {
    transform: scale(1) translateY(-100px) rotate(-20deg);
    opacity: 0;
  }
}

/* RESPONSIVE & MOBILE FIXES */
@media (max-width: 600px) {
  body {
    padding: 0;
    align-items: flex-start;
    /* Stick to top */
  }

  #app {
    height: 100vh;
    max-height: none;
    min-height: 100vh;
    border: none;
    box-shadow: none;
    width: 100vw;
  }

  /* Home View */
  .title {
    font-size: 3rem;
  }

  /* Select View */
  .files-grid {
    grid-template-columns: 1fr 1fr;
    /* 2 cols on mobile */
    gap: 1rem;
  }

  .file-folder {
    height: 100px;
  }

  .file-name {
    font-size: 0.8rem;
  }

  /* Game View Layout */
  .panel-boss {
    flex: 5;
    /* More space for visual */
  }

  #view-game {
    overflow-y: auto;
  }

  .panel-player {
    flex: 4;
    /* Increase space for controls */
    flex-direction: column;
    /* Stack cards on really small screens? Or keep row but smaller */
    padding: 0.5rem;
    gap: 0.5rem;
  }

  .action-card {
    padding: 0.5rem;
  }

  .action-label {
    font-size: 1rem;
  }

  .action-text {
    font-size: 0.8rem;
  }

  /* Boss Elements */
  .speech-bubble {
    top: 50px;
    left: 10px;
    width: 60%;
    padding: 0.8rem;
    font-size: 0.9rem;
  }

  .ego-meter-container {
    right: 10px;
    height: 150px;
    width: 30px;
  }

  .ego-label {
    font-size: 0.8rem;
  }

  /* Buttons */
  #btn-back-select {
    top: 5px;
    right: 5px;
    font-size: 0.7rem;
  }

  .turn-counter {
    top: 5px;
    bottom: auto;
    right: 5px;
    border-top: none;
    border-bottom: var(--border-thick);
  }

  /* Move Rage Next button away from cards to avoid overlap */
  #btn-rage-next {
    position: fixed !important;
    top: auto !important;
    bottom: 12px !important;
    right: 12px !important;
    left: auto !important;
    transform: none !important;
    width: auto;
    min-width: 120px;
    max-width: 65vw;
    padding: 0.45rem 0.8rem;
    font-size: 0.95rem;
    z-index: 500;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  }
}