:root {
  --bg: #0a0614;
  --panel: #140c24;
  --panel-2: #1e1434;
  --line: #3a2c5a;
  --gold: #ffd040;
  --pink: #ff60c0;
  --cyan: #40d0ff;
  --text: #f4f0ff;
  --dim: #8a84a8;
  --red: #ff5a5a;
  --green: #60e080;
  --font: "Press Start 2P", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 10px;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

#app {
  display: flex;
  height: 100vh;
  height: 100dvh;
}

/* ---------- Escena ---------- */

#stage {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  background: var(--bg);
}

#stage canvas {
  position: absolute;
  inset: 0;
  image-rendering: pixelated;
  display: block;
}

#fx { position: absolute; inset: 0; pointer-events: none; }
#stage canvas { cursor: grab; }
#stage canvas.dragging { cursor: grabbing; }

#cam {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

#cam button {
  width: 32px;
  height: 32px;
  font: 12px var(--font);
  color: var(--text);
  background: var(--panel);
  border: 2px solid #000;
  box-shadow: 0 3px 0 #000, inset 0 0 0 2px var(--line);
  cursor: pointer;
}

#cam button:hover { background: #8a2a6a; }
#cam button:active { transform: translateY(2px); box-shadow: 0 1px 0 #000; }
#cam .touch { display: none; }
@media (pointer: coarse) { #cam .desk { display: none; } #cam .touch { display: block; } }
#stage.raw { background: linear-gradient(#090514, #000003); }
#stage canvas.raw { image-rendering: auto; }
#cam span { width: 100%; text-align: right; color: var(--dim); font-size: 7px; text-shadow: 1px 1px 0 #000; }

.float {
  position: absolute;
  transform: translate(-50%, -50%);
  color: var(--gold);
  font-size: 16px;
  text-shadow: 2px 2px 0 #000;
  animation: floatUp 1.8s ease-out forwards;
}

@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, 0) scale(.6); }
  15% { opacity: 1; transform: translate(-50%, -30%) scale(1.2); }
  100% { opacity: 0; transform: translate(-50%, -260%) scale(1); }
}

#chant, #bubble {
  position: absolute;
  transform: translate(-50%, -100%);
  background: #fff;
  color: #1a1020;
  padding: 8px 10px;
  border: 3px solid #000;
  box-shadow: 3px 3px 0 #000;
  white-space: nowrap;
  pointer-events: none;
}

#chant::after, #bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -9px;
  width: 10px;
  height: 10px;
  background: #fff;
  border: solid #000;
  border-width: 0 3px 3px 0;
  transform: translateX(-50%) rotate(45deg);
}

#toast {
  position: absolute;
  left: 50%;
  top: 16px;
  transform: translate(-50%, -150%);
  background: var(--panel);
  border: 3px solid var(--pink);
  box-shadow: 4px 4px 0 #000;
  padding: 10px 14px;
  line-height: 1.6;
  transition: transform .2s;
  pointer-events: none;
  max-width: 90%;
  text-align: center;
}

#toast.show { transform: translate(-50%, 0); }
#toast.error { border-color: var(--red); color: var(--red); }

.overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(10, 6, 20, .72);
}

.overlay.show { display: flex; animation: pop .3s ease-out; }
#finale { background: rgba(10, 6, 20, .35); align-items: flex-end; }

@keyframes pop { from { opacity: 0; transform: translateY(10px); } }

.card {
  background: var(--panel);
  border: 3px solid var(--gold);
  box-shadow: 6px 6px 0 #000;
  padding: 16px;
}

.intro-card { display: flex; gap: 16px; align-items: flex-end; max-width: 520px; }
.intro-card img { height: 200px; image-rendering: pixelated; }
.intro-card h2 { font-size: 14px; line-height: 1.5; margin: 8px 0 12px; }
.intro-card p { color: var(--gold); line-height: 1.6; }
.intro-card p.error { color: var(--red); }

