/* ============================================================
   JACKEN LACAR · RIFF ATTACK — estética arcade/CRT de bar de rock
   ============================================================ */
:root {
  --bg: #0a0608;
  --panel: #14090d;
  --ink: #f5e9d6;
  --pink: #ff2e63;
  --amber: #ffb000;
  --cyan: #08d9d6;
  --green: #7dff5a;
  --red: #ff3b30;
  --pixel: "Press Start 2P", monospace;
  --crt: "VT323", monospace;
}

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

html, body {
  height: 100%;
  background: #000;
  overflow: hidden;
  font-family: var(--crt);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

#cabinet {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background:
    radial-gradient(ellipse at 50% -20%, #2a0f1c 0%, transparent 60%),
    radial-gradient(ellipse at 50% 120%, #101c2a 0%, transparent 55%),
    var(--bg);
  overflow: hidden;
}

/* ---- Efectos CRT ---- */
#scanlines {
  position: absolute; inset: 0; z-index: 40; pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px, transparent 2px,
    rgba(0, 0, 0, 0.22) 3px, rgba(0, 0, 0, 0.22) 4px
  );
  mix-blend-mode: multiply;
}
#vignette {
  position: absolute; inset: 0; z-index: 41; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.55) 100%);
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  user-select: none;
}

/* ---- Pantallas ---- */
.screen {
  position: absolute; inset: 0; z-index: 30;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 24px;
  text-align: center;
  background: rgba(6, 3, 5, 0.72);
  backdrop-filter: blur(2px);
}
.screen.active { display: flex; animation: screenIn 0.35s steps(6) both; }

@keyframes screenIn {
  from { opacity: 0; transform: scale(1.04); }
  to   { opacity: 1; transform: scale(1); }
}

/* ---- Título ---- */
.kicker {
  font-family: var(--pixel);
  font-size: clamp(8px, 1.6vw, 12px);
  color: var(--cyan);
  letter-spacing: 2px;
  animation: blink 1.1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0.25; } }

.logo {
  font-family: var(--pixel);
  font-size: clamp(28px, 7vw, 64px);
  line-height: 1.15;
  color: var(--ink);
  text-shadow:
    0 0 6px rgba(255, 46, 99, 0.9),
    4px 4px 0 var(--pink),
    8px 8px 0 rgba(0,0,0,0.6);
  margin: 14px 0 6px;
}
.game-title {
  font-family: var(--pixel);
  font-size: clamp(14px, 3vw, 26px);
  color: var(--amber);
  text-shadow: 0 0 10px rgba(255, 176, 0, 0.8), 3px 3px 0 rgba(0,0,0,0.6);
  letter-spacing: 4px;
}
.tagline {
  font-size: clamp(18px, 2.6vw, 24px);
  color: var(--ink);
  opacity: 0.85;
  margin-top: 10px;
}
.hint {
  font-size: 17px;
  color: var(--cyan);
  opacity: 0.8;
}

/* ---- Botones ---- */
.menu-buttons { display: flex; flex-direction: column; gap: 14px; align-items: center; }

.btn {
  font-family: var(--pixel);
  font-size: clamp(10px, 1.8vw, 14px);
  color: var(--ink);
  background: var(--panel);
  border: 3px solid var(--ink);
  padding: 14px 26px;
  cursor: pointer;
  box-shadow: 0 5px 0 rgba(0,0,0,0.7), inset 0 0 0 2px rgba(0,0,0,0.4);
  transition: transform 0.06s steps(2), box-shadow 0.06s steps(2);
  image-rendering: pixelated;
}
.btn:hover { border-color: var(--amber); color: var(--amber); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0,0,0,0.7); }
.btn-primary { border-color: var(--pink); color: var(--pink); }
.btn-primary:hover { border-color: var(--green); color: var(--green); }
.btn-back { font-size: 10px; opacity: 0.85; }

/* ---- Selector de personajes ---- */
.screen-title {
  font-family: var(--pixel);
  font-size: clamp(14px, 3vw, 24px);
  color: var(--amber);
  text-shadow: 3px 3px 0 rgba(0,0,0,0.7);
  letter-spacing: 3px;
}

