:root {
  --bg: #F3F4F6;
  --surface: #FFFFFF;
  --surface2: #F9FAFB;
  --surface3: #E5E7EB;
  --text: #111827;
  --text2: #4B5563;
  --text3: #9CA3AF;
  --accent: #2563EB; 
  --yes: #EF4444;    
  --no: #10B981;     
  --green: #10B981;
  --red: #EF4444;
  --border: #D1D5DB;
  --shadow: rgba(0, 0, 0, 0.05);
  --shadow-hover: rgba(0, 0, 0, 0.15);
  --modal-bg: rgba(0, 0, 0, 0.4);
  --radius: 4px;
  --header-h: 56px;
  --bottom-h: 60px;
}

[data-theme='dark'] {
  --bg: #0F172A;
  --surface: #1E293B;
  --surface2: #334155;
  --surface3: #475569;
  --text: #F8FAFC;
  --text2: #CBD5E1;
  --text3: #94A3B8;
  --accent: #38BDF8;
  --border: #334155;
  --shadow: rgba(0, 0, 0, 0.3);
  --shadow-hover: rgba(0, 0, 0, 0.5);
  --modal-bg: rgba(0, 0, 0, 0.7);
  --yes: #F87171;
  --no: #4ADE80;
  --green: #4ADE80;
  --red: #F87171;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 14px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Base resets & utility overrides */
.glass-card, .train-card, .btn-primary, .modal, .toast, .trade-summary {
  box-shadow: none !important;
  backdrop-filter: none !important;
  background: var(--surface);
}

a { color: var(--text); text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input { font-family: inherit; }

.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--text);
  color: var(--surface);
  border: 1px solid var(--text);
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  transition: background 0.1s;
}
.btn-primary:hover { background: #000; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

/* LAYOUT */
#main-header {
  position: sticky; top: 0; z-index: 100; height: var(--header-h);
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1200px; margin: 0 auto; height: 100%; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between;
}
.header-actions { display: flex; align-items: center; }
.logo-text { font-size: 1.25rem; font-weight: 900; letter-spacing: -0.5px; text-transform: uppercase; color: var(--text); }
.logo-icon { display: none; }

.user-badge {
  display: flex; align-items: center; gap: 8px; padding: 4px 10px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface2); cursor: pointer;
}
.user-avatar { display: none; }
.user-info { display: flex; align-items: baseline; gap: 8px; }
.user-name { font-size: 0.8rem; font-weight: 800; text-transform: uppercase; }
.user-coins { font-size: 0.85rem; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.btn-login { padding: 6px 12px; font-weight: 700; text-transform: uppercase; font-size: 0.8rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.btn-login:hover { background: var(--surface2); }

/* MAIN CONTAINER */
.hidden { display: none !important; }
#main-content {
  max-width: 1200px; margin: 0 auto; padding: 24px 24px calc(var(--bottom-h) + 20px);
}
.view { display: none; }
.view.active { display: block; }
.section-header { margin-bottom: 12px; border-bottom: 2px solid var(--text); padding-bottom: 4px; display: flex; justify-content: space-between; align-items: baseline; }
.section-header h2 { font-size: 1.1rem; font-weight: 800; text-transform: uppercase; }
.train-count { font-size: 0.8rem; font-weight: 700; color: var(--text2); }

/* TRAIN CARDS - Data Row Style */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 16px; }
.train-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 20px; display: flex; flex-direction: column; gap: 8px;
  background: var(--surface); cursor: pointer; transition: all 0.15s;
}
.train-card:hover { border-color: var(--text); box-shadow: 0 4px 12px var(--shadow); transform: translateY(-2px); }
.train-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin: 0; }
.train-time { font-size: 1.4rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.5px; line-height: 1; }
.train-destination { font-size: 1.05rem; font-weight: 800; text-transform: uppercase; margin-top: 4px; }
.train-category { font-size: 0.75rem; color: var(--text2); text-transform: uppercase; font-weight: 700; }

.train-badges { display: flex; gap: 6px; margin-top: 4px; }
.badge { padding: 2px 6px; font-size: 0.7rem; font-weight: 800; border-radius: 2px; text-transform: uppercase; border: 1px solid var(--border); }
.badge-platform { background: var(--surface2); color: var(--text); }
.badge-price { background: var(--yes); color: white; border-color: var(--yes); font-variant-numeric: tabular-nums; }
.badge-ontime { background: var(--no); color: white; border-color: var(--no); }
.badge-delayed { background: var(--yes); color: white; border-color: var(--yes); }

