/* The lobby: the casino floor. Same palace as the machines (variables and
   the gold lettering come from style.css): a balance bar on top, the
   casino sign, the bonus tiles, then the row of slot machine cards. It
   fits an iPhone 16 without scrolling; only the card row scrolls, and
   only sideways. */

.lobby {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 520px;
  margin: 0 auto;
  padding: max(6px, var(--safe-top)) 16px max(10px, calc(var(--safe-bottom) + 4px));
}

.lobby[hidden],
.app[hidden] {
  display: none;
}

.lobby.enter {
  animation: lobby-in 260ms ease-out;
}

/* ---------- Top bar ---------- */

.lobby-level {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 2px;
}

/* The star stands alone here, not against the XP bar. */
.lobby-level .level-star {
  margin-right: 0;
}

/* ---------- The sign ---------- */

.lobby-sign {
  position: relative;
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 9px 12px 7px;
  border-radius: 14px;
  background:
    radial-gradient(80% 70% at 50% 0%, rgba(255, 120, 90, 0.35), transparent 70%),
    repeating-linear-gradient(90deg, transparent 0 14px, rgba(255, 255, 255, 0.03) 14px 16px),
    linear-gradient(180deg, var(--lacquer-light), var(--lacquer) 45%, #4a0810);
  border: 3px solid var(--gold);
  box-shadow: 0 0 0 2px var(--gold-deep), inset 0 0 0 2px rgba(0, 0, 0, 0.35), 0 6px 16px rgba(0, 0, 0, 0.55), 0 0 22px rgba(255, 211, 77, 0.25);
}

/* Lantern tassels hang off both ends of the sign. */
.lobby-sign::before,
.lobby-sign::after {
  content: "🏮";
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.6rem;
  line-height: 1;
  filter: drop-shadow(0 0 8px rgba(255, 120, 40, 0.8));
  animation: lantern-swing 2.6s ease-in-out infinite;
  transform-origin: 50% 0;
}

.lobby-sign::before { left: 10px; }
.lobby-sign::after { right: 10px; animation-delay: -1.3s; }

.lobby-sign-title,
.game-card-name,
.lobby-games-head {
  font-family: var(--display);
  background-image: var(--gold-bevel);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 1px 0 var(--gold-deep)) drop-shadow(0 2px 1px rgba(0, 0, 0, 0.7));
}

.lobby-sign-title {
  font-size: 2rem;
  letter-spacing: 0.1em;
  line-height: 1;
  white-space: nowrap;
}

.lobby-sign-sub {
  margin-top: 3px;
  color: var(--gold-light);
  font-family: var(--display);
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  opacity: 0.85;
}

/* ---------- Bonus tiles ---------- */

.lobby-tiles {
  flex: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* Navy glass tiles in a gold rim, lit gold when there is something to
   collect. */
.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 74px;
  padding: 7px 6px 6px;
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.14), transparent 50%),
    linear-gradient(180deg, #2a2470, var(--navy-deep));
  border: 2px solid var(--gold-dark);
  box-shadow: 0 0 0 1px var(--gold-deep), 0 4px 10px rgba(0, 0, 0, 0.5);
  color: var(--muted);
  text-align: center;
}

.tile:active {
  transform: translateY(2px);
}

.tile-icon {
  font-size: 1.6rem;
  line-height: 1;
}

.tile-name {
  color: var(--gold-light);
  font-family: var(--display);
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.tile-state {
  font-family: var(--display);
  font-size: 0.76rem;
  letter-spacing: 0.03em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tile.ready {
  border-color: var(--gold);
  color: var(--gold-light);
  animation: wheel-ready 1.6s ease-in-out infinite;
}

/* The red dot on a tile with something waiting. */
.tile.ready::after {
  content: "";
  position: absolute;
  top: -5px;
  right: -4px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--ruby);
  border: 2px solid #fff;
}

.tile .wheel-icon {
  width: 30px;
  height: 30px;
}

#wheel-button.ready .wheel-icon {
  animation: wheel-icon-spin 4s linear infinite;
}

.tile .lantern-icon {
  width: auto;
  height: auto;
  font-size: 1.6rem;
}

#lantern-button:not(.ready) .lantern-icon {
  filter: grayscale(0.7) brightness(0.7);
}

#lantern-button.ready .lantern-icon {
  animation: lantern-swing 2.4s ease-in-out infinite;
}

.tile .pearl {
  width: 28px;
  height: 28px;
}

.tile-league.up .tile-state { color: #7affb0; }
.tile-league.down .tile-state { color: #ff8a96; }

.tile-league.fever {
  box-shadow: 0 0 0 1px var(--gold-deep), 0 0 14px #ff6a00, 0 4px 10px rgba(0, 0, 0, 0.5);
}

.tile-league .tile-state + .tile-state {
  font-size: 0.66rem;
  opacity: 0.8;
}

/* The coin shop runs the width of the floor, in jade. */
.tile-shop {
  grid-column: 1 / -1;
  flex-direction: row;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 4px 10px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.05) 48%, transparent 52%),
    linear-gradient(180deg, #1fae4c, #0a6a2a 60%, #04401a);
  border-color: var(--gold);
  color: #fff;
}

.tile-shop .tile-name {
  color: #fff;
  text-shadow: 0 2px 0 #03300f;
}

.tile-shop .tile-state {
  color: #d8ffe4;
}

/* ---------- Slot machines ---------- */

.lobby-games-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  letter-spacing: 0.22em;
}

