/* Deal Sense v0 — calm coach, soft felt, teach first */
:root {
  --felt-deep: #1B4D3E;
  --felt-mid: #2F6B55;
  --felt-edge: #0F2E26;
  --card-white: #F7F4EE;
  --ink-rank: #1A1A1A;
  --suit-red: #C62828;
  --suit-black: #1A1A1A;
  --chip-cream: #E8E0D0;
  --chip-navy: #2C3E50;
  --hit-green: #2E7D4F;
  --stand-slate: #3D4F5F;
  --legal-gold: #D4A84B;
  --disabled: #6B736E;
  --coach-cream: #F3EEE4;
  --coach-ink: #1F2A24;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--felt-edge);
  color: var(--coach-cream);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#app {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse at 50% 40%, var(--felt-mid) 0%, var(--felt-deep) 55%, var(--felt-edge) 100%);
  position: relative;
  overflow: hidden;
}

/* —— Top chrome —— */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 6px;
  gap: 8px;
  flex-shrink: 0;
}

.brand {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--chip-cream);
  opacity: 0.9;
}

.phase-pill {
  font-size: 11px;
  background: rgba(15, 46, 38, 0.55);
  border: 1px solid rgba(232, 224, 208, 0.25);
  color: var(--chip-cream);
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.chip-stack {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--chip-cream);
}

.chip-disc {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--chip-cream), var(--chip-navy));
  border: 2px solid var(--chip-cream);
  box-shadow: 0 1px 2px rgba(0,0,0,0.35);
}

.rule-chip {
  margin: 0 14px 8px;
  padding: 6px 12px;
  background: rgba(15, 46, 38, 0.65);
  border: 1px solid rgba(212, 168, 75, 0.45);
  border-radius: 8px;
  font-size: 11px;
  color: var(--chip-cream);
  text-align: center;
  letter-spacing: 0.01em;
  flex-shrink: 0;
}

/* —— Felt table —— */
.felt {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 8px 16px 12px;
  min-height: 0;
  position: relative; /* anchor for corner tally */
}

/* —— Corner session tally (Guided / Free) —— */
.tally {
  position: absolute;
  top: 4px;
  left: 12px;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  line-height: 1;
  color: var(--chip-cream);
  background: rgba(15, 46, 38, 0.55);
  border: 1px solid rgba(232, 224, 208, 0.22);
  border-radius: 999px;
  padding: 4px 9px;
  opacity: 0.85;
  pointer-events: none;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.tally b { font-weight: 700; }
.tally-good b { color: var(--legal-gold); }
.tally-bad b { color: var(--chip-cream); opacity: 0.8; }
.tally-sep { opacity: 0.5; }

.hand-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.hand-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.7;
  color: var(--chip-cream);
}

.hand-total {
  font-size: 12px;
  color: var(--legal-gold);
  min-height: 16px;
  font-weight: 500;
}

.cards {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  min-height: 88px;
}

/* —— CSS cards —— */
.card {
  width: 58px;
  height: 84px;
  border-radius: 8px;
  background: var(--card-white);
  border: 1px solid rgba(26, 26, 26, 0.55);
  position: relative;
  box-shadow: 0 2px 6px rgba(0,0,0,0.28);
  flex-shrink: 0;
}

.card .corner {
  position: absolute;
  top: 4px;
  left: 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  font-weight: 700;
  font-size: 13px;
  color: var(--ink-rank);
}

.card .corner .suit {
  font-size: 12px;
  margin-top: 1px;
}

.card .corner-br {
  top: auto;
  left: auto;
  bottom: 4px;
  right: 5px;
  transform: rotate(180deg);
}

.card.red .corner { color: var(--suit-red); }

.card .pip-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--ink-rank);
  pointer-events: none;
}

.card.red .pip-center { color: var(--suit-red); }

