:root {
  --felt: #0b6b3a;
  --felt-dark: #084d2a;
  --ink: #1b1b1f;
  --paper: #fdfdf7;
  --gold: #f2c14e;
  --gold-deep: #d49a1a;
  --red: #c0392b;
  --good: #2e9e5b;
  --mid: #e0a82e;
  --bad: #b94a48;
  --shadow: 0 6px 18px rgba(0,0,0,.25);
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  color: var(--paper);
  background:
    radial-gradient(circle at 50% -10%, #11854a 0%, var(--felt) 45%, var(--felt-dark) 100%);
  min-height: 100vh;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px 22px;
  background: rgba(0,0,0,.22);
  border-bottom: 2px solid rgba(242,193,78,.5);
}
.topline { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { font-size: 1.5rem; font-weight: 800; letter-spacing: .5px; }
.brand span { color: var(--gold); }
.tabs { display: flex; gap: 8px; justify-content: center; }
.tab {
  background: transparent; color: var(--paper);
  border: 1px solid rgba(255,255,255,.25);
  padding: 8px 16px; border-radius: 999px; cursor: pointer;
  font-size: .95rem; transition: all .15s;
}
.tab:hover { background: rgba(255,255,255,.12); }
.tab.active { background: var(--gold); color: var(--ink); border-color: var(--gold); font-weight: 700; }

/* ---------- account / auth ---------- */
.account { display: flex; align-items: center; gap: 8px; }
.acct-name { font-size: .9rem; opacity: .9; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-mini {
  background: rgba(255,255,255,.12); color: var(--paper);
  border: 1px solid rgba(255,255,255,.25); padding: 6px 12px; border-radius: 999px;
  font-size: .82rem; cursor: pointer; transition: all .15s; font-weight: 600;
}
.btn-mini:hover:not(:disabled) { background: rgba(255,255,255,.22); }
.btn-mini.primary { background: var(--gold); color: var(--ink); border-color: var(--gold); }
.btn-mini.primary:hover:not(:disabled) { background: var(--gold-deep); }
.btn-mini:disabled { opacity: .5; cursor: not-allowed; }

.toast {
  position: fixed; left: 50%; top: 76px; transform: translateX(-50%) translateY(-12px);
  background: rgba(0,0,0,.85); color: var(--paper); padding: 10px 18px; border-radius: 10px;
  font-size: .9rem; opacity: 0; pointer-events: none; transition: all .25s; z-index: 50;
  border: 1px solid rgba(255,255,255,.15); max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.good { border-color: var(--good); }
.toast.bad { border-color: var(--bad); }

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  padding: 18px;
}
.modal-overlay[hidden] { display: none; }
.modal {
  position: relative; width: 100%; max-width: 440px; max-height: 88vh; overflow-y: auto;
  background: linear-gradient(180deg, #0e7a42, var(--felt-dark));
  border: 1px solid rgba(242,193,78,.5); border-radius: 16px;
  padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.modal-close {
  position: absolute; top: 10px; right: 12px; background: transparent; border: none;
  color: var(--paper); font-size: 1.6rem; line-height: 1; cursor: pointer; opacity: .7;
}
.modal-close:hover { opacity: 1; }
.modal h2 { margin: 0 0 4px; font-size: 1.25rem; }
.modal h3 { margin: 18px 0 6px; font-size: .8rem; text-transform: uppercase; letter-spacing: 1px; opacity: .7; }
.modal p { margin: 6px 0; font-size: .9rem; opacity: .9; }
.modal .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 8px 0; }
.modal .field { width: 100%; padding: 11px 14px; border-radius: 10px; font-size: 1.05rem;
  letter-spacing: 2px; text-align: center; text-transform: uppercase;
  background: rgba(0,0,0,.25); border: 1px solid rgba(255,255,255,.25); color: var(--paper); }
.modal .field::placeholder { letter-spacing: 1px; opacity: .5; }
.codes { background: rgba(0,0,0,.3); border: 1px dashed rgba(242,193,78,.5); border-radius: 10px;
  padding: 12px 14px; margin: 10px 0; font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 1rem; letter-spacing: 1px; line-height: 1.7; white-space: pre; overflow-x: auto; }
.warn { color: var(--gold); font-size: .85rem; font-weight: 600; }
.modal .btn { width: 100%; margin-top: 8px; justify-content: center; }
.modal a.btn { display: block; text-decoration: none; text-align: center; box-sizing: border-box; }
.modal-divider { height: 1px; background: rgba(255,255,255,.16); margin: 18px 0 10px; }
.btn.ghost { background: transparent; }
.btn.ghost:hover:not(:disabled) { background: rgba(255,255,255,.12); }
.muted { opacity: .7; font-size: .85rem; }

main { max-width: 880px; margin: 0 auto; padding: 22px 16px 60px; }

/* ---------- HUD ---------- */
.hud {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
  margin-top: 28px;
}
.hud-item {
  background: rgba(0,0,0,.25); border-radius: 14px; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 2px;
  border: 1px solid rgba(255,255,255,.08);
}
.hud-label { font-size: .72rem; text-transform: uppercase; letter-spacing: 1px; opacity: .7; }
.hud-value { font-size: 1.5rem; font-weight: 800; color: var(--gold); line-height: 1.1; }
.hud-sub { font-size: .75rem; opacity: .75; }
.xpbar { height: 6px; background: rgba(255,255,255,.15); border-radius: 4px; margin: 4px 0 2px; overflow: hidden; }
.xpbar-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--gold), var(--gold-deep)); transition: width .5s; }

/* ---------- panels ---------- */
.panel { display: none; }
.panel.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px);} to {opacity:1; transform:none;} }

