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

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
    Cantarell, sans-serif;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f172a 100%);
  min-height: 100vh;
}

/* Top Header Bar */
.top-header-bar {
  background: linear-gradient(135deg, #c9a227 0%, #d4af37 50%, #c9a227 100%);
  border-bottom: 3px solid #b8941f;
  box-shadow: 0 4px 20px rgba(201, 162, 39, 0.3);
}

.header-bar-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-bar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.spade-svg {
  width: 48px;
  height: 48px;
  color: #1a1a2e;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.header-bar-title h1 {
  font-family: Georgia, serif;
  font-size: 1.75rem;
  font-weight: bold;
  color: #1a1a2e;
  letter-spacing: 0.1em;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.header-bar-title p {
  color: #3d3d52;
  font-size: 0.875rem;
  margin-top: 0.125rem;
}

.header-bar-right {
  display: flex;
  align-items: center;
}

.combinations-display {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  background: rgba(26, 26, 46, 0.2);
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  border: 2px solid rgba(26, 26, 46, 0.3);
}

.combinations-label {
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #3d3d52;
}

.combinations-value {
  font-size: 1.5rem;
  font-weight: bold;
  color: #1a1a2e;
  font-family: Georgia, serif;
}

.app-container {
  padding: 2rem;
}

.content-wrapper {
  max-width: 1400px;
  margin: 0 auto;
}

/* Main Grid */
/* minmax(0, …) stops the wide results table from stretching the page; it scrolls inside its card. */
.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 3fr);
  gap: 1.5rem;
}

@media (max-width: 1024px) {
  .main-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 480px) {
  .header-bar-content { padding: 1rem; }
  .header-bar-right { display: none; }
}

