/* ── 小瑪莉 — casino ring-of-lights ── */

/* Light mode: follow site theme; dark mode: deep casino black */
body.dark { background: #06060f; }

/* Prevent display:flex from overriding [hidden] attribute */
#sc-jp-overlay[hidden], #sc-win-flash[hidden], #history-modal[hidden] { display: none; }

main.app {
  background: transparent;
  max-width: 480px;
}

/* Dark mode: override score colours for dark casino background */
body.dark .score-box-label,
body.dark .score-box-value { color: #f0e8c8; }
body.dark .score-box { background: rgba(255,255,255,0.07); border-color: rgba(255,200,50,0.3); }

/* ── Machine body frame ── */
#slot-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(5, auto);
  gap: 4px;
  background: #12122a;
  padding: 7px;
  border-radius: 14px;
  border: 3px solid #edc22e;
  box-shadow:
    0 0 30px rgba(237,194,46,0.35),
    0 0 60px rgba(237,194,46,0.12),
    inset 0 0 24px rgba(0,0,0,0.6);
  margin: 10px auto 6px;
  max-width: 460px;
}

/* ── Individual ring cell ── */
.slot-item {
  aspect-ratio: 1;
  border: 2px solid #333355;
  border-radius: 8px;
  background: #1e1e3a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  cursor: default;
  user-select: none;
  transition: background 0.06s, border-color 0.06s, box-shadow 0.06s, transform 0.06s;
  overflow: hidden;
  box-shadow: inset 0 0 8px rgba(0,0,0,0.5);
}

.slot-item .si-emoji { font-size: clamp(14px, 4.5vw, 24px); line-height: 1.1; }
.slot-item .si-name  { font-size: clamp(6px,  1.6vw,  8px); color: #8888aa; line-height: 1; }
.slot-item .si-mult  { font-size: clamp(8px,  2vw,  11px); font-weight: 800; color: #edc22e; line-height: 1; }

/* ── Active (lit) cell ── */
.slot-item.active {
  background: #ffe135;
  border-color: #ff9500;
  transform: scale(1.07);
  box-shadow:
    0 0 20px 6px rgba(255,200,0,0.85),
    0 0 40px 4px rgba(255,150,0,0.4),
    inset 0 0 10px rgba(255,255,255,0.25);
  z-index: 2;
}
.slot-item.active .si-name { color: #7a4800; }
.slot-item.active .si-mult { color: #b35800; }

/* ── Winner celebration ── */
.slot-item.winner { animation: winner-flash 0.45s ease 4; }
@keyframes winner-flash {
  0%   { transform: scale(1);    box-shadow: 0 0 0 rgba(255,180,0,0); }
  50%  { transform: scale(1.16); box-shadow: 0 0 32px 12px rgba(255,200,0,0.85); }
  100% { transform: scale(1);    box-shadow: 0 0 0 rgba(255,180,0,0); }
}

/* ── Explicit grid placement for side rows ── */
.slot-item[data-pos="7"]  { grid-column: 1; grid-row: 2; }
.slot-item[data-pos="8"]  { grid-column: 7; grid-row: 2; }
.slot-item[data-pos="16"] { grid-column: 1; grid-row: 3; }
.slot-item[data-pos="17"] { grid-column: 7; grid-row: 3; }
.slot-item[data-pos="18"] { grid-column: 1; grid-row: 4; }
.slot-item[data-pos="19"] { grid-column: 7; grid-row: 4; }

/* Corner jackpot slots — golden glow */
.slot-item[data-pos="0"],  .slot-item[data-pos="6"],
.slot-item[data-pos="9"],  .slot-item[data-pos="15"] {
  border-color: #ffd700;
  box-shadow: inset 0 0 8px rgba(0,0,0,0.5), 0 0 10px rgba(255,215,0,0.55);
}


/* ── Centre panel ── */
#slot-center {
  grid-column: 2 / 7;
  grid-row: 2 / 5;
  position: relative;
  background: #0a0a1a;
  border: 2px solid #edc22e;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0;
  padding: 4px 4px 4px;
  box-shadow: inset 0 0 16px rgba(0,0,0,0.7), 0 0 8px rgba(237,194,46,0.15);
  transition: border-color 0.3s, box-shadow 0.3s;
  overflow: hidden;
}

#sc-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 100%;
}

/* Jackpot mode: pulsing gold border */
#slot-center.jackpot-mode {
  border-color: #ffd700;
  animation: jp-border-pulse 0.55s ease-in-out infinite alternate;
}
@keyframes jp-border-pulse {
  from { box-shadow: 0 0 16px rgba(255,215,0,0.5), inset 0 0 16px rgba(0,0,0,0.7); }
  to   { box-shadow: 0 0 50px rgba(255,215,0,0.95), 0 0 80px rgba(255,180,0,0.35), inset 0 0 16px rgba(0,0,0,0.7); }
}

/* ── Jackpot overlay ── */
#sc-jp-overlay {
  position: absolute;
  inset: 0;
  border-radius: 6px;
  background: radial-gradient(ellipse at center, #1a0a00 0%, #0a0a1a 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  z-index: 5;
  animation: jp-appear 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes jp-appear {
  from { opacity: 0; transform: scale(0.4); }
  to   { opacity: 1; transform: scale(1); }
}

#sc-jp-emoji {
  font-size: clamp(26px, 9vw, 44px);
  animation: jp-bounce 0.5s ease-in-out infinite alternate;
  line-height: 1;
}
@keyframes jp-bounce {
  from { transform: scale(1)   rotate(-8deg); }
  to   { transform: scale(1.25) rotate(8deg); }
}

#sc-jp-title {
  font-size: clamp(11px, 3.5vw, 18px);
  font-weight: 900;
  letter-spacing: 0.05em;
  background: linear-gradient(90deg, #ffd700, #ff9500, #ffd700);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: jp-shine 1s linear infinite;
}
@keyframes jp-shine {
  to { background-position: 200% center; }
}

#sc-jp-amount {
  font-size: clamp(20px, 7vw, 34px);
  font-weight: 900;
  color: #edc22e;
  text-shadow: 0 0 14px rgba(255,215,0,0.8), 0 0 28px rgba(255,150,0,0.4);
  animation: jp-amount-pop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0.2s both;
}
@keyframes jp-amount-pop {
  from { opacity: 0; transform: scale(0.3) translateY(10px); }
  to   { opacity: 1; transform: scale(1)   translateY(0); }
}

#sc-credits {
  font-size: clamp(22px, 8vw, 38px);
  font-weight: 900;
  color: #edc22e;
  line-height: 1;
  text-shadow: 0 0 10px rgba(237,194,46,0.5);
}
#sc-credits-label { font-size: clamp(9px, 2.5vw, 12px); color: #6666aa; }
#sc-totalbet-row {
  font-size: clamp(11px, 3vw, 15px);
  font-weight: 700;
  color: #00d4ff;
  display: flex;
  gap: 4px;
  align-items: baseline;
}
#sc-totalbet { color: #00d4ff; font-size: clamp(14px, 4vw, 20px); }

