:root {
  --bg: #08231d;
  --ink: #fff7e8;
  --muted: rgba(255, 247, 232, 0.68);
  --panel: rgba(12, 59, 46, 0.82);
  --panel-strong: rgba(10, 40, 34, 0.94);
  --line: rgba(255, 239, 200, 0.18);
  --gold: #f2c861;
  --gold-2: #ffe7a1;
  --red: #d83d35;
  --cyan: #69d6d0;
  --violet: #8b7cff;
  --shadow: 0 28px 60px rgba(0, 0, 0, 0.34);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --app-height: 100dvh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  overscroll-behavior: none;
}

body {
  min-height: var(--app-height);
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

h1,
h2,
p {
  margin: 0;
}

.viewport {
  position: relative;
  width: 100vw;
  height: var(--app-height);
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(11, 80, 61, 0.92), rgba(8, 35, 29, 1) 44%, #120d22 100%),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.03) 0 1px, transparent 1px 108px);
}

.design {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1080px;
  height: 1920px;
  transform: translate(-50%, -50%) scale(var(--stage-scale, 0.45));
  transform-origin: center center;
  overflow: hidden;
  padding: 64px 56px 50px;
}

.is-tma .design {
  transform-origin: top center;
}

.topbar,
.wallet-strip,
.machine-head,
.action-grid,
.invite-panel,
.panel-title,
.pack-row,
.modal-head {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  min-height: 156px;
}

.eyebrow,
.mini-label,
.wallet-pill span,
.action-card span,
.pack-btn span,
.panel-title span,
.jackpot span {
  color: var(--muted);
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0;
}

h1 {
  margin-top: 8px;
  color: var(--gold-2);
  font-size: 92px;
  line-height: 0.92;
  font-weight: 950;
  letter-spacing: 0;
}

.icon-btn {
  width: 96px;
  height: 96px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 2px solid var(--line);
  background: rgba(255, 255, 255, 0.1);
  color: var(--gold-2);
  font-size: 38px;
  font-weight: 950;
}

.wallet-strip {
  gap: 18px;
  margin: 24px 0;
}

.wallet-pill {
  flex: 1;
  min-height: 116px;
  display: grid;
  gap: 8px;
  padding: 20px 24px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: rgba(4, 23, 19, 0.55);
  box-shadow: var(--shadow);
}

.wallet-pill strong {
  min-width: 0;
  overflow: hidden;
  color: var(--gold);
  font-size: 42px;
  line-height: 1;
  text-overflow: ellipsis;
}

.machine {
  position: relative;
  min-height: 720px;
  padding: 34px;
  border: 4px solid rgba(242, 200, 97, 0.42);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(18, 86, 64, 0.96), rgba(62, 22, 40, 0.96)),
    linear-gradient(90deg, rgba(255,255,255,0.05), transparent);
  box-shadow: var(--shadow);
}

.machine::before {
  content: "";
  position: absolute;
  inset: 18px;
  pointer-events: none;
  border: 2px solid rgba(255, 239, 200, 0.16);
  border-radius: 8px;
}

.machine-head {
  position: relative;
  z-index: 1;
  justify-content: space-between;
  margin-bottom: 36px;
}

.machine-head strong,
.jackpot strong {
  display: block;
  margin-top: 8px;
  color: var(--gold-2);
  font-size: 44px;
  line-height: 1;
  font-weight: 950;
}

.jackpot {
  min-width: 220px;
  padding: 18px 22px;
  border: 2px solid rgba(242, 200, 97, 0.35);
  border-radius: 8px;
  background: rgba(19, 16, 31, 0.5);
  text-align: right;
}

.reels {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
}

.reel {
  height: 292px;
  display: grid;
  place-items: center;
  gap: 12px;
  padding: 18px 10px;
  border: 3px solid rgba(8, 35, 29, 0.55);
  border-radius: 8px;
  background: linear-gradient(180deg, #fff8e6, #d5b981);
  color: #351807;
  box-shadow: inset 0 -16px 24px rgba(67, 34, 4, 0.14), 0 16px 24px rgba(0, 0, 0, 0.22);
}

.reel.is-spinning {
  animation: reelPulse 520ms ease-in-out infinite;
}

.reel img {
  width: 132px;
  height: 166px;
  object-fit: contain;
}

.reel span {
  font-size: 28px;
  font-weight: 950;
}

.result-line {
  position: relative;
  z-index: 1;
  min-height: 72px;
  margin: 30px 0 22px;
  padding: 18px 22px;
  border: 2px solid rgba(255, 239, 200, 0.16);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.24);
  color: var(--gold-2);
  font-size: 32px;
  font-weight: 900;
  text-align: center;
}

