:root {
  --bg-primary: #0b0f17;
  --bg-secondary: #141c2b;
  --bg-card: #1c2638;
  --accent-gold: #fbbf24;
  --accent-emerald: #10b981;
  --accent-blue: #3b82f6;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-color: #2d3a4f;
  --suit-red: #ef4444;
  --suit-black: #000000;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  background: linear-gradient(180deg, #141c2b 0%, rgba(20, 28, 43, 0.8) 100%);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-group img {
  width: 40px;
  height: 40px;
  border-radius: 8px;
}

.logo-group h1 {
  font-size: 1.4rem;
  font-weight: 700;
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

nav ul {
  display: flex;
  list-style: none;
  gap: 1.5rem;
  flex-wrap: wrap;
}

@media (max-width: 640px) {
  header {
    padding: 0.75rem 1rem;
  }
  .header-container {
    justify-content: center;
    text-align: center;
  }
  .logo-group {
    justify-content: center;
  }
  nav ul {
    gap: 0.85rem;
    justify-content: center;
    font-size: 0.9rem;
  }
  .hero-section h2 {
    font-size: clamp(1.2rem, 5vw, 1.65rem);
    word-break: normal;
    overflow-wrap: normal;
  }
  th, td {
    padding: 0.5rem 0.4rem !important;
    font-size: 0.85rem;
    white-space: normal;
    word-wrap: break-word;
  }
}

nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

nav a:hover, nav a.active {
  color: var(--accent-gold);
}

.main-container {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 1.5rem;
  flex: 1;
  width: 100%;
}

.hero-section {
  text-align: center;
  margin-bottom: 3rem;
  padding: 2.5rem 1rem;
  background: radial-gradient(circle at center, rgba(59, 130, 246, 0.1) 0%, transparent 70%);
  border-radius: 16px;
  border: 1px solid var(--border-color);
}

.hero-section h2 {
  font-size: clamp(1.3rem, 5.5vw, 2.5rem);
  margin-bottom: 0.75rem;
  letter-spacing: -0.02em;
}

.hero-section p {
  color: var(--text-muted);
  font-size: 1.1rem;
  max-width: 700px;
  margin: 0 auto 1.5rem;
}

.grid-layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1.5rem;
  margin-bottom: 3rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.75rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s, border-color 0.2s;
}

.card:hover {
  transform: translateY(-4px);
  border-color: var(--accent-gold);
}

.card h3 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--accent-gold);
}

.form-group {
  margin-bottom: 1.25rem;
}

label {
  display: block;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.input-wrapper input[type="text"],
.input-wrapper textarea {
  padding-right: 2.5rem;
}

.btn-clear {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  line-height: 1;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 2;
}

.input-wrapper textarea + .btn-clear {
  top: 1rem;
  transform: none;
}

.btn-clear:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.15);
}

input[type="text"], textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-main);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

input[type="text"]:focus, textarea:focus {
  border-color: var(--accent-blue);
}

.radio-group {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1.25rem;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

button.btn-primary {
  width: 100%;
  padding: 0.85rem;
  background: linear-gradient(135deg, #fbbf24 0%, #d97706 100%);
  color: #0b0f17;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}

button.btn-primary:hover {
  opacity: 0.95;
  transform: scale(0.99);
}

.results-box {
  margin-top: 1.25rem;
  padding: 1rem;
  background: var(--bg-secondary);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  font-size: 0.95rem;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Histogram Chart Styling */
.histogram-container {
  margin-top: 1rem;
  padding: 0.85rem;
  background: var(--bg-card);
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.histogram-header {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent-gold);
  margin-bottom: 0.75rem;
  display: flex;
  justify-content: space-between;
}

.histogram-grid {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.histogram-bar-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.825rem;
}

.histogram-label {
  width: 40px;
  text-align: right;
  font-weight: 600;
  color: var(--text-main);
  flex-shrink: 0;
}

.histogram-track {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  height: 20px;
  position: relative;
  overflow: hidden;
}

.histogram-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6 0%, #10b981 100%);
  border-radius: 4px;
  transition: width 0.4s ease;
}

.histogram-count {
  width: 50px;
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Suit Emoji Colors & 1-pixel White Outline */
.suit-red {
  color: var(--suit-red);
  font-weight: bold;
  text-shadow: 
    -1px -1px 0 #ffffff,
     1px -1px 0 #ffffff,
    -1px  1px 0 #ffffff,
     1px  1px 0 #ffffff;
}

.suit-black {
  color: var(--suit-black);
  font-weight: bold;
  text-shadow: 
    -1px -1px 0 #ffffff,
     1px -1px 0 #ffffff,
    -1px  1px 0 #ffffff,
     1px  1px 0 #ffffff;
}

.card-tag {
  display: inline-block;
  background: rgba(255, 255, 255, 0.07);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  font-family: monospace;
  font-weight: 600;
}

footer {
  text-align: center;
  padding: 2rem;
  border-top: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: auto;
}
