/* Kawaii avatar styles */
@keyframes float {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-5px);
  }
}

@keyframes shake {
  0% {
    transform: translate(1px, 1px) rotate(0deg);
  }

  10% {
    transform: translate(-1px, -2px) rotate(-1deg);
  }

  20% {
    transform: translate(-3px, 0px) rotate(1deg);
  }

  30% {
    transform: translate(3px, 2px) rotate(0deg);
  }

  40% {
    transform: translate(1px, -1px) rotate(1deg);
  }

  50% {
    transform: translate(-1px, 2px) rotate(-1deg);
  }

  60% {
    transform: translate(-3px, 1px) rotate(0deg);
  }

  70% {
    transform: translate(3px, 1px) rotate(-1deg);
  }

  80% {
    transform: translate(-1px, -1px) rotate(1deg);
  }

  90% {
    transform: translate(1px, 2px) rotate(0deg);
  }

  100% {
    transform: translate(1px, -2px) rotate(-1deg);
  }
}

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

  50% {
    transform: scale(1.1);
  }

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

@keyframes bounce {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-6px);
  }
}

/* Animation Utility Classes */
.float {
  animation-name: float;
}

.pulse {
  animation-name: pulse;
}

.shake {
  animation-name: shake;
}

/* Transitions */
.screen-transition {
  animation-duration: 0.5s;
  animation-fill-mode: both;
  animation-timing-function: cubic-bezier(0.19, 1, 0.22, 1);
}

.fade-in {
  animation-name: fadeIn;
}

.slide-up {
  animation-name: slideUp;
}

.fade-out {
  animation-name: fadeOut;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Game Over Screen */
.game-over-card {
  text-align: center;
  border-color: rgba(255, 0, 85, 0.5);
  box-shadow: 0 0 50px rgba(255, 0, 85, 0.2);
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 20px 0;
}

.stat-box {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-value {
  font-size: 24px;
  font-weight: 900;
  color: #fff;
}

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
  letter-spacing: 1px;
}

.achievement-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
}

.achievement-badge {
  font-size: 20px;
  background: rgba(255, 215, 0, 0.1);
  border: 1px solid rgba(255, 215, 0, 0.3);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
}

.bounce {
  animation-name: bounce;
}

.kawaii-avatar {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 35px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
  border: none;
  position: relative;
  transition: all 0.3s ease;
  animation-duration: 2s;
  animation-iteration-count: infinite;
}

.avatar-svg {
  width: 46px;
  height: 46px;
  display: block;
}

.kawaii-tag {
  position: absolute;
  bottom: -5px;
  right: -5px;
  font-size: 14px;
  background: #fff;
  border-radius: 10px;
  padding: 2px 5px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  font-weight: bold;
  color: #555;
}

:root {
  --bg-dark: #050510;
  --miami-cyan: #00f3ff;
  --miami-pink: #ff00ff;
  --miami-purple: #9d00ff;
  --glass-bg: rgba(20, 10, 40, 0.65);
  --glass-border: rgba(255, 255, 255, 0.15);
  --text-main: #f0f0f5;
  --safe-bottom: env(safe-area-inset-bottom, 20px);
}

body {
  margin: 0;
  padding: 0;
  font-family: "Inter", sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  background-image:
    linear-gradient(rgba(157, 0, 255, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(157, 0, 255, 0.07) 1px, transparent 1px),
    radial-gradient(circle at 50% 50%, rgba(0, 243, 255, 0.03) 0%, rgba(0, 0, 0, 0) 70%);
  background-size: 40px 40px, 40px 40px, 100% 100%;
  background-attachment: fixed;
}

.hud-font {
  font-family: "Chakra Petch", sans-serif;
}

.miami-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.3),
    inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 24px;
  padding: 24px;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}

.miami-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, transparent 100%);
  pointer-events: none;
}

.hero-card {
  text-align: center;
  display: grid;
  gap: 14px;
}

.hero-title {
  font-size: 36px;
  font-weight: 900;
  letter-spacing: 2px;
  color: rgba(0, 243, 255, 0.95);
  text-transform: uppercase;
}

.hero-subtitle {
  font-size: 14px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.7);
}

.hero-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.hero-pill {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-weight: 700;
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
}

.hero-meta {
  display: flex;
  justify-content: center;
  gap: 16px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.7);
}

.case-card {
  padding: 18px;
}

.caseHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.caseBadge {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.75);
  font-weight: 700;
}

.caseTitle {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(0, 243, 255, 0.9);
}

.caseLabel {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.6);
  font-weight: 700;
  margin-bottom: 6px;
}

.caseSummary {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(0, 243, 255, 0.08);
  border: 1px solid rgba(0, 243, 255, 0.2);
}

