:root {
  --paper: #f3ecdc;
  --paper-2: #ebe2cc;
  --white: #fffdf7;
  --ink: #121212;
  --muted: #5b5548;
  --yellow: #ffd23f;
  --green: #14F195;
  --purple: #9945FF;
  --pink: #ff5fa2;
  --blue: #5ec8ff;
  --line: 3px solid var(--ink);
  --shadow: 5px 5px 0 var(--ink);
  --shadow-lg: 8px 8px 0 var(--ink);
  --cell: clamp(62px, 9.6vw, 108px);
  --display: "Archivo Black", "Arial Black", sans-serif;
  --mono: "Space Mono", ui-monospace, monospace;
  --hand: "Permanent Marker", "Comic Sans MS", cursive;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Archivo, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  background-color: var(--paper);
  background-image: radial-gradient(rgba(18, 18, 18, .13) 1px, transparent 1.2px);
  background-size: 18px 18px;
}
a { color: var(--ink); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 2px; }
a:hover { background: var(--yellow); }
button { font: inherit; cursor: pointer; color: var(--ink); }
[hidden] { display: none !important; }
.muted { color: var(--muted); }

/* ---------- ticker tape ---------- */
.ticker { background: var(--ink); color: var(--yellow); overflow: hidden; border-bottom: var(--line); white-space: nowrap; }
.ticker-track { display: inline-block; padding: 7px 0; font-family: var(--mono); font-weight: 700; font-size: 13px; letter-spacing: .5px; animation: ticker 40s linear infinite; }
.ticker-track span { margin: 0 18px; }
.ticker-track .t-win { color: var(--green); }
@keyframes ticker { to { transform: translateX(-50%); } }

/* ---------- stickers & buttons ---------- */
.sticker {
  display: inline-block; font-family: var(--display); font-size: 12px; letter-spacing: 1px;
  padding: 4px 10px; border: var(--line); background: var(--white); box-shadow: 3px 3px 0 var(--ink);
}
.sticker-test { background: var(--pink); transform: rotate(-3deg); }
.sticker-label { background: var(--ink); color: var(--yellow); position: absolute; top: -16px; left: 22px; transform: rotate(-4deg); font-size: 14px; padding: 5px 12px; box-shadow: none; }

.btn {
  border: var(--line); border-radius: 8px; padding: 9px 16px; font-weight: 700;
  background: var(--white); box-shadow: 4px 4px 0 var(--ink);
  transition: transform .06s, box-shadow .06s; text-decoration: none; display: inline-block; text-align: center;
}
.btn:hover { background: var(--yellow); }
.btn:active { transform: translate(4px, 4px); box-shadow: 0 0 0 var(--ink); }
.btn-wallet { background: var(--yellow); white-space: nowrap; font-family: var(--display); font-weight: 400; letter-spacing: .5px; }
.btn-wallet.connected { background: var(--white); display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono); font-weight: 700; }
.btn-wallet .signout { font-family: Archivo, sans-serif; font-size: 12px; margin-left: 2px; }
.btn-wallet.connected:hover { background: var(--pink); }
.btn-primary { background: var(--green); font-family: var(--display); font-weight: 400; font-size: 18px; padding: 12px 40px; margin-top: 20px; }
.btn-ghost { background: var(--white); }
.wide { display: flex; justify-content: center; align-items: center; gap: 10px; width: 100%; margin-top: 12px; }

.avatar { width: 22px; height: 22px; border-radius: 50%; flex: none; border: 2px solid var(--ink); }