/* Gold rules either side of the heading. */
.lobby-games-head::before,
.lobby-games-head::after {
  content: "";
  flex: 1;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold-dark), transparent);
}

.game-list {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  gap: 12px;
  padding: 6px 2px 6px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.game-list::-webkit-scrollbar {
  display: none;
}

/* A machine's cabinet: its art over a lacquer front, its name in gold,
   and a PLAY button. The card's glow takes the machine's gem colour. */
.game-card {
  position: relative;
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  width: 74%;
  height: 100%;
  min-height: 150px;
  padding: 10px 10px 10px;
  border-radius: 18px;
  overflow: hidden;
  scroll-snap-align: center;
  /* The art is sized from the card's own height (cqh), so it fills a tall
     card and still fits a short one. */
  container-type: size;
  background:
    radial-gradient(70% 50% at 50% 30%, var(--c, var(--ruby)), transparent 70%),
    repeating-linear-gradient(90deg, transparent 0 14px, rgba(255, 255, 255, 0.03) 14px 16px),
    linear-gradient(180deg, #6a0e1c, #3a0610 60%, var(--bg-deep));
  border: 3px solid var(--gold);
  box-shadow: 0 0 0 2px var(--gold-deep), inset 0 0 0 2px rgba(0, 0, 0, 0.35), 0 6px 16px rgba(0, 0, 0, 0.55);
  color: var(--text);
  text-align: center;
}

.game-card:active:not(:disabled) {
  transform: scale(0.98);
}

.game-card-ribbon {
  flex: none;
  padding: 3px 12px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ff5a6a, #c8102e 60%, #6e0a1a);
  border: 2px solid var(--gold);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  color: #fff;
  font-family: var(--display);
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  white-space: nowrap;
}

.game-card-art {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
  overflow: hidden;
  font-size: min(13vh, 6.5rem);
  font-size: min(30cqh, 6.5rem);
  line-height: 1;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.6));
}

.game-card-name {
  font-size: 1.5rem;
  line-height: 1;
  white-space: nowrap;
}

.game-card-tag {
  min-height: 2.4em;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.2;
}

.game-card-play {
  padding: 9px 30px;
  border-radius: 999px;
  background:
    radial-gradient(70% 45% at 50% 12%, rgba(255, 255, 255, 0.55), transparent 70%),
    radial-gradient(120% 90% at 50% 20%, #7aff9a, #1fae4c 45%, #0a6a2a 75%, #04401a);
  border: 2px solid var(--gold);
  box-shadow: 0 0 0 1px var(--gold-deep), 0 4px 0 #03300f, 0 6px 12px rgba(0, 0, 0, 0.5);
  color: #fff;
  font-family: var(--display);
  font-size: 1.1rem;
  letter-spacing: 0.1em;
  text-shadow: 0 2px 0 #03300f;
}

/* A machine that isn't built yet: dimmed, with no PLAY. */
.game-card.soon {
  filter: saturate(0.45) brightness(0.8);
  cursor: default;
}

.game-card.soon .game-card-play {
  background: linear-gradient(180deg, #4a4a60, #22222e);
  box-shadow: 0 0 0 1px var(--gold-deep), 0 4px 0 #101018;
  font-size: 0.85rem;
  text-shadow: none;
}

.game-card.soon .game-card-art {
  opacity: 0.7;
}

/* ---------- In a machine: the way back ---------- */

.lobby-button {
  flex: none;
  height: 36px;
  padding: 0 11px 0 9px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.6);
  color: var(--gold-light);
  font-family: var(--display);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.lobby-button::before {
  content: "‹ ";
  font-size: 1rem;
}

.lobby-button:disabled {
  opacity: 0.45;
}

@media (max-height: 700px) {
  .lobby { gap: 6px; }
  .lobby-sign { padding: 7px 12px 5px; }
  .lobby-sign-title { font-size: 1.7rem; }
  .lobby-sign::before,
  .lobby-sign::after { font-size: 1.3rem; }
  .lobby-tiles { gap: 6px; }
  .tile { min-height: 64px; padding: 5px 6px 4px; }
  .tile-shop { min-height: 44px; }
  .game-card { padding: 8px 10px 8px; gap: 4px; }
  .game-card-name { font-size: 1.3rem; }
  .game-card-tag { display: none; }
  .game-card-play { padding: 7px 26px; font-size: 1rem; }
}

@keyframes lobby-in {
  from { opacity: 0; transform: scale(0.98); }
}

@media (prefers-reduced-motion: reduce) {
  .lobby.enter,
  .lobby-sign::before,
  .lobby-sign::after,
  .tile.ready,
  #wheel-button.ready .wheel-icon,
  #lantern-button.ready .lantern-icon {
    animation: none;
    transform: none;
  }
  .lobby-sign::before,
  .lobby-sign::after { transform: translateY(-50%); }
}
