:root {
  --felt: #0d5b3d;
  --felt-dark: #073a28;
  --felt-light: #16724f;
  --gold: #e0b55a;
  --cream: #fff7e6;
  --ink: #17231f;
  --muted: #c7d8cf;
  --danger: #f06449;
  --success: #5fd38d;
  --panel: rgba(5, 27, 20, 0.72);
  --line: rgba(255, 255, 255, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--cream);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background:
    radial-gradient(circle at 20% 15%, rgba(255, 255, 255, 0.09), transparent 24rem),
    linear-gradient(135deg, var(--felt-light), var(--felt-dark));
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.screen {
  min-height: 100vh;
  padding: 18px;
}

.auth-screen {
  display: grid;
  place-items: center;
}

.auth-shell {
  width: min(100%, 420px);
}

.brand {
  margin-bottom: 26px;
  text-align: center;
}

.brand-mark {
  display: inline-grid;
  width: 62px;
  height: 62px;
  margin-bottom: 14px;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  background: rgba(2, 18, 12, 0.48);
  color: var(--gold);
  font-size: 22px;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(34px, 10vw, 54px);
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  font-size: 26px;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  font-size: 16px;
}

.subtle {
  color: var(--muted);
  line-height: 1.45;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(18px);
}

.auth-panel {
  padding: 18px;
}

.tabs,
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
}

.tab,
.segment {
  min-height: 42px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.tab.active,
.segment.active {
  background: var(--cream);
  color: var(--ink);
}

.field {
  display: grid;
  gap: 7px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  min-height: 46px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--cream);
  padding: 0 12px;
  outline: none;
}

option {
  color: var(--ink);
}

.money-field {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
}

.money-field span {
  padding-left: 12px;
  color: var(--gold);
  font-weight: 900;
}

.money-field input {
  border: 0;
  background: transparent;
}

.primary,
.secondary,
.danger-button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  padding: 0 14px;
  font-weight: 800;
}

.primary {
  width: 100%;
  margin-top: 16px;
  background: var(--gold);
  color: #1e1608;
}

.secondary {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.1);
  color: var(--cream);
}

.danger-button {
  border: 1px solid rgba(240, 100, 73, 0.5);
  background: rgba(240, 100, 73, 0.14);
  color: #ffd7cf;
}

.message {
  min-height: 22px;
  margin: 12px 0 0;
  color: #ffd2c8;
  font-size: 14px;
}

.app-screen {
  max-width: 720px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 6px 0 18px;
}

.tiny-logo {
  display: inline-flex;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(2, 18, 12, 0.55);
  color: var(--gold);
  font-weight: 900;
}

.settings-grid {
  display: grid;
  gap: 12px;
}

.setting-panel {
  padding: 16px;
}

.disabled-panel {
  opacity: 0.52;
}

.disabled-panel input {
  cursor: not-allowed;
}