.crib-banner {
  text-align: center; font-size: 1.15rem; font-weight: 700;
  padding: 10px; border-radius: 12px; margin-bottom: 8px;
  background: rgba(0,0,0,.2); border: 1px dashed rgba(242,193,78,.5);
}
.crib-banner.mine { background: rgba(46,158,91,.25); border-color: var(--good); }
.crib-banner.theirs { background: rgba(185,74,72,.22); border-color: var(--bad); }
.hint { text-align: center; opacity: .85; margin: 6px 0 14px; }

/* ---------- cards ---------- */
.table {
  display: flex; flex-wrap: wrap; gap: 14px; justify-content: center;
  min-height: 140px; align-items: center;
}
.card {
  width: 84px; height: 120px; border-radius: 10px; background: var(--paper);
  color: var(--ink); position: relative; cursor: pointer; user-select: none;
  box-shadow: var(--shadow); border: 2px solid transparent;
  transition: transform .12s, border-color .12s, box-shadow .12s;
  display: flex; align-items: center; justify-content: center;
}
.card:hover { transform: translateY(-6px); }
.card.red { color: var(--red); }
.card .corner { position: absolute; font-weight: 800; line-height: 1; }
.card .tl { top: 7px; left: 8px; text-align: left; }
.card .br { bottom: 7px; right: 8px; transform: rotate(180deg); text-align: left; }
.card .rank { font-size: 1.05rem; }
.card .pip { font-size: 1rem; }
.card .center { font-size: 2.2rem; }
.card.selected {
  border-color: var(--gold); transform: translateY(-12px);
  box-shadow: 0 12px 22px rgba(0,0,0,.35), 0 0 0 4px rgba(242,193,78,.35);
}
.card.selected::after {
  content: "CRIB"; position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  background: var(--gold); color: var(--ink); font-size: .62rem; font-weight: 800;
  padding: 2px 8px; border-radius: 999px; letter-spacing: 1px;
}
.card.locked { cursor: default; }
.card.locked:hover { transform: none; }

/* ---------- actions ---------- */
.actions { display: flex; gap: 12px; justify-content: center; margin: 22px 0; }
.btn {
  background: rgba(255,255,255,.12); color: var(--paper);
  border: 1px solid rgba(255,255,255,.25); padding: 11px 22px; border-radius: 999px;
  font-size: 1rem; cursor: pointer; transition: all .15s; font-weight: 600;
}
.btn:hover:not(:disabled) { background: rgba(255,255,255,.22); }
.btn.primary { background: var(--gold); color: var(--ink); border-color: var(--gold); }
.btn.big { font-size: 1.12rem; font-weight: 800; padding: 14px 40px; }
.btn.primary:hover:not(:disabled) { background: var(--gold-deep); }
.btn:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- result / ranking ---------- */
.result:empty { display: none; }
.result {
  background: rgba(0,0,0,.25); border-radius: 14px; padding: 16px;
  border: 1px solid rgba(255,255,255,.1);
  overflow-x: auto;  /* never let the ranking table break the layout on phones */
}
.verdict { text-align: center; margin-bottom: 14px; }
.verdict .pts { font-size: 2.4rem; font-weight: 900; }
.verdict.t5 .pts { color: var(--good); }
.verdict.t3 .pts { color: var(--mid); }
.verdict.t1 .pts { color: var(--gold); }
.verdict.t0 .pts { color: var(--bad); }
.verdict .msg { font-size: 1.05rem; opacity: .95; }
.verdict .cribnote { font-size: .82rem; opacity: .7; margin-top: 2px; }
.coach { background: rgba(242,193,78,.12); border-left: 3px solid var(--gold);
  border-radius: 8px; padding: 9px 12px; margin: 0 0 10px; font-size: .92rem; }
.starter { text-align: center; font-size: .9rem; opacity: .92; margin: 0 0 12px; }
.starter .mc { font-size: .9rem; }