/* Left Panel */
.left-panel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Cards */
.card {
  background: linear-gradient(135deg, #1e293b 0%, #1a1f2e 100%);
  border-radius: 0.75rem;
  padding: 1.25rem;
  border: 1px solid #d4af37;
  box-shadow:
    0 8px 16px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(212, 175, 55, 0.1);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.icon-svg {
  width: 20px;
  height: 20px;
  color: #d4af37;
}

.card-header h2 {
  color: #d4af37;
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.card-label {
  color: #cbd5e1;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.card-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Form Elements */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  color: #cbd5e1;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

.select-input {
  background: #0f172a;
  color: white;
  font-size: 0.875rem;
  border-radius: 0.5rem;
  padding: 0.625rem 0.875rem;
  border: 1px solid #334155;
  outline: none;
  transition: all 0.3s;
  cursor: pointer;
}

.select-input:hover {
  border-color: #d4af37;
}

.select-input:focus {
  border-color: #d4af37;
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.1);
}

.text-input {
  background: #0f172a;
  color: white;
  font-size: 0.875rem;
  border-radius: 0.5rem;
  padding: 0.625rem 0.875rem;
  border: 1px solid #334155;
  outline: none;
  transition: all 0.3s;
}

.text-input:focus {
  border-color: #d4af37;
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.1);
}

.custom-input-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.back-button {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 0.75rem;
  cursor: pointer;
  text-align: left;
  padding: 0;
  transition: color 0.3s;
}

.back-button:hover {
  color: #d4af37;
}

/* Toggle */
.toggle-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem;
  background: rgba(15, 23, 42, 0.6);
  border-radius: 0.5rem;
  border: 1px solid #334155;
}

.toggle-label {
  color: white;
  font-size: 0.8125rem;
  font-weight: 500;
}

.toggle-desc {
  color: #94a3b8;
  font-size: 0.75rem;
  margin-top: 0.125rem;
}

.toggle-button {
  width: 3rem;
  height: 1.5rem;
  border-radius: 9999px;
  border: none;
  cursor: pointer;
  position: relative;
  transition: background-color 0.3s;
  background: #475569;
}

.toggle-button.active {
  background: #d4af37;
}

.toggle-slider {
  width: 1.25rem;
  height: 1.25rem;
  background: white;
  border-radius: 9999px;
  position: absolute;
  top: 0.125rem;
  left: 0.125rem;
  transition: transform 0.3s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.toggle-button.active .toggle-slider {
  transform: translateX(1.5rem);
}

/* Game Mode Buttons */
.game-mode-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.mode-button {
  padding: 0.875rem;
  border-radius: 0.5rem;
  border: 2px solid #334155;
  background: rgba(15, 23, 42, 0.6);
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.3s;
}

.mode-button:hover {
  background: rgba(30, 41, 59, 0.6);
  border-color: #475569;
  transform: translateY(-2px);
}

.mode-button.active {
  background: linear-gradient(135deg, #d4af37 0%, #c9a227 100%);
  border-color: #d4af37;
  color: #1a1a2e;
  transform: scale(1.02);
  box-shadow: 0 4px 12px rgba(212, 175, 55, 0.4);
}

.mode-title {
  font-weight: 700;
  font-size: 0.875rem;
  letter-spacing: 0.025em;
}

.mode-desc {
  font-size: 0.75rem;
  margin-top: 0.25rem;
  opacity: 0.8;
}

/* Buttons */
.run-button {
  width: 100%;
  background: linear-gradient(135deg, #d4af37 0%, #c9a227 100%);
  color: #1a1a2e;
  font-weight: bold;
  font-size: 0.9375rem;
  padding: 0.875rem;
  border-radius: 0.625rem;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.3s;
  box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
  letter-spacing: 0.025em;
}

.run-button:hover:not(:disabled) {
  background: linear-gradient(135deg, #e6c043 0%, #d4af37 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(212, 175, 55, 0.5);
}

.run-button:active:not(:disabled) {
  transform: translateY(0);
}

.run-button:disabled {
  background: #334155;
  color: #64748b;
  cursor: not-allowed;
  box-shadow: none;
}

.stop-button {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.625rem;
  border: 1px solid #f87171;
  border-radius: 0.625rem;
  background: transparent;
  color: #fca5a5;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.stop-button:hover { background: #7f1d1d; }

/* Settings lock while a run is in progress. */
.select-input:disabled,
.text-input:disabled,
.back-button:disabled,
.toggle-button:disabled,
.mode-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}
.stop-button:focus-visible { outline: 3px solid #fca5a5; outline-offset: 2px; }

.export-button {
  width: 100%;
  background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
  color: #d4af37;
  font-weight: bold;
  font-size: 0.875rem;
  padding: 0.625rem;
  border-radius: 0.625rem;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.3s;
  letter-spacing: 0.025em;
}

.export-button:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1e3a8a 100%);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
  transform: translateY(-2px);
}

.button-icon {
  width: 18px;
  height: 18px;
}

/* Progress */
.progress-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.progress-bar {
  width: 100%;
  background: #0f172a;
  border-radius: 9999px;
  height: 0.75rem;
  overflow: hidden;
  border: 2px solid #334155;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #d4af37 0%, #c9a227 50%, #d4af37 100%);
  background-size: 200% 100%;
  animation: shimmer 2s infinite;
  transition: width 0.3s ease-out;
  width: 0%;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.progress-text {
  text-align: center;
  font-size: 0.75rem;
  color: #94a3b8;
}

/* Best Hand Card */
.best-hand-card {
  animation: fadeIn 0.5s;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.best-hand-content {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.card-display {
  background: white;
  border-radius: 0.625rem;
  padding: 0.875rem;
  display: flex;
  gap: 0.625rem;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.card-icon {
  font-size: 2rem;
  font-weight: bold;
}

.best-win-rate {
  color: #d4af37;
  font-size: 2.25rem;
  font-weight: bold;
  font-family: Georgia, serif;
}

.best-win-count {
  color: #cbd5e1;
  font-size: 0.75rem;
  margin-top: 0.25rem;
}

/* Notice Card */
.notice-card {
  background: linear-gradient(
    135deg,
    rgba(212, 175, 55, 0.15) 0%,
    rgba(201, 162, 39, 0.1) 100%
  );
  border: 2px solid #d4af37;
  border-radius: 0.75rem;
  padding: 1rem;
  box-shadow: 0 4px 12px rgba(212, 175, 55, 0.2);
}

.notice-title {
  color: #d4af37;
  font-weight: 700;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.375rem;
}

.notice-desc {
  color: #cbd5e1;
  font-size: 0.8125rem;
  line-height: 1.5;
}

/* Right Panel */
.right-panel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.results-card {
  background: linear-gradient(135deg, #1e293b 0%, #1a1f2e 100%);
  border-radius: 0.75rem;
  border: 1px solid #d4af37;
  overflow: hidden;
  box-shadow:
    0 12px 24px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(212, 175, 55, 0.1);
}

.results-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  padding: 1rem 1.5rem;
  border-bottom: 2px solid #d4af37;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: center;
  justify-content: space-between;
}

.results-title {
  color: #d4af37;
  font-size: 1.25rem;
  font-weight: bold;
  letter-spacing: 0.1em;
}

.results-info {
  color: #94a3b8;
  font-size: 0.875rem;
}

.results-info .highlight {
  color: #d4af37;
  font-weight: 600;
}

.results-body {
  max-height: 700px;
  overflow-y: auto;
}

.results-body::-webkit-scrollbar {
  width: 10px;
}

.results-body::-webkit-scrollbar-track {
  background: #0f172a;
}

.results-body::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 5px;
}

.results-body::-webkit-scrollbar-thumb:hover {
  background: #475569;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 8rem 1rem;
}

.empty-title {
  color: #cbd5e1;
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
  font-weight: 600;
}

.empty-desc {
  color: #64748b;
  font-size: 0.9375rem;
  max-width: 32rem;
  margin: 0 auto;
  line-height: 1.6;
}

.empty-desc .highlight {
  color: #d4af37;
  font-weight: 600;
}

/* Results Table */
.results-table {
  width: 100%;
  border-collapse: collapse;
}

.results-table thead {
  background: linear-gradient(135deg, #d4af37 0%, #c9a227 100%);
  color: #1a1a2e;
  position: sticky;
  top: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  z-index: 10;
}

.results-table th {
  padding: 0.875rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  user-select: none;
  position: relative;
}

.results-table th.sortable:hover {
  background: rgba(26, 26, 46, 0.1);
}

.sort-button {
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  text-align: inherit;
  cursor: pointer;
}

.sort-button:focus-visible {
  outline: 2px solid #1a1a2e;
  outline-offset: 4px;
  border-radius: 2px;
}

.view-toggle {
  display: flex;
  gap: 0.25rem;
  padding: 0.25rem;
  border: 1px solid #334155;
  border-radius: 0.5rem;
  background: rgba(15, 23, 42, 0.6);
}

.view-button {
  padding: 0.375rem 0.75rem;
  border: 0;
  border-radius: 0.375rem;
  background: transparent;
  color: #94a3b8;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
}

.view-button:hover {
  color: #e2e8f0;
}

.view-button.active {
  background: #d4af37;
  color: #1a1a2e;
}

.view-button:focus-visible {
  outline: 2px solid #d4af37;
  outline-offset: 2px;
}

.results-table td:first-child {
  white-space: nowrap;
}

.combo-count {
  margin-left: 0.375rem;
  color: #94a3b8;
  font-size: 0.75rem;
  font-weight: 500;
}

.results-table th.text-right {
  text-align: right;
}

.sort-indicator {
  display: inline-block;
  margin-left: 0.25rem;
  opacity: 0.3;
}

.sort-indicator::after {
  content: "⬍";
}

.sortable.active .sort-indicator {
  opacity: 1;
}

.sortable.active.asc .sort-indicator::after {
  content: "▲";
}

.sortable.active.desc .sort-indicator::after {
  content: "▼";
}

.results-table tbody tr {
  border-bottom: 1px solid #334155;
  transition: all 0.2s;
}

.results-table tbody tr:nth-child(even) {
  background: rgba(30, 41, 59, 0.4);
}

.results-table tbody tr:nth-child(odd) {
  background: rgba(15, 23, 42, 0.4);
}

.results-table tbody tr:hover {
  background: rgba(212, 175, 55, 0.1);
  transform: translateX(4px);
}

.results-table td {
  padding: 0.875rem 1rem;
  font-size: 0.875rem;
}

.results-table td:first-child {
  color: white;
  font-weight: 600;
}

.text-right {
  text-align: right;
}

.win-rate {
  color: #4ade80;
  font-weight: 700;
}

.loss-rate {
  color: #f87171;
  font-weight: 700;
}

.tie-rate {
  color: #9ca3af;
  font-weight: 700;
}

.result-count {
  color: #cbd5e1;
}

/* Visual Bars */
.visual-bars {
  display: flex;
  gap: 2px;
  width: 8rem;
  margin-left: auto;
}

.bar {
  height: 0.75rem;
  border-radius: 0.25rem;
  transition: all 0.3s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.bar:hover {
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
  filter: brightness(1.2);
}

.bar-win {
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
}

.bar-loss {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.bar-tie {
  background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
}

/* Info Panels */
.info-panels {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

@media (max-width: 768px) {
  .info-panels {
    grid-template-columns: 1fr;
  }
}

.info-card {
  background: linear-gradient(135deg, #1e293b 0%, #1a1f2e 100%);
  border-radius: 0.75rem;
  padding: 1rem;
  border: 1px solid #d4af37;
  box-shadow:
    0 8px 16px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(212, 175, 55, 0.1);
}

.info-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.625rem;
}

.icon-svg-small {
  width: 16px;
  height: 16px;
  color: #d4af37;
}

.info-header h3 {
  color: #d4af37;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.info-text {
  color: #cbd5e1;
  font-size: 0.8125rem;
  line-height: 1.6;
}

.info-text .highlight {
  color: #d4af37;
  font-weight: 600;
}

.info-subtext {
  color: #94a3b8;
  font-size: 0.75rem;
  margin-top: 0.5rem;
  line-height: 1.5;
}

.ruleset-list {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.ruleset-item {
  color: #cbd5e1;
  font-size: 0.8125rem;
}

.ruleset-item span {
  color: #d4af37;
  font-weight: 700;
}

.formula-box {
  font-family: "Courier New", monospace;
  background: rgba(15, 23, 42, 0.6);
  padding: 0.625rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  border: 1px solid #334155;
  color: #cbd5e1;
  margin-bottom: 0.625rem;
}

.formula-list {
  list-style: none;
  color: #94a3b8;
  font-size: 0.75rem;
  line-height: 1.6;
  padding-left: 0;
}

.formula-list li {
  margin-top: 0.25rem;
  padding-left: 1rem;
  position: relative;
}

.formula-list li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: #d4af37;
}

/* Simulation progress details */
.progress-text {
  color: #e2e8f0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.progress-detail {
  color: #94a3b8;
  font-size: 0.75rem;
  line-height: 1.5;
  text-align: center;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.progress-container[data-complete="true"] .progress-fill {
  animation: none;
  background: #22c55e;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  .progress-fill {
    animation: none;
    transition: none;
  }
}