.fin-card { text-align: center; max-width: 380px; width: 100%; }
.fin-card .big { color: var(--gold); font-size: 18px; line-height: 1.4; margin: 4px 0 16px; text-shadow: 3px 3px 0 #8a2a6a; }
.fin-card dl { display: grid; grid-template-columns: 1fr auto; gap: 10px; text-align: left; margin: 0 0 12px; }
.fin-card dt { color: var(--dim); }
.fin-card dd { margin: 0; color: var(--pink); }
.fin-card .good { color: var(--green); line-height: 1.6; min-height: 1em; }
.fin-card .row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* ---------- Panel ---------- */

#panel {
  width: 320px;
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  background: var(--panel);
  border-left: 3px solid #000;
  box-shadow: inset 3px 0 0 var(--line);
  overflow-y: auto;
}

.kicker { color: var(--pink); font-size: 8px; letter-spacing: 1px; }
#panel h1 { font-size: 12px; line-height: 1.5; margin: 6px 0 0; color: var(--gold); }

.who {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: var(--panel-2);
  border: 2px solid var(--line);
  padding: 8px 8px 0;
  overflow: hidden;
}

.who img { height: 92px; image-rendering: pixelated; display: block; }
.who > div { padding-bottom: 10px; line-height: 1.8; }
.who .name { font-size: 10px; }
.who .sub { color: var(--dim); font-size: 8px; }
.who .sub b { color: var(--pink); font-weight: normal; }

.block { background: var(--panel-2); border: 2px solid var(--line); padding: 8px; }

.label { display: flex; justify-content: space-between; align-items: center; color: var(--dim); font-size: 8px; margin-bottom: 8px; }
.label b { color: var(--text); font-weight: normal; }
.hint { color: var(--gold); }

