/* stockbetting.com — Play extras: visitor banner, green primary button, toast,
   streak badge, share button, skeletons and friendly states.
   Loads last on play/index.html. Everything here is scoped to the Play page
   (body[data-page="play"]) or to classes that only the Play page uses.

   .skeleton and .state-msg are being added to site.css by another change. The
   markup carries BOTH those classes and a pe- class, so the minimal rules below
   still apply if site.css doesn't have them yet, and the site.css rules win
   wherever they exist (they load first and are not overridden here). */

:root {
  --pe-up: var(--up, #16D67E);
  --pe-down: var(--down, #FF4D5E);
  --pe-sideways: var(--sideways, #FFC53D);
  --pe-panel: var(--panel, #11161E);
  --pe-line: var(--line, #232C3A);
  --pe-text: var(--text, #EEF2F7);
  --pe-muted: var(--muted, #A9B4C4);
}

/* ---------- primary = green, secondary = outlined (Play page only) ---------- */
body[data-page="play"] .btn.primary {
  background: var(--pe-up);
  border-color: var(--pe-up);
  color: #04120A;
  font-weight: 600;
}
body[data-page="play"] .btn.primary:hover {
  background: #2BE38E;
  border-color: #2BE38E;
  color: #04120A;
}
body[data-page="play"] .btn.pe-outline,
body[data-page="play"] .btn.pe-outline:hover {
  background: transparent;
  border: 1px solid var(--pe-text);
  color: var(--pe-text);
}
body[data-page="play"] .btn.pe-outline:hover { border-color: var(--pe-up); color: var(--pe-up); }

/* ---------- visitor banner (replaces the old login wall) ---------- */
.pe-keep {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  background: var(--pe-panel);
  border: 1px solid var(--pe-line);
  border-left: 3px solid var(--pe-up);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 14px;
  color: var(--pe-muted);
}
.pe-keep[hidden] { display: none; }
.pe-keep-text { flex: 1 1 260px; min-width: 0; }
.pe-keep-text b { color: var(--pe-text); font-weight: 600; }
.pe-keep-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.pe-keep-actions .btn { padding: 7px 14px; font-size: 14px; white-space: nowrap; }

/* visitor name in the top bar */
.play-user.pe-visitor { color: var(--pe-muted); font-weight: 500; }

/* ---------- login modal (opened from the banner, not a page wall) ---------- */
.pe-authmodal { width: min(420px, calc(100vw - 32px)); }
.pe-authmodal .pe-close {
  float: right;
  background: none;
  border: 0;
  color: var(--pe-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  /* 44px tap target; negative margins keep the visual position unchanged */
  min-width: 44px; min-height: 44px;
  margin: -12px -12px 0 0;
}
.pe-authmodal .pe-close:hover { color: var(--pe-text); }
.pe-authmodal #authForm { display: flex; flex-direction: column; gap: 10px; }
.pe-authmodal .auth-note { font-size: 13px; margin-top: 12px; }
.pe-authmodal .btn.pe-outline { width: 100%; }

/* ---------- token balance + streak flame ---------- */
.play-balance .streak-flame {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono, monospace);
  font-size: 13px;
  font-weight: 600;
  color: var(--pe-sideways);
  border-left: 1px solid var(--pe-line);
  padding-left: 10px;
  margin-left: 2px;
}
.play-balance .streak-flame[hidden] { display: none; }
.streak-flame .flame {
  width: 14px;
  height: 18px;
  display: inline-block;
  transform-origin: 50% 90%;
}
.streak-flame.pe-live .flame { animation: pe-flicker 1.6s ease-in-out infinite; }
@keyframes pe-flicker {
  0%, 100% { transform: scale(1) rotate(-1deg); }
  50% { transform: scale(1.08) rotate(1.5deg); }
}
@media (prefers-reduced-motion: reduce) {
  .streak-flame.pe-live .flame { animation: none; }
}

/* the balance number pops briefly when it changes */
.play-balance .v.pe-bump { animation: pe-bump .45s ease-out; }
@keyframes pe-bump {
  0% { transform: scale(1.12); color: var(--pe-up); }
  100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .play-balance .v.pe-bump { animation: none; }
}

/* ---------- toast (replaces the flat green claim bar) ---------- */
.claim-toast.pe-toast {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--pe-panel);
  border: 1px solid var(--pe-line);
  border-left: 4px solid var(--pe-up);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
  color: var(--pe-text);
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 14px;
  animation: pe-slidein .35s ease-out;
}
.claim-toast.pe-toast[hidden] { display: none; }
@keyframes pe-slidein {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .claim-toast.pe-toast { animation: none; }
}
.pe-coin {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #FFE08A, #E0A526 60%, #8A5B0A);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .25);
}
.pe-toast-body { flex: 1 1 auto; min-width: 0; }
.pe-toast-title { font-size: 17px; font-weight: 700; color: var(--pe-up); }
.pe-toast-title.pe-neutral { color: var(--pe-text); }
.pe-toast-sub { color: var(--pe-muted); font-size: 13px; margin-top: 2px; overflow-wrap: anywhere; }
.pe-toast-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pe-toast-x {
  background: none;
  border: 0;
  color: var(--pe-muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
  align-self: flex-start;
}
.pe-toast-x:hover { color: var(--pe-text); }

/* ---------- share button ---------- */
.pe-share {
  background: transparent;
  border: 1px solid var(--pe-line);
  color: var(--pe-text);
  border-radius: 6px;
  font-family: var(--font-ui, system-ui, sans-serif);
  font-size: 12px;
  padding: 4px 10px;
  cursor: pointer;
  white-space: nowrap;
}
.pe-share:hover { border-color: var(--pe-up); color: var(--pe-up); }
.pe-share:disabled { opacity: .5; cursor: default; }

/* ---------- skeletons (fallback for site.css .skeleton) ---------- */
.pe-skeleton {
  display: block;
  background: linear-gradient(90deg, #1A2230 25%, #242E40 37%, #1A2230 63%);
  background-size: 400% 100%;
  border-radius: 6px;
  min-height: 14px;
  animation: pe-shimmer 1.4s ease infinite;
}
@keyframes pe-shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}
@media (prefers-reduced-motion: reduce) {
  .pe-skeleton { animation: none; }
}
.pe-skel-block { height: 120px; margin-bottom: 10px; }
.pe-skel-line { height: 14px; margin: 10px 0; }
.pe-skel-row td { padding: 12px 10px; }
.pe-skel-row .pe-skeleton { height: 12px; width: 70%; }
.pe-skel-stats { display: flex; gap: 10px; flex-wrap: wrap; }
.pe-skel-stats .pe-skeleton { height: 30px; width: 110px; }

/* ---------- friendly states (fallback for site.css .state-msg) ---------- */
.pe-state {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  border: 1px dashed var(--pe-line);
  border-radius: 8px;
  padding: 14px 16px;
  margin: 10px 0;
  color: var(--pe-muted);
  font-size: 14px;
  line-height: 1.5;
}
.pe-state b { color: var(--pe-text); font-weight: 600; }
.pe-state.pe-state-error { border-style: solid; border-color: rgba(255, 77, 94, .55); color: var(--pe-text); }
.pe-state.pe-state-info { border-style: solid; }
.pe-state.pe-state-empty { text-align: center; justify-content: center; }
.pe-state .btn { padding: 6px 12px; font-size: 13px; }
.pe-state[hidden] { display: none; }
.pe-state-text { flex: 1 1 240px; min-width: 0; }

/* ---------- My bets on phones: tables become cards ----------
   The open and history tables are 7 and 9 columns wide, which cut the SETTLES
   and RESULT columns off at 390px. Under 640px each row becomes a two-column
   card; each cell shows its header (data-label, set in play.js) above the value.
   Desktop keeps the table. */
@media (max-width: 640px) {
  .tbl-stack thead { display: none; }
  .tbl-stack, .tbl-stack tbody { display: block; width: 100%; }
  .tbl-stack tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px 12px;
    padding: 12px 14px;
    margin-bottom: 10px;
    background: var(--pe-panel);
    border: 1px solid var(--pe-line);
    border-radius: 10px;
  }
  .tbl-stack td {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
    padding: 0;
    border: 0;
    text-align: left;
    font-size: 13px;
    overflow-wrap: anywhere;
  }
  .tbl-stack td[data-label] { gap: 2px; }
  .tbl-stack td[data-label]::before {
    content: attr(data-label);
    font-family: var(--font-ui);
    font-size: 10.5px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--pe-muted);
  }
  .tbl-stack td:first-child:not([colspan]) { grid-column: 1 / -1; font-size: 16px; padding-bottom: 8px; border-bottom: 1px solid var(--pe-line); }
  .tbl-stack td:last-child:not([colspan]) { grid-column: 1 / -1; align-items: flex-end; }
  .tbl-stack td[colspan] { grid-column: 1 / -1; display: block; font-family: var(--font-ui); font-size: 13px; line-height: 1.5; }
}
