/* ==========================================================================
   The Count – Fresh CSS
   Mobile-first, light/dark aware, Half Baked Idea palette
   ========================================================================== */

/* Reset & base ---------------------------------------------------------------- */

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

.the-count-wrapper--blackjack {
  -webkit-font-smoothing: antialiased;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
  line-height: 1.5;
  color: #eaf7f7;
}


/* Light theme toggled via .the-count-wrapper--blackjack.light ---------------------------------------- */

.the-count-wrapper--blackjack {
  --hbi-deep-teal: #013854;
  --hbi-mid-teal: #185f66;
  --hbi-light-teal: #9dd2d0;
  --hbi-gold: #f2c335;
  --hbi-orange: #d86604;
  --card-bg: rgba(1, 14, 22, 0.9);
  --card-border: rgba(11, 46, 60, 0.9);
  --card-shadow: 0 24px 70px rgba(0, 0, 0, 0.9);
  --text-main: #eaf7f7;
  --text-muted: #9ac3cf;
  --text-soft: #7fa4b0;
  --link-color: #9dd2d0;
  --pill-bg: rgba(2, 24, 34, 0.96);
  --pill-border: rgba(33, 92, 108, 0.9);
  --pill-bg-active: #d86604;
  --pill-text-active: #013854;
  --pill-bg-inactive: #9dd2d0;
  --pill-text-inactive: #d86604;
  --button-bg: #f2c335;
  --button-border: #d86604;
  --button-text: #013854;
  --stat-card-bg: radial-gradient(circle at top, #022033 0, #010b14 80%);
  --stat-card-border: rgba(23, 79, 99, 0.9);
}

.the-count-wrapper--blackjack.light {
  color: #013854;
  --card-bg: rgba(255, 255, 255, 0.9);
  --card-border: #d3e6e5;
  --card-shadow: 0 18px 40px rgba(0, 0, 0, 0.18);
  --text-main: #013854;
  --text-muted: #567883;
  --text-soft: #678893;
  --link-color: #013854;
  --pill-bg: #e5f4f3;
  --pill-border: #bfdede;
  --stat-card-bg: #f5fbfb;
  --stat-card-border: #c7e0df;
}
.the-count-wrapper--blackjack.light h2,
.the-count-wrapper--blackjack.light .section-subtitle,
.the-count-wrapper--blackjack.light .deck-label {
  color: #013854;
}


/* Layout: app container ------------------------------------------------------ */

.app {
  width: 90%;
  max-width: 960px;
  margin-left: auto;
  margin-right: auto;
  background: var(--card-bg);
  border-radius: 20px;
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
  padding: 1.4rem 1.4rem 1.2rem;
  color: var(--text-main);
}

/* Header & brand ------------------------------------------------------------ */

.header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.25rem;
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.logo-wrap {
  width: 40px;
  height: 40px;
}

.hbi-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-row {
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: lowercase;
  font-variant: small-caps;
  color: inherit;
}

.brand-link {
  color: var(--link-color);
  text-decoration: none;
  border-bottom: 1px solid rgba(1, 56, 84, 0.55);
  padding-bottom: 0.08rem;
}

.brand-link:hover,
.brand-link:focus-visible {
  border-bottom-color: rgba(242, 195, 53, 0.9);
}

.brand-sub {
  opacity: 0.9;
  color: inherit;
}

.the-count-wrapper--blackjack h1 {
  margin: 0.15rem 0 0;
  font-size: 1.7rem;
  color: var(--hbi-gold);
}

/* Mode toggle --------------------------------------------------------------- */

.mode-toggle {
  align-self: flex-start;
  border-radius: 999px;
  border: 2px solid var(--button-border);
  background: #ffffff;
  color: #013854;
  font-size: 0.8rem;
  padding: 0.28rem 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);

  font-weight: 600;
}

.the-count-wrapper--blackjack.dark .mode-toggle {
  background: rgba(1, 20, 27, 0.96);
  color: var(--text-main);
}

.mode-toggle .icon {
  font-size: 0.85rem;
}

