@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@600;700;800&family=Inter:wght@400;500;600;700;800;900&display=swap');

:root {
  --bg: #080604;
  --bg2: #140f0b;
  --panel: rgba(20, 15, 12, .86);
  --panel2: rgba(36, 26, 19, .9);
  --stroke: rgba(240, 198, 118, .22);
  --stroke-strong: rgba(240, 198, 118, .44);
  --gold: #f2c66e;
  --gold2: #9f6d2c;
  --red: #c43c35;
  --green: #8ee07d;
  --text: #f7ead5;
  --muted: #bba98d;
  --black: #050403;
  --shadow: 0 24px 90px rgba(0,0,0,.55);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select {
  font: inherit;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.game-body {
  min-height: 100svh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 50% 0%, rgba(199, 57, 42, .22), transparent 34%),
    radial-gradient(circle at 20% 28%, rgba(242, 198, 110, .12), transparent 28%),
    linear-gradient(180deg, #0b0806 0%, #040302 100%);
}

.game-body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(rgba(0,0,0,.1), rgba(0,0,0,.64)),
    url("../img/bg-maquina-deuda.jpg");
  background-size: cover;
  background-position: center;
  opacity: .34;
  pointer-events: none;
}

.bg-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .08;
  mix-blend-mode: screen;
  background-image:
    repeating-radial-gradient(circle at 0 0, rgba(255,255,255,.8) 0 1px, transparent 1px 4px);
  background-size: 9px 9px;
}

.phone-shell {
  position: relative;
  z-index: 1;
  width: min(100%, 480px);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
  display: grid;
  place-items: center;
}

.hidden { display: none !important; }

