/* Daily Black Jack — "Stammtisch" theme.
   Riso-print, gentlemen's club newsletter feel.
   Tokens straight from the design handoff. */

:root {
  --paper:   #EFE6D2;
  --paper2:  #E5DAC0;
  --ink:     #1B1714;
  --ink2:    #3A312A;
  --oxblood: #9B2A2A;
  --mustard: #C8932A;
  --forest:  #2F4A35;

  --font-display: 'IM Fell English', 'EB Garamond', Georgia, serif;
  --font-mono:    'JetBrains Mono', 'Courier New', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-display);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#paper {
  min-height: 100vh;
  background: var(--paper);
  /* Riso noise: small dark dots + tiny oxblood dots, slightly offset */
  background-image:
    radial-gradient(rgba(27,23,20,0.07) 1px, transparent 1px),
    radial-gradient(rgba(155,42,42,0.04) 1px, transparent 1px);
  background-size: 3px 3px, 7px 7px;
  background-position: 0 0, 1px 2px;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#root {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
}

/* ─── Header ─── */
.header {
  padding: 14px 18px 10px;
  border-bottom: 1.5px solid var(--ink);
}
.header-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.kicker {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 2px;
  text-transform: uppercase;
}
.aside {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 1px;
}
.title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 30px;
  line-height: 1;
  margin: 6px 0 0;
}
.subtitle {
  font-family: var(--font-mono);
  font-size: 10px;
  margin-top: 6px;
  color: var(--ink2);
}

/* Help icon top-right inside views */
.help-link {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink);
  border: 1.5px solid var(--ink);
  padding: 4px 8px;
  background: var(--paper);
  box-shadow: 1.5px 1.5px 0 var(--ink);
  cursor: pointer;
}

/* ─── Page ─── */
.page { padding: 18px; }

.label-mono {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* ─── Buttons ─── */
.btn {
  appearance: none;
  border: 1.5px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  padding: 14px 18px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  border-radius: 0;
  box-shadow: 2px 2px 0 var(--ink);
  cursor: pointer;
  min-height: 48px;
  font-weight: 500;
}
.btn:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--ink); }
.btn-primary {
  background: var(--ink);
  color: var(--paper);
  box-shadow: 2px 2px 0 var(--oxblood);
}
.btn-primary:active { box-shadow: 1px 1px 0 var(--oxblood); }
.btn-full { width: 100%; }
.btn[disabled] { opacity: 0.4; cursor: not-allowed; }

/* big serif buttons (Karte / Genug) */
.btn-serif {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 22px;
  text-transform: none;
  letter-spacing: 0;
  padding: 14px 18px;
  min-height: 56px;
  box-shadow: 3px 3px 0 var(--ink);
  flex: 1;
}
.btn-serif.btn-primary { box-shadow: 3px 3px 0 var(--oxblood); }

/* ─── Login ─── */
.players-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.player-btn {
  appearance: none;
  border: 1.5px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  padding: 14px 8px;
  text-align: left;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--ink);
  font-family: var(--font-display);
  min-height: 60px;
}
.player-btn[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
  box-shadow: 2px 2px 0 var(--oxblood);
}
.player-btn .id {
  font-size: 28px;
  font-style: italic;
  line-height: 1;
}
.player-btn .name {
  font-family: var(--font-mono);
  font-size: 9px;
  margin-top: 4px;
  letter-spacing: 1px;
  opacity: 0.85;
  text-transform: uppercase;
}