.mode-toggle .label-text {
  text-transform: lowercase;
  font-variant: small-caps;
}

/* Subtitle / intro ---------------------------------------------------------- */

.subtitle {
  margin-top: 0.9rem;
  font-size: 0.9rem;
  color: var(--text-main);
}

.game-switch-row {
  margin-top: 0.8rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.game-switch-label {
  font-size: 0.8rem;
  color: var(--text-soft);
}

.game-switch-select {
  border-radius: 999px;
  padding: 0.55rem 0.9rem;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid var(--pill-border);
  background: var(--pill-bg-inactive);
  color: var(--pill-text-inactive);
  appearance: none;
  -webkit-appearance: none;
}

.game-switch-select:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(175, 69, 0, 0.35);
  border-color: rgba(175, 69, 0, 0.7);
}

.the-count-wrapper--blackjack h2 {
  margin: 0.9rem 0 0.35rem;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: lowercase;
  font-variant: small-caps;
  color: var(--hbi-gold);
}


.subtitle em {
  color: var(--hbi-orange);
  font-style: normal;
}

/* Top layout: stats + strategy ---------------------------------------------- */

.top-layout {
  margin-top: 1.4rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1.4rem;
}

.left-panel,
.right-panel {
  flex: 1 1 320px;
  min-width: 0;
}

/* Stats cards --------------------------------------------------------------- */

.display-row {
  display: flex;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.top-stats-row {
  margin-bottom: 0.85rem;
}

.bet-ramp-row {
  margin-bottom: 0.85rem;
}

.bet-display-box .bet-ramp-legend {
  margin-top: 0.3rem;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  color: var(--text-soft);
}

.penetration-row {
  margin-top: 0.85rem;
  margin-bottom: 0.85rem;
}

.penetration-box .label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.penetration-percent {
  font-size: 0.8rem;
  color: var(--text-soft);
}

.penetration-bar {
  margin-top: 0.35rem;
  width: 100%;
  height: 0.5rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.the-count-wrapper--blackjack.light .penetration-bar {
  background: rgba(0, 0, 0, 0.12);
}

.penetration-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--hbi-gold);
  transition: width 0.22s ease-out;
}

.the-count-wrapper--blackjack.light .penetration-bar-fill {
  background: var(--hbi-orange);
}

.display-box {
  flex: 1 1 30%;
  min-width: 0;
  background: var(--stat-card-bg);
  border-radius: 14px;
  padding: 0.75rem 0.8rem 0.6rem;
  border: 1px solid var(--stat-card-border);
  box-shadow: 0 10px 26px rgba(1, 5, 10, 0.75);
  text-align: center;
}

.the-count-wrapper--blackjack.light .display-box {
  background: var(--stat-card-bg);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.16);
}

.label {
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-soft);
  margin-bottom: 0.2rem;
}

.value {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--hbi-orange);
}

/* Edge display label -------------------------------------------------------- */

.edge-side {
  display: block;
  margin-top: 0.1rem;
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.edge-positive {
  color: #4ade80;
}

.edge-negative {
  color: var(--hbi-gold);
}

.the-count-wrapper--blackjack.light .edge-positive {
  color: #15803d;
}

/* Decks remaining card ------------------------------------------------------ */

#decksRemainingDisplay {
  font-size: 1.8rem;
}

/* Decks in shoe selector ---------------------------------------------------- */

.deck-section {
  margin-top: 1.2rem;
}

.deck-label {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: lowercase;
  font-variant: small-caps;
  color: var(--hbi-gold);
  margin: 1.1rem 0 0.4rem;
}


.deck-toggle-bar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;

  font-weight: 600;
}

.deck-toggle {
  position: relative;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
  cursor: pointer;
  background: var(--pill-bg-inactive);
  border: 1px solid var(--pill-border);
  color: var(--pill-text-inactive);
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease,
    border-color 0.18s ease;
  width: 100%;
}

.deck-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.deck-toggle.active {
  background: var(--pill-bg-active);
  border-color: #ad4f03;
  color: var(--pill-text-active);
  box-shadow: 0 8px 20px rgba(175, 69, 0, 0.6);
}