/* adaptive practice */
.drill-chip { font-size: .85rem; font-weight: 600; color: var(--ink);
  background: var(--gold); border-radius: 999px; padding: 5px 14px;
  display: block; width: fit-content; margin: 8px auto 0; }
.adaptive-toggle { display: flex; align-items: center; gap: 8px; justify-content: center;
  font-size: .9rem; opacity: .85; cursor: pointer; margin-top: -8px; user-select: none; }
.adaptive-toggle input { width: 18px; height: 18px; accent-color: var(--gold); cursor: pointer; }

table.ranking { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.ranking th, table.ranking td { padding: 7px 8px; text-align: left; }
table.ranking thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .5px; opacity: .65; border-bottom: 1px solid rgba(255,255,255,.15); }
table.ranking tbody tr { border-bottom: 1px solid rgba(255,255,255,.06); }
table.ranking tbody tr.chosen { background: rgba(242,193,78,.16); }
table.ranking tbody tr.best td:first-child { color: var(--good); font-weight: 800; }
.minicards { display: inline-flex; gap: 3px; }
.mc { display: inline-block; padding: 1px 5px; border-radius: 4px; background: var(--paper); color: var(--ink); font-weight: 700; font-size: .8rem; }
.mc.red { color: var(--red); }
.tossed { opacity: .9; }
.ev { font-variant-numeric: tabular-nums; }
.tag { font-size: .66rem; font-weight: 800; padding: 1px 7px; border-radius: 999px; }
.tag.you { background: var(--gold); color: var(--ink); }
.tag.opt { background: var(--good); color: #fff; }

/* ---------- daily ---------- */
.daily-progress { display: flex; gap: 8px; justify-content: center; margin-bottom: 6px; }
.pip-dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2); font-weight: 700; font-size: .8rem; }
.pip-dot.done { background: var(--good); border-color: var(--good); }
.pip-dot.current { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(242,193,78,.3); }
.daily-done { text-align: center; padding: 24px; }
.daily-done .big { font-size: 2.6rem; font-weight: 900; color: var(--gold); }

/* ---------- stats ---------- */
.statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.statcard { background: rgba(0,0,0,.25); border-radius: 14px; padding: 18px; text-align: center; border: 1px solid rgba(255,255,255,.08); min-width: 0; }
.statcard .n { font-size: 2rem; font-weight: 900; color: var(--gold); overflow-wrap: anywhere; line-height: 1.1; }
/* text-y values (e.g. "1 · Greenhorn") shrink so they never spill the box */
.statcard .n.text { font-size: 1.2rem; }
.statcard .l { font-size: .78rem; opacity: .75; text-transform: uppercase; letter-spacing: .5px; margin-top: 4px; }

/* ---------- insights ---------- */
.insights { margin-top: 22px; }
.insights:empty { display: none; }
.insight-head { font-size: 1.05rem; font-weight: 700; color: var(--gold); margin-bottom: 4px; }
.insights table.ranking { margin-top: 8px; }
.insights tr.weak td { background: rgba(185,74,72,.18); font-weight: 600; }

/* ---------- admin ---------- */
.adminbadge { font-size: .6rem; font-weight: 800; text-transform: uppercase; letter-spacing: 1px;
  background: var(--gold); color: var(--ink); padding: 2px 7px; border-radius: 999px; vertical-align: middle; }
.adminlink { color: var(--gold); }
.metricgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 22px; }
.admin-section { margin: 22px 0; }
.admin-section h3 { font-size: .82rem; text-transform: uppercase; letter-spacing: 1px; opacity: .75; margin-bottom: 8px; }
.table-wrap { overflow-x: auto; background: rgba(0,0,0,.22); border-radius: 12px; border: 1px solid rgba(255,255,255,.08); padding: 6px 12px; }
table.admin-users { min-width: 640px; }
table.admin-users td, table.admin-users th { white-space: nowrap; }
.actions-cell { display: flex; gap: 6px; justify-content: flex-end; }
.btn-mini.danger { background: rgba(185,74,72,.25); border-color: var(--bad); }
.btn-mini.danger:hover { background: var(--bad); }
.muted { opacity: .6; }

.footer { text-align: center; padding: 18px; opacity: .55; font-size: .82rem; }

@media (max-width: 620px) {
  .hud { grid-template-columns: repeat(2, 1fr); }
  .card { width: 66px; height: 96px; }
  .card .center { font-size: 1.7rem; }
  /* tighter table on phones */
  table.ranking th, table.ranking td { padding: 6px 5px; font-size: .84rem; }
}

/* On narrow phones, drop the secondary Hand/Crib breakdown columns; the Net EV,
   your pick and the best pick are what matter. The full breakdown is still there
   on tablets/desktop. */
@media (max-width: 540px) {
  table.ranking th:nth-child(5), table.ranking td:nth-child(5),
  table.ranking th:nth-child(6), table.ranking td:nth-child(6) { display: none; }
}