.train-card-footer { display: flex; justify-content: space-between; align-items: center; border-top: 1px dashed var(--border); padding-top: 16px; margin-top: 8px; }
.train-meta { font-size: 0.75rem; color: var(--text2); font-weight: 600; font-variant-numeric: tabular-nums; }
.btn-trade-sm { padding: 8px 16px; border: 1px solid var(--text); background: var(--text); color: var(--surface); font-weight: 800; font-size: 0.8rem; border-radius: var(--radius); text-transform: uppercase; transition: all 0.15s; cursor: pointer; }
.btn-trade-sm:hover { opacity: 0.9; box-shadow: 0 4px 12px var(--shadow-hover); transform: translateY(-1px); }

/* MODAL - TRADING TICKET */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--modal-bg);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  overflow-y: auto;
  padding: 18px 12px;
  -webkit-overflow-scrolling: touch;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  position: relative;
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* PUBLIC PROFILE (Polymarket-like) */
.public-profile-modal { max-width: 980px; }
.public-profile-header {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
.public-profile-card { border: 1px solid var(--border); padding: 16px; background: var(--surface); }
.public-profile-top { display:flex; gap: 12px; align-items:center; }
.public-profile-ident { display:flex; flex-direction:column; gap: 2px; min-width: 0; }
.public-profile-name { font-size: 1.2rem; font-weight: 900; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.public-profile-sub { font-size: .8rem; color: var(--text2); font-weight: 700; }
.public-profile-metrics {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.ppm-item { border: 1px solid var(--border); background: var(--surface2); padding: 10px; border-radius: var(--radius); }
.ppm-label { font-size: .65rem; font-weight: 900; text-transform: uppercase; color: var(--text2); }
.ppm-value { margin-top: 6px; font-size: 1.1rem; font-weight: 900; font-variant-numeric: tabular-nums; }

.public-profile-chart-head { display:flex; justify-content:space-between; align-items:baseline; gap: 12px; margin-bottom: 8px; }
.ppc-title { font-size: .75rem; font-weight: 900; text-transform: uppercase; color: var(--text2); }
.ppc-sub { font-size: .75rem; font-weight: 900; color: var(--text3); }
.public-profile-chart { height: 92px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface2); padding: 6px; }

.public-profile-tabs { display:flex; gap: 10px; border-bottom: 2px solid var(--text); margin: 4px 0 12px; }
.pp-tab {
  background: none;
  border: none;
  font-weight: 900;
  text-transform: uppercase;
  font-size: .8rem;
  padding: 10px 2px;
  color: var(--text3);
  border-bottom: 2px solid transparent;
}
.pp-tab.active { color: var(--text); border-bottom-color: var(--text); }
.public-profile-body { }
.pp-panel { display:none; }
.pp-panel.active { display:block; }
.pp-panel-head { display:flex; justify-content:space-between; align-items:center; margin-bottom: 10px; }
.pp-panel-title { font-size: .85rem; font-weight: 900; text-transform: uppercase; }
.pp-muted { font-size: .75rem; font-weight: 900; color: var(--text3); text-transform: uppercase; }

.pp-table { width: 100%; border-collapse: collapse; border: 1px solid var(--border); background: var(--surface); }
.pp-table th { text-align:left; padding: 10px 12px; border-bottom: 2px solid var(--text); background: var(--surface2); font-size: .7rem; text-transform: uppercase; font-weight: 900; }
.pp-table td { padding: 12px; border-bottom: 1px solid var(--border); font-size: .85rem; font-weight: 800; vertical-align: middle; }
.pp-table tr:hover { background: var(--surface2); }
.pp-pos-market { font-weight: 900; text-transform: uppercase; }
.pp-pos-sub { font-size: .75rem; color: var(--text2); font-weight: 700; margin-top: 2px; }
.pp-pill { display:inline-block; padding: 2px 6px; border: 1px solid var(--border); border-radius: 999px; font-size: .65rem; font-weight: 900; text-transform: uppercase; background: var(--surface); }
.pp-pill.yes { border-color: var(--yes); color: var(--yes); }
.pp-pill.no { border-color: var(--no); color: var(--no); }

@media (max-width: 860px) {
  .public-profile-header { grid-template-columns: 1fr; }
  .public-profile-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.market-header { border-bottom: 2px solid var(--text); padding-bottom: 12px; margin-bottom: 16px; display: flex; justify-content: space-between; align-items: center; padding-right: 40px; }
.modal h3 { font-size: 1.2rem; font-weight: 800; text-transform: uppercase; margin: 0; line-height: 1.2; }
.modal-close { position: absolute; top: 18px; right: 18px; background: none; border: none; font-size: 2rem; line-height: 0.5; font-weight: bold; cursor: pointer; color: var(--text3); padding: 8px; }
.modal-close:hover { color: var(--text); }

.market-status-badge { display: inline-block; padding: 2px 6px; border: 1px solid var(--no); color: var(--no); font-size: 0.75rem; font-weight: 800; text-transform: uppercase; border-radius: 2px; }
.market-status-badge.closed { border-color: var(--text3); color: var(--text3); }
.market-question { display: none; }

.market-info { display: flex; border: 1px solid var(--border); margin-bottom: 20px; border-radius: var(--radius); overflow: hidden; }
.market-info-item { flex: 1; text-align: center; padding: 10px; border-right: 1px solid var(--border); background: var(--surface2); }
.market-info-item:last-child { border-right: none; }
.market-info-item .label { font-size: 0.65rem; font-weight: 800; text-transform: uppercase; color: var(--text2); display: block; }
.market-info-item .value { font-size: 0.95rem; font-weight: 800; margin-top: 4px; display: block; }

/* PRICE BOXES */
.market-price-display { display: flex; gap: 12px; margin-bottom: 24px; }
.price-box { flex: 1; text-align: center; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.yes-box { border-bottom: 4px solid var(--yes); }
.no-box { border-bottom: 4px solid var(--no); }
.price-label { font-size: 0.75rem; font-weight: 800; text-transform: uppercase; color: var(--text); display: block; }
.price-value { font-size: 2rem; font-weight: 900; font-variant-numeric: tabular-nums; margin-top: 4px; display: block; }
.yes-box .price-value { color: var(--yes); }
.no-box .price-value { color: var(--no); }
.market-chart { display: none; }

/* TOGGLES */
.trade-controls { margin-bottom: 16px; }
.trade-type-toggle { display: flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 16px; }
.trade-toggle, .trade-mode-toggle { flex: 1; padding: 12px; background: var(--surface2); border: none; font-weight: 800; font-size: 0.85rem; text-transform: uppercase; color: var(--text2); border-right: 1px solid var(--border); transition: none; }
.trade-toggle:last-child, .trade-mode-toggle:last-child { border-right: none; }
.trade-toggle.active[data-side="yes"] { background: var(--yes); color: white; }
.trade-toggle.active[data-side="no"] { background: var(--no); color: white; }
.trade-mode-toggle.active { background: var(--text); color: white; }

.form-group label { display: block; font-size: 0.8rem; font-weight: 800; text-transform: uppercase; margin-bottom: 6px; }
.form-group input { width: 100%; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 1.1rem; font-weight: 800; font-variant-numeric: tabular-nums; background: var(--surface); color: var(--text); }
.form-group input:focus { outline: none; border-color: var(--text); }
.form-switch { margin-top: 16px; font-size: 0.85rem; text-align: center; color: var(--text2); font-weight: 600; }
.form-switch a { color: var(--text); font-weight: 800; text-decoration: underline; text-underline-offset: 2px; }
.form-switch a:hover { color: var(--accent); }

/* TRADE SUMMARY */
.trade-summary { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface2); padding: 12px; margin: 16px 0; }
.trade-summary-row { display: flex; justify-content: space-between; font-size: 0.85rem; padding: 4px 0; font-weight: 700; color: var(--text2); }
.trade-summary-row span.accent { font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.trade-summary-row.profit-row { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 8px; color: var(--text); }

/* HOLDINGS */
.my-holdings { border-top: 2px solid var(--text); padding-top: 16px; margin-top: 24px; }
.my-holdings h4 { font-size: 0.9rem; font-weight: 800; text-transform: uppercase; margin-bottom: 12px; }
.holding-row { display: flex; justify-content: space-between; padding: 10px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 6px; font-size: 0.85rem; font-weight: 800; }

/* BOTTOM NAV */
#bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; height: var(--bottom-h); background: var(--surface); border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-around; z-index: 100; }
.nav-btn { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px; background: none; border: none; font-size: 0.65rem; font-weight: 800; text-transform: uppercase; color: var(--text3); }
.nav-btn.active { color: var(--text); }

/* TOASTS */
#toast-container { position: fixed; top: 16px; right: 16px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 14px 20px; background: var(--surface); border: 1px solid var(--text); font-size: 0.85rem; font-weight: 800; border-left: 6px solid var(--text); box-shadow: 4px 4px 0px rgba(0,0,0,0.1); animation: toastIn 0.2s ease, toastOut 0.2s ease 2.7s forwards; }
.toast.success { border-left-color: var(--no); }
.toast.error { border-left-color: var(--yes); }
@keyframes toastIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastOut { to { transform: translateX(100%); opacity: 0; } }

/* LEADERBOARD & PROFILE */
.lb-empty { text-align: center; padding: 40px 20px; border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); }

/* LEADERBOARD PODIUM */
.lb-podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 12px;
  margin-bottom: 32px;
  padding-top: 40px;
  height: 240px;
}
@media(max-width: 480px) { .lb-podium { gap: 6px; } }

.podium-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  max-width: 110px;
  position: relative;
  animation: lbPopIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}
.podium-col.rank-1 { animation-delay: 0s; z-index: 3; }
.podium-col.rank-2 { animation-delay: 0.1s; z-index: 2; }
.podium-col.rank-3 { animation-delay: 0.2s; z-index: 1; }

.podium-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 900;
  color: #111;
  margin-bottom: 8px;
  position: relative;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.podium-crown {
  position: absolute;
  top: -24px;
  font-size: 1.5rem;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
  animation: tutBounce 2s infinite ease-in-out;
}
.podium-avatar.gold { background: linear-gradient(135deg, #FFDF00, #D4AF37); box-shadow: 0 0 20px rgba(255, 223, 0, 0.4); border: 2px solid #FFF; }
.podium-avatar.silver { background: linear-gradient(135deg, #E0E0E0, #9E9E9E); border: 2px solid #FFF; }
.podium-avatar.bronze { background: linear-gradient(135deg, #CD7F32, #8C5A23); border: 2px solid #FFF; }

.podium-name { font-weight: 800; font-size: 0.9rem; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%; margin-bottom: 2px; }
.podium-name a { color: var(--text); text-decoration: none; }
.podium-name a:hover { color: var(--accent); }
.podium-bal { font-size: 0.75rem; color: var(--text2); font-weight: 700; margin-bottom: 12px; }

.podium-bar {
  width: 100%;
  border-radius: 8px 8px 0 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-bottom: none;
  position: relative;
  overflow: hidden;
}
.podium-col.rank-1 .podium-bar { background: linear-gradient(180deg, rgba(255,223,0,0.15) 0%, var(--surface2) 100%); border-color: rgba(255,223,0,0.3); }
.podium-col.rank-2 .podium-bar { background: linear-gradient(180deg, rgba(224,224,224,0.1) 0%, var(--surface2) 100%); }
.podium-col.rank-3 .podium-bar { background: linear-gradient(180deg, rgba(205,127,50,0.1) 0%, var(--surface2) 100%); }

.podium-rank-num { font-size: 2rem; font-weight: 900; color: var(--text); opacity: 0.15; }

@keyframes lbPopIn {
  0% { transform: translateY(40px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

/* LEADERBOARD TABLE MODERN */
.lb-table-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto; /* allows scrolling on very small screens */
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}
.leaderboard-table.modern { width: 100%; border-collapse: collapse; border: none; min-width: 400px; }
.leaderboard-table.modern th { text-align: left; padding: 16px; border-bottom: 1px solid var(--border); background: rgba(255,255,255,0.02); font-size: 0.75rem; text-transform: uppercase; font-weight: 800; color: var(--text2); }
.leaderboard-table.modern td { padding: 16px; border-bottom: 1px solid rgba(255,255,255,0.05); font-size: 0.9rem; font-weight: 700; font-variant-numeric: tabular-nums; vertical-align: middle; }
.leaderboard-table.modern tr:last-child td { border-bottom: none; }
.leaderboard-table.modern tr { transition: background 0.2s; animation: lbFadeInRow 0.4s ease-out backwards; }
.leaderboard-table.modern tr:hover { background: rgba(255,255,255,0.04); }

@keyframes lbFadeInRow {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

.lb-rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--surface2);
  color: var(--text2);
  font-size: 0.75rem;
  font-weight: 800;
}
.lb-user a { color: var(--text); text-decoration: none; transition: color 0.2s; font-weight: 800; text-transform: uppercase; }
.lb-user a:hover { color: var(--accent); }
.lb-balance { font-weight: 800; color: var(--text); }

.wr-visual { display: flex; align-items: center; gap: 8px; }
.wr-bar-bg { flex: 1; max-width: 60px; height: 6px; background: var(--surface2); border-radius: 3px; overflow: hidden; display: inline-block;}
.wr-bar-fill { height: 100%; border-radius: 3px; transition: width 1s ease-out; }


.profile-card { border: 1px solid var(--border); padding: 24px; text-align: center; background: var(--surface); margin-bottom: 16px; }
.profile-avatar { width: 64px; height: 64px; margin: 0 auto 16px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; font-size: 1.8rem; font-weight: 800; color: var(--text); }
.profile-stats { display: flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 16px; }
.stat-box { flex: 1; padding: 16px; border-right: 1px solid var(--border); background: var(--surface2); text-align: center; }
.stat-box:last-child { border-right: none; }
.stat-value { font-size: 1.4rem; font-weight: 900; font-variant-numeric: tabular-nums; display: block; }
.stat-label { font-size: 0.65rem; font-weight: 800; text-transform: uppercase; color: var(--text2); margin-top: 4px; display: block; }

.bonus-card { margin-bottom: 16px; padding: 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border: 2px solid var(--accent); background: var(--surface); }
.bonus-info { display: flex; align-items: center; gap: 16px; }
.bonus-icon { font-size: 2.2rem; }
.bonus-text h4 { margin: 0; font-size: 0.95rem; font-weight: 900; text-transform: uppercase; }
.bonus-text p { margin: 4px 0 0; font-size: 0.8rem; font-weight: 700; color: var(--text2); }
.btn-claim-bonus { background: var(--accent); color: white; border: none; padding: 12px 18px; font-weight: 900; font-size: 0.8rem; border-radius: var(--radius); text-transform: uppercase; cursor: pointer; transition: transform 0.15s, opacity 0.15s; }
.btn-claim-bonus:hover:not(:disabled) { transform: scale(1.03); }
.btn-claim-bonus:disabled { opacity: 0.6; cursor: not-allowed; }

.profile-portfolio, .trade-history { border: 1px solid var(--border); padding: 16px; background: var(--surface); margin-bottom: 16px; }
.profile-portfolio h4, .trade-history h4 { font-size: 0.9rem; font-weight: 800; text-transform: uppercase; border-bottom: 2px solid var(--text); padding-bottom: 8px; margin-bottom: 12px; }
.history-select { padding: 4px 8px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); font-size: 0.75rem; font-weight: 800; text-transform: uppercase; cursor: pointer; outline: none; }
.history-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 10px; margin: 0 -10px; border-bottom: 1px dashed var(--border); border-radius: var(--radius); transition: background 0.15s; }
.history-row:hover { background: var(--surface2); }
.history-dest { font-weight: 800; text-transform: uppercase; font-size: 0.85rem; }
.history-time { font-size: 0.75rem; color: var(--text2); font-variant-numeric: tabular-nums; font-weight: 600; }
.btn-logout { display: block; width: 100%; padding: 12px; margin-top: 16px; border: 1px solid var(--yes); color: var(--yes); font-size: 0.85rem; font-weight: 800; text-transform: uppercase; text-align: center; border-radius: var(--radius); background: transparent; cursor: pointer; transition: all 0.15s; }
.btn-logout:hover { background: var(--yes); color: white; }
.btn-delete-account { display: block; width: 100%; padding: 10px; margin-top: 8px; border: 1px solid var(--border); color: var(--text3); font-size: 0.8rem; font-weight: 700; text-transform: uppercase; text-align: center; border-radius: var(--radius); background: transparent; cursor: pointer; transition: all 0.15s; }
.btn-delete-account:hover { border-color: var(--yes); color: var(--yes); }
.btn-tutorial-replay { display: block; width: 100%; padding: 12px; margin-top: 16px; border: 2px dashed var(--accent); color: var(--accent); font-size: 0.85rem; font-weight: 800; text-transform: uppercase; text-align: center; border-radius: var(--radius); background: transparent; cursor: pointer; transition: all 0.15s; }
.btn-tutorial-replay:hover { background: var(--accent); color: white; border-style: solid; }
.portfolio-card { justify-content: space-between; height: 100%; }
.portfolio-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.history-side { padding: 2px 6px; font-weight: 800; font-size: 0.7rem; text-transform: uppercase; border: 1px solid; border-radius: 2px; }
.history-side.side-yes { color: var(--yes); border-color: var(--yes); background: var(--surface); }
.history-side.side-no { color: var(--no); border-color: var(--no); background: var(--surface); }
.history-status { font-weight: 800; font-size: 0.7rem; text-transform: uppercase; }
.history-status.won { color: var(--no); }
.history-status.lost { color: var(--yes); }
.history-status.open { color: var(--text2); }

.demo-banner { border: 1px solid var(--text); background: var(--text); color: var(--surface); padding: 12px; font-weight: 800; font-size: 0.85rem; text-align: center; border-radius: var(--radius); margin-bottom: 16px; text-transform: uppercase; display: flex; align-items: center; justify-content: center; gap: 8px; }

/* DANGER MODAL */
.modal-danger { max-width: 400px; }
.danger-header { display: flex; align-items: center; gap: 12px; border-bottom: 2px solid var(--yes); padding-bottom: 12px; margin-bottom: 16px; padding-right: 40px; }
.danger-header h3 { font-size: 1.1rem; font-weight: 800; text-transform: uppercase; margin: 0; color: var(--yes); }
.danger-icon { font-size: 1.5rem; }
.danger-desc { font-size: 0.85rem; color: var(--text2); margin-bottom: 20px; line-height: 1.5; border-left: 3px solid var(--yes); padding-left: 12px; }
.form-error { background: var(--yes); color: white; padding: 10px 12px; font-size: 0.8rem; font-weight: 800; border-radius: var(--radius); margin-bottom: 12px; }
.btn-danger-confirm { display: block; width: 100%; padding: 14px; margin-top: 16px; border: 2px solid var(--yes); color: var(--yes); font-size: 0.85rem; font-weight: 800; text-transform: uppercase; text-align: center; border-radius: var(--radius); background: transparent; cursor: pointer; transition: all 0.2s; }
.btn-danger-confirm:not(:disabled):hover { background: var(--yes); color: white; }
.btn-danger-confirm:disabled { opacity: 0.4; cursor: not-allowed; }



/* LANG DROPDOWN */
.header-actions { display: flex; align-items: center; gap: 12px; }

.theme-toggle-btn {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  transition: background 0.2s, color 0.2s;
}

.theme-toggle-btn:hover {
  background: var(--surface3);
  color: var(--text);
}

[data-theme='dark'] .sun-icon { display: none; }
[data-theme='dark'] .moon-icon { display: block !important; }

.global-search-container { margin-bottom: 24px; }
.search-box { position: relative; display: flex; align-items: center; background: var(--surface2); border: 2px solid var(--border); border-radius: 8px; padding: 0 16px; height: 48px; transition: all 0.2s; }
.search-box:focus-within { border-color: var(--accent); background: var(--surface); box-shadow: 0 4px 12px var(--shadow); }
#search-input { width: 100%; background: transparent; border: none; outline: none; color: var(--text); font-family: inherit; font-size: 16px; font-weight: 600; margin-left: 12px; }
#search-input::placeholder { color: var(--text3); font-weight: 500; }

.user-area { display: flex; align-items: center; }
.lang-dropdown { position: relative; margin-right: 12px; }
.lang-dropdown-btn { background: var(--surface); border: 1px solid var(--border); color: var(--text); padding: 6px 10px; font-size: 0.8rem; font-weight: 800; border-radius: var(--radius); cursor: pointer; display: flex; align-items: center; gap: 6px; }
.lang-dropdown-btn:hover { background: var(--surface2); }
.lang-dropdown-menu { position: absolute; top: 100%; right: 0; margin-top: 4px; background: var(--surface); border: 1px solid var(--text); border-radius: var(--radius); overflow: hidden; z-index: 1000; min-width: 120px; box-shadow: 4px 4px 0px var(--shadow); }
.lang-option { padding: 10px 14px; font-size: 0.8rem; font-weight: 800; cursor: pointer; display: flex; align-items: center; gap: 8px; transition: background 0.15s; }
.lang-option:hover { background: var(--surface2); }
.lang-option.active { background: var(--text); color: var(--surface); }

.btn-login { padding: 6px 12px; border: 2px solid var(--text); background: var(--text); color: var(--surface); font-weight: 800; font-size: 0.8rem; border-radius: var(--radius); text-transform: uppercase; cursor: pointer; transition: all 0.15s; }

/* LOADERS */
.loader-overlay { position: fixed; inset: 0; background: var(--bg); z-index: 9999; display: flex; flex-direction: column; align-items: center; justify-content: center; transition: opacity 0.2s; }
.loader-spinner { width: 32px; height: 32px; border: 3px solid var(--surface2); border-top-color: var(--text); border-radius: 50%; animation: spin 0.8s linear infinite; }
.loader-text { margin-top: 16px; font-size: 0.8rem; font-weight: 800; text-transform: uppercase; color: var(--text2); }
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton { background: var(--surface3); animation: pulse 1.5s infinite; border-radius: var(--radius); }
@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.5; } 100% { opacity: 1; } }
.skeleton-card { height: 100px; }

/* COOKIE BANNER & LEGAL */
.cookie-banner { position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000; background: var(--text); color: var(--surface); padding: 16px 24px; border-top: 4px solid var(--accent); }
.cookie-content { max-width: 1200px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.cookie-content p { font-size: 0.85rem; font-weight: 700; margin: 0; line-height: 1.4; }
.cookie-content button { background: var(--surface); color: var(--text); border: 2px solid var(--surface); flex-shrink: 0; padding: 10px 16px; font-size: 0.8rem; font-weight: 800; border-radius: var(--radius); cursor: pointer; text-transform: uppercase; transition: background 0.15s; }
.cookie-content button:hover { background: var(--surface2); }
/* FOOTER RINNOVATO */
.app-footer { margin-top: 48px; border-top: 1px solid var(--border); padding-top: 32px; display: flex; flex-direction: column; gap: 24px; }
.footer-legal { font-size: 0.75rem; color: var(--text2); line-height: 1.6; text-transform: uppercase; }
.footer-legal strong { color: var(--text); font-weight: 800; }
.privacy-link { display: inline-block; margin-top: 8px; font-weight: 800; color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.privacy-link:hover { color: var(--accent); }
.footer-bottom { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 16px; }
.footer-brand { font-size: 1.5rem; font-weight: 900; letter-spacing: -1px; text-transform: uppercase; color: var(--text); line-height: 1; }
.footer-links { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.footer-links a { font-size: 0.8rem; font-weight: 800; text-transform: uppercase; color: var(--text2); text-decoration: none; transition: color 0.15s; }
.footer-links a:hover { color: var(--text); }
.footer-author { font-size: 0.75rem; font-weight: 800; color: var(--text3); border-left: 1px solid var(--border); padding-left: 16px; }

/* Responsive adjustments */
.header-tabs { display: none; }

@media(min-width: 640px) {
  #bottom-nav { display: none; }
  #main-content { padding-bottom: 32px; }
  .header-tabs { display: flex; gap: 16px; }
  .tab-btn { display: flex; align-items: center; gap: 6px; background: none; border: none; font-size: 0.85rem; font-weight: 800; text-transform: uppercase; padding: 10px 12px; color: var(--text3); transition: all 0.15s; cursor: pointer; border-bottom: 2px solid transparent; }
  .tab-btn:hover { color: var(--text); }
  .tab-btn.active { color: var(--text); border-bottom-color: var(--text); }
}
/* WHEEL MODAL */
.wheel-modal { text-align: center; max-width: 320px !important; padding: 20px !important; }
.wheel-header { margin-bottom: 16px; }
.wheel-header h3 { font-size: 1.1rem; font-weight: 900; text-transform: uppercase; margin-bottom: 2px; }
.wheel-header p { font-size: 0.75rem; font-weight: 700; color: var(--text2); }

.wheel-container { position: relative; width: 220px; height: 220px; margin: 0 auto 20px; }
.wheel-pointer { position: absolute; top: -8px; left: 50%; transform: translateX(-50%); width: 24px; height: 30px; background: var(--text); clip-path: polygon(0 0, 100% 0, 50% 100%); z-index: 10; filter: drop-shadow(0 4px 4px rgba(0,0,0,0.2)); }
.wheel { position: relative; width: 100%; height: 100%; border-radius: 50%; border: 6px solid var(--text); overflow: hidden; transition: transform 4s cubic-bezier(0.15, 0, 0.15, 1); background: var(--text); box-shadow: 0 0 0 4px var(--surface), 0 8px 24px var(--shadow-hover); }
.wheel-segment { position: absolute; width: 50%; height: 50%; left: 50%; top: 50%; transform-origin: 0 0; background: var(--color); display: flex; align-items: center; justify-content: center; clip-path: polygon(0 0, 100% 0, 100% 100%); transform: rotate(calc(45deg * (var(--i) - 1))) translate(-100%, -100%); }
.wheel-segment span { position: absolute; left: 58%; top: 40%; transform: rotate(22deg); font-weight: 900; font-size: 0.95rem; color: white; text-shadow: 0 1px 3px rgba(0,0,0,0.3); }

.wheel-result { margin-top: 12px; padding: 12px; border-radius: var(--radius); font-weight: 800; font-size: 0.95rem; text-transform: uppercase; animation: pop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.wheel-result.win { background: var(--no); color: white; }
@keyframes pop { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }

@media(max-width: 639px) {
  .bonus-card { flex-direction: column; text-align: center; }
  .bonus-info { flex-direction: column; gap: 8px; }
}

/* ============================================
   TUTORIAL SYSTEM
   ============================================ */

/* Welcome Modal Overlay */
.tutorial-welcome-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: tutFadeIn 0.3s ease;
}

.tutorial-welcome-modal {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 40px 32px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  animation: tutSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.tutorial-welcome-icon {
  font-size: 4rem;
  margin-bottom: 16px;
  animation: tutBounce 1s ease infinite;
}

.tutorial-welcome-modal h2 {
  font-size: 1.4rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -0.5px;
  margin-bottom: 12px;
  color: var(--text);
}

.tutorial-welcome-modal p {
  font-size: 0.9rem;
  color: var(--text2);
  line-height: 1.6;
  font-weight: 600;
  margin-bottom: 28px;
}

.tutorial-welcome-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tutorial-btn-start {
  width: 100%;
  padding: 14px 24px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 800;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.tutorial-btn-start:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.3);
}

.tutorial-btn-skip {
  width: 100%;
  padding: 12px 24px;
  background: transparent;
  color: var(--text3);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.tutorial-btn-skip:hover {
  border-color: var(--text2);
  color: var(--text2);
}

/* Tutorial Overlay */
.tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
}

.tutorial-spotlight {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: auto;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Tooltip */
.tutorial-tooltip {
  position: fixed;
  z-index: 10001;
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: 12px;
  padding: 20px 24px;
  max-width: 340px;
  width: calc(100vw - 32px);
  pointer-events: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  animation: tutPopIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  transition: top 0.4s cubic-bezier(0.16, 1, 0.3, 1), left 0.4s cubic-bezier(0.16, 1, 0.3, 1), bottom 0.4s cubic-bezier(0.16, 1, 0.3, 1), right 0.4s cubic-bezier(0.16, 1, 0.3, 1), transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.tutorial-tooltip-step {
  font-size: 0.65rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
  margin-bottom: 8px;
}

.tutorial-tooltip-title {
  font-size: 1.05rem;
  font-weight: 900;
  text-transform: uppercase;
  color: var(--text);
  margin: 0 0 8px;
  line-height: 1.3;
}

.tutorial-tooltip-desc {
  font-size: 0.85rem;
  color: var(--text2);
  line-height: 1.5;
  font-weight: 600;
  margin: 0 0 20px;
}

.tutorial-tooltip-actions {
  display: flex;
  gap: 8px;
}

.tutorial-btn-prev,
.tutorial-btn-next {
  flex: 1;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s;
}

.tutorial-btn-prev {
  background: var(--surface2);
  color: var(--text2);
  border: 1px solid var(--border);
}
.tutorial-btn-prev:hover {
  background: var(--surface3);
  color: var(--text);
}
.tutorial-btn-prev:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.tutorial-btn-next {
  background: var(--accent);
  color: white;
  border: none;
}
.tutorial-btn-next:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

/* Progress Dots */
.tutorial-progress {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 16px;
}

.tutorial-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: all 0.3s ease;
}
.tutorial-dot.active {
  background: var(--accent);
  transform: scale(1.3);
}
.tutorial-dot.done {
  background: var(--no);
}

/* Highlighted element */
.tutorial-highlight {
  position: relative;
  z-index: 10000 !important;
  pointer-events: none;
  border-radius: 8px;
  box-shadow: 0 0 0 4px var(--accent), 0 0 0 6px rgba(37, 99, 235, 0.2) !important;
  transition: box-shadow 0.3s ease;
  animation: tutPulseRing 2s ease infinite;
}

/* Animations */
@keyframes tutFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes tutSlideUp {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes tutBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
@keyframes tutPopIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes tutPulseRing {
  0%, 100% { box-shadow: 0 0 0 4px var(--accent), 0 0 0 6px rgba(37, 99, 235, 0.2); }
  50% { box-shadow: 0 0 0 4px var(--accent), 0 0 0 12px rgba(37, 99, 235, 0.08); }
}

/* Mobile adjustments */
@media(max-width: 639px) {
  .tutorial-welcome-modal { padding: 32px 20px; }
  .tutorial-tooltip { max-width: calc(100vw - 24px); }
}