/* ---------- top bar ---------- */
.topbar { background: var(--paper); border-bottom: var(--line); position: sticky; top: 0; z-index: 20; }
.topbar-inner { max-width: 1320px; margin: 0 auto; padding: 12px 24px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 12px; white-space: nowrap; min-width: 0; text-decoration: none; color: var(--ink); }
.brand:hover { background: none; }
.brand-logo { width: 52px; height: 52px; border: 3px solid var(--ink); border-radius: 10px; box-shadow: 3px 3px 0 var(--ink); transform: rotate(-4deg); transition: transform .2s; flex: none; }
.brand:hover .brand-logo { transform: rotate(8deg) scale(1.08); }
.brand-box { font-family: var(--display); font-size: 22px; letter-spacing: .5px; background: var(--purple); color: var(--white); border: var(--line); padding: 2px 12px 3px; box-shadow: 4px 4px 0 var(--ink); -webkit-text-stroke: 1px var(--ink); }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.online { font-family: var(--mono); font-size: 13px; font-weight: 700; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); border: 2px solid var(--ink); animation: blinkDot 1.4s steps(2) infinite; }
@keyframes blinkDot { 50% { background: var(--white); } }

.banner {
  position: fixed; top: 96px; left: 50%; transform: translateX(-50%) rotate(-1deg); z-index: 30;
  padding: 12px 20px; font-family: var(--display); font-size: 15px; max-width: calc(100vw - 32px); text-align: center;
  background: var(--green); border: var(--line); box-shadow: var(--shadow-lg);
  animation: slap .3s cubic-bezier(.2, 1.6, .4, 1);
}
@keyframes slap { from { transform: translateX(-50%) rotate(-6deg) scale(1.3); opacity: 0; } }

/* ---------- page ---------- */
.page { max-width: 1320px; margin: 0 auto; padding: 40px 24px 24px; }

