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

body {
  font-family: 'Trebuchet MS', sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: radial-gradient(circle at top, #1a0a2e 0%, #050010 100%);
  color: #fff;
  padding: 20px;
}

.machine {
  background: linear-gradient(145deg, #c62828, #6a0a0a);
  border: 6px solid #ffd54f;
  border-radius: 20px;
  padding: 22px 22px 28px;
  width: 100%;
  max-width: 760px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.6), inset 0 0 30px rgba(0,0,0,0.4);
  text-align: center;
}

.title {
  color: #ffd54f;
  text-shadow: 2px 2px 0 #000, 0 0 15px #ff8a00;
  margin-bottom: 8px;
  letter-spacing: 2px;
  font-size: 24px;
}

/* ===== Jackpot ===== */
.jackpot {
  background: linear-gradient(90deg, #ff8a00, #ffd54f, #ff8a00);
  background-size: 200% 100%;
  animation: jackpotShine 3s linear infinite;
  color: #4a1500;
  font-weight: bold;
  font-size: 18px;
  padding: 6px 12px;
  border-radius: 10px;
  margin-bottom: 8px;
  border: 3px solid #b35900;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.jackpot-label { letter-spacing: 1px; }
.grand-jackpot { font-size: 20px; }
@keyframes jackpotShine {
  0%   { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

/* ===== Tier bar ===== */
.tier-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}
.tier {
  background: rgba(0,0,0,0.45);
  border: 2px solid #ffd54f;
  border-radius: 8px;
  padding: 6px 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
  transition: all 0.3s;
}
.tier.collected {
  background: linear-gradient(180deg, #1b5e20, #2e7d32);
  border-color: #69f0ae;
  box-shadow: 0 0 18px #69f0ae;
  animation: tierCollected 0.6s ease 3;
}
@keyframes tierCollected {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.05); }
}
.tier-icon { font-size: 22px; }
.tier-info { flex: 1; text-align: left; min-width: 0; }
.tier-label { font-size: 9px; color: #ffd54f; text-transform: uppercase; letter-spacing: 1px; }
.tier-amount { font-size: 13px; font-weight: bold; color: #fff; line-height: 1.1; }
.tier-grand-mini { border-color: #ff8a00; }
.tier-grand-mini .tier-label { color: #ff8a00; }

.tier-progress {
  display: flex;
  gap: 3px;
  position: absolute;
  bottom: -8px;
  right: 4px;
}
.tier-pip {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #444;
  border: 1px solid #ffd54f;
  transition: all 0.3s;
}
.tier-pip.lit {
  background: #69f0ae;
  box-shadow: 0 0 6px #69f0ae;
}

/* ===== Free spins banner ===== */
.free-spins-banner {
  background: linear-gradient(90deg, #00e5ff, #2979ff, #00e5ff);
  background-size: 200% 100%;
  animation: jackpotShine 2s linear infinite;
  color: #fff;
  font-weight: bold;
  font-size: 15px;
  padding: 6px 10px;
  border-radius: 8px;
  margin-bottom: 8px;
  border: 2px solid #00b8d4;
  text-shadow: 1px 1px 0 #000;
}
.free-spins-banner.hidden { display: none; }

/* ===== Reels grid (dynamic size) ===== */
.reels-wrapper {
  position: relative;
  background: #1a1a1a;
  padding: 10px;
  border-radius: 12px;
  border: 4px solid #ffd54f;
  margin-bottom: 14px;
  transition: border-color 0.4s, box-shadow 0.4s;
}
.reels-wrapper.free-mode {
  border-color: #00e5ff;
  box-shadow: 0 0 30px rgba(0, 229, 255, 0.5);
}
.reels {
  display: grid;
  gap: 5px;
  position: relative;
  z-index: 1;
}
.reels[data-size="3"] { grid-template-columns: repeat(3, 1fr); }
.reels[data-size="6"] { grid-template-columns: repeat(6, 1fr); }

.reel {
  background: #fff;
  color: #000;
  height: 76px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
  transition: transform 0.05s, font-size 0.3s, height 0.3s;
}
.reels[data-size="6"] .reel { height: 56px; font-size: 30px; }

.reel.spinning { animation: shake 0.1s linear infinite; }
.reel.win      { animation: cellGlow 0.6s ease-in-out 3; }
.reel.tier-symbol {
  background: linear-gradient(135deg, #fff, #fffacd);
  box-shadow: 0 0 12px #ffd700, inset 0 0 6px rgba(0,0,0,0.2);
  animation: tierShimmer 1.5s ease-in-out infinite;
}
@keyframes tierShimmer {
  0%, 100% { transform: scale(1); box-shadow: 0 0 12px #ffd700, inset 0 0 6px rgba(0,0,0,0.2); }
  50%      { transform: scale(1.08); box-shadow: 0 0 22px #ffd700, inset 0 0 6px rgba(0,0,0,0.2); }
}
.reel.tier-collected { background: #69f0ae !important; animation: cellGlow 0.4s 2; }

@keyframes shake {
  0%   { transform: translateY(-4px); }
  50%   { transform: translateY(4px); }
  100% { transform: translateY(-4px); }
}
@keyframes cellGlow {
  0%, 100% { box-shadow: inset 0 0 6px rgba(0,0,0,0.3); }
  50%      { box-shadow: 0 0 18px #ffd54f, inset 0 0 6px rgba(0,0,0,0.3); }
}

#paylineCanvas {
  position: absolute;
  top: 10px; left: 10px;
  width: calc(100% - 20px);
  height: calc(100% - 20px);
  pointer-events: none;
  z-index: 2;
}

/* ===== Info bar ===== */
.info {
  display: flex;
  gap: 5px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.info-box {
  flex: 1 1 70px;
  background: #1a1a1a;
  border: 2px solid #ffd54f;
  border-radius: 8px;
  padding: 5px;
}
.info-box.highlight {
  background: #2a1a05;
  border-color: #ff8a00;
}
.label, .total-label {
  display: block;
  font-size: 9px;
  color: #ffd54f;
  text-transform: uppercase;
  letter-spacing: 1px;
}
#credits, #betPerLine, #linesActive, #totalBet, #lastWin {
  display: block;
  font-size: 16px;
  font-weight: bold;
  margin-top: 2px;
}

/* ===== Controls ===== */
.controls {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.controls.secondary-controls { margin-top: -2px; }
.btn {
  padding: 10px 8px;
  font-size: 13px;
  font-weight: bold;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: transform 0.1s, box-shadow 0.1s;
  color: #fff;
  font-family: inherit;
}
.btn:active { transform: translateY(2px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  flex: 2;
  background: linear-gradient(180deg, #ffd54f, #ff8a00);
  color: #4a1500;
  box-shadow: 0 4px 0 #b35900, 0 6px 10px rgba(0,0,0,0.4);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 2px 0 #b35900, 0 4px 8px rgba(0,0,0,0.4); }
.btn-secondary {
  flex: 1;
  background: linear-gradient(180deg, #444, #222);
  box-shadow: 0 4px 0 #000, 0 6px 8px rgba(0,0,0,0.4);
}
.btn-secondary:hover:not(:disabled) { box-shadow: 0 2px 0 #000, 0 4px 6px rgba(0,0,0,0.4); }
.btn-success {
  flex: 1;
  background: linear-gradient(180deg, #66bb6a, #2e7d32);
  color: #fff;
  box-shadow: 0 4px 0 #1b5e20, 0 6px 8px rgba(0,0,0,0.4);
}
.btn-success:hover:not(:disabled) { box-shadow: 0 2px 0 #1b5e20, 0 4px 6px rgba(0,0,0,0.4); }
.btn-small { padding: 5px 9px; font-size: 11px; }

/* Payline nav buttons — bright blue on dark bg */
.btn-payline-nav {
  background: linear-gradient(180deg, #42a5f5, #1565c0) !important;
  color: #fff !important;
  box-shadow: 0 4px 0 #0d47a1, 0 6px 8px rgba(0,0,0,0.4) !important;
}
.btn-payline-nav:hover:not(:disabled) {
  box-shadow: 0 2px 0 #0d47a1, 0 4px 6px rgba(0,0,0,0.4) !important;
}
/* Autoplay button — green */
.btn-autoplay {
  background: linear-gradient(180deg, #66bb6a, #2e7d32) !important;
  color: #fff !important;
  box-shadow: 0 4px 0 #1b5e20, 0 6px 8px rgba(0,0,0,0.4) !important;
}
/* Stop auto-spin — red */
.btn-stop-auto {
  background: linear-gradient(180deg, #ef5350, #b71c1c) !important;
  color: #fff !important;
  box-shadow: 0 4px 0 #880e0e, 0 6px 8px rgba(0,0,0,0.4) !important;
}

.payline-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 8px;
  background: rgba(0,0,0,0.3);
  padding: 5px;
  border-radius: 8px;
  flex-wrap: wrap;
}
.payline-info { font-size: 12px; color: #ffd54f; }

.message {
  min-height: 24px;
  font-size: 16px;
  font-weight: bold;
  color: #ffd54f;
  text-shadow: 1px 1px 0 #000;
  margin-bottom: 8px;
}
.message.win { color: #69f0ae; animation: pulse 0.5s ease-in-out 2; }
.message.jackpot { color: #ffeb3b; font-size: 20px; animation: pulse 0.4s ease-in-out 4; }
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.1); }
}

/* ===== Paytable (inline removed — now in modal) ===== */

/* ===== Modals ===== */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex; justify-content: center; align-items: center;
  z-index: 100;
  animation: fadeIn 0.25s ease;
}
.modal.hidden { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-content {
  background: linear-gradient(145deg, #1a0a3a, #2a0a5a);
  border: 5px solid #ffd54f;
  border-radius: 18px;
  padding: 22px;
  width: 90%;
  max-width: 460px;
  text-align: center;
  box-shadow: 0 0 50px rgba(255, 213, 79, 0.6);
  max-height: 90vh;
  overflow-y: auto;
  animation: zoomIn 0.3s ease;
}
@keyframes zoomIn { from { transform: scale(0.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-content h2 { color: #ffd54f; margin-bottom: 10px; }
.modal-content p { margin-bottom: 8px; }

/* Paytable modal — slightly wider */
.paytable-modal-content {
  max-width: 480px;
}

/* Free-game intro */
.intro-content { border-color: #00e5ff; box-shadow: 0 0 50px rgba(0, 229, 255, 0.7); }
.intro-tiers {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 14px 0;
  font-size: 14px;
}
.intro-tiers > div {
  background: rgba(0,0,0,0.4);
  padding: 6px;
  border-radius: 6px;
  border: 1px solid #ffd54f;
}
.intro-tiers span { color: #ffd54f; font-weight: bold; }
.free-count { font-size: 18px; color: #00e5ff; font-weight: bold; margin: 10px 0; }

/* Tier-won modal */
.tier-won { border-color: #69f0ae; }
.tier-won-icon { font-size: 80px; margin: 14px 0; animation: bounce 0.6s ease infinite alternate; }
@keyframes bounce { from { transform: scale(1); } to { transform: scale(1.15); } }
.tier-won-amount { font-size: 32px; color: #69f0ae; font-weight: bold; margin-bottom: 14px; text-shadow: 2px 2px 0 #000; }

/* Add Credits */
.credit-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 16px 0;
}
.credit-opt { padding: 14px; font-size: 15px; }

/* Difficulty */
.difficulty-options { display: flex; flex-direction: column; gap: 8px; margin: 16px 0; }
.diff-opt {
  background: linear-gradient(180deg, #444, #222);
  color: #fff;
  padding: 10px;
  font-size: 13px;
}
.diff-opt.active {
  background: linear-gradient(180deg, #ff8a00, #ffd54f);
  color: #4a1500;
  box-shadow: 0 0 15px #ffd54f inset;
}

@media (max-width: 600px) {
  .reel { font-size: 32px; height: 60px; }
  .reels[data-size="6"] .reel { font-size: 22px; height: 44px; }
  .tier-bar { grid-template-columns: repeat(2, 1fr); }
  .tier-amount { font-size: 11px; }
  .info-box { flex: 1 1 60px; }
  .btn { font-size: 11px; padding: 8px 5px; }
  .pay-grid { grid-template-columns: 1fr; }
}

/* ===== Auto-Spin modal ===== */
.auto-spin-content { max-width: 500px; text-align: left; }
.auto-spin-content h2 { text-align: center; }
.auto-hint { text-align: center; color: #ccc; margin-bottom: 12px; }
.auto-row { margin: 10px 0; }
.auto-row > label {
  display: block;
  font-size: 12px;
  color: #ffd54f;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.auto-options {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}
.auto-opt {
  padding: 8px 4px;
  font-size: 12px;
}
.auto-opt.active {
  background: linear-gradient(180deg, #ff8a00, #ffd54f);
  color: #4a1500;
  box-shadow: 0 0 12px #ffd54f inset;
}
.check-row { display: flex; flex-direction: column; gap: 6px; }
.check-row > label.check-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #fff;
  text-transform: none;
  letter-spacing: 0;
  margin: 0;
  cursor: pointer;
}
.mini-input {
  width: 80px;
  padding: 2px 6px;
  font-size: 12px;
  background: #1a1a1a;
  color: #ffd54f;
  border: 2px solid #ffd54f;
  border-radius: 4px;
  text-align: center;
  font-family: 'Trebuchet MS', monospace;
}
.auto-status {
  margin: 10px 0;
  padding: 8px;
  background: rgba(0,0,0,0.4);
  border: 1px solid #ffd54f;
  border-radius: 6px;
  font-size: 12px;
  text-align: center;
  min-height: 18px;
}
.auto-status.running { color: #69f0ae; border-color: #69f0ae; }
.auto-actions { display: flex; gap: 8px; margin-top: 10px; }
.auto-actions .btn { flex: 1; padding: 10px; }
@media (max-width: 600px) {
  .auto-options { grid-template-columns: repeat(3, 1fr); }
}

/* ===== Add Credits modal — typed input + stepper ===== */
.add-credit-content { max-width: 480px; }
.credit-adder {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 16px 0 6px;
}
.adder-btn {
  flex: 0 0 56px;
  height: 48px;
  font-size: 24px;
  font-weight: bold;
  padding: 0;
  background: linear-gradient(180deg, #ffd54f, #ff8a00);
  color: #4a1500;
  box-shadow: 0 4px 0 #b35900;
  border-radius: 10px;
}
.adder-btn:hover { box-shadow: 0 2px 0 #b35900; transform: translateY(2px); }
.adder-btn:active { transform: translateY(4px); box-shadow: 0 0 0 #b35900; }
.credit-input {
  flex: 1;
  height: 48px;
  font-size: 20px;
  font-weight: bold;
  text-align: center;
  border: 3px solid #ffd54f;
  border-radius: 10px;
  background: #1a1a1a;
  color: #ffd54f;
  font-family: 'Trebuchet MS', monospace;
  padding: 0 10px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.credit-input:focus {
  border-color: #69f0ae;
  box-shadow: 0 0 12px rgba(105, 240, 174, 0.5);
}
.credit-input.invalid {
  border-color: #ff5252;
  box-shadow: 0 0 12px rgba(255, 82, 82, 0.5);
}
.credit-helper {
  font-size: 11px;
  color: #ccc;
  margin: 4px 0 14px;
  line-height: 1.4;
}
.credit-helper code {
  background: #1a1a1a;
  padding: 1px 6px;
  border-radius: 4px;
  color: #ffd54f;
  font-family: monospace;
}
.credit-quick {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 8px 0 14px;
}
.quick-add { padding: 8px 4px; font-size: 12px; }
.credit-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
.credit-actions .btn { flex: 1; padding: 12px; font-size: 14px; }

/* ===== Tier progress (10/20/30/40 pips) ===== */
.tier-progress {
  display: flex;
  gap: 1.5px;
  position: absolute;
  bottom: -6px;
  left: 4px;
  right: 4px;
  justify-content: center;
}
.tier-pip {
  flex: 1;
  max-width: 6px;
  height: 5px;
  border-radius: 1.5px;
  background: #333;
  border: none;
  transition: background 0.2s, box-shadow 0.2s;
}
.tier-pip.lit {
  background: #69f0ae;
  box-shadow: 0 0 4px #69f0ae;
}