/* Controls: counting buttons ------------------------------------------------ */

.controls {
  margin-top: 1.25rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
}

.controls button {
  border-radius: 999px;
  border: 1px solid var(--button-border);
  background: var(--button-bg);
  color: var(--button-text);
  font-size: 1rem;
  padding: 0.6rem 0.4rem;
  text-align: center;
  cursor: pointer;
  text-transform: lowercase;
  font-variant: small-caps;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.5);

  font-weight: 600;
}

.controls button span {
  font-size: 0.7rem;
}

/* Start / reset buttons span full width rows */

.start-shoe {
  grid-column: 1 / -1;
}

.reset-count {
  grid-column: 1 / -1;
}

/* Shoe warning -------------------------------------------------------------- */

.shoe-warning {
  margin-top: 0.6rem;
  font-size: 0.82rem;
  color: #f97373;
  min-height: 1.1rem;
}

/* Hint / how-to copy -------------------------------------------------------- */

.hint {
  margin-top: 1.4rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Rules / strategy section -------------------------------------------------- */

.section-subtitle {
  margin: 0.9rem 0 0.35rem;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: lowercase;
  font-variant: small-caps;
  color: var(--hbi-gold);
}


.rules-section {
  margin-top: 0.15rem;
  margin-bottom: 0.9rem;
}

.rules-label {
  font-size: 0.8rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--hbi-orange);
  margin-bottom: 0.25rem;
}

.rules-toggle-bar {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: flex-start;
}

.rule-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--pill-border);
  background: var(--pill-bg-inactive);
  color: var(--pill-text-inactive);
  font-size: 0.8rem;
  padding: 0.25rem 0.9rem;
  cursor: pointer;
  text-transform: lowercase;
  font-variant: small-caps;

  width: 100%;
  text-align: center;

  font-weight: 600;
}

.rule-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.rule-toggle span {
  display: inline-block;
}

.rule-toggle.active {
  background: var(--pill-bg-active);
  border-color: #ad4f03;
  color: var(--pill-text-active);
}

.rule-toggle input {
  margin-top: 0.1rem;
}

.rules-note {
  margin-top: 0.45rem;
  font-size: 0.82rem;
  color: var(--text-soft);
}

.rules-tooltips {
  margin-top: 0.35rem;
  font-size: 0.82rem;
  color: var(--text-soft);
}

/* Strategy tabs & tables ---------------------------------------------------- */

.strategy-note {
  margin-top: 0.6rem;
  font-size: 0.85rem;
  color: var(--text-soft);
}

.strategy-note.rules-profile {
  margin-top: 0.4rem;
}

.strategy-tabs {
  margin-top: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;

  width: 100%;
  text-align: center;

  font-weight: 600;
}

.strategy-tab {
  border-radius: 999px;
  border: 1px solid var(--pill-border);
  background: var(--pill-bg-inactive);
  color: var(--pill-text-inactive);
  font-size: 0.8rem;
  padding: 0.25rem 0.85rem;
  cursor: pointer;
  text-transform: lowercase;
  font-variant: small-caps;
}

.strategy-tab.active {
  background: var(--pill-bg-active);
  border-color: #ad4f03;
  color: var(--pill-text-active);
}

.strategy-table-wrapper {
  display: none;
  margin-top: 0.6rem;
}

.strategy-table-wrapper.active {
  display: block;
}

.strategy-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.72rem;
  background: rgba(1, 20, 27, 0.97);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 10px 20px rgba(1, 8, 13, 0.85);
}

.the-count-wrapper--blackjack.light .strategy-table {
  background: #f5fbfb;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
}

.strategy-table th,
.strategy-table td {
  border: 1px solid rgba(11, 36, 42, 0.9);
  padding: 0.22rem 0.3rem;
  text-align: center;
  min-width: 22px;
}