.card.back {
  background: var(--felt-mid);
  border-color: rgba(15, 46, 38, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card.back::after {
  content: "";
  width: 28px;
  height: 28px;
  background: var(--chip-cream);
  transform: rotate(45deg);
  border-radius: 3px;
  opacity: 0.92;
}

.card.deal-in {
  animation: dealIn 0.28s ease-out;
}

@keyframes dealIn {
  from { opacity: 0; transform: translateY(-12px) scale(0.92); }
  to { opacity: 1; transform: none; }
}

/* —— Coach bar —— */
.coach {
  margin: 0 14px 8px;
  min-height: 40px;
  padding: 8px 12px;
  background: var(--coach-cream);
  color: var(--coach-ink);
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.35;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  transition: opacity 0.2s;
}

.coach.empty {
  opacity: 0.35;
  background: rgba(243, 238, 228, 0.35);
  color: transparent;
}

.coach.teach {
  border-left: 3px solid var(--legal-gold);
}

.result-line {
  text-align: center;
  font-size: 13px;
  color: var(--chip-cream);
  min-height: 20px;
  margin-bottom: 4px;
  flex-shrink: 0;
  padding: 0 14px;
}

/* —— Actions —— */
.actions {
  padding: 8px 14px calc(14px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
  background: linear-gradient(to top, rgba(15, 46, 38, 0.85), transparent);
}

.row-primary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.row-secondary {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.btn {
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  padding: 16px 12px;
  cursor: pointer;
  color: var(--coach-cream);
  transition: transform 0.1s, box-shadow 0.2s, background 0.2s, opacity 0.2s;
  touch-action: manipulation;
}

.btn:active:not(:disabled) { transform: scale(0.97); }

.btn-hit {
  background: var(--hit-green);
  box-shadow: 0 3px 0 #1e5a38;
}

.btn-stand {
  background: var(--stand-slate);
  box-shadow: 0 3px 0 #2a3844;
}

.btn-double, .btn-split {
  background: transparent;
  border: 2px solid var(--disabled);
  color: var(--disabled);
  padding: 12px 8px;
  font-size: 14px;
  box-shadow: none;
}

.btn-double.legal, .btn-split.legal {
  background: var(--legal-gold);
  border-color: var(--legal-gold);
  color: var(--felt-edge);
  box-shadow: 0 2px 0 #a87f2e;
}

.btn:disabled, .btn.disabled {
  background: var(--disabled) !important;
  border-color: var(--disabled) !important;
  color: rgba(243, 238, 228, 0.55) !important;
  box-shadow: none !important;
  cursor: not-allowed;
  opacity: 0.7;
}

.btn-hint {
  background: var(--coach-cream);
  color: var(--coach-ink);
  font-size: 13px;
  padding: 12px 8px;
  box-shadow: none;
}

.btn-hint:disabled {
  opacity: 0.4;
}

.btn.ghost-pulse {
  animation: goldPulse 1.4s ease-in-out infinite;
}

@keyframes goldPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212, 168, 75, 0.55); }
  50% { box-shadow: 0 0 0 8px rgba(212, 168, 75, 0); }
}

.btn-hit.ghost-pulse {
  outline: 2px solid var(--legal-gold);
  outline-offset: 2px;
}

.btn-stand.ghost-pulse {
  outline: 2px solid var(--legal-gold);
  outline-offset: 2px;
}

.btn-double.ghost-pulse.legal,
.btn-split.ghost-pulse.legal {
  animation: goldPulse 1.4s ease-in-out infinite;
}

.btn.shake {
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.btn.flash-ok {
  animation: flashOk 0.45s ease;
}

@keyframes flashOk {
  0%, 100% { filter: brightness(1); }
  40% { filter: brightness(1.35); }
}

.btn-session {
  width: 100%;
  background: rgba(15, 46, 38, 0.7);
  border: 1px solid rgba(232, 224, 208, 0.3);
  color: var(--chip-cream);
  font-size: 13px;
  font-weight: 600;
  padding: 10px;
  border-radius: 10px;
  margin-top: 2px;
}

.btn-session:active { transform: scale(0.98); }

/* —— Overlays / screens —— */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 24px;
  background:
    radial-gradient(ellipse at 50% 40%, var(--felt-mid) 0%, var(--felt-deep) 55%, var(--felt-edge) 100%);
  z-index: 20;
  text-align: center;
}

.screen.hidden { display: none; }

.screen h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--chip-cream);
  margin-bottom: 8px;
}

.screen .tagline {
  font-size: 14px;
  color: var(--legal-gold);
  margin-bottom: 20px;
}

.screen p {
  font-size: 14px;
  line-height: 1.5;
  color: var(--coach-cream);
  opacity: 0.9;
  max-width: 320px;
  margin-bottom: 12px;
}

.screen .btn-start {
  margin-top: 16px;
  background: var(--hit-green);
  color: var(--coach-cream);
  font-size: 17px;
  font-weight: 700;
  padding: 16px 36px;
  border: none;
  border-radius: 12px;
  box-shadow: 0 3px 0 #1e5a38;
  cursor: pointer;
}

.screen .btn-start:active { transform: scale(0.97); }