/* ── Running animal (idle state) ── */
#sc-animal-track {
  position: relative;
  width: 100%;
  height: 22px;
  flex-shrink: 0;
  pointer-events: none;
  overflow: hidden;
}
#sc-animal-mover {
  position: absolute;
  bottom: 0;
  animation: animal-lr 3.5s linear infinite, animal-bob 0.38s ease-in-out infinite;
}
@keyframes animal-lr {
  0%, 100% { left: 2px; }
  49.99%   { left: calc(100% - 22px); }
  50%      { left: calc(100% - 22px); }
}
@keyframes animal-bob {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-5px); }
}
#sc-animal-sprite {
  font-size: clamp(12px, 3.5vw, 17px);
  display: inline-block;
  line-height: 1;
  animation: animal-flip 3.5s linear infinite;
}
@keyframes animal-flip {
  0%, 49.99% { transform: scaleX(1); }
  50%, 100%  { transform: scaleX(-1); }
}

/* ── Regular win flash (z-index 4, below jackpot overlay at 5) ── */
#sc-win-flash {
  position: absolute;
  inset: 0;
  border-radius: 6px;
  background: rgba(8, 8, 22, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  z-index: 4;
  animation: wf-pop 0.22s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes wf-pop {
  from { opacity: 0; transform: scale(0.65); }
  to   { opacity: 1; transform: scale(1); }
}
#sc-wf-emoji {
  font-size: clamp(20px, 7vw, 32px);
  animation: wf-entrance 0.35s ease;
}
@keyframes wf-entrance {
  from { transform: rotate(-20deg) scale(0.6); }
  to   { transform: rotate(0)      scale(1);   }
}
#sc-wf-prize {
  font-size: clamp(15px, 5vw, 25px);
  font-weight: 900;
  color: #edc22e;
  text-shadow: 0 0 10px rgba(255,215,0,0.6);
}

