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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #0d4f2b;
  color: #e8e8e8;
  min-height: 100vh;
  overflow-x: hidden;
}

/* === Felt texture === */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(30,120,70,0.4) 0%, transparent 70%),
    repeating-conic-gradient(rgba(255,255,255,0.01) 0% 25%, transparent 0% 50%) 0 0 / 4px 4px;
  pointer-events: none;
  z-index: 0;
}

/* === Overlays === */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  background: rgba(0,0,0,0.6);
}

.overlay-box {
  background: #1a1a2e;
  border: 2px solid #2a5a3a;
  border-radius: 16px;
  padding: 40px;
  max-width: 600px;
  width: 90%;
  text-align: center;
  max-height: 85vh;
  overflow-y: auto;
}

.hidden { display: none !important; }

/* === Start Screen === */
.start-box h1 {
  font-size: 2rem;
  color: #4ecb71;
  margin-bottom: 8px;
}

.subtitle {
  color: #888;
  margin-bottom: 24px;
  font-size: 0.95rem;
}

.instructions {
  color: #ccc;
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 8px;
  text-align: left;
}

.instructions-note {
  color: #999;
  font-size: 0.85rem;
  font-style: italic;
  margin-bottom: 20px;
}

#player-name-input {
  display: block;
  width: 100%;
  padding: 14px 16px;
  font-size: 1.1rem;
  border: 2px solid #2a5a3a;
  border-radius: 8px;
  background: #0f1923;
  color: #fff;
  margin-bottom: 16px;
  outline: none;
  transition: border-color 0.2s;
}

#player-name-input:focus { border-color: #4ecb71; }
#player-name-input.input-error { border-color: #e74c3c; }

/* === Buttons === */
.btn {
  padding: 14px 32px;
  font-size: 1.1rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.1s, background 0.2s;
}
.btn:active { transform: scale(0.97); }

.btn-primary { background: #27ae60; color: #fff; }
.btn-primary:hover { background: #2ecc71; }

.btn-secondary { background: #34495e; color: #fff; margin-left: 8px; }
.btn-secondary:hover { background: #4a6a8a; }

.btn-link {
  background: none;
  color: #4ecb71;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 8px;
  margin-top: 8px;
  display: block;
  width: 100%;
}
.btn-link:hover { text-decoration: underline; }

.btn-close {
  background: none;
  border: none;
  color: #aaa;
  font-size: 1.8rem;
  cursor: pointer;
  line-height: 1;
}
.btn-close:hover { color: #fff; }

/* === Status Bar === */
#status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: rgba(0,0,0,0.35);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  font-size: 0.95rem;
  position: relative;
  z-index: 10;
}

#hand-counter { font-weight: 600; }
#accuracy { color: #4ecb71; font-weight: 600; }
#timer { color: #f39c12; font-variant-numeric: tabular-nums; min-width: 50px; text-align: right; }

/* === Game Table === */
#game-area {
  position: relative;
  z-index: 1;
  transition: background-color 0.3s;
}

#game-area.correct-flash {
  background-color: rgba(46, 204, 113, 0.15);
}

#table {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  min-height: calc(100vh - 160px);
  justify-content: center;
  gap: 16px;
}

#dealer-section {
  text-align: center;
}

#player-section {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 20px;
  min-height: 180px;
}

#player-center {
  text-align: center;
  z-index: 2;
}

/* Split side hands (completed on left, waiting on right) */
.split-side {
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1;
  transition: opacity 0.3s;
  min-width: 90px;
}

.split-side-hand {
  text-align: center;
  transform: scale(0.7);
  transform-origin: bottom center;
  opacity: 0.6;
  transition: transform 0.3s, opacity 0.3s;
}

.split-side-hand .card-row {
  min-height: 90px;
  padding: 2px 10px;
}

.split-side-hand .card {
  width: 65px;
  height: 95px;
}

.split-side-hand .card-rank { font-size: 0.8rem; }
.split-side-hand .card-suit { font-size: 0.6rem; }
.split-side-hand .card-suit-large { font-size: 1.5rem; }

.split-side-hand .hand-total {
  font-size: 0.9rem;
  margin-top: 2px;
}

.split-side-hand .split-hand-label {
  font-size: 0.7rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 2px;
}

.split-side-hand.completed-hand {
  opacity: 0.45;
}

.split-side-hand.waiting-hand {
  opacity: 0.55;
}

#split-left {
  align-items: flex-end;
}

#split-right {
  align-items: flex-start;
}

.section-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: rgba(255,255,255,0.5);
  margin-bottom: 8px;
}

.card-row {
  display: flex;
  justify-content: center;
  min-height: 140px;
  align-items: center;
  padding: 4px 40px;
}