.jackpot-hero { display: flex; flex-direction: column; align-items: center; margin-bottom: 34px; }
.jackpot-box {
  position: relative; background: var(--yellow); border: 4px solid var(--ink); box-shadow: var(--shadow-lg);
  padding: 18px 40px 12px; transform: rotate(-1deg);
}
.jackpot-value { font-family: var(--display); font-size: clamp(44px, 7.5vw, 84px); line-height: 1; letter-spacing: -1px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.scribble { font-family: var(--hand); font-size: 18px; color: var(--ink); margin-top: 16px; transform: rotate(1.5deg); }
.scribble.small { font-size: 14px; margin: 0 0 0 4px; display: inline-block; font-weight: 400; letter-spacing: 0; }

.layout { display: grid; grid-template-columns: 280px minmax(0, 1fr) 300px; gap: 26px; align-items: start; }

/* ---------- machine ---------- */
.machine { background: var(--white); border: 4px solid var(--ink); box-shadow: var(--shadow-lg); padding: 20px; border-radius: 14px; }
.machine-head { display: flex; gap: 14px; align-items: stretch; margin-bottom: 14px; }
.label { font-family: var(--mono); font-size: 12px; font-weight: 700; letter-spacing: 1px; }
.prize-box { flex: 1; background: var(--green); border: var(--line); padding: 8px 14px; box-shadow: 4px 4px 0 var(--ink); }
.prize-value { font-family: var(--display); font-size: clamp(24px, 3.2vw, 34px); line-height: 1.1; font-variant-numeric: tabular-nums; white-space: nowrap; }
.countdown { background: var(--ink); color: var(--white); border: var(--line); padding: 8px 16px; min-width: 128px; text-align: center; box-shadow: 4px 4px 0 var(--pink); }
.countdown .label { color: var(--yellow); }
.countdown-time { font-family: var(--display); font-size: clamp(26px, 3.2vw, 34px); line-height: 1.1; font-variant-numeric: tabular-nums; }
.countdown.hot { background: var(--pink); color: var(--ink); box-shadow: 4px 4px 0 var(--ink); animation: jitter .3s steps(2) infinite; }
.countdown.hot .label { color: var(--ink); }
@keyframes jitter { 50% { transform: rotate(-1.5deg); } }

.timer-bar { height: 18px; border: var(--line); background: var(--white); overflow: hidden; }
.timer-fill {
  height: 100%; width: 100%; border-right: var(--line);
  background: repeating-linear-gradient(-45deg, var(--purple) 0 10px, #b27dff 10px 20px);
  transition: width .5s linear;
}
.countdown.hot ~ .timer-bar .timer-fill, .timer-bar.hot .timer-fill { background: repeating-linear-gradient(-45deg, var(--pink) 0 10px, #ff9ac6 10px 20px); }
.timer-hint { font-family: var(--mono); font-size: 12px; margin: 6px 0 16px; color: var(--muted); }

.reel-window { position: relative; padding: 10px; border: 4px solid var(--ink); background: var(--ink); border-radius: 10px; }
.reels { position: relative; display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.reel { height: calc(var(--cell) * 3); overflow: hidden; position: relative; background: var(--paper); border-radius: 4px; }
.reel.tease { outline: 4px solid var(--yellow); outline-offset: -4px; background: #fff6cf; }
.strip { will-change: transform; }
.cell { height: var(--cell); display: flex; align-items: center; justify-content: center; }
.cell svg { width: 76%; height: 76%; }
.cell.hit { background: var(--yellow); }
.cell.hit svg { animation: bounce .45s ease-in-out infinite alternate; }
@keyframes bounce { to { transform: translateY(-6%) rotate(-6deg) scale(1.08); } }
.payline {
  position: absolute; left: 0; right: 0; top: 50%; height: var(--cell); transform: translateY(-50%);
  pointer-events: none; z-index: 2; border-top: 3px dashed var(--pink); border-bottom: 3px dashed var(--pink);
}
.payline-mark { position: absolute; top: 50%; transform: translateY(-50%); z-index: 3; width: 0; height: 0; border-top: 12px solid transparent; border-bottom: 12px solid transparent; }
.payline-mark.left { left: -16px; border-left: 16px solid var(--pink); filter: drop-shadow(-3px 0 0 var(--ink)); }
.payline-mark.right { right: -16px; border-right: 16px solid var(--pink); filter: drop-shadow(3px 0 0 var(--ink)); }
.shake { animation: shake .2s linear infinite; }
@keyframes shake { 25% { transform: translateX(-2px); } 75% { transform: translateX(2px); } }

.btn-spin {
  --cd: 0;
  display: block; width: 100%; margin-top: 20px; padding: 20px; position: relative; overflow: hidden;
  font-family: var(--display); font-size: clamp(20px, 2.6vw, 28px); letter-spacing: 1px;
  background: var(--pink); border: 4px solid var(--ink); border-radius: 12px; box-shadow: 0 8px 0 var(--ink);
  transition: transform .06s, box-shadow .06s;
}
.btn-spin::after {
  content: ""; position: absolute; inset: 0; transform-origin: right; transform: scaleX(var(--cd));
  background: repeating-linear-gradient(-45deg, rgba(18,18,18,.18) 0 8px, transparent 8px 16px);
}
.btn-spin span { position: relative; z-index: 1; }
.btn-spin:hover:not(:disabled) { background: #ff77b1; }
.btn-spin:active:not(:disabled) { transform: translateY(8px); box-shadow: 0 0 0 var(--ink); }
.btn-spin:disabled { cursor: not-allowed; background: #e8ddd0; color: var(--muted); }

.status { text-align: center; margin: 16px 0 0; min-height: 1.5em; font-weight: 600; }
.status.good { background: var(--green); border: 2px solid var(--ink); padding: 4px 8px; }
.status.bad { background: #ffd6e7; border: 2px solid var(--ink); padding: 4px 8px; }

/* ---------- side ---------- */
.card { background: var(--white); border: var(--line); box-shadow: var(--shadow); padding: 18px; margin-bottom: 22px; }
.card h3 { margin: 0 0 12px; font-family: var(--display); font-weight: 400; font-size: 17px; letter-spacing: .5px; }
.card-rules { background: var(--blue); transform: rotate(.6deg); }

.winners { list-style: none; margin: 0; padding: 0; }
.winners li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 2px dashed rgba(18,18,18,.3); }
.winners li:first-child { border-top: 0; padding-top: 0; }
.winners .empty { font-family: var(--hand); justify-content: center; padding: 12px 0; font-size: 16px; }
.w-main { flex: 1; min-width: 0; }
.w-wallet { font-family: var(--mono); font-weight: 700; font-size: 13px; }
.w-meta { font-size: 12px; color: var(--muted); }
.w-amt { font-family: var(--display); font-size: 14px; background: var(--green); border: 2px solid var(--ink); padding: 1px 6px; white-space: nowrap; }
.w-jack .w-amt { background: var(--yellow); }
.tag-jack { font-weight: 700; color: var(--ink); background: var(--yellow); padding: 0 4px; }

.steps { margin: 0; padding-left: 22px; display: grid; gap: 10px; font-size: 14px; }
.steps li::marker { font-family: var(--display); }

.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 20px 24px 40px; max-width: 720px; margin: 0 auto; }
.footer p { margin: 4px 0; }

/* ---------- chat ---------- */
.chat {
  position: sticky; top: 84px; display: flex; flex-direction: column;
  height: min(700px, calc(100vh - 110px));
  background: var(--white); border: var(--line); box-shadow: var(--shadow);
}
.chat-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--ink); color: var(--white); }
.chat-head h3 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 16px; letter-spacing: 1px; flex: 1; color: var(--yellow); }
.chat-count { font-family: var(--mono); font-size: 12px; }
.chat-close { display: none; background: none; border: 0; color: var(--white); font-size: 18px; padding: 0 4px; }
.chat-list { list-style: none; margin: 0; padding: 12px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { display: flex; gap: 8px; align-items: flex-start; }
.chat-msg .avatar { margin-top: 2px; }
.chat-body { min-width: 0; flex: 1; }
.chat-meta { display: flex; gap: 6px; align-items: baseline; }
.chat-name { font-family: var(--mono); font-weight: 700; font-size: 12px; }
.chat-msg.mine .chat-name { background: var(--green); padding: 0 3px; }
.chat-time { color: var(--muted); font-size: 11px; font-family: var(--mono); }
.chat-text { font-size: 14px; overflow-wrap: anywhere; }
.chat-system { font-family: var(--display); font-size: 12px; letter-spacing: .3px; text-align: center; padding: 7px 8px; background: var(--green); border: 2px solid var(--ink); transform: rotate(-.8deg); }
.chat-system.jack { background: var(--yellow); }
.chat-empty { font-family: var(--hand); text-align: center; margin: auto 0; font-size: 16px; color: var(--muted); }
.chat-form { display: flex; gap: 8px; padding: 10px; border-top: var(--line); background: var(--paper-2); }
.chat-form input { flex: 1; min-width: 0; background: var(--white); color: var(--ink); border: var(--line); padding: 9px 10px; font: inherit; font-size: 14px; }
.chat-form input:focus { outline: none; background: #fffbe8; }
.chat-form input:disabled { background: #eee6d6; }
.chat-form input.chat-error::placeholder { color: #d4145a; font-weight: 700; }
.chat-form button { flex: none; border: var(--line); background: var(--yellow); font-family: var(--display); font-size: 13px; padding: 0 12px; box-shadow: 3px 3px 0 var(--ink); }
.chat-form button:active:not(:disabled) { transform: translate(3px, 3px); box-shadow: none; }
.chat-form button:disabled { background: #eee6d6; color: var(--muted); cursor: not-allowed; box-shadow: none; }
.chat-fab {
  display: none; position: fixed; right: 16px; bottom: 16px; z-index: 40;
  padding: 12px 18px; font-family: var(--display); font-size: 15px;
  background: var(--yellow); border: var(--line); box-shadow: var(--shadow);
}
.chat-badge { position: absolute; top: -8px; right: -8px; width: 16px; height: 16px; border-radius: 50%; background: var(--pink); border: 3px solid var(--ink); }

/* ---------- overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: rgba(18, 18, 18, .55); padding: 16px;
}
.overlay-card {
  background: var(--green); border: 4px solid var(--ink); box-shadow: 10px 10px 0 var(--ink);
  padding: 30px 26px; text-align: center; width: min(420px, 100%); transform: rotate(-2deg);
  animation: slapIn .35s cubic-bezier(.2, 1.6, .4, 1);
}
@keyframes slapIn { from { transform: rotate(-10deg) scale(1.4); opacity: 0; } }
.overlay-title { font-family: var(--display); font-size: 20px; }
.overlay-amount { font-family: var(--display); font-size: clamp(40px, 10vw, 56px); line-height: 1.05; margin: 8px 0; background: var(--white); border: var(--line); padding: 6px 10px; }
.overlay-sub { font-family: var(--hand); font-size: 17px; }
.overlay.jackpot .overlay-card { background: var(--yellow); }
.wallet-card { background: var(--white); transform: none; text-align: left; }
.wallet-card h3 { margin: 0 0 6px; font-family: var(--display); font-weight: 400; }

/* ---------- responsive ---------- */
@media (max-width: 1240px) {
  .layout { grid-template-columns: minmax(0, 1fr) 300px; }
  .chat {
    position: fixed; z-index: 45; top: auto; right: 16px; bottom: 80px;
    width: min(360px, calc(100vw - 32px)); height: min(540px, calc(100vh - 120px));
    box-shadow: var(--shadow-lg); display: none;
  }
  body.chat-open .chat { display: flex; }
  .chat-close { display: block; }
  .chat-fab { display: block; }
}
@media (max-width: 920px) {
  .layout { grid-template-columns: 1fr; }
  .page { padding: 30px 16px 16px; }
  .topbar-inner { padding: 10px 16px; }
  :root { --cell: calc((100vw - 32px - 28px - 28px - 24px) / 5); }
  .machine { padding: 14px; }
  .reel-window { padding: 6px; }
  .reels { gap: 4px; }
  .payline-mark.left { left: -13px; } .payline-mark.right { right: -13px; }
}
@media (max-width: 520px) {
  .online { display: none; }
  .brand-box { font-size: 17px; }
  .brand { gap: 8px; }
  .brand-logo { width: 42px; height: 42px; }
  .sticker-test { display: none; }
  .btn-wallet { padding: 7px 10px; font-size: 13px; }
  .jackpot-box { padding: 16px 20px 10px; }
  .scribble { font-size: 15px; }
  .countdown { min-width: 0; padding: 8px 10px; }
  .chat { inset: 0; width: auto; height: auto; border: 0; box-shadow: none; }
  body.chat-open { overflow: hidden; }
}

/* ---------- contract address ---------- */
.ca-bar { display: flex; justify-content: center; padding: 14px 16px 0; }
.ca-btn {
  display: inline-flex; align-items: center; gap: 10px; max-width: 100%; cursor: pointer;
  border: var(--line); border-radius: 8px; background: var(--white); box-shadow: 4px 4px 0 var(--ink);
  padding: 7px 8px 7px 7px; font-family: var(--mono); font-weight: 700; font-size: 14px; color: var(--ink);
  transition: transform .06s, box-shadow .06s;
}
.ca-btn:hover { background: var(--yellow); }
.ca-btn:active { transform: translate(4px, 4px); box-shadow: 0 0 0 var(--ink); }
.ca-label { background: var(--ink); color: var(--yellow); padding: 3px 8px; border-radius: 4px; font-family: var(--display); letter-spacing: 1px; }
.ca-addr { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ca-copy { background: var(--green); border: 2px solid var(--ink); border-radius: 4px; padding: 2px 8px; font-size: 12px; }
@media (max-width: 520px) { .ca-btn { font-size: 12px; gap: 7px; } }
