/* PlayTime Casino — own theme (dark / light / system)
 *
 * Two palettes are declared (dark, light) and a `system` mode that
 * follows `prefers-color-scheme`. The `data-theme` attribute on <html>
 * is set inline at the top of every page (before stylesheets apply) so
 * there's no flash of wrong colors on first paint.
 */

/* ============== Palette: DARK (default) ============== */
:root,
:root[data-theme="dark"] {
  --bg:        #0d0e15;
  --bg-2:      #14161f;
  --card:      #181b27;
  --card-hi:   #21253a;
  --border:    #2a2f44;
  --text:      #e9ecf3;
  --muted:     #8c93a8;
  --accent:    #f0b400;     /* gold */
  --accent-2:  #ff6a3d;     /* warm orange */
  --hero-grad: linear-gradient(135deg, #2c1d3d 0%, #1a1d2c 60%, #2a1f12 100%);
  --hero-text: #fff;
  --ok:        #39d27a;
  --err:       #ff5c5c;
  --shadow:    0 8px 30px rgba(0,0,0,0.45);
  --modal-bg:  rgba(8,9,14,0.7);
}

/* ============== Palette: LIGHT ============== */
:root[data-theme="light"] {
  --bg:        #f4f5f8;
  --bg-2:      #ffffff;
  --card:      #ffffff;
  --card-hi:   #f8f9fc;
  --border:    #e3e6ee;
  --text:      #181b27;
  --muted:     #6b7185;
  --accent:    #c89500;
  --accent-2:  #ff6a3d;
  --hero-grad: linear-gradient(135deg, #1f2540 0%, #2d2245 60%, #4a2618 100%);
  --hero-text: #fff;
  --ok:        #1f9c54;
  --err:       #d83a3a;
  --shadow:    0 8px 24px rgba(20,24,40,0.08);
  --modal-bg:  rgba(20,24,40,0.45);
}

/* ============== System: follow OS preference (light only override; dark
 *                already matches the default) ============== */
@media (prefers-color-scheme: light) {
  :root[data-theme="system"] {
    --bg:        #f4f5f8;
    --bg-2:      #ffffff;
    --card:      #ffffff;
    --card-hi:   #f8f9fc;
    --border:    #e3e6ee;
    --text:      #181b27;
    --muted:     #6b7185;
    --accent:    #c89500;
    --accent-2:  #ff6a3d;
    --hero-grad: linear-gradient(135deg, #1f2540 0%, #2d2245 60%, #4a2618 100%);
    --hero-text: #fff;
    --ok:        #1f9c54;
    --err:       #d83a3a;
    --shadow:    0 8px 24px rgba(20,24,40,0.08);
    --modal-bg:  rgba(20,24,40,0.45);
  }
}

/* ============== Reset ============== */
* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s, color 0.2s;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code, .mono {
  font-family: ui-monospace, SFMono-Regular, "JetBrains Mono", Consolas, monospace;
}

/* ============== Generic utilities ============== */
.muted        { color: var(--muted); }
.muted-link   { color: var(--muted); cursor: pointer; text-decoration: underline; }
.small        { font-size: 0.85em; }
.ok           { color: var(--ok); }
.err          { color: var(--err); }
.center       { text-align: center; }
.mt-1         { margin-top: 1em; }
.no-margin-top{ margin-top: 0; }
.block        { display: block; width: 100%; }

p { margin: 8px 0; }
h1, h2, h3 { margin: 0; }

/* ============== Inputs ============== */
input[type="text"], input[type="tel"], input[type="number"],
input[type="password"], input:not([type]) {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 1em;
  font-family: inherit;
  letter-spacing: 0.04em;
  transition: border 0.15s, box-shadow 0.15s;
}
input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(240,180,0,0.18);
}

.lbl {
  display: block;
  font-size: 0.78em;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  margin: 14px 0 6px;
}

/* ============== Buttons ============== */
button, .btn-link {
  display: inline-block;
  padding: 11px 16px;
  font-size: 0.95em;
  font-weight: 600;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card-hi);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  text-decoration: none;
  transition: transform 0.05s, opacity 0.15s, background 0.15s;
}
button:active, .btn-link:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

button.primary, .btn-link.primary {
  background: linear-gradient(180deg, var(--accent),
              color-mix(in srgb, var(--accent) 70%, black));
  color: #1a1300;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(240,180,0,0.25);
}

button.ghost, .btn-link.ghost {
  background: transparent;
  border: 1px solid var(--border);
}
button.ghost.danger, .btn-link.ghost.danger {
  color: var(--err);
  border-color: rgba(255,92,92,0.35);
}

button.big {
  font-size: 1.05em;
  padding: 14px 18px;
  border-radius: 12px;
}

button.copy-btn {
  padding: 7px 11px;
  font-size: 0.85em;
  font-weight: 500;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}
button.copy-btn.copied {
  color: var(--ok);
  border-color: var(--ok);
}

.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* ============== Auth pages (login, signup) ============== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px 80px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px 24px;
  box-shadow: var(--shadow);
}