.hand-total {
  font-size: 1.3rem;
  font-weight: 700;
  margin-top: 6px;
  min-height: 28px;
}

.hand-result {
  font-size: 1.5rem;
  font-weight: 700;
  min-height: 36px;
  text-align: center;
}
.result-win { color: #2ecc71; }
.result-lose { color: #e74c3c; }

.split-label {
  font-size: 0.9rem;
  color: #f39c12;
  font-weight: 600;
  min-height: 20px;
  text-align: center;
}

/* === Playing Cards === */
.card {
  width: 90px;
  height: 130px;
  background: #fff;
  border-radius: 8px;
  position: relative;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  transition: margin-left 0.2s;
}

.card.face-down {
  background: linear-gradient(135deg, #1a3a6e, #2a4a8e);
  border: 2px solid #4a6aae;
}

.card-back {
  width: 100%;
  height: 100%;
  background:
    repeating-linear-gradient(45deg, transparent, transparent 5px, rgba(255,255,255,0.05) 5px, rgba(255,255,255,0.05) 10px);
  border-radius: 6px;
}

.card-red { color: #c0392b; }
.card-black { color: #1a1a1a; }

.card-corner {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}

.card-top-left { top: 5px; left: 6px; }
.card-bottom-right { bottom: 5px; right: 6px; transform: rotate(180deg); }

.card-rank { font-size: 1rem; font-weight: 700; }
.card-suit { font-size: 0.75rem; }

.card-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-suit-large { font-size: 2.2rem; }

/* Small cards for results/detail */
.small-card {
  display: inline-block;
  background: #fff;
  padding: 2px 5px;
  border-radius: 3px;
  font-size: 0.85rem;
  font-weight: 600;
  margin: 0 1px;
  border: 1px solid #ccc;
}
.small-card.card-red { color: #c0392b; }
.small-card.card-black { color: #1a1a1a; }

/* === Action Buttons === */
#actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  flex-wrap: wrap;
}

.action-btn {
  padding: 16px 28px;
  font-size: 1.15rem;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.1s, filter 0.15s;
  min-width: 100px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.action-btn:active:not(:disabled) { transform: scale(0.95); }

.action-btn:disabled {
  opacity: 0.25;
  cursor: default;
  filter: grayscale(1);
}

.btn-hit { background: #27ae60; color: #fff; }
.btn-hit:hover { filter: brightness(1.1); }

.btn-stand { background: #e74c3c; color: #fff; }
.btn-stand:hover { filter: brightness(1.1); }

.btn-double { background: #f39c12; color: #fff; }
.btn-double:hover { filter: brightness(1.1); }

.btn-split { background: #3498db; color: #fff; }
.btn-split:hover { filter: brightness(1.1); }

.btn-surrender { background: #7f8c8d; color: #fff; }
.btn-surrender:hover { filter: brightness(1.1); }

.btn-ins-yes { background: #f39c12; color: #fff; }
.btn-ins-no { background: #95a5a6; color: #fff; }

/* === Insurance === */
#insurance-prompt {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
}

.insurance-box {
  background: rgba(0,0,0,0.85);
  padding: 20px;
  text-align: center;
  border-top: 2px solid #f39c12;
}

.insurance-box p {
  font-size: 1.1rem;
  margin-bottom: 12px;
  color: #f39c12;
}

.insurance-btns {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.insurance-btns .action-btn {
  min-width: 120px;
}

/* === Feedback === */
.feedback-overlay {
  z-index: 200;
  background: rgba(0,0,0,0.75);
}

.feedback-box {
  max-width: 650px;
}

.feedback-wrong h3 {
  color: #e74c3c;
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.feedback-wrong p {
  font-size: 1.1rem;
  margin-bottom: 16px;
}

.feedback-wrong strong {
  color: #4ecb71;
}

.feedback-continue-btn {
  margin-top: 18px;
  display: inline-block;
}

/* === Mini Strategy Chart === */
.mini-chart-wrap {
  margin-top: 12px;
}

.mini-chart-wrap h4 {
  font-size: 0.85rem;
  color: #aaa;
  margin-bottom: 6px;
}

.mini-chart {
  border-collapse: collapse;
  font-size: 0.75rem;
  margin: 0 auto;
}

.mini-chart th, .mini-chart td {
  padding: 4px 7px;
  border: 1px solid #333;
  text-align: center;
  min-width: 28px;
}

.mini-chart th {
  background: #1a1a2e;
  color: #aaa;
  font-weight: 600;
}

.mini-chart .rl {
  background: #1a1a2e;
  color: #ccc;
  font-weight: 600;
  text-align: right;
  padding-right: 8px;
}

.mini-chart .col-hl { background: #2a3a4e; }
.mini-chart .row-hl td { background: rgba(255,255,255,0.05); }
.mini-chart .cell-hl {
  background: #4ecb71 !important;
  color: #000 !important;
  font-weight: 700;
}

/* Action colors in chart */
.mini-chart .a-H { color: #3498db; }
.mini-chart .a-S { color: #e74c3c; }
.mini-chart .a-D, .mini-chart .a-Ds { color: #f39c12; }
.mini-chart .a-P { color: #9b59b6; }
.mini-chart .a-Rh, .mini-chart .a-Rs { color: #95a5a6; }

/* === Results Screen === */
.results-box {
  max-width: 650px;
  text-align: left;
}

.results-box h2 {
  text-align: center;
  color: #4ecb71;
  margin-bottom: 16px;
}

.stat-big {
  text-align: center;
  font-size: 1.8rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}

.stat-sub {
  text-align: center;
  color: #aaa;
  margin-bottom: 20px;
}

.breakdown {
  margin-bottom: 20px;
}

.breakdown h3, .mistakes h3 {
  font-size: 1rem;
  color: #888;
  border-bottom: 1px solid #333;
  padding-bottom: 4px;
  margin-bottom: 8px;
}

.bd-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 0.95rem;
}

.mistakes {
  margin-bottom: 20px;
}

.mistake-row {
  padding: 8px 0;
  border-bottom: 1px solid #222;
}

.mistake-hand {
  font-size: 0.9rem;
  margin-bottom: 2px;
}

.mistake-detail {
  font-size: 0.85rem;
  color: #e74c3c;
}

.results-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 24px;
}

/* === What's New Modal === */
.wn-box {
  text-align: left;
  max-width: 500px;
}

.wn-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.wn-header h2 {
  color: #4ecb71;
}

.wn-item {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #333;
}

.wn-item:last-child { border-bottom: none; }

.wn-item h3 {
  font-size: 1rem;
  color: #fff;
  margin-bottom: 4px;
}

.wn-date {
  font-size: 0.8rem;
  color: #888;
  margin-bottom: 6px;
}

.wn-item p:last-child {
  color: #ccc;
  font-size: 0.9rem;
  line-height: 1.5;
}

/* === Leaderboard Page === */
.page-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px;
  position: relative;
  z-index: 1;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.page-header h1 {
  color: #4ecb71;
  font-size: 1.6rem;
}

.page-header a {
  color: #4ecb71;
  text-decoration: none;
}
.page-header a:hover { text-decoration: underline; }

.filters {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-group label {
  font-size: 0.8rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.filter-group input {
  padding: 8px 12px;
  border: 1px solid #2a5a3a;
  border-radius: 6px;
  background: #0f1923;
  color: #fff;
  font-size: 0.9rem;
  outline: none;
}

.filter-group input:focus { border-color: #4ecb71; }

.filter-btn {
  padding: 8px 20px;
  background: #27ae60;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
}
.filter-btn:hover { background: #2ecc71; }

table.lb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.lb-table th {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid #2a5a3a;
  color: #4ecb71;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.lb-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #1a2a3a;
}

.lb-table tr:hover td {
  background: rgba(255,255,255,0.03);
}

.lb-table .rank { width: 50px; color: #888; }
.lb-table .accuracy { font-weight: 700; color: #4ecb71; }
.lb-table .clickable { cursor: pointer; text-decoration: underline; color: #3498db; }
.lb-table .clickable:hover { color: #5dade2; }

/* Session detail modal */
.detail-box {
  max-width: 700px;
  text-align: left;
  max-height: 80vh;
  overflow-y: auto;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.detail-header h2 { color: #4ecb71; font-size: 1.2rem; }

table.detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.detail-table th {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid #333;
  color: #888;
  font-size: 0.75rem;
  text-transform: uppercase;
}

.detail-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #1a1a2e;
}

.detail-table .correct { color: #2ecc71; }
.detail-table .wrong { color: #e74c3c; }

.empty-state {
  text-align: center;
  color: #666;
  padding: 40px;
  font-size: 1.1rem;
}

/* === Responsive === */
@media (max-width: 600px) {
  .overlay-box { padding: 24px 16px; }
  .start-box h1 { font-size: 1.5rem; }
  .action-btn { padding: 14px 18px; font-size: 1rem; min-width: 80px; }
  .card { width: 70px; height: 100px; }
  .card-rank { font-size: 0.85rem; }
  .card-suit-large { font-size: 1.6rem; }
  .card-row { padding: 4px 10px; min-height: 110px; }
  .mini-chart { font-size: 0.65rem; }
  .mini-chart th, .mini-chart td { padding: 3px 4px; min-width: 22px; }
}