#roster {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 18px;
  width: min(760px, 92vw);
}
.member-card {
  background: var(--panel);
  border: 3px solid var(--member, var(--ink));
  padding: 16px 10px 14px;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  box-shadow: 0 6px 0 rgba(0,0,0,0.7);
  transition: transform 0.08s steps(3);
}
.member-card:hover { transform: translateY(-6px); background: #1d0d14; }
.member-card:active { transform: translateY(2px); }
.member-card canvas { image-rendering: pixelated; width: 96px; height: 96px; }
.member-name {
  font-family: var(--pixel);
  font-size: 11px;
  color: var(--member, var(--ink));
}
.member-role { font-size: 18px; opacity: 0.8; }

/* ---- Selector de tema ---- */
#tracklist {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(560px, 92vw);
}
.track-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--panel);
  border: 3px solid var(--cyan);
  padding: 14px 18px;
  cursor: pointer;
  text-align: left;
  box-shadow: 0 5px 0 rgba(0,0,0,0.7);
  transition: transform 0.08s steps(3);
}
.track-card:hover { transform: translateX(6px); border-color: var(--pink); background: #1d0d14; }
.track-card:active { transform: translateY(2px); }
.track-num {
  font-family: var(--pixel);
  font-size: 9px;
  color: var(--amber);
  white-space: nowrap;
}
.track-name {
  font-size: clamp(18px, 2.6vw, 24px);
  color: var(--ink);
}

/* ---- Resultado ---- */
.stats { display: flex; gap: 26px; flex-wrap: wrap; justify-content: center; }
.stat { display: flex; flex-direction: column; gap: 8px; }
.stat-label { font-family: var(--pixel); font-size: 9px; color: var(--cyan); }
.stat-value { font-family: var(--pixel); font-size: clamp(16px, 3.4vw, 28px); color: var(--ink); }
.result-stars {
  margin: 0;
  color: var(--amber);
  font-family: var(--pixel);
  font-size: clamp(18px, 5vw, 34px);
  letter-spacing: 4px;
}

#prize-box {
  border: 3px dashed var(--amber);
  padding: 14px 22px;
  font-family: var(--pixel);
  font-size: 10px;
  color: var(--amber);
  animation: blink 1.4s steps(2) infinite;
}
.prize-code { font-size: 16px; color: var(--green); margin: 8px 0; }
.prize-note { font-family: var(--crt); font-size: 17px; color: var(--ink); }

.submit-row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
#player-name {
  font-family: var(--pixel);
  font-size: 12px;
  background: #000;
  color: var(--green);
  border: 3px solid var(--green);
  padding: 12px 14px;
  width: min(260px, 70vw);
  text-transform: uppercase;
  outline: none;
}
#player-name::placeholder { color: rgba(125, 255, 90, 0.4); }

/* ---- Ranking ---- */
.board-note { font-size: 18px; color: var(--cyan); opacity: 0.85; }
.board-tracks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: min(720px, 94vw);
  gap: 6px;
  padding: 2px;
}
.board-track {
  min-height: 44px;
  border: 2px solid rgba(245, 233, 214, 0.28);
  background: var(--panel);
  color: var(--ink);
  font-family: var(--pixel);
  font-size: 8px;
  line-height: 1.45;
  cursor: pointer;
}
.board-track.active {
  border-color: var(--pink);
  background: var(--pink);
  color: #fff;
}
#board-list {
  list-style: none;
  width: min(520px, 92vw);
  display: flex; flex-direction: column; gap: 8px;
  max-height: 46vh;
  overflow-y: auto;
}
#board-list li {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  background: var(--panel);
  border: 2px solid rgba(245, 233, 214, 0.25);
  padding: 10px 14px;
  font-size: 20px;
}
#board-list li:first-child { border-color: var(--amber); box-shadow: 0 0 14px rgba(255,176,0,0.35); }
#board-list .pos { font-family: var(--pixel); font-size: 11px; color: var(--amber); }
#board-list .pname { text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#board-list .pscore { font-family: var(--pixel); font-size: 12px; color: var(--green); }
.board-empty { font-size: 20px; opacity: 0.7; padding: 20px; }
#board-list .board-empty {
  display: block;
  text-align: center;
  line-height: 1.5;
}

@media (min-width: 768px) {
  .board-tracks { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ---- Flash / countdown ---- */
#flash {
  position: absolute; inset: 0; z-index: 35;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--pixel);
  font-size: clamp(30px, 9vw, 80px);
  color: var(--amber);
  text-shadow: 0 0 18px rgba(255,176,0,0.9), 5px 5px 0 rgba(0,0,0,0.7);
  pointer-events: none;
}

#pause-overlay {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 24px;
  background: rgba(0, 0, 0, 0.92);
}
#pause-title {
  font-family: var(--pixel);
  font-size: clamp(17px, 5vw, 30px);
  color: var(--amber);
  text-shadow: 3px 3px 0 rgba(0,0,0,0.7);
}