.brand-h1 {
  text-align: center;
  font-size: 1.5em;
  margin-bottom: 4px;
}

.or-line {
  margin: 22px 0 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.or-line::before, .or-line::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}

.footer-note { margin-top: 22px; }

.auth-footer {
  position: fixed;
  bottom: 16px;
  left: 0; right: 0;
  display: flex; justify-content: center; gap: 6px;
}

/* ============== Theme buttons ============== */
.theme-btn {
  padding: 6px 10px;
  font-size: 1em;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--border);
  cursor: pointer;
}
.theme-btn.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(240,180,0,0.25);
}

/* ============== Maker Key reveal (signup stage 2) ============== */
.key-reveal {
  margin: 18px 0;
  padding: 22px;
  background: var(--card-hi);
  border: 2px dashed var(--accent);
  border-radius: 14px;
  text-align: center;
}
.key-reveal-key {
  font-family: ui-monospace, SFMono-Regular, "JetBrains Mono", Consolas, monospace;
  font-size: 2.2em;
  letter-spacing: 0.18em;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 14px;
  word-break: break-all;
}
.warn-box {
  background: color-mix(in srgb, var(--err) 8%, var(--card));
  border: 1px solid color-mix(in srgb, var(--err) 35%, var(--border));
  border-radius: 10px;
  padding: 12px 14px;
  margin: 14px 0;
}
.warn-box strong { color: var(--err); }

/* ============== Dashboard ============== */
.dashboard-page {
  padding: 16px 14px 60px;
  max-width: 480px;
  margin: 0 auto;
}

.dash-greet {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 4px 14px;
}
.hello {
  font-size: 1.4em;
  font-weight: 700;
}
.theme-row { display: flex; gap: 4px; }

.dash-grid { display: flex; flex-direction: column; gap: 14px; }

/* Hero card */
.hero-card {
  background: var(--hero-grad);
  color: var(--hero-text);
  border-radius: 18px;
  padding: 26px 22px;
  box-shadow: var(--shadow);
}
.hero-label {
  text-align: center;
  font-size: 0.75em;
  letter-spacing: 1.5px;
  opacity: 0.85;
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.hero-balance {
  text-align: center;
  font-size: 2.6em;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.hero-divider {
  height: 1px;
  background: rgba(255,255,255,0.18);
  margin: 18px 0 14px;
}
.hero-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  text-align: center;
}
.hero-stat-num {
  font-size: 1.4em;
  font-weight: 700;
  color: var(--accent);
}
.hero-stat-lbl {
  font-size: 0.7em;
  letter-spacing: 1.2px;
  opacity: 0.75;
  font-weight: 600;
  text-transform: uppercase;
  margin-top: 2px;
}

/* Info card */
.info-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.info-label {
  font-size: 0.72em;
  letter-spacing: 1.3px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 8px;
}
.info-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.info-value {
  font-size: 1.15em;
  letter-spacing: 0.12em;
  color: var(--accent);
  font-weight: 600;
  flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lock-icon {
  font-size: 0.85em;
  margin-left: 4px;
  opacity: 0.7;
}

/* Actions */
.action-row { display: flex; flex-direction: column; gap: 6px; }
.action-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Schedule */
.schedule {
  background: linear-gradient(135deg,
              color-mix(in srgb, var(--accent) 7%, var(--card)),
              var(--card));
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
}
.schedule strong { color: var(--accent); }
.schedule em     { color: var(--muted); }

/* ============== Modal ============== */
.modal-bg {
  position: fixed; inset: 0;
  background: var(--modal-bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; padding: 16px;
  backdrop-filter: blur(4px);
}
.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { font-size: 1.1em; }
.modal-x {
  background: transparent;
  border: none;
  font-size: 1.2em;
  padding: 4px 8px;
  color: var(--muted);
}
.modal-body { padding: 18px 20px; }

/* Withdraw amount preview */
.balance-preview {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 12px 0;
}
.balance-preview strong {
  font-size: 1.3em; color: var(--accent);
}

/* History lists */
.recent-list .item {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.recent-list .item:last-child { border-bottom: none; }
.recent-list code {
  background: var(--bg-2);
  padding: 1px 6px;
  border-radius: 4px;
}
.recent-list .receipt-link {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--accent);
  font-weight: 600;
  font-size: 0.9em;
}
.recent-list .receipt-link:hover {
  background: color-mix(in srgb, var(--accent) 35%, transparent);
  text-decoration: none;
}

/* Disable transitions on theme change to avoid jank */
.no-transition * { transition: none !important; }