.pin-display {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.pin-cell {
  flex: 1;
  height: 46px;
  border: 1.5px solid var(--ink);
  background: var(--paper2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 26px;
  font-style: italic;
}

.pin-pad {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-top: 16px;
}
.pin-key {
  height: 52px;
  border: 1.5px solid var(--ink);
  background: var(--paper);
  font-family: var(--font-display);
  font-size: 22px;
  font-style: italic;
  cursor: pointer;
  box-shadow: 1.5px 1.5px 0 var(--ink);
  border-radius: 0;
  font-weight: inherit;
  color: var(--ink);
}
.pin-key:active { transform: translate(1px,1px); box-shadow: 0.5px 0.5px 0 var(--ink); }
.pin-key.empty { border: none; background: transparent; box-shadow: none; cursor: default; }

.error-line {
  margin-top: 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--oxblood);
  min-height: 14px;
}

/* ─── Today ─── */
.callout {
  border: 1.5px solid var(--ink);
  background: var(--paper2);
  box-shadow: 3px 3px 0 var(--ink);
  padding: 16px;
}
.callout-headline {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 38px;
  line-height: 1;
  margin: 4px 0 0;
}
.callout-body {
  font-family: var(--font-mono);
  font-size: 10px;
  margin-top: 8px;
  color: var(--ink2);
  line-height: 1.5;
}
.callout .btn { margin-top: 14px; }

.section-head {
  margin-top: 20px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 2px;
  text-transform: uppercase;
}
.dashed-list {
  margin-top: 8px;
  border-top: 1px dashed var(--ink);
}
.dashed-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--ink);
}
.initial-square {
  width: 32px;
  height: 32px;
  border: 1.5px solid var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 14px;
  flex-shrink: 0;
}
.row-name { flex: 1; }
.row-name .top { font-size: 16px; font-style: italic; font-family: var(--font-display); }
.row-name .bottom { font-family: var(--font-mono); font-size: 9px; color: var(--ink2); }
.delta {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
}
.delta.pos { color: var(--forest); }
.delta.neg { color: var(--oxblood); }
.delta.neutral { color: var(--ink2); }

/* ─── Card ─── */
.card {
  width: 58px;
  height: 84px;
  border-radius: 4px;
  background: var(--paper);
  box-shadow: 1px 1.5px 0 var(--ink), inset 0 0 0 1.5px var(--ink);
  position: relative;
  flex-shrink: 0;
  font-family: var(--font-display);
}
.card .corner-tl, .card .corner-br, .card .center {
  position: absolute;
  color: var(--ink);
}
.card.red .corner-tl, .card.red .corner-br, .card.red .center {
  color: var(--oxblood);
}
.card .corner-tl {
  top: 4px;
  left: 5px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
}
.card .corner-tl .suit {
  display: block;
  font-size: 11px;
  margin-top: 2px;
}
.card .corner-br {
  bottom: 4px;
  right: 5px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  transform: rotate(180deg);
}
.card .center {
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
}
.card.back {
  background: var(--oxblood);
  background-image:
    repeating-linear-gradient(45deg, rgba(255,255,255,0.12) 0 2px, transparent 2px 6px),
    repeating-linear-gradient(-45deg, rgba(0,0,0,0.18) 0 2px, transparent 2px 6px);
  box-shadow: 1px 1px 0 var(--ink), inset 0 0 0 3px var(--paper), inset 0 0 0 4px var(--oxblood);
}
.card.back .corner-tl, .card.back .corner-br, .card.back .center { display: none; }

/* slight riso misregister via per-card transforms applied inline */

.cards-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

/* ─── Game table ─── */
.table-bar {
  padding: 12px 18px 8px;
  border-bottom: 1.5px solid var(--ink);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.table-stat-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 2px;
}
.table-stat-value {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 24px;
  line-height: 1;
}
.table-stat-value .small {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink2);
  font-style: normal;
}

.section-dealer {
  padding: 18px;
  border-bottom: 1px dashed var(--ink);
}
.section-felt {
  padding: 14px 18px;
  text-align: center;
  background: var(--paper2);
  background-image: repeating-linear-gradient(0deg, transparent 0 16px, rgba(27,23,20,0.05) 16px 17px);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 3px;
  color: var(--ink2);
}
.section-player { padding: 18px; }

