* {
  box-sizing: border-box;
}

:root {
  --bg: #f6f9ff;
  --bg-soft: #eef5ff;
  --card: #ffffff;
  --card-strong: #f8fbff;
  --border: #dce7f7;
  --border-strong: #cbd9ea;
  --text: #132033;
  --muted: #4d6178;
  --accent: #2478ff;
  --accent-2: #3ccf91;
  --accent-3: #ffd166;
  --danger: #e23b4d;
  --shadow: 0 14px 38px rgba(30, 80, 160, 0.11);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(36, 120, 255, 0.14), transparent 34%),
    radial-gradient(circle at 85% 12%, rgba(60, 207, 145, 0.1), transparent 25%),
    radial-gradient(circle at bottom right, rgba(255, 209, 102, 0.1), transparent 30%),
    linear-gradient(180deg, #f6f9ff 0%, #eef5ff 48%, #edf3fb 100%);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(36, 120, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(36, 120, 255, 0.04) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(circle at center, black 25%, transparent 85%);
  opacity: 0.22;
}

.eqsy-poker-trainer {
  width: 100%;
  padding: 24px;
}

.trainer-card {
  position: relative;
  max-width: 1180px;
  margin: 0 auto;
  padding: 26px;
  border: 1px solid var(--border);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.92));
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.trainer-card::after {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: 27px;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.top-bar {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 1fr);
  gap: 18px;
  align-items: start;
  margin-bottom: 22px;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mode-badge,
.panel-badge {
  width: fit-content;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 800;
  color: #ffffff;
  background: linear-gradient(135deg, var(--accent) 0%, #4e94ff 100%);
  box-shadow: 0 10px 28px rgba(36, 120, 255, 0.18);
}

h1 {
  margin: 0;
  font-size: clamp(32px, 5vw, 58px);
  line-height: 0.96;
  letter-spacing: -0.04em;
}

.hero-copy p,
.panel-copy {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
  max-width: 62ch;
}

.metric-rail {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.metric-box,
.panel,
.hand-section,
.guess-area,
.result-box,
.leaderboard-card {
  border: 1px solid var(--border);
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(30, 80, 160, 0.08);
}

.metric-box {
  padding: 18px 16px 16px;
  border-radius: 20px;
  min-height: 112px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.metric-box span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.metric-box strong {
  font-size: clamp(28px, 3.6vw, 42px);
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--accent);
}

.controls {
  display: grid;
  grid-template-columns: 1.1fr 1fr 0.9fr 0.9fr 0.9fr;
  gap: 12px;
  margin-bottom: 14px;
}

label {
  display: block;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

select,
input[type="number"] {
  width: 100%;
  margin-top: 8px;
  padding: 13px 14px;
  border-radius: 16px;
  border: 1px solid var(--border-strong);
  background: #ffffff;
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
}

select:focus,
input[type="number"]:focus,
input[type="range"]:focus-visible {
  border-color: rgba(102, 194, 255, 0.8);
  box-shadow: 0 0 0 4px rgba(102, 194, 255, 0.12);
}

select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

button {
  border: 0;
  border-radius: 16px;
  padding: 13px 18px;
  background: linear-gradient(135deg, #2478ff 0%, #5aa4ff 100%);
  color: #ffffff;
  font-weight: 900;
  font-size: 15px;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
  align-self: end;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(36, 120, 255, 0.2);
  filter: saturate(1.02);
}

button:disabled {
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  opacity: 0.6;
}

button.secondary {
  background: linear-gradient(135deg, #132033 0%, #22334d 100%);
  color: #ffffff;
  border: 1px solid var(--border);
}

button.secondary:hover {
  box-shadow: 0 14px 30px rgba(19, 32, 51, 0.22);
}

.spot-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 14px 18px;
  margin-bottom: 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: #f8fbff;
}

.spot-theme {
  font-weight: 900;
  letter-spacing: -0.02em;
  font-size: 16px;
}

.spot-details {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.spot-area {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.hand-section {
  border-radius: 22px;
  padding: 18px;
  min-height: 182px;
  background: #f8fbff;
}

.hand-section h2,
.panel h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.cards {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.card {
  width: 78px;
  height: 108px;
  border-radius: 16px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: #ffffff;
  border: 1px solid #cbd9ea;
  box-shadow: 0 8px 18px rgba(40, 70, 110, 0.12);
  font-size: 24px;
  font-weight: 900;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.card:hover {
  transform: translateY(-2px) rotate(-1deg);
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.3);
}

.card .rank {
  line-height: 1;
}

.card .suit {
  align-self: flex-end;
  font-size: 30px;
  line-height: 1;
}

.card.red {
  color: #e23b4d;
}

.card.black {
  color: #202b3a;
}

.empty-board {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  padding: 18px 0 4px;
}

.guess-area {
  border-radius: 22px;
  padding: 18px;
  margin-bottom: 16px;
  background: #f8fbff;
}

.guess-area label {
  font-size: 14px;
}

.guess-row {
  display: grid;
  grid-template-columns: 120px 26px 1fr;
  gap: 10px;
  align-items: end;
  margin-top: 10px;
}

.guess-row span {
  font-size: 22px;
  font-weight: 900;
  color: var(--accent);
  padding-bottom: 8px;
}

input[type="range"] {
  width: 100%;
  margin-top: 16px;
  accent-color: var(--accent);
}

.result-box {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
  border-radius: 22px;
  padding: 12px;
  background: #ffffff;
}

.result-box > div {
  padding: 16px;
  border-radius: 18px;
  background: #eef5ff;
  border: 1px solid var(--border);
  text-align: center;
}

.result-box span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.result-box strong {
  font-size: 26px;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--accent);
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 18px;
}

.panel {
  border-radius: 22px;
  padding: 18px;
  background: #ffffff;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.panel-copy {
  margin-bottom: 14px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 10px;
}

.progress-meta strong {
  font-size: 15px;
  letter-spacing: -0.01em;
}

.progress-meta span {
  color: var(--muted);
  font-size: 13px;
}

.progress-track {
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: #dce7f7;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) 100%);
  transition: width 0.32s ease;
}

.leaderboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.leaderboard-card {
  padding: 16px;
  border-radius: 18px;
  background: #eef5ff;
  border: 1px solid var(--border);
}

.leaderboard-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.leaderboard-card strong {
  font-size: 28px;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--accent);
}

.bottom-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, #eef5ff 0%, #ffffff 100%);
  color: var(--accent);
  font-weight: 900;
  text-decoration: none;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.secondary-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(36, 120, 255, 0.12);
}

.flash-perfect .trainer-card {
  box-shadow: 0 0 0 1px rgba(140, 233, 154, 0.18), var(--shadow);
}

.flash-good .trainer-card {
  box-shadow: 0 0 0 1px rgba(102, 194, 255, 0.16), var(--shadow);
}

.flash-close .trainer-card {
  box-shadow: 0 0 0 1px rgba(255, 209, 102, 0.16), var(--shadow);
}

.flash-miss .trainer-card {
  box-shadow: 0 0 0 1px rgba(255, 102, 122, 0.18), var(--shadow);
}

.flash-perfect .mode-badge,
.flash-perfect .panel-badge {
  background: linear-gradient(135deg, #3ccf91 0%, #7ee8b5 100%);
}

.flash-good .mode-badge,
.flash-good .panel-badge {
  background: linear-gradient(135deg, #2478ff 0%, #5aa4ff 100%);
}

.flash-close .mode-badge,
.flash-close .panel-badge {
  background: linear-gradient(135deg, #ffd166 0%, #ffdf8b 100%);
  color: #132033;
}

.flash-miss .mode-badge,
.flash-miss .panel-badge {
  background: linear-gradient(135deg, #e23b4d 0%, #ff6e7d 100%);
}

.hidden {
  display: none;
}

@media (max-width: 920px) {
  .top-bar,
  .summary-grid,
  .spot-area {
    grid-template-columns: 1fr;
  }

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

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

@media (max-width: 640px) {
  .eqsy-poker-trainer {
    padding: 16px;
  }

  .trainer-card {
    padding: 18px;
    border-radius: 22px;
  }

  .metric-rail,
  .controls,
  .leaderboard-grid,
  .result-box {
    grid-template-columns: 1fr;
  }

  .spot-meta,
  .progress-meta,
  .panel-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .guess-row {
    grid-template-columns: 1fr 24px;
  }

  .guess-row button {
    grid-column: 1 / -1;
  }

  .bottom-actions {
    flex-direction: column;
  }

  .secondary-link {
    width: 100%;
  }

  .card {
    width: 66px;
    height: 94px;
    font-size: 20px;
  }

  .card .suit {
    font-size: 26px;
  }
}

/* Leaderboard Card */
.leaderboard-card {
  margin: 24px 0;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.8), rgba(248, 251, 255, 0.6));
  backdrop-filter: blur(8px);
}

.leaderboard-card h2 {
  margin: 0 0 14px 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.leaderboard-tabs,
.leaderboard-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.lb-tab {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.lb-tab:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.lb-tab.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.daily-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 8px 12px;
  background: var(--bg-soft);
  border-radius: 8px;
}

.daily-bar label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.daily-bar input[type="date"] {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
}

.lb-sub {
  margin: 0 0 12px 0;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

.leaderboard-wrap {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-bottom: 12px;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 600px;
}

.leaderboard-table thead {
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
}

.leaderboard-table th {
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text);
}

.leaderboard-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s ease;
}

.leaderboard-table tbody tr:hover {
  background: var(--bg-soft);
}

.leaderboard-table td {
  padding: 8px 12px;
  color: var(--text);
}

.leaderboard-table td:first-child {
  font-weight: 700;
  color: var(--accent);
}

.leaderboard-footer {
  text-align: center;
}

.lb-inline-toggle {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #ffffff;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.lb-inline-toggle:hover {
  border-color: var(--accent);
  color: #1a5dd4;
}

.link-more {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s ease;
}

.link-more:hover {
  color: #1a5dd4;
}

/* Modal for name input */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  pointer-events: none;
}

.modal:not(.hidden) {
  pointer-events: auto;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--card);
  border-radius: 12px;
  padding: 32px;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(30, 80, 160, 0.2);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-content h2 {
  margin: 0 0 8px 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.modal-content p {
  margin: 0 0 20px 0;
  font-size: 14px;
  color: var(--muted);
}

.modal-content input {
  width: 100%;
  padding: 12px 16px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  margin-bottom: 20px;
  font-family: inherit;
  transition: border-color 0.2s ease;
}

.modal-content input:focus {
  outline: none;
  border-color: var(--accent);
  background: #ffffff;
}

.modal-content input::placeholder {
  color: var(--muted);
}

.modal-actions {
  display: flex;
  gap: 12px;
  flex-direction: row-reverse;
}

.modal-btn {
  flex: 1;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.modal-btn.save {
  background: var(--accent);
  color: white;
}

.modal-btn.save:hover {
  background: #1a5dd4;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(36, 120, 255, 0.3);
}

.modal-btn.cancel {
  background: var(--border);
  color: var(--muted);
}

.modal-btn.cancel:hover {
  background: var(--border-strong);
  color: var(--text);
}

.hidden {
  display: none !important;
}