.bet-row {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.bet-btn,
.spin-btn,
.action-card,
.primary-small,
.pack-btn {
  border-radius: 8px;
  font-weight: 950;
}

.bet-btn {
  min-height: 86px;
  border: 2px solid var(--line);
  background: rgba(255, 255, 255, 0.1);
  color: var(--muted);
  font-size: 34px;
}

.bet-btn.is-active {
  border-color: rgba(242, 200, 97, 0.8);
  background: var(--gold);
  color: #201104;
}

.spin-btn {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 148px;
  margin-top: 24px;
  background: linear-gradient(180deg, #ffe7a1, #f0b633);
  color: #2a1303;
  font-size: 62px;
  box-shadow: 0 18px 0 #8d4b12, 0 36px 50px rgba(0, 0, 0, 0.34);
}

.spin-btn:active {
  transform: translateY(10px);
  box-shadow: 0 8px 0 #8d4b12, 0 24px 40px rgba(0, 0, 0, 0.3);
}

.spin-btn:disabled,
.bet-btn:disabled,
.action-card:disabled,
.pack-btn:disabled,
.primary-small:disabled {
  opacity: 0.52;
  cursor: wait;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 22px;
}

.action-card {
  min-height: 142px;
  display: grid;
  gap: 10px;
  padding: 22px;
  border: 2px solid var(--line);
  background: rgba(12, 59, 46, 0.72);
  text-align: left;
}

.action-card strong {
  color: var(--cyan);
  font-size: 40px;
}

.invite-panel,
.shop-panel,
.feed-panel {
  margin-top: 22px;
  padding: 26px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.invite-panel {
  justify-content: space-between;
  gap: 28px;
}

.invite-panel h2,
.panel-title h2 {
  color: var(--gold-2);
  font-size: 38px;
  line-height: 1.08;
}

.invite-panel p {
  max-width: 650px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 26px;
  line-height: 1.38;
}

.primary-small {
  flex: 0 0 auto;
  min-width: 218px;
  min-height: 92px;
  padding: 0 28px;
  background: var(--red);
  color: #fff7e8;
  font-size: 32px;
}

.panel-title {
  justify-content: space-between;
  margin-bottom: 20px;
}

.pack-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.pack-btn {
  min-height: 126px;
  display: grid;
  gap: 8px;
  padding: 18px;
  border: 2px solid rgba(242, 200, 97, 0.32);
  background: rgba(19, 16, 31, 0.44);
  text-align: left;
}

.pack-btn strong {
  color: var(--gold);
  font-size: 38px;
}

.feed {
  display: grid;
  gap: 10px;
  max-height: 176px;
  overflow: hidden;
}

.feed-item {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  min-height: 48px;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--muted);
  font-size: 24px;
  font-weight: 800;
}

.feed-item strong {
  color: var(--gold-2);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(6, 10, 18, 0.72);
}

.modal.is-open {
  display: flex;
}

.modal-card {
  width: min(92vw, 560px);
  max-height: min(82vh, 760px);
  overflow: auto;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

.modal-head {
  justify-content: space-between;
  margin-bottom: 18px;
}

.modal-head h2 {
  color: var(--gold-2);
  font-size: 28px;
}

.modal-head .icon-btn {
  width: 48px;
  height: 48px;
  font-size: 26px;
}

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

.leaderboard-row {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 50px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 15px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + var(--safe-bottom));
  z-index: 40;
  width: min(90vw, 520px);
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(10, 40, 34, 0.95);
  color: var(--ink);
  font-size: 14px;
  font-weight: 850;
  text-align: center;
  transform: translate(-50%, 18px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-open {
  opacity: 1;
  transform: translate(-50%, 0);
}

@keyframes reelPulse {
  0% { transform: translateY(-4px); filter: brightness(1.15); }
  50% { transform: translateY(5px); filter: brightness(0.9); }
  100% { transform: translateY(-4px); filter: brightness(1.15); }
}

@media (max-width: 420px) {
  .toast {
    font-size: 13px;
  }
}