.strategy-table th {
  background: linear-gradient(135deg, #043040, #021018);
  color: #eaf7f7;
  font-weight: 500;
}

.the-count-wrapper--blackjack.light .strategy-table th {
  background: #dfeff0;
  color: #013854;
}

.strategy-table th.row-header {
  background: linear-gradient(135deg, #021018, #043040);
  width: 60px;
}

.the-count-wrapper--blackjack.light .strategy-table th.row-header {
  background: #d3e6e5;
}

.strategy-table tbody tr:nth-child(even) {
  background: #021018;
}

.strategy-table tbody tr:nth-child(odd) {
  background: #02181f;
}

.the-count-wrapper--blackjack.light .strategy-table tbody tr:nth-child(even) {
  background: #f3faf9;
}

.the-count-wrapper--blackjack.light .strategy-table tbody tr:nth-child(odd) {
  background: #e9f4f3;
}

/* Deviation & surrender highlighting in strategy grid */

.strategy-table td.deviation {
  background: radial-gradient(circle at top, #4ade80 0, #16a34a 80%);
  color: #f0fdf4;
  font-weight: 700;
}

.strategy-table td.surrender-cell {
  background: radial-gradient(circle at top, #facc15 0, #ea580c 80%);
  color: #111827;
  font-weight: 700;
}

/* Strategy footer / legend -------------------------------------------------- */

.strategy-footer {
  margin-top: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Tooltips ------------------------------------------------------------------ */

.help-term {
  position: relative;
  display: inline-block;
  border-bottom: 1px dotted rgba(157, 210, 208, 0.8);
  cursor: pointer;
  text-decoration: none;
}
.deck-label .help-icon {
  margin-left: 0.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--pill-border);
  font-size: 0.7rem;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
}

.deck-label .help-icon.help-term {
  border-bottom: none;
}


.help-term::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 125%;
  background: #ffffff;
  color: #000000;
  padding: 0.35rem 0.55rem;
  font-size: 0.7rem;
  line-height: 1.35;
  text-transform: none;
  border-radius: 0.35rem;
  border: 1px solid #185f66;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.7);
  white-space: normal;
  min-width: 18ch;
  max-width: min(32ch, 90vw);
  opacity: 0;
  pointer-events: none;
  z-index: 999;
  transition: opacity 0.15s ease-out, transform 0.15s ease-out;
}

.help-term:hover::after,
.help-term:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(-2px);
}


.the-count-wrapper--blackjack.light .help-term::after {
  background: #000000;
  color: #ffffff;
}

/* Mobile-friendly tooltip positioning */
@media (max-width: 540px) {
  .help-term::after {
    top: 120%;
    bottom: auto;
    left: 50vw;
    transform: translateX(-50%);
    max-width: 92vw;
  }
}

/* Rules tooltips block */

.rules-tooltips .help-term {
  border-bottom-style: dotted;
}

/* Footer note --------------------------------------------------------------- */


.legal-note {
  margin-top: 1.6rem;
  font-size: 0.72rem;
  text-align: center;
  color: var(--text-soft);
}
.footer-note {
  margin-top: 1.4rem;
  font-size: 0.78rem;
  text-align: right;
  color: var(--text-soft);
}
.footer-block {
  margin-top: 1.8rem;
  font-size: 0.78rem;
  text-align: center;
  color: var(--text-soft);
  line-height: 1.5;
}

.footer-block p {
  margin: 0.2rem 0;
}

.footer-block a {
  color: inherit;
  text-decoration: underline;
}



.the-count-wrapper--blackjack .footer-block a {
  color: var(--hbi-orange);
}

/* First two footer lines: mode-aware text colour */
.the-count-wrapper--blackjack .footer-block p:nth-child(1),
.the-count-wrapper--blackjack .footer-block p:nth-child(2) {
  color: var(--text-main);
}

/* In light mode, make first two lines solid black for maximum contrast */
.the-count-wrapper--blackjack.light .footer-block p:nth-child(1),
.the-count-wrapper--blackjack.light .footer-block p:nth-child(2) {
  color: #000000;
}

/* Legal line: always red in both modes */
.the-count-wrapper--blackjack .footer-block p:nth-child(3) {
  color: #e53935;
}

.footer-note a {
  color: var(--link-color);
}

/* Mobile layout ------------------------------------------------------------- */

@media (max-width: 540px) {
  .the-count-wrapper--blackjack {
    display: block;
    padding: 0.75rem 0.45rem 1rem;
  }

  .the-count-wrapper--blackjack .app {
    margin: 0 auto;
    border-radius: 18px;
    padding: 1.15rem 1.0rem 1rem;
  }

  .header-row {
    flex-direction: row;
    align-items: flex-start;
  }

  .top-layout {
    flex-direction: column;
  }

  .controls {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .display-box {
    flex: 1 1 30%;
  }
}


/* Desktop two-column app layout -------------------------------------------- */
@media (min-width: 1024px) {
  .the-count-wrapper--blackjack .app {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.3fr);
    grid-template-areas:
      "header header"
      "hint   hint"
      "rules  stats"
      "decks  stats"
      "strategy strategy"
      "footer footer";
    column-gap: 1.5rem;
    row-gap: 1.25rem;
    align-items: start;
  }

  .the-count-wrapper--blackjack .header-row {
    grid-area: header;
  }

  /* Let the three-column layout act as pass-through for grid children */
  .the-count-wrapper--blackjack .three-column-layout {
    display: contents;
  }

  /* Column 1: break its children out as grid items */
  .the-count-wrapper--blackjack .three-column-layout .column.col-1 {
    display: contents;
  }

  .the-count-wrapper--blackjack .three-column-layout .column.col-1 .hint {
    grid-area: hint;
  }

  .the-count-wrapper--blackjack .three-column-layout .column.col-1 .rules-section {
    grid-area: rules;
  }

  .the-count-wrapper--blackjack .three-column-layout .column.col-1 .deck-section {
    grid-area: decks;
  }

  /* Column 2: stats stack */
  .the-count-wrapper--blackjack .three-column-layout .column.col-2 {
    grid-area: stats;
  }

  /* Column 3: basic strategy as its own full-width row */
  .the-count-wrapper--blackjack .three-column-layout .column.col-3.strategy-section {
    grid-area: strategy;
  }

  /* Footer spans full width */
  .the-count-wrapper--blackjack .footer-block {
    grid-area: footer;
  }

  /* Strategy tables: lay out left-to-right on desktop when multiple active */

  /* Slightly smaller text inside strategy tables on desktop to help fit three across */
  .the-count-wrapper--blackjack .strategy-section table {
    font-size: 0.9rem;
  }

  .the-count-wrapper--blackjack .strategy-table-wrapper {
    width: 100%;
    position: relative;
  }

  .the-count-wrapper--blackjack .strategy-table-wrapper.active {
    display: block;
    width: 100%;
    min-width: 0;
    margin-right: 0;
    margin-bottom: 1.25rem;
  }

  .the-count-wrapper--blackjack .strategy-table-wrapper.active:last-child {
    margin-bottom: 0;
  }
}
}

  /* On smaller screens, allow horizontal scrolling so the strategy tables stay readable */
@media (max-width: 768px) {
  .the-count-wrapper--blackjack .strategy-section {
    overflow-x: auto;
    overflow-y: visible;
    padding-bottom: 0.75rem;
  }

  .the-count-wrapper--blackjack .strategy-table {
    min-width: 560px;
    font-size: 0.8rem;
  }
}

/* On very small screens, switch the vertical labels to inline headings so they don't crowd the content */
@media (max-width: 480px) {
  .the-count-wrapper--blackjack .strategy-table-wrapper {
    padding-left: 0;
  }

  .the-count-wrapper--blackjack .strategy-subheading {
    position: static;
    transform: none;
    transform-origin: initial;
    margin-bottom: 0.35rem;
    display: block;
  }
}

  .the-count-wrapper--blackjack .strategy-table--soft th.row-header {
    white-space: nowrap;
    min-width: 150px;
  }



/* Tooltip cursor overrides: question-mark only for explicit help terms ------------ */
.the-count-wrapper--blackjack .help-term,
.the-count-wrapper--blackjack .deck-label .help-icon {
  cursor: help;
}