.hidden { display: none !important; }

@media (max-width: 560px) {
  #roster { grid-template-columns: repeat(2, 1fr); }
  .member-card canvas { width: 72px; height: 72px; }
}

/* ---- Intro / diálogos estilo RPG ---- */
#screen-intro { justify-content: flex-end; padding-bottom: 6vh; }

#intro-band {
  width: min(420px, 80vw);
  height: auto;
  image-rendering: pixelated;
  margin-bottom: auto;
  margin-top: 8vh;
  animation: bandBob 0.9s steps(2) infinite;
}
@keyframes bandBob { 50% { transform: translateY(-6px); } }

.dialog-box {
  position: relative;
  width: min(620px, 92vw);
  background: rgba(10, 5, 8, 0.95);
  border: 3px solid var(--ink);
  box-shadow: 0 6px 0 rgba(0,0,0,0.7), inset 0 0 0 2px rgba(0,0,0,0.5);
  padding: 26px 20px 18px;
  text-align: left;
  cursor: pointer;
}
.dialog-speaker {
  position: absolute;
  top: -16px;
  left: 14px;
  font-family: var(--pixel);
  font-size: 10px;
  background: var(--panel);
  border: 3px solid currentColor;
  padding: 6px 10px;
}
.dialog-text {
  font-size: clamp(20px, 3vw, 26px);
  line-height: 1.35;
  min-height: 3.2em;
  color: var(--ink);
}
.dialog-next {
  text-align: right;
  font-family: var(--pixel);
  font-size: 8px;
  color: var(--amber);
  animation: blink 0.9s steps(2) infinite;
  margin-top: 8px;
}
#dialog-input-row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}
#dialog-name {
  flex: 1;
  font-family: var(--pixel);
  font-size: 12px;
  background: #000;
  color: var(--green);
  border: 3px solid var(--green);
  padding: 10px 12px;
  text-transform: uppercase;
  outline: none;
}
#dialog-name::placeholder { color: rgba(125, 255, 90, 0.4); }

.submit-name {
  font-family: var(--pixel);
  font-size: 11px;
  color: var(--green);
  align-self: center;
}

/* ---- Fondos generados con IA ---- */
#screen-title {
  background:
    linear-gradient(rgba(6, 3, 5, 0.55), rgba(6, 3, 5, 0.75)),
    url("img/title-bg.png") center / cover no-repeat;
  image-rendering: pixelated;
}

/* ---- Intro: banda con sprites reales ---- */
#intro-band {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2vw;
  margin-bottom: auto;
  margin-top: 6vh;
  width: min(640px, 94vw);
}
#intro-band img {
  width: 23%;
  image-rendering: pixelated;
  filter: drop-shadow(0 8px 0 rgba(0,0,0,0.5));
  animation: bandBob 0.9s steps(2) infinite;
}
#intro-band img:nth-child(2) { animation-delay: 0.22s; }
#intro-band img:nth-child(3) { animation-delay: 0.45s; }
#intro-band img:nth-child(4) { animation-delay: 0.67s; }

.dialog-face {
  position: absolute;
  top: -34px;
  right: 14px;
  width: 72px;
  height: 72px;
  object-fit: contain;
  image-rendering: pixelated;
  background: var(--panel);
  border: 3px solid var(--ink);
  padding: 2px;
}

/* ---- Intro: llegada a Malta Studio + speaker grande ---- */
#screen-intro {
  background:
    linear-gradient(rgba(6, 3, 5, 0.45), rgba(6, 3, 5, 0.8)),
    url("img/bg-malta-ext.png") center / cover no-repeat;
  image-rendering: pixelated;
}
#intro-hero {
  height: 44vh;
  max-width: 80vw;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 10px 0 rgba(0,0,0,0.55));
  margin-bottom: auto;
  margin-top: 5vh;
}
#intro-hero.pop { animation: heroPop 0.35s steps(4) both; }
@keyframes heroPop {
  from { transform: translateY(24px) scale(0.92); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

/* ---- Fix: que nada tape el cuadro de diálogo ---- */
.dialog-box { margin-top: 78px; flex-shrink: 0; }
.dialog-face {
  top: -72px;
  right: 10px;
  width: 64px;
  height: 64px;
}
#intro-hero {
  height: 34vh;
  margin-top: 2vh;
  margin-bottom: 12px;
}