.meter { height: 12px; background: #000; border: 2px solid #000; box-shadow: 0 0 0 2px var(--line); }
.meter i { display: block; height: 100%; width: 0; background: var(--green); transition: width .15s linear; }
.meter i[data-level=mid] { background: var(--gold); }
.meter i[data-level=low] { background: var(--red); }
.meter.thin { height: 8px; margin-top: 8px; }
.meter.thin i { background: var(--pink); transition: none; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.stats div { background: var(--panel-2); border: 2px solid var(--line); padding: 8px 6px; display: flex; flex-direction: column; gap: 6px; }
.stats span { color: var(--dim); font-size: 7px; }
.stats b { font-weight: normal; font-size: 10px; }
.stats .gold { color: var(--gold); }

#now { color: var(--dim); line-height: 1.5; min-height: 1.5em; }
.now.on #now { color: var(--gold); }
.eq { display: flex; gap: 2px; align-items: flex-end; height: 10px; }
.eq i { width: 3px; height: 3px; background: var(--dim); }
.now.on .eq i { background: var(--pink); animation: eq .5s steps(3) infinite alternate; }
.now.on .eq i:nth-child(2) { animation-delay: -.2s; }
.now.on .eq i:nth-child(3) { animation-delay: -.35s; }
@keyframes eq { to { height: 10px; } }

.setlist { flex: 1; min-height: 0; }
#songs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }

#songs button {
  width: 100%;
  display: flex;
  gap: 8px;
  align-items: center;
  font: 9px/1.4 var(--font);
  color: var(--text);
  background: #2a2040;
  border: 2px solid #000;
  box-shadow: 0 3px 0 #000;
  padding: 7px 8px;
  text-align: left;
  cursor: pointer;
}

#songs button .n { color: var(--pink); }
#songs button .t { flex: 1; }
#songs button .d { color: var(--dim); font-size: 7px; }
#songs button:hover:not(:disabled) { background: #8a2a6a; transform: translateY(-1px); }
#songs button:hover:not(:disabled) .n { color: var(--gold); }
#songs button:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 #000; }
#songs button:disabled { cursor: default; }
#panel.busy #songs button:not(.done):not(.current) { opacity: .55; }
#songs button.done { background: transparent; box-shadow: none; border-color: var(--line); color: var(--dim); }
#songs button.done .t { text-decoration: line-through; }
#songs button.done .n::before { content: "* "; color: var(--green); }
#songs button.current { background: #8a2a6a; color: var(--gold); opacity: 1; }

footer { display: flex; gap: 8px; }

.btn {
  flex: 1;
  font: 9px var(--font);
  color: var(--text);
  background: #3a3456;
  border: 2px solid #000;
  box-shadow: 0 3px 0 #000;
  padding: 9px 8px;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { background: #4a4470; }
.btn.primary { background: #8a2a6a; }
.btn.primary:hover { background: #a83a84; }

/* ---------- Móvil: escena arriba, panel debajo ---------- */

@media (max-width: 820px), (orientation: portrait) {
  #app { flex-direction: column; }
  #stage { flex: none; height: 52%; }
  #panel { width: auto; flex: 1; border-left: 0; border-top: 3px solid #000; box-shadow: inset 0 3px 0 var(--line); padding: 10px 16px; gap: 8px; }
  .who, #panel header { display: none; }
  .setlist { flex: none; }
  footer { position: sticky; bottom: 0; background: var(--panel); padding-top: 6px; }
  .intro-card img { height: 120px; }
  #songs { display: grid; grid-template-columns: 1fr 1fr; }
}

/* ---------- Restaurante: carta con primero, segundo y postre ---------- */

#bubble[hidden] { display: none; }
.intro-card .btn { display: inline-block; flex: none; }
#courses { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.course .head { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 8px; color: var(--dim); }
.course .head b { font-weight: normal; color: var(--pink); }
.course .dishes { display: flex; flex-direction: column; gap: 4px; }
.course button {
  font: 9px/1.4 var(--font);
  color: var(--text);
  background: #2a2040;
  border: 2px solid #000;
  box-shadow: 0 3px 0 #000;
  padding: 7px 8px;
  text-align: left;
  cursor: pointer;
}
.course button:hover:not(:disabled) { background: #8a2a6a; color: var(--gold); }
.course button:disabled { cursor: default; opacity: .45; }
.course.now .head b { color: var(--gold); }
.course.now button:disabled { opacity: .6; }
.course button.chosen, .course.now button.chosen:disabled { opacity: 1; background: #8a2a6a; color: var(--gold); }
.course.done button:not(.chosen) { display: none; }
.course.done button.chosen { background: transparent; box-shadow: none; border-color: var(--line); color: var(--green); }
.course.done button.chosen::after { content: " - OK"; color: var(--dim); }

/* ---------- Menú principal (index.html) ---------- */

.lead { line-height: 1.8; color: var(--dim); margin: 0; }

.tabs, .seg { display: flex; gap: 6px; }
.tabs button, .seg button {
  flex: 1;
  font: 9px var(--font);
  color: var(--dim);
  background: transparent;
  border: 2px solid var(--line);
  padding: 8px 6px;
  cursor: pointer;
}
.tabs button.active, .seg button.active { color: var(--gold); background: var(--panel-2); border-color: var(--gold); }

.auth-box {
  max-width: 420px;
  margin: 0 auto 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--panel);
  border: 3px solid #000;
  box-shadow: 6px 6px 0 #000, inset 0 0 0 2px var(--line);
}
.auth-box[hidden], .form[hidden], .modal[hidden], .btn[hidden] { display: none; }

.form { display: flex; flex-direction: column; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 8px; color: var(--dim); line-height: 1.5; }
.form small { color: var(--line); font-size: 7px; }
.form input[type=email], .form input[type=password], .form input[type=text] {
  font: 10px var(--font);
  color: var(--text);
  background: #0a0614;
  border: 2px solid var(--line);
  padding: 9px 8px;
  outline: none;
}
.form input:focus { border-color: var(--gold); }
.form-error { color: var(--red); line-height: 1.6; min-height: 1em; margin: 0; }
.btn:disabled { opacity: .5; cursor: default; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(5, 3, 10, .75);
}
.modal-card {
  width: min(420px, 100%);
  max-height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--panel);
  border: 3px solid #000;
  box-shadow: 6px 6px 0 #000, inset 0 0 0 2px var(--gold);
}
.modal-card header { display: flex; justify-content: space-between; align-items: center; }
.modal-card h3 { margin: 0; font-size: 14px; color: var(--gold); text-shadow: 2px 2px 0 #8a2a6a; }
.modal-card header .btn { flex: none; padding: 7px 10px; }

#ranking { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; min-height: 120px; }
#ranking li { display: flex; gap: 8px; font-size: 9px; }
#ranking .pos { width: 3ch; }
#ranking .nick { flex: 1; overflow: hidden; text-overflow: ellipsis; }
#ranking li.mine { color: var(--pink); }
#ranking .empty { color: var(--dim); line-height: 1.6; }
#ranking .error { color: var(--red); }
.me { display: flex; justify-content: space-between; gap: 8px; background: #8a2a6a; border: 2px solid #000; padding: 8px; font-size: 9px; color: var(--text); }
.me b { font-weight: normal; color: var(--gold); }

#status { max-width: 1200px; margin: 16px auto 0; color: var(--red); }

/* ---------- Elegir escenario (tarjetas con la maqueta de cada sala) ---------- */

.tour {
  position: fixed;
  inset: 0;
  z-index: 10;
  overflow-y: auto;
  padding: 28px 24px 32px;
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(58, 44, 90, .35) 1px, transparent 1px),
    linear-gradient(90deg, rgba(58, 44, 90, .35) 1px, transparent 1px);
  background-size: 48px 48px;
}

.tour-head {
  max-width: 1200px;
  margin: 0 auto 24px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}
.tour-head h2 { margin: 10px 0 8px; font-size: 18px; color: var(--gold); text-shadow: 3px 3px 0 #8a2a6a; }
.tour-head p { margin: 0; color: var(--dim); }
.tour-head .kicker b { color: var(--text); font-weight: normal; }
.tour-actions { display: flex; gap: 8px; }

#tour-cards {
  list-style: none;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.scene-card {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  padding: 0;
  overflow: hidden;
  font: inherit;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  border: 3px solid #000;
  box-shadow: 6px 6px 0 #000, inset 0 0 0 2px var(--line);
  background: radial-gradient(ellipse at 50% 35%, #2a1e4a 0%, #140c26 55%, #07040e 100%);
  transition: transform .15s, box-shadow .15s;
}
.scene-card:hover, .scene-card:focus-visible { transform: translateY(-4px); box-shadow: 6px 10px 0 #000, inset 0 0 0 3px var(--gold); outline: none; }
.scene-card .iso { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scene-card .iso:not([src]) { visibility: hidden; }
.scene-card::after {
  content: "";
  position: absolute;
  inset: 45% 0 0;
  background: linear-gradient(transparent, rgba(7, 4, 14, .92));
  pointer-events: none;
}
.scene-card .num { position: absolute; left: 18px; top: 16px; z-index: 1; font-size: 24px; color: var(--gold); text-shadow: 3px 3px 0 #000; }
.scene-card .guille { position: absolute; right: 12px; bottom: 10px; z-index: 1; height: 34%; image-rendering: pixelated; filter: drop-shadow(2px 2px 0 #000); }
.scene-card .txt { position: absolute; left: 18px; right: 30%; bottom: 16px; z-index: 1; display: flex; flex-direction: column; gap: 10px; }
.scene-card .txt b { font-weight: normal; font-size: 14px; line-height: 1.4; text-shadow: 2px 2px 0 #000; }
.scene-card .txt small { color: var(--green); font-size: 8px; line-height: 1.6; letter-spacing: 1px; }

@media (max-width: 820px), (orientation: portrait) {
  .tour { padding: 18px 16px 24px; }
  .tour-head h2 { font-size: 14px; }
  #tour-cards { grid-template-columns: 1fr; gap: 16px; }
}

/* ---------- Firma de discos: dos maneras de firmar ---------- */

.sign-actions { display: flex; flex-direction: column; gap: 8px; }
.sign-actions button {
  font: 9px/1.5 var(--font);
  color: var(--text);
  background: #2a2040;
  border: 2px solid #000;
  box-shadow: 0 3px 0 #000;
  padding: 10px;
  text-align: left;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.sign-actions button small { color: var(--dim); font-size: 7px; }
.sign-actions button:hover:not(:disabled) { background: #8a2a6a; color: var(--gold); }
.sign-actions button:disabled { cursor: default; opacity: .45; }
.sign-actions button.busy { opacity: 1; background: #8a2a6a; color: var(--gold); }
.sign-actions .rule { color: var(--dim); font-size: 7px; line-height: 1.7; margin: 2px 0 0; }
#flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; transition: opacity .35s ease-out; }
#flash.on { opacity: .85; transition: none; }