.practice-types {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.length-options {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.wide-segment {
  grid-column: 1 / -1;
}

.reset-stats-button {
  width: 100%;
  margin: -4px 0 14px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.toggle-row:last-child {
  border-bottom: 0;
}

.rule-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.rule-list span {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  padding: 0 11px;
  color: var(--cream);
  font-size: 13px;
  font-weight: 800;
}

.switch {
  position: relative;
  width: 54px;
  height: 30px;
  flex: 0 0 auto;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}

.slider::after {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--cream);
  content: "";
  transition: 0.18s ease;
}

.switch input:checked + .slider {
  background: var(--gold);
}

.switch input:checked + .slider::after {
  transform: translateX(24px);
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 14px 0;
}

.stat {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
}

.stat strong {
  display: block;
  font-size: 22px;
}

.stat span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.table {
  position: relative;
  overflow: hidden;
  min-height: 100vh;
  padding: 14px;
}

.table::before {
  position: absolute;
  inset: 14px;
  border: 2px solid rgba(224, 181, 90, 0.52);
  border-radius: 50%;
  content: "";
  opacity: 0.5;
  transform: scaleX(1.2) translateY(18px);
}

.table > * {
  position: relative;
  z-index: 1;
}

.practice-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mini-stats {
  display: flex;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.felt-area {
  display: grid;
  gap: 30px;
  padding: 22px 0;
}

.table.answered .felt-area {
  gap: 12px;
  padding: 10px 0;
}

.hand-zone {
  text-align: center;
}

.label {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.cards {
  display: flex;
  min-height: 126px;
  align-items: center;
  justify-content: center;
}

.table.answered .cards {
  min-height: 76px;
}

.dealer-cards .card + .card {
  margin-left: -34px;
  transform: translateY(-16px);
}

.table.answered .dealer-cards .card + .card {
  margin-left: -22px;
  transform: translateY(-9px);
}

.player-cards {
  gap: 8px;
}

.card {
  display: grid;
  width: 82px;
  height: 116px;
  grid-template-rows: auto 1fr auto;
  border-radius: 8px;
  background: #fffdf8;
  color: #151515;
  padding: 8px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.32);
  font-weight: 900;
}

.table.answered .card {
  width: 54px;
  height: 76px;
  border-radius: 6px;
  padding: 5px;
}

.table.answered .card.back {
  border-width: 4px;
}

.card.red {
  color: #c32336;
}

.card.back {
  border: 6px solid #fffdf8;
  background:
    repeating-linear-gradient(45deg, #842333 0 8px, #5e1724 8px 16px);
}

.card-rank {
  align-self: start;
  justify-self: start;
  font-size: 19px;
}

.card-suit {
  align-self: center;
  justify-self: center;
  font-size: 34px;
}

.table.answered .card-rank {
  font-size: 13px;
}

.table.answered .card-suit {
  font-size: 22px;
}

.card-rank.bottom {
  align-self: end;
  justify-self: end;
  transform: rotate(180deg);
}

.total-pill {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.22);
  padding: 0 12px;
  color: var(--cream);
  font-weight: 800;
}

.actions {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 10px 0 calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(5, 38, 27, 0.92) 22%);
}

.table.answered .actions {
  margin: 0 -14px;
  padding: 8px 14px calc(8px + env(safe-area-inset-bottom));
  background: rgba(5, 38, 27, 0.96);
}

.action-button {
  min-height: 58px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(255, 247, 230, 0.96);
  color: var(--ink);
  font-size: 16px;
  font-weight: 900;
}

.table.answered .action-button {
  min-height: 52px;
}

.feedback {
  margin: 2px 0 8px;
  padding: 12px;
}

.feedback.correct {
  border-color: rgba(95, 211, 141, 0.6);
}

.feedback.incorrect {
  border-color: rgba(240, 100, 73, 0.6);
  background: rgba(240, 100, 73, 0.32);
}

.feedback-title {
  margin-bottom: 4px;
  font-size: 18px;
  font-weight: 900;
}

.table.answered .feedback-title {
  font-size: 16px;
}

@media (max-width: 520px) {
  .table.answered {
    padding: 10px 14px 0;
  }

  .table.answered .practice-header {
    align-items: flex-start;
  }

  .table.answered .secondary {
    min-height: 40px;
    padding: 0 12px;
  }

  .table.answered .mini-stats {
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    font-size: 12px;
  }

  .table.answered .felt-area {
    grid-template-columns: 1fr 1fr;
    align-items: start;
    gap: 8px;
    padding: 6px 0;
  }

  .table.answered .label {
    margin-bottom: 5px;
    font-size: 10px;
  }

  .table.answered .cards {
    min-height: 64px;
  }

  .table.answered .card {
    width: 46px;
    height: 64px;
    padding: 4px;
  }

  .table.answered .card-rank {
    font-size: 11px;
  }

  .table.answered .card-suit {
    font-size: 18px;
  }

  .table.answered .total-pill {
    min-height: 28px;
    padding: 0 9px;
    font-size: 13px;
  }

  .table.answered .feedback {
    padding: 10px;
    font-size: 14px;
  }

  .table.answered .feedback p {
    margin-bottom: 8px;
    line-height: 1.3;
  }

  .table.answered .ev-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    margin-top: 8px;
  }

  .table.answered .ev-item {
    padding: 7px;
  }

  .table.answered .ev-money {
    font-size: 14px;
  }

  .table.answered .ev-units {
    font-size: 11px;
  }
}

.feedback.correct .feedback-title {
  color: var(--success);
}

.feedback.incorrect .feedback-title {
  color: #ffb2a4;
}

.ev-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.ev-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px;
  background: rgba(0, 0, 0, 0.18);
}

.ev-item.best {
  border-color: rgba(224, 181, 90, 0.9);
  background: rgba(224, 181, 90, 0.18);
  box-shadow: inset 0 0 0 1px rgba(224, 181, 90, 0.24);
}

.ev-item.best strong {
  color: var(--gold);
}

.ev-item.chosen-wrong {
  border-color: rgba(240, 100, 73, 0.95);
  background: rgba(240, 100, 73, 0.95);
  color: #fff7f4;
}

.ev-item.chosen-wrong strong,
.ev-item.chosen-wrong .ev-money,
.ev-item.chosen-wrong .ev-units {
  color: #fff7f4;
}

.ev-item strong {
  display: block;
}

.ev-money {
  display: block;
  color: var(--cream);
  font-size: 16px;
  font-weight: 900;
}

.ev-units {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.ev-loss {
  color: #ffd7cf;
}

.summary-screen {
  padding-bottom: 28px;
}

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

.summary-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
  padding: 11px;
}

.summary-row strong,
.summary-row span {
  display: block;
}

.summary-row div span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.summary-row > span {
  color: var(--gold);
  font-weight: 900;
  text-align: right;
}

.summary-actions {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.summary-actions .secondary {
  width: 100%;
}

.hidden {
  display: none;
}

@media (min-width: 620px) {
  .settings-grid {
    grid-template-columns: 1.1fr 0.9fr;
  }

  .setting-panel.wide {
    grid-column: 1 / -1;
  }

  .actions {
    grid-template-columns: repeat(4, 1fr);
  }

  .card {
    width: 96px;
    height: 136px;
  }
}