/* ── Betting prompt — same look as win-flash, z-index below it ── */
#sc-bet-prompt {
  position: absolute;
  inset: 0;
  border-radius: 6px;
  background: rgba(8, 8, 22, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  z-index: 3;
}
#sc-bet-prompt[hidden] { display: none !important; }
#sc-bp-emoji {
  font-size: clamp(20px, 7vw, 32px);
  line-height: 1;
  animation: hint-bob 1.1s ease-in-out infinite alternate;
}
@keyframes hint-bob {
  from { transform: scale(1)    rotate(-6deg); }
  to   { transform: scale(1.15) rotate( 6deg); }
}
#sc-bp-text {
  font-size: clamp(11px, 3vw, 14px);
  font-weight: 700;
  color: #b0a0d0;
  text-align: center;
  padding: 0 6px;
}

/* ── History button (in scores area) ── */
#history-btn {
  padding: 6px 10px;
  font-size: 1rem;
  background: rgba(255,255,255,0.07);
  color: #edc22e;
  border-color: rgba(255,200,50,0.3);
  min-width: 0;
  align-self: center;
}
#history-btn:hover { background: rgba(255,255,255,0.13); }

/* ── History modal overlay ── */
#history-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: hist-backdrop-in 0.18s ease;
}
@keyframes hist-backdrop-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
#history-modal-box {
  width: min(94vw, 400px);
  max-height: 70vh;
  background: #0c0c20;
  border: 1px solid #252545;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: hist-in 0.22s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes hist-in {
  from { opacity: 0; transform: scale(0.88) translateY(12px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}
.hist-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  background: #16162e;
  border-bottom: 1px solid #252545;
  font-size: 0.8rem;
  font-weight: 700;
  color: #8878aa;
}
.hist-close {
  padding: 1px 7px;
  font-size: 0.78rem;
  background: #1e1e3a;
  border-color: #3a3a5a;
  color: #8878aa;
  min-width: 0;
}
#history-list {
  flex: 1;
  overflow-y: auto;
}
.hist-empty {
  text-align: center;
  padding: 18px;
  color: #4a4a6a;
  font-size: 0.82rem;
}
.hist-row {
  display: grid;
  grid-template-columns: 1.4em 1fr auto auto;
  gap: 3px 8px;
  align-items: center;
  padding: 5px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  font-size: 0.78rem;
}
.hist-row:last-child { border-bottom: none; }
.hist-win   { background: rgba(237,194,46,0.05); }
.hist-devil { background: rgba(200,0,0,0.06); }
.hist-emoji { font-size: 1em; }
.hist-name  { color: #8888aa; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist-bet   { color: #5a5a7a; font-size: 0.72rem; white-space: nowrap; }
.hist-prize { font-weight: 800; text-align: right; white-space: nowrap; }
.hist-win   .hist-prize { color: #edc22e; }
.hist-devil .hist-prize { color: #cc3333; }
.hist-row:not(.hist-win):not(.hist-devil) .hist-prize { color: #444466; }

@keyframes pop-in {
  0%  { transform: scale(0.4); opacity: 0; }
  70% { transform: scale(1.15); }
  100%{ transform: scale(1);   opacity: 1; }
}

/* loss result in center panel */
#sc-win-flash.loss-mode #sc-wf-prize {
  color: #665566;
  font-size: clamp(11px, 3vw, 14px);
  font-weight: 600;
  text-shadow: none;
}

/* ── Chip row ── */
#chip-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin: 6px 0 4px;
  flex-wrap: wrap;
}
.chip-label { font-size: 0.85rem; color: #8888aa; }
.chip-btn { min-width: 38px; font-weight: 700; background: #1e1e3a; border-color: #444466; color: #b0a0d0; }
.chip-btn:hover { background: #2a2a50; }
.chip-btn.active { background: #edc22e; color: #0d0d20; border-color: #edc22e; }
.chip-btn.chip-allin { border-color: #ff6b35; color: #ff9060; }
.chip-btn.chip-allin.active {
  background: #ff6b35; color: #fff; border-color: #ff6b35;
  animation: allin-pulse 0.6s ease infinite alternate;
}
@keyframes allin-pulse {
  from { box-shadow: 0 0 6px rgba(255,107,53,0.5); }
  to   { box-shadow: 0 0 18px rgba(255,107,53,0.9); }
}

/* ── Per-prize bet area ── */
#bet-area {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
  margin: 0 0 6px;
  width: 100%;
  max-width: 460px;
  transition: opacity 0.2s;
}
.bet-tile {
  background: #1a1a32;
  border: 2px solid #2a2a4a;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 5px 2px 4px;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  position: relative;
}
.bet-tile:hover { background: #22224a; border-color: #4444aa; }
.bet-tile.has-bet {
  border-color: #00d4ff;
  box-shadow: 0 0 10px rgba(0,212,255,0.4);
  background: #0f1f2a;
}
.bet-tile.winner-tile {
  animation: winner-tile-flash 0.45s ease 4;
}
@keyframes winner-tile-flash {
  0%   { border-color: #00d4ff; box-shadow: 0 0 4px rgba(0,212,255,0.4); }
  50%  { border-color: #ffd700; box-shadow: 0 0 22px rgba(255,215,0,0.9); background: #1a1500; }
  100% { border-color: #00d4ff; box-shadow: 0 0 4px rgba(0,212,255,0.4); }
}
.bt-emoji { font-size: clamp(14px, 4vw, 22px); line-height: 1.1; }
.bt-name  { font-size: clamp(7px, 1.8vw, 9px); color: #6666aa; line-height: 1; }
.bt-mult  { font-size: clamp(9px, 2.2vw, 12px); font-weight: 800; color: #edc22e; line-height: 1; }
.bt-amount {
  font-size: clamp(8px, 2vw, 11px);
  font-weight: 900;
  color: #00d4ff;
  line-height: 1;
  background: rgba(0,0,0,0.6);
  padding: 1px 3px;
  border-radius: 3px;
}
#bet-area.disabled, #chip-row.disabled { pointer-events: none; opacity: 0.45; }

/* ── Action area (spin btn + broke msg, no layout shift) ── */
#action-area {
  position: relative;
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}
#spin-btn.spin-hidden { visibility: hidden; pointer-events: none; }
#broke-msg {
  position: absolute;
  top: 0; left: 0; right: 0;
  text-align: center;
  padding: 10px 0;
  color: #b0a0d0;
}

/* ── Spin button ── */
#spin-btn {
  display: block;
  width: 100%;
  max-width: 400px;
  margin: 0 0 10px;
  font-size: 1.3rem;
  font-weight: 800;
  padding: 14px;
  letter-spacing: 0.05em;
  background: #edc22e;
  color: #0d0d20;
  border-color: #edc22e;
  box-shadow: 0 0 16px rgba(237,194,46,0.35);
}
#spin-btn:hover:not(:disabled) { background: #ffd54f; box-shadow: 0 0 24px rgba(237,194,46,0.5); }
#spin-btn:disabled { opacity: 0.35; cursor: not-allowed; box-shadow: none; }


/* ── Confetti / ribbon ── */
#confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 9999;
}
.ribbon {
  position: absolute;
  top: -24px;
  border-radius: 2px;
  animation: ribbon-fall linear forwards;
}
@keyframes ribbon-fall {
  0%   { transform: translateY(0)    rotate(0deg)   scaleX(1);  opacity: 1; }
  25%  { transform: translateY(25vh) rotate(180deg) scaleX(-1); }
  50%  { transform: translateY(50vh) rotate(360deg) scaleX(1);  }
  75%  { transform: translateY(75vh) rotate(540deg) scaleX(-1); }
  100% { transform: translateY(110vh) rotate(720deg) scaleX(1); opacity: 0.4; }
}

/* ── Mobile compact layout ── */
@media (max-width: 480px) {
  /* Shared .app has padding-bottom:40px — shrink it for slot */
  main.app { padding-bottom: 6px; }

  /* Tighter header */
  .header { margin-bottom: 6px !important; }

  /* History button: reliable 44px touch target for iOS */
  #history-btn {
    min-height: 44px;
    min-width: 44px;
    padding: 6px 10px;
    font-size: 1rem;
    touch-action: manipulation;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Tighter grid */
  #slot-grid { margin: 4px auto 3px; gap: 3px; padding: 5px; }

  /* Hide unreadable 6px name; larger emoji + mult so prizes are clear */
  .slot-item .si-name  { display: none; }
  .slot-item .si-emoji { font-size: clamp(15px, 4.8vw, 22px); }
  .slot-item .si-mult  { font-size: clamp(10px, 2.6vw, 11px); }

  /* Compact win banner */


  /* Tighter chip row, bet area and spin button */
  #chip-row { margin: 3px 0 2px; gap: 4px; }
  .chip-btn  { min-width: 32px; padding: 5px 4px; }
  #bet-area { gap: 3px; margin-bottom: 4px; }
  .bet-tile { padding: 4px 2px 3px; }
  .bt-name { display: none; }
  #spin-btn { padding: 10px; font-size: 1.1rem; margin-bottom: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  .slot-item, .ribbon { transition: none !important; animation: none !important; }
}