.row-between {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.score {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
}
.score.bust { color: var(--oxblood); }

.actions { display: flex; gap: 10px; margin-top: 22px; }

.hint {
  margin-top: 14px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 1.5px;
  color: var(--ink2);
  text-align: center;
}

/* ─── Result overlay ─── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(27,23,20,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  padding: 18px;
}
.overlay-card {
  width: 100%;
  max-width: 360px;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  box-shadow: 5px 5px 0 var(--oxblood);
  padding: 22px;
  text-align: center;
}
.result-head {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 3px;
}
.result-verdict {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 44px;
  line-height: 1;
  margin: 8px 0 0;
}
.result-verdict.win { color: var(--forest); }
.result-verdict.loss, .result-verdict.bust { color: var(--oxblood); }
.result-verdict.push { color: var(--ink2); }
.result-detail {
  font-family: var(--font-mono);
  font-size: 11px;
  margin-top: 12px;
  color: var(--ink2);
}
.result-delta {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 600;
  margin-top: 12px;
}
.result-delta.pos { color: var(--forest); }
.result-delta.neg { color: var(--oxblood); }

/* ─── Daily summary ─── */
.daily-headline {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 72px;
  line-height: 1;
  margin: 6px 0 0;
}
.daily-headline.pos { color: var(--forest); }
.daily-headline.neg { color: var(--oxblood); }
.daily-headline.neutral { color: var(--ink); }
.daily-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink2);
  margin-top: 4px;
}
.daily-hands {
  margin-top: 22px;
  padding: 14px;
  border: 1.5px solid var(--ink);
  text-align: left;
  box-shadow: 2px 2px 0 var(--ink);
}
.daily-hand-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-top: 1px dashed var(--ink);
  align-items: baseline;
}
.daily-hand-label { font-family: var(--font-mono); font-size: 11px; }
.daily-hand-result { font-family: var(--font-display); font-style: italic; font-size: 16px; }
.daily-hand-delta { font-family: var(--font-mono); font-size: 13px; font-weight: 600; }

.waiting {
  margin-top: 20px;
  padding: 12px;
  background: var(--paper2);
  border: 1.5px solid var(--ink);
  text-align: left;
}

/* ─── Leaderboard ─── */
.tabs {
  display: flex;
  border-bottom: 1.5px solid var(--ink);
}
.tab {
  flex: 1;
  padding: 12px 0;
  border: none;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  cursor: pointer;
}
.tab[aria-selected="true"] {
  background: var(--ink);
  color: var(--paper);
}
.lb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px dashed var(--ink);
}
.lb-rank {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 36px;
  line-height: 1;
  width: 32px;
}
.lb-rank.first { color: var(--mustard); text-shadow: 1px 1px 0 var(--ink); }
.lb-id {
  width: 36px;
  height: 36px;
  border: 1.5px solid var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 16px;
  box-shadow: 1.5px 1.5px 0 var(--ink);
}
.lb-meta { flex: 1; }
.lb-meta .top { font-family: var(--font-display); font-style: italic; font-size: 18px; }
.lb-meta .bottom { font-family: var(--font-mono); font-size: 9px; color: var(--ink2); letter-spacing: 1px; }
.lb-delta {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 600;
}
.lb-foot {
  margin-top: 18px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 1.5px;
  color: var(--ink2);
  text-align: center;
}

.locked-note {
  border: 1.5px solid var(--ink);
  padding: 16px;
  background: var(--paper2);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 18px;
  line-height: 1.4;
  box-shadow: 2px 2px 0 var(--ink);
}
.locked-note .hint-mono {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink2);
  font-style: normal;
  letter-spacing: 1px;
  margin-top: 8px;
}

/* ─── Help ─── */
.help-section { margin-top: 0; }
.help-section + .help-section { margin-top: 16px; }
.help-section .label-mono { display: block; }
.help-section p {
  margin: 4px 0 0;
  font-size: 14px;
  line-height: 1.55;
  font-family: var(--font-display);
}
.help-section .mono {
  font-family: var(--font-mono);
  font-size: 11px;
}
.help-frame {
  background: var(--paper2);
  border: 1.5px solid var(--ink);
  padding: 12px;
  margin-top: 8px;
}

/* PWA install hint (iOS) */
.ios-hint {
  margin: 12px 0;
  border: 1.5px dashed var(--ink);
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.5px;
  color: var(--ink2);
  background: var(--paper2);
}
.ios-hint strong { color: var(--ink); }

@media (max-width: 360px) {
  .card { width: 52px; height: 76px; }
  .card .center { font-size: 22px; }
}