.brand-kicker {
  color: var(--gold);
  font-size: .7rem;
  font-weight: 900;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.intro-card,
.instructions-card,
.game-card,
.end-card,
.ranking-panel,
.modal-card {
  width: 100%;
  border: 1px solid var(--stroke);
  background:
    linear-gradient(180deg, rgba(255,255,255,.045), transparent 22%),
    linear-gradient(180deg, var(--panel), rgba(10,8,6,.94));
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(255,255,255,.03);
  border-radius: 28px;
  backdrop-filter: blur(18px);
}

.intro-card,
.instructions-card,
.end-card {
  padding: 28px 22px;
  text-align: center;
}

.intro-card h1 {
  margin: 10px 0 10px;
  font-family: Cinzel, serif;
  font-size: clamp(2.4rem, 13vw, 4.2rem);
  line-height: .88;
  letter-spacing: -.06em;
  text-shadow: 0 0 28px rgba(242, 198, 110, .14);
}

.intro-copy {
  max-width: 34ch;
  margin: 0 auto 20px;
  color: var(--muted);
  line-height: 1.45;
}

.name-label {
  display: block;
  text-align: left;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .04em;
  margin: 16px 4px 8px;
}

.name-input,
.admin-login input,
.admin-filters input,
.admin-filters select {
  width: 100%;
  border: 1px solid rgba(242, 198, 110, .26);
  border-radius: 16px;
  background: rgba(0,0,0,.42);
  color: var(--text);
  padding: 14px 14px;
  outline: none;
  box-shadow: inset 0 0 24px rgba(0,0,0,.28);
}

.name-input:focus,
.admin-login input:focus,
.admin-filters input:focus,
.admin-filters select:focus {
  border-color: var(--gold);
}

.main-button,
.secondary-button,
.ghost-button,
.small-button,
.admin-card button,
.admin-filters button,
.action-cell button {
  border: 0;
  border-radius: 16px;
  font-weight: 900;
  letter-spacing: .02em;
  min-height: 48px;
  transition: transform .12s ease, filter .12s ease, opacity .12s ease;
}

.main-button {
  width: 100%;
  margin-top: 14px;
  color: #1b1005;
  background:
    linear-gradient(180deg, #ffd98c 0%, #d08b35 100%);
  box-shadow: 0 14px 34px rgba(208, 139, 53, .24);
}

.secondary-button {
  width: 100%;
  color: #fff4e2;
  background: linear-gradient(180deg, #873c31 0%, #501c18 100%);
  border: 1px solid rgba(255,255,255,.08);
}

.ghost-button {
  width: 100%;
  margin-top: 10px;
  color: var(--text);
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
}

.small-button {
  min-height: 38px;
  padding: 0 14px;
  color: var(--text);
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
}

button:hover { filter: brightness(1.06); }
button:active { transform: scale(.98); }
button:disabled {
  cursor: not-allowed;
  opacity: .42;
  filter: grayscale(.3);
}

.tiny-note {
  color: rgba(247, 234, 213, .46);
  font-size: .76rem;
  margin: 16px 0 0;
}

/* INSTRUCTIONS */
.instructions-card h2 {
  margin: 8px 0 10px;
  font-family: Cinzel, serif;
  font-size: clamp(1.9rem, 10vw, 2.7rem);
  line-height: 1;
}

.rules-list {
  display: grid;
  gap: 8px;
  margin: 16px 0;
  text-align: left;
}

.rules-list article {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 16px;
  background: rgba(0,0,0,.22);
}

.rules-list strong {
  color: var(--gold);
  font-size: .86rem;
}

.rules-list span {
  color: var(--muted);
  font-size: .84rem;
  line-height: 1.32;
}

.mini-help {
  margin-top: 12px;
  padding: 12px;
  border-radius: 18px;
  background: rgba(0,0,0,.2);
  border: 1px solid rgba(242,198,110,.14);
  text-align: left;
}

.symbol-preview-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.symbol-preview-grid span {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 7px;
  border-radius: 12px;
  background: rgba(255,255,255,.045);
  color: #f9e7c6;
  font-size: .72rem;
  font-weight: 800;
}

.symbol-preview-grid img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  flex: 0 0 auto;
}

/* GAME */
.game-card {
  padding: 16px;
}

.game-header,
.ranking-header,
.admin-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.game-header h2,
.end-card h2,
.ranking-header h2,
.admin-header h1 {
  font-family: Cinzel, serif;
  margin: 4px 0 0;
  line-height: 1;
}

.status-pill {
  border: 1px solid rgba(142, 224, 125, .34);
  color: var(--green);
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 900;
  letter-spacing: .12em;
  padding: 8px 10px;
  background: rgba(142, 224, 125, .08);
  white-space: nowrap;
}

.status-pill.danger {
  color: #ff8077;
  border-color: rgba(196, 60, 53, .5);
  background: rgba(196, 60, 53, .12);
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.stats-grid,
.end-stats,
.admin-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 16px 0;
}

.stats-grid article,
.end-stats article,
.admin-stats article {
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 16px;
  background: rgba(0,0,0,.24);
  padding: 10px 8px;
  text-align: center;
}

.stats-grid span,
.end-stats span,
.admin-stats span {
  display: block;
  color: var(--muted);
  font-size: .66rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.stats-grid strong,
.end-stats strong,
.admin-stats strong {
  display: block;
  margin-top: 3px;
  font-size: clamp(1rem, 5vw, 1.35rem);
}

.slot-machine {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 14px 0;
  padding: 12px;
  border-radius: 24px;
  border: 1px solid var(--stroke-strong);
  background:
    radial-gradient(circle at 50% 10%, rgba(242,198,110,.12), transparent 42%),
    linear-gradient(180deg, rgba(0,0,0,.32), rgba(0,0,0,.58));
  box-shadow: inset 0 0 36px rgba(0,0,0,.48);
}

.slot {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 20px;
  border: 1px solid rgba(242, 198, 110, .24);
  background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(0,0,0,.38));
  overflow: hidden;
  box-shadow: inset 0 0 24px rgba(0,0,0,.52);
}

.slot-icon {
  width: 78%;
  height: 78%;
  object-fit: contain;
  filter: drop-shadow(0 0 14px rgba(242,198,110,.24));
}

.slot-placeholder {
  width: 42%;
  height: 42%;
  border-radius: 50%;
  border: 1px solid rgba(242,198,110,.24);
  background: radial-gradient(circle, rgba(242,198,110,.14), rgba(0,0,0,.18));
  box-shadow: inset 0 0 18px rgba(0,0,0,.56);
}

.inline-icon {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.slot.spin {
  animation: slotSpin .36s linear infinite;
}

@keyframes slotSpin {
  0% { transform: translateY(-2px); filter: blur(0); }
  50% { transform: translateY(2px); filter: blur(1px); }
  100% { transform: translateY(-2px); filter: blur(0); }
}

.machine-message {
  min-height: 58px;
  margin: 0;
  padding: 12px;
  color: #ffe6bd;
  line-height: 1.35;
  border-left: 3px solid var(--gold2);
  background: rgba(0,0,0,.22);
  border-radius: 14px;
}

.action-row {
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  gap: 10px;
  margin-top: 12px;
}

.action-row .main-button,
.action-row .secondary-button {
  margin: 0;
}

.wide {
  width: 100%;
}

.relic-panel {
  margin-top: 12px;
  padding: 12px;
  border-radius: 18px;
  background: rgba(0,0,0,.23);
  border: 1px solid rgba(255,255,255,.08);
}

.panel-title {
  color: var(--gold);
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .11em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.relic-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.relic-list.empty {
  color: var(--muted);
  font-size: .88rem;
}

.relic-chip,
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 7px 10px;
  font-size: .75rem;
  font-weight: 900;
  background: rgba(242, 198, 110, .11);
  border: 1px solid rgba(242, 198, 110, .18);
  color: #ffe4aa;
}

.relic-chip img {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

/* MODAL */
.modal {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0,0,0,.72);
  backdrop-filter: blur(8px);
}

.modal-card {
  max-width: 460px;
  padding: 20px;
}

.modal-card h2 {
  margin: 8px 0;
  font-family: Cinzel, serif;
}

.modal-card p {
  color: var(--muted);
  line-height: 1.45;
}

.relic-choices {
  display: grid;
  gap: 10px;
}

.relic-choice {
  width: 100%;
  min-height: auto;
  text-align: left;
  padding: 12px;
  border: 1px solid rgba(242, 198, 110, .2);
  border-radius: 18px;
  color: var(--text);
  background: rgba(255,255,255,.06);
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 10px;
  align-items: center;
}

.relic-choice-icon {
  width: 46px;
  height: 46px;
  object-fit: contain;
  filter: drop-shadow(0 0 12px rgba(242,198,110,.18));
}

.relic-choice-copy {
  display: block;
}

.relic-choice strong {
  display: block;
  color: var(--gold);
  margin-bottom: 4px;
}

.relic-choice span {
  color: var(--muted);
  line-height: 1.35;
}

.modal-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.help-card {
  max-height: min(86svh, 720px);
  overflow: auto;
}

.help-section {
  margin-top: 14px;
}

.help-list {
  display: grid;
  gap: 8px;
}

.help-row {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 10px;
  align-items: center;
  padding: 9px;
  border-radius: 14px;
  background: rgba(0,0,0,.24);
  border: 1px solid rgba(255,255,255,.08);
}

.help-icon {
  width: 44px;
  height: 44px;
  object-fit: contain;
  filter: drop-shadow(0 0 10px rgba(242,198,110,.16));
}

.help-row strong {
  display: block;
  color: var(--gold);
  font-size: .88rem;
}

.help-row span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.3;
}

/* END + RANKING */
.end-card h2 {
  font-size: 2rem;
}

.end-card p {
  color: var(--muted);
  line-height: 1.45;
}

.end-stats {
  grid-template-columns: repeat(3, 1fr);
}

.save-status {
  min-height: 40px;
  margin: 14px 0 2px;
  padding: 10px;
  border-radius: 14px;
  background: rgba(0,0,0,.24);
  color: var(--muted);
  font-size: .88rem;
}

.save-status.ok { color: var(--green); }
.save-status.danger { color: #ff8b80; }

.ranking-panel {
  position: fixed;
  z-index: 15;
  inset: 14px;
  width: auto;
  max-width: 480px;
  margin: auto;
  padding: 18px;
  overflow: auto;
}

.ranking-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.rank-row {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(0,0,0,.24);
}

.rank-row.suspicious {
  border-color: rgba(196,60,53,.4);
  background: rgba(196,60,53,.08);
}

.rank-num {
  color: var(--gold);
  font-weight: 900;
}

.rank-name {
  font-weight: 900;
}

.rank-meta {
  color: var(--muted);
  font-size: .75rem;
  margin-top: 2px;
}

.rank-score {
  font-weight: 900;
  color: #ffe0a2;
}

.cheat-label {
  color: #ff8b80;
  font-size: .72rem;
  font-weight: 900;
  text-transform: uppercase;
}

/* ADMIN */
.admin-body {
  min-height: 100svh;
  background:
    radial-gradient(circle at top, rgba(196,60,53,.16), transparent 35%),
    linear-gradient(180deg, #0a0705, #030202);
  color: var(--text);
}

.admin-login {
  width: min(92vw, 420px);
  min-height: 100svh;
  margin: 0 auto;
  display: grid;
  place-content: center;
}

.admin-login h1,
.admin-header h1 {
  font-family: Cinzel, serif;
}

.admin-login p,
.admin-header p {
  color: var(--muted);
}

.admin-card,
.admin-table-card,
.admin-filters {
  border: 1px solid var(--stroke);
  background: var(--panel);
  border-radius: 22px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.admin-card label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
}

.admin-card button,
.admin-filters button,
.action-cell button {
  padding: 0 14px;
  color: #1a0f06;
  background: linear-gradient(180deg, #ffd98c, #d08b35);
}

.admin-error {
  margin: 10px 0;
  border-radius: 14px;
  padding: 10px;
  background: rgba(196,60,53,.16);
  color: #ff8b80;
  border: 1px solid rgba(196,60,53,.34);
}

.admin-wrap {
  width: min(1200px, calc(100% - 24px));
  margin: 0 auto;
  padding: 24px 0;
}

.admin-stats {
  grid-template-columns: repeat(4, 1fr);
}

.admin-filters {
  display: grid;
  grid-template-columns: 1fr 220px auto auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.checkline {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  color: var(--muted);
  white-space: nowrap;
}

.checkline input {
  width: auto;
}

.admin-table-scroll {
  width: 100%;
  overflow: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

.admin-table th,
.admin-table td {
  padding: 10px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  vertical-align: top;
  text-align: left;
}

.admin-table th {
  color: var(--gold);
  font-size: .72rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.admin-table td {
  color: #f2e4ce;
  font-size: .9rem;
}

.admin-table tr.is-suspicious td {
  background: rgba(196,60,53,.05);
}

.badge.ok {
  color: var(--green);
  border-color: rgba(142,224,125,.32);
  background: rgba(142,224,125,.08);
}

.badge.danger {
  color: #ff8b80;
  border-color: rgba(196,60,53,.42);
  background: rgba(196,60,53,.1);
}

.action-cell {
  display: grid;
  gap: 6px;
}

.action-cell form {
  margin: 0;
}

.action-cell button {
  width: 100%;
  min-height: 34px;
  border-radius: 10px;
  font-size: .78rem;
}

.action-cell .danger-button {
  color: #fff;
  background: linear-gradient(180deg, #bb3d36, #641f1a);
}

details pre {
  max-width: 360px;
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
  color: #cbbba3;
  background: rgba(0,0,0,.35);
  padding: 8px;
  border-radius: 10px;
}

@media (max-width: 760px) {
  .phone-shell {
    padding-inline: 12px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .intro-card h1 {
    font-size: clamp(2.45rem, 16vw, 4rem);
  }

  .action-row {
    grid-template-columns: 1fr;
  }

  .symbol-preview-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .header-actions {
    align-items: flex-end;
  }

  .admin-header {
    flex-direction: column;
  }

  .admin-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .admin-filters {
    grid-template-columns: 1fr;
  }
}

@media (max-height: 720px) {
  .intro-card,
  .end-card {
    padding: 20px 18px;
  }

  .intro-card h1 {
    font-size: 2.8rem;
  }

  .slot {
    font-size: 2.2rem;
  }

  .stats-grid article {
    padding: 8px;
  }
}

/* V3 gameplay refinements */
.game-stats {
  grid-template-columns: repeat(3, 1fr);
}

.credits-number {
  color: #79f06b !important;
  text-shadow: 0 0 16px rgba(121, 240, 107, .18);
}

.debt-number {
  color: #ff5c50 !important;
  text-shadow: 0 0 16px rgba(255, 92, 80, .18);
}

.slot {
  border: 1px solid rgba(242, 198, 110, .24);
  color: inherit;
  cursor: default;
  padding: 0;
}

.slot:disabled {
  opacity: 1;
  filter: none;
  cursor: default;
}

.slot.selectable {
  cursor: pointer;
  border-color: rgba(121, 240, 107, .75);
  box-shadow: inset 0 0 24px rgba(0,0,0,.52), 0 0 22px rgba(121, 240, 107, .18);
  animation: selectablePulse 1s ease-in-out infinite;
}

@keyframes selectablePulse {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

.relic-chip-large {
  border-radius: 16px;
  padding: 8px 9px;
  gap: 7px;
  flex-wrap: wrap;
}

.relic-chip-large span {
  max-width: 120px;
}

.relic-chip-large em {
  font-style: normal;
  color: rgba(247, 234, 213, .52);
  font-size: .64rem;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 999px;
  padding: 2px 6px;
}

.tiny-use-button {
  min-height: 26px;
  border: 0;
  border-radius: 999px;
  padding: 0 8px;
  color: #161006;
  font-size: .68rem;
  font-weight: 900;
  background: linear-gradient(180deg, #9eff8d, #55b944);
}

.tiny-use-button:disabled {
  opacity: .35;
}

.modified-value {
  color: #79f06b !important;
  text-shadow: 0 0 10px rgba(121, 240, 107, .24);
}

.help-row span strong {
  display: inline;
  font-size: inherit;
}

@media (max-width: 760px) {
  .game-stats {
    grid-template-columns: repeat(3, 1fr);
  }

  .game-stats article {
    padding-inline: 5px;
  }

  .relic-chip-large span {
    max-width: 95px;
  }
}

/* V4 gameplay refinements */
.stats-grid article {
  position: relative;
}

.slot-machine.four-slots {
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.slot-machine.four-slots .slot {
  border-radius: 16px;
}

.slot-machine.four-slots .slot-icon {
  width: 72%;
  height: 72%;
}

.msg-gain {
  color: #79f06b;
  text-shadow: 0 0 10px rgba(121, 240, 107, .24);
  white-space: nowrap;
}

.msg-loss {
  color: #ff5c50;
  text-shadow: 0 0 10px rgba(255, 92, 80, .24);
  white-space: nowrap;
}

.msg-note {
  display: block;
  margin-top: 6px;
  color: #d9c3a0;
  font-size: .9em;
}

.credit-feedback {
  position: absolute;
  left: 50%;
  bottom: -5px;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 3;
  font-weight: 900;
  font-size: .95rem;
  letter-spacing: .02em;
  animation: creditFloat .9s ease-out forwards;
}

.credit-feedback.gain {
  color: #79f06b;
  text-shadow: 0 0 14px rgba(121, 240, 107, .42);
}

.credit-feedback.loss {
  color: #ff5c50;
  text-shadow: 0 0 14px rgba(255, 92, 80, .42);
}

@keyframes creditFloat {
  0% { opacity: 0; transform: translate(-50%, 8px) scale(.88); }
  18% { opacity: 1; transform: translate(-50%, -2px) scale(1.05); }
  100% { opacity: 0; transform: translate(-50%, -34px) scale(.98); }
}

.credits-number.flash-gain {
  animation: flashGain .55s ease-out;
}

.credits-number.flash-loss {
  animation: flashLoss .55s ease-out;
}

@keyframes flashGain {
  0% { transform: scale(1); text-shadow: 0 0 0 rgba(121, 240, 107, 0); }
  30% { transform: scale(1.16); text-shadow: 0 0 24px rgba(121, 240, 107, .7); }
  100% { transform: scale(1); text-shadow: 0 0 16px rgba(121, 240, 107, .18); }
}

@keyframes flashLoss {
  0% { transform: scale(1); color: #79f06b; }
  30% { transform: scale(1.16); color: #ff5c50; text-shadow: 0 0 24px rgba(255, 92, 80, .62); }
  100% { transform: scale(1); color: #79f06b; }
}

#audioBtn {
  font-size: .68rem;
  padding-inline: 10px;
}

@media (max-width: 380px) {
  .slot-machine.four-slots {
    gap: 6px;
    padding: 9px;
  }

  .slot-machine.four-slots .slot {
    border-radius: 14px;
  }
}

/* v5 extra slots */
.slot-machine.many-slots {
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.slot-machine.many-slots .slot {
  aspect-ratio: 1;
  border-radius: 15px;
}
.slot-machine.many-slots .slot-icon {
  width: 70%;
  height: 70%;
}
@media (min-width: 560px) {
  .slot-machine.many-slots {
    grid-template-columns: repeat(6, 1fr);
  }
}

/* v7 slot refinements */
.slot-machine.two-slots {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}


/* v8 slot layouts */
.slot-machine.many-slots {
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.slot-machine.many-slots .slot {
  aspect-ratio: 1;
}
@media (min-width: 640px) {
  .slot-machine.many-slots {
    grid-template-columns: repeat(10, 1fr);
  }
}

/* v9: agrupar slots en varias filas para móvil */
.slot-machine.many-slots {
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 8px;
}

.slot-machine.many-slots .slot {
  border-radius: 15px;
}

.slot-machine.many-slots .slot-icon {
  width: 72%;
  height: 72%;
}

@media (min-width: 520px) {
  .slot-machine.many-slots {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 380px) {
  .slot-machine.many-slots {
    gap: 6px;
    padding: 9px;
  }
}

/* v11 UX refinements */
.machine-message {
  height: clamp(74px, 13vh, 104px);
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.machine-message::-webkit-scrollbar {
  width: 5px;
}

.machine-message::-webkit-scrollbar-thumb {
  background: rgba(242, 198, 110, .35);
  border-radius: 999px;
}

.relic-panel-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.relic-panel-top .panel-title {
  margin-bottom: 0;
}

.inventory-button {
  white-space: nowrap;
  padding-inline: 12px;
}

.inventory-card .help-list,
.inventory-list {
  max-height: min(62vh, 520px);
  overflow-y: auto;
  padding-right: 4px;
}

.inventory-count {
  color: var(--muted);
  font-size: .82rem;
  margin: -2px 0 10px;
}

.relic-chip.activable-chip {
  background: rgba(121, 240, 107, .10);
  border-color: rgba(121, 240, 107, .28);
}


/* v13 mobile modal + public UI tweaks */
.modal {
  overflow-y: auto;
  align-items: start;
}

.modal-card {
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
}

.relic-choices {
  max-height: min(58dvh, 520px);
  overflow-y: auto;
  padding-right: 4px;
  overscroll-behavior: contain;
}

.relic-choices::-webkit-scrollbar,
.modal-card::-webkit-scrollbar {
  width: 5px;
}

.relic-choices::-webkit-scrollbar-thumb,
.modal-card::-webkit-scrollbar-thumb {
  background: rgba(242, 198, 110, .35);
  border-radius: 999px;
}

.header-actions .inventory-button {
  padding-inline: 10px;
}

.code-reward-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
  text-align: left;
}

.code-reward-item {
  border: 1px solid rgba(242,198,110,.18);
  border-radius: 14px;
  padding: 9px 10px;
  background: rgba(0,0,0,.2);
}

.code-reward-item code {
  color: var(--green);
  font-weight: 900;
}

.code-reward-item strong {
  color: var(--gold);
}

.code-reward-item span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.35;
}

@media (max-width: 520px) {
  .modal {
    padding: 10px;
  }

  .modal-card {
    max-height: calc(100dvh - 20px);
  }

  .relic-choices {
    max-height: 52dvh;
  }

  .header-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
  }
}

.prob-line { color: var(--green); font-size: .76rem; }


/* v15: rarezas, eventos y auditorías */
.relic-choice {
  position: relative;
  overflow: hidden;
}
.relic-choice::before,
.relic-chip-large::before,
.help-row.relic-row::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .35;
}
.relic-choice.rarity-common, .relic-chip-large.rarity-common, .help-row.rarity-common { border-color: rgba(170, 130, 78, .45); }
.relic-choice.rarity-rare, .relic-chip-large.rarity-rare, .help-row.rarity-rare { border-color: rgba(64, 214, 143, .7); box-shadow: 0 0 0 1px rgba(64,214,143,.18), 0 0 18px rgba(64,214,143,.08); }
.relic-choice.rarity-legendary, .relic-chip-large.rarity-legendary, .help-row.rarity-legendary { border-color: rgba(255, 205, 75, .9); box-shadow: 0 0 0 1px rgba(255,205,75,.25), 0 0 22px rgba(255,205,75,.12); }
.relic-choice.rarity-cursed, .relic-chip-large.rarity-cursed, .help-row.rarity-cursed { border-color: rgba(255, 68, 68, .85); box-shadow: 0 0 0 1px rgba(255,68,68,.2), 0 0 22px rgba(255,68,68,.10); }
.relic-choice.rarity-mythic, .relic-chip-large.rarity-mythic, .help-row.rarity-mythic { border-color: rgba(184, 92, 255, .9); box-shadow: 0 0 0 1px rgba(184,92,255,.25), 0 0 26px rgba(184,92,255,.14); }
.rarity-tag {
  display: inline-flex;
  width: fit-content;
  margin-top: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  border: 1px solid rgba(255,255,255,.12);
  color: rgba(255,255,255,.72);
  background: rgba(0,0,0,.22);
}
.rarity-tag.rarity-rare { color: #73ffc0; }
.rarity-tag.rarity-legendary { color: #ffd75a; }
.rarity-tag.rarity-cursed { color: #ff7373; }
.rarity-tag.rarity-mythic { color: #d5a0ff; }
.event-card { max-height: min(82vh, 680px); overflow-y: auto; }
.event-choices { display: grid; gap: 10px; margin-top: 14px; }
.event-choice {
  border: 1px solid rgba(216, 184, 113, .24);
  background: linear-gradient(135deg, rgba(50, 35, 22, .96), rgba(12, 10, 9, .98));
  color: #f4e8d2;
  border-radius: 16px;
  padding: 13px;
  text-align: left;
  display: grid;
  gap: 5px;
  box-shadow: inset 0 0 20px rgba(0,0,0,.25);
}
.event-choice strong { color: #fff0bc; font-size: 15px; }
.event-choice span { color: rgba(244,232,210,.76); font-size: 13px; line-height: 1.35; }
.event-choice.audit { border-color: rgba(255, 80, 80, .45); }
.event-choice.boon { border-color: rgba(64, 214, 143, .35); }
.synergy-list { display: grid; gap: 8px; margin-top: 8px; }
.synergy-pill {
  border: 1px solid rgba(216,184,113,.2);
  background: rgba(0,0,0,.22);
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 12px;
  color: rgba(244,232,210,.84);
}
.machine-message .flavor-line {
  display: block;
  margin-top: 6px;
  color: rgba(255, 216, 134, .76);
  font-style: italic;
}


/* v16 shop/reroll and stat feedback */
.shop-controls {
  display: grid;
  gap: 8px;
  margin: 12px 0 14px;
  padding: 12px;
  border: 1px solid rgba(218, 170, 86, .28);
  border-radius: 16px;
  background: rgba(14, 10, 8, .72);
}
.shop-controls .secondary-button {
  width: 100%;
  min-height: 42px;
}
.shop-controls small {
  color: rgba(245, 231, 202, .68);
  line-height: 1.35;
}
#rollsValue.flash-gain, #rollsValue.flash-loss,
#debtValue.flash-gain, #debtValue.flash-loss {
  animation: flashGain .55s ease-out;
}
#rollsValue.flash-loss, #debtValue.flash-loss {
  animation-name: flashLoss;
}

/* v17: pantalla principal compacta para móviles con muchos slots */
@media (max-width: 520px) {
  .phone-shell {
    padding: max(6px, env(safe-area-inset-top)) 7px max(6px, env(safe-area-inset-bottom));
    place-items: stretch;
  }

  .game-card {
    min-height: auto;
    max-height: calc(100svh - 12px);
    padding: 9px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 22px;
  }

  .game-header {
    flex: 0 0 auto;
    gap: 8px;
    align-items: flex-start;
  }

  .game-header h2 {
    font-size: 1.08rem;
    line-height: .95;
    margin-top: 2px;
  }

  .brand-kicker {
    font-size: .58rem;
    letter-spacing: .12em;
  }

  .header-actions {
    gap: 5px;
    justify-content: flex-end;
  }

  .small-button,
  .status-pill,
  #audioBtn {
    min-height: 28px;
    padding: 0 8px;
    border-radius: 10px;
    font-size: .57rem;
    letter-spacing: .04em;
  }

  .game-stats {
    flex: 0 0 auto;
    margin: 7px 0;
    gap: 5px;
  }

  .stats-grid article {
    padding: 5px 4px;
    border-radius: 12px;
  }

  .stats-grid span {
    font-size: .52rem;
    letter-spacing: .06em;
  }

  .stats-grid strong {
    font-size: .95rem;
    margin-top: 1px;
  }

  .slot-machine {
    flex: 0 1 auto;
    margin: 6px auto;
    padding: 7px;
    gap: 6px;
    border-radius: 18px;
    width: 100%;
    max-width: 330px;
  }

  .slot-machine.four-slots {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    max-width: 330px;
  }

  .slot-machine.many-slots {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    max-width: 330px;
    gap: 5px;
    padding: 6px;
  }

  .slot-machine.many-slots .slot,
  .slot-machine.four-slots .slot,
  .slot {
    border-radius: 12px;
    min-width: 0;
  }

  .slot-machine.many-slots .slot-icon,
  .slot-machine.four-slots .slot-icon,
  .slot-icon {
    width: 66%;
    height: 66%;
  }

  .machine-message {
    flex: 0 0 auto;
    height: clamp(48px, 8.5svh, 62px);
    padding: 8px 9px;
    border-radius: 11px;
    font-size: .76rem;
    line-height: 1.22;
  }

  .machine-message .flavor-line,
  .msg-note {
    margin-top: 3px;
  }

  .action-row {
    flex: 0 0 auto;
    margin-top: 7px;
    gap: 7px;
    grid-template-columns: 1fr;
  }

  .main-button,
  .secondary-button,
  .ghost-button {
    min-height: 40px;
    border-radius: 12px;
    font-size: .86rem;
  }

  .relic-panel {
    flex: 0 1 auto;
    margin-top: 7px;
    padding: 7px;
    border-radius: 13px;
    min-height: 0;
    max-height: 70px;
    overflow: hidden;
  }

  .relic-panel-top {
    margin-bottom: 4px;
  }

  .panel-title {
    font-size: .58rem;
    margin-bottom: 4px;
  }

  .relic-list {
    gap: 5px;
    max-height: 42px;
    overflow-y: auto;
    padding-right: 2px;
  }

  .relic-list.empty {
    font-size: .72rem;
  }

  .relic-chip,
  .badge {
    padding: 4px 7px;
    gap: 4px;
    font-size: .62rem;
  }

  .relic-chip img {
    width: 16px;
    height: 16px;
  }

  .tiny-use-button {
    min-height: 24px;
    padding: 0 7px;
    border-radius: 8px;
    font-size: .6rem;
  }
}

@media (max-width: 380px) {
  .slot-machine,
  .slot-machine.four-slots,
  .slot-machine.many-slots {
    max-width: 300px;
    gap: 4px;
    padding: 5px;
  }

  .machine-message {
    height: 46px;
    font-size: .72rem;
  }

  .game-card {
    padding: 7px;
  }
}

@media (max-height: 690px) and (max-width: 520px) {
  .slot-machine,
  .slot-machine.four-slots,
  .slot-machine.many-slots {
    max-width: 292px;
  }

  .machine-message {
    height: 42px;
    font-size: .7rem;
  }

  .relic-panel {
    display: none;
  }
}

/* v19: barra fija inferior para acciones principales en móvil */
@media (max-width: 640px) {
  .game-card {
    padding-bottom: calc(86px + env(safe-area-inset-bottom));
  }

  .game-card:not(.hidden) .action-row {
    position: fixed;
    left: 50%;
    right: auto;
    bottom: calc(10px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 12;
    width: min(460px, calc(100vw - 18px));
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
    margin: 0;
    padding: 8px;
    border: 1px solid rgba(242, 198, 110, .22);
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(20, 16, 12, .88), rgba(6, 5, 4, .96));
    box-shadow: 0 -14px 32px rgba(0,0,0,.45), 0 0 18px rgba(242,198,110,.08);
    backdrop-filter: blur(10px);
  }

  .game-card:not(.hidden) .action-row .main-button,
  .game-card:not(.hidden) .action-row .secondary-button {
    min-height: 52px;
    border-radius: 14px;
    font-size: .86rem;
    padding-inline: 8px;
  }

  .game-card:not(.hidden) .machine-message {
    margin-bottom: 7px;
  }

  .game-card:not(.hidden) .relic-panel {
    margin-bottom: 6px;
  }
}

@media (max-width: 380px) {
  .game-card:not(.hidden) .action-row {
    width: min(330px, calc(100vw - 14px));
    gap: 7px;
    padding: 7px;
    border-radius: 16px;
  }

  .game-card:not(.hidden) .action-row .main-button,
  .game-card:not(.hidden) .action-row .secondary-button {
    min-height: 48px;
    font-size: .8rem;
  }
}

@media (max-height: 690px) and (max-width: 520px) {
  .game-card {
    padding-bottom: calc(74px + env(safe-area-inset-bottom));
  }

  .game-card:not(.hidden) .action-row .main-button,
  .game-card:not(.hidden) .action-row .secondary-button {
    min-height: 44px;
    font-size: .78rem;
  }
}


/* v21: aviso visual de reliquias ganadas/destruidas */
.relic-change-toast {
  position: fixed;
  z-index: 60;
  left: 50%;
  top: calc(12px + env(safe-area-inset-top));
  transform: translateX(-50%);
  width: min(440px, calc(100vw - 24px));
  pointer-events: none;
}
.relic-change-card {
  border: 1px solid rgba(242,198,110,.38);
  border-radius: 20px;
  padding: 12px;
  background: linear-gradient(180deg, rgba(30,22,16,.96), rgba(7,5,4,.96));
  box-shadow: 0 18px 45px rgba(0,0,0,.5), 0 0 22px rgba(242,198,110,.1);
  backdrop-filter: blur(10px);
  animation: relicToastIn .24s ease-out both;
}
.relic-change-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}
.relic-change-row {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border-radius: 14px;
  background: rgba(255,255,255,.055);
  border: 1px solid rgba(255,255,255,.08);
}
.relic-change-row.lost {
  border-color: rgba(255,92,80,.45);
  background: rgba(140,30,25,.18);
}
.relic-change-row.gained {
  border-color: rgba(121,240,107,.35);
  background: rgba(35,115,45,.12);
}
.relic-change-row img {
  width: 38px;
  height: 38px;
  object-fit: contain;
}
.relic-change-row strong {
  display: block;
  color: var(--gold);
  font-size: .9rem;
}
.relic-change-row span {
  display: block;
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.25;
}
@keyframes relicToastIn {
  from { opacity: 0; transform: translateY(-10px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}


/* v22: ajustes visuales cabecera y popup centrado */
.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  min-height: 32px;
  box-sizing: border-box;
  text-align: center;
}

.audio-icon-button,
#audioBtn {
  width: 34px;
  min-width: 34px;
  padding-inline: 0 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem !important;
  line-height: 1;
  letter-spacing: 0 !important;
}

.relic-change-toast {
  top: 50% !important;
  transform: translate(-50%, -50%) !important;
  z-index: 90;
}

.relic-change-card {
  animation: relicToastCenterIn .24s ease-out both;
}

@keyframes relicToastCenterIn {
  from { opacity: 0; transform: translateY(12px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 520px) {
  .status-pill {
    min-height: 28px;
    padding-top: 0;
    padding-bottom: 0;
    align-self: center;
  }
  .audio-icon-button,
  #audioBtn {
    width: 30px;
    min-width: 30px;
    min-height: 28px;
    font-size: .95rem !important;
  }
  .relic-change-toast {
    width: min(360px, calc(100vw - 28px));
  }
}

/* v23 public version box */
.public-version-box {
  margin-top: 14px;
  padding: 9px 11px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.74rem;
  color: rgba(255, 255, 255, 0.62);
  text-align: center;
}
.public-version-box strong {
  color: var(--terminal);
  letter-spacing: 0.04em;
}
.public-version-box span + span::before {
  content: "·";
  margin-right: 8px;
  color: rgba(255, 255, 255, 0.28);
}
.admin-settings-card h2 {
  margin: 0 0 6px;
  font-size: 1.1rem;
}
.admin-settings-card p {
  margin: 0 0 14px;
  color: rgba(255, 255, 255, 0.64);
}
.admin-settings-form {
  display: grid;
  gap: 10px;
}


/* v24: cuando hay tienda/evento abierto, el aviso de reliquias sube arriba para no tapar opciones */
.relic-change-toast.toast-top {
  top: calc(12px + env(safe-area-inset-top)) !important;
  transform: translateX(-50%) !important;
  z-index: 120;
}
.relic-change-toast.toast-top .relic-change-card {
  animation: relicToastIn .24s ease-out both;
}
@media (max-width: 520px) {
  .relic-change-toast.toast-top {
    width: min(360px, calc(100vw - 28px));
  }
}