.caseBody {
  color: rgba(255, 255, 255, 0.82);
  line-height: 1.45;
  font-size: 15px;
}

.caseDetails {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.78);
}

.caseDetails summary {
  cursor: pointer;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.85);
  list-style: none;
}

.caseDetails summary::-webkit-details-marker {
  display: none;
}

.caseDetails summary::after {
  content: "▼";
  font-size: 12px;
  margin-left: 8px;
  color: rgba(0, 243, 255, 0.8);
}

.caseDetails[open] summary::after {
  content: "▲";
}

.welcome-title {
  color: rgba(255, 255, 255, 0.95);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.welcome-subtitle {
  margin-top: 8px;
  color: rgba(0, 243, 255, 0.8);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.rules-list {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.rules-list li {
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(0, 243, 255, 0.08);
  border: 1px solid rgba(0, 243, 255, 0.25);
  color: rgba(255, 255, 255, 0.82);
  font-weight: 600;
}

.narrative-title {
  color: rgba(0, 243, 255, 0.9);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.narrative-body {
  color: rgba(255, 255, 255, 0.78);
  margin-top: 10px;
  line-height: 1.5;
}

.narrative-quote {
  margin-top: 14px;
  padding: 10px 14px;
  border-left: 4px solid rgba(0, 243, 255, 0.6);
  color: rgba(255, 255, 255, 0.9);
  font-style: italic;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
}

.narrative-footer {
  margin-top: 12px;
  color: rgba(255, 255, 255, 0.6);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.caseAside {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(255, 0, 85, 0.12);
  border: 1px solid rgba(255, 0, 85, 0.3);
  color: rgba(255, 255, 255, 0.8);
  font-weight: 600;
}

.caseQuestion {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(0, 243, 255, 0.08);
  border: 1px solid rgba(0, 243, 255, 0.25);
  color: rgba(255, 255, 255, 0.85);
  font-weight: 700;
}

.hudMeta {
  margin-top: 18px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  flex-wrap: wrap;
}

.hudRow {
  display: grid;
  gap: 12px;
  align-items: center;
  padding-bottom: 4px;
}

@media (min-width: 520px) {
  .hudRow {
    grid-template-columns: 1fr 1.2fr 1fr;
  }
}

@media (max-width: 380px) {
  .hudBox .badge {
    display: none;
  }

  .hudBox {
    gap: 8px;
  }

  .kawaii-avatar {
    width: 48px;
    height: 48px;
    font-size: 24px;
  }

  .avatar-svg {
    width: 32px;
    height: 32px;
  }

  .hero-title {
    font-size: 28px;
  }
}

/* Safe Area for Mobile */
#app {
  padding-bottom: calc(20px + var(--safe-bottom));
}

.hudBox {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}

.track {
  flex: 1;
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  overflow: hidden;
  position: relative;
}

.bar {
  height: 100%;
  background: linear-gradient(90deg, var(--miami-cyan), var(--miami-pink));
  box-shadow: 0 0 15px var(--miami-cyan);
  transition: width 0.1s linear;
}

.track-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 10px;
  letter-spacing: 1px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.7);
  text-transform: uppercase;
  pointer-events: none;
}

.track--danger .bar {
  background: linear-gradient(90deg, #ff0055, #ff9a9e);
  box-shadow: 0 0 15px rgba(255, 0, 85, 0.8);
}

.combo-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: linear-gradient(135deg, rgba(0, 243, 255, 0.25), rgba(255, 0, 255, 0.2));
  box-shadow: 0 0 18px rgba(0, 243, 255, 0.25);
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: 1px;
}

.combo-chip--alt {
  border-color: rgba(255, 255, 255, 0.15);
  background: linear-gradient(135deg, rgba(255, 0, 255, 0.25), rgba(112, 0, 255, 0.2));
  box-shadow: 0 0 18px rgba(255, 0, 255, 0.25);
}

.combo-label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
}

.combo-value {
  font-size: 18px;
  color: #fff;
}

.modalNote {
  margin-top: 8px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.7);
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.65);
  z-index: 1200;
  backdrop-filter: blur(4px);
}

.modalCard {
  width: min(520px, 100%);
  max-height: 85vh;
  background: rgba(10, 5, 25, 0.95);
  border: 1px solid var(--glass-border);
  border-radius: 32px;
  padding: 24px;
  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: pop-in 0.4s cubic-bezier(0.19, 1, 0.22, 1);
  backdrop-filter: blur(20px);
}

.modalContent {
  overflow: auto;
  padding-right: 6px;
  display: grid;
  gap: 10px;
}

.modalSection {
  display: grid;
  gap: 6px;
}

.modalSectionTitle {
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
  font-weight: 800;
}