.bet-stub {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 12px;
  color: var(--chip-cream);
  opacity: 0.8;
  margin-bottom: 4px;
  min-height: 18px;
}

.hidden { display: none !important; }

@media (max-height: 700px) {
  .card { width: 50px; height: 72px; }
  .cards { min-height: 76px; }
  .btn { padding: 14px 10px; font-size: 15px; }
}

.btn-next {
  width: 100%;
  background: var(--hit-green);
  box-shadow: 0 3px 0 #1e5a38;
  font-size: 17px;
  padding: 16px 12px;
}

/* —— Tips / glossary (tap, not hover) —— */
.act { position: relative; display: flex; }
.act > .btn { width: 100%; }

.tip-i, .tip-all, .tip-i-demo {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid rgba(243, 238, 228, 0.85);
  background: rgba(15, 46, 38, 0.55);
  color: var(--coach-cream);
  font: italic 700 12px/1 Georgia, "Times New Roman", serif;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}
.tip-i {
  position: absolute;
  top: -7px;
  right: -5px;
  z-index: 2;
  box-shadow: 0 1px 3px rgba(0,0,0,0.35);
}
/* bigger invisible tap target */
.tip-i::after, .tip-all::after, .term::after {
  content: "";
  position: absolute;
  inset: -10px;
}
.tip-all, .term { position: relative; }
.tip-all {
  border-color: rgba(212, 168, 75, 0.8);
  color: var(--legal-gold);
  flex-shrink: 0;
}
.tip-i-demo { position: static; vertical-align: -4px; }

.phase-pill[data-term], .chip-stack[data-term] { cursor: pointer; }

.term {
  display: inline;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  text-decoration: underline dotted;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
  text-decoration-color: rgba(212, 168, 75, 0.95);
  cursor: pointer;
  touch-action: manipulation;
}
.coach .term { text-decoration-color: #9a7428; font-weight: 600; }
.coach.empty .term { color: transparent; }
.term:active { opacity: 0.6; }
.term-demo {
  text-decoration: underline dotted;
  text-decoration-color: var(--legal-gold);
  text-underline-offset: 3px;
}
.screen p.tip-note { font-size: 12px; opacity: 0.75; }

.btn.just-lit { animation: justLit 0.7s ease; }
@keyframes justLit {
  0% { transform: scale(1); }
  35% { transform: scale(1.07); box-shadow: 0 0 0 6px rgba(212, 168, 75, 0.35); }
  100% { transform: scale(1); }
}

.tip-sheet {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.tip-sheet.hidden { display: none; }
.tip-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 24, 20, 0.55);
  animation: tipFade 0.18s ease-out;
}
.tip-panel {
  position: relative;
  background: var(--coach-cream);
  color: var(--coach-ink);
  border-radius: 16px 16px 0 0;
  border-top: 3px solid var(--legal-gold);
  padding: 10px 18px calc(16px + var(--safe-bottom));
  box-shadow: 0 -6px 24px rgba(0,0,0,0.35);
  animation: tipUp 0.22s ease-out;
  max-height: 75%;
  overflow-y: auto;
  user-select: text;
}
.tip-grab {
  width: 36px; height: 4px; border-radius: 2px;
  background: rgba(31, 42, 36, 0.25);
  margin: 0 auto 10px;
}
.tip-title { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.tip-def { font-size: 15px; line-height: 1.45; margin-bottom: 8px; }
.tip-when {
  font-size: 13px;
  line-height: 1.45;
  background: rgba(212, 168, 75, 0.16);
  border-left: 3px solid var(--legal-gold);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 8px;
}
.tip-when b { font-weight: 700; }
.tip-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.tip-list button {
  background: #fff;
  border: 1px solid rgba(31, 42, 36, 0.18);
  color: var(--coach-ink);
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.tip-row { display: flex; gap: 10px; margin-top: 6px; }
.tip-more, .tip-done {
  flex: 1;
  border: none;
  border-radius: 10px;
  padding: 12px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}
.tip-more { background: transparent; border: 1.5px solid rgba(31, 42, 36, 0.25); color: var(--coach-ink); }
.tip-done { background: var(--hit-green); color: var(--coach-cream); box-shadow: 0 3px 0 #1e5a38; }
@keyframes tipUp { from { transform: translateY(100%); } to { transform: none; } }
@keyframes tipFade { from { opacity: 0; } to { opacity: 1; } }

/* Beginner rules list in the tip sheet */
.tip-rules { margin: 0; padding-left: 18px; }
.tip-rules li { margin: 2px 0; }
.tip-rules li + li { margin-top: 5px; }