.modalFeedback {
  margin-top: 10px;
  font-size: 15px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(0, 243, 255, 0.08);
  border: 1px solid rgba(0, 243, 255, 0.2);
  padding: 10px 12px;
  border-radius: 14px;
}

.modalDetails {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.78);
}

.modalDetails summary {
  cursor: pointer;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.85);
  list-style: none;
}

.modalDetails summary::-webkit-details-marker {
  display: none;
}

.modalDetails summary::after {
  content: "▼";
  font-size: 12px;
  margin-left: 8px;
  color: rgba(0, 243, 255, 0.8);
}

.modalDetails[open] summary::after {
  content: "▲";
}

.modalFull {
  margin-top: 8px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.8);
}

.take-home {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-weight: 700;
  color: rgba(255, 255, 255, 0.85);
}

.modal .btn-action {
  margin-top: 6px;
}

@keyframes pop-in {
  0% {
    transform: translateY(12px) scale(0.98);
    opacity: 0;
  }

  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

/* --- FACELIFTED BUTTONS --- */
.btn-action {
  width: 100%;
  padding: 20px;
  border: none;
  border-radius: 99px;
  background: linear-gradient(135deg, var(--miami-pink), var(--miami-purple));
  color: white;
  font-family: "Chakra Petch", sans-serif;
  font-weight: 900;
  font-size: 20px;
  text-transform: uppercase;
  letter-spacing: 3px;
  box-shadow:
    0 0 15px rgba(255, 0, 255, 0.4),
    inset 0 2px 0 rgba(255, 255, 255, 0.4);
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.btn-action::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  transform: skewX(-20deg);
  transition: 0.5s;
}

.btn-action:hover {
  transform: translateY(-2px);
  box-shadow:
    0 0 25px rgba(255, 0, 255, 0.7),
    inset 0 2px 0 rgba(255, 255, 255, 0.6);
}

.btn-action:hover::before {
  left: 100%;
}

.btn-action:active {
  transform: translateY(2px) scale(0.98);
  box-shadow: 0 0 5px rgba(255, 0, 255, 0.4);
}

.options {
  display: grid;
  gap: 12px;
}

@media (min-width: 520px) {
  .options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.option-btn {
  width: 100%;
  min-height: 54px;
  /* Mobile touch target */
  padding: 16px;
  background: rgba(13, 10, 33, 0.6);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  border-radius: 16px;
  text-align: left;
  font-weight: 600;
  font-size: 16px;
  transition: all 0.2s ease-out;
  cursor: pointer;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: center;
  backdrop-filter: blur(8px);
}

.option-index {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(0, 243, 255, 0.1);
  border: 1px solid rgba(0, 243, 255, 0.3);
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 800;
  color: var(--miami-cyan);
  transition: all 0.2s;
}

.option-text {
  display: block;
  line-height: 1.4;
}

.option-btn:hover:not(:disabled) {
  border-color: var(--miami-cyan);
  background: rgba(0, 243, 255, 0.1);
  box-shadow: 0 0 15px rgba(0, 243, 255, 0.15);
  transform: translateX(4px);
}

.option-btn:hover:not(:disabled) .option-index {
  background: var(--miami-cyan);
  color: black;
}

.option-btn.correct {
  border-color: #39ff14 !important;
  background: rgba(57, 255, 20, 0.2) !important;
  box-shadow: 0 0 20px rgba(57, 255, 20, 0.3);
  color: #caffbf !important;
}

.option-btn.incorrect {
  border-color: #ff0055 !important;
  background: rgba(255, 0, 85, 0.2) !important;
  box-shadow: 0 0 20px rgba(255, 0, 85, 0.3);
  color: #ffb3c1 !important;
  animation: shake 0.4s;
}

.option-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

.patience-track {
  height: 12px;
  background: #111;
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.patience-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--miami-cyan), var(--miami-pink));
  box-shadow: 0 0 15px var(--miami-cyan);
  transition: width 0.1s linear;
}

.avatar-glow {
  filter: drop-shadow(0 0 12px rgba(255, 255, 255, 0.3));
}

.shake {
  animation: shake 0.4s ease-in-out;
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-12px);
  }

  75% {
    transform: translateX(12px);
  }
}

.scanline {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.1) 50%);
  background-size: 100% 4px;
  z-index: 1000;
  pointer-events: none;
  opacity: 0.3;
}

.spinner {
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top: 4px solid var(--miami-cyan);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 20px auto;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

#debug {
  display: none;
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: 10px;
  background: rgba(0, 0, 0, .92);
  border: 2px solid rgba(0, 243, 255, .45);
  border-radius: 18px;
  padding: 12px;
  z-index: 2000;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  white-space: pre-wrap;
  max-height: 35vh;
  overflow: auto;
}