/* ─── Root Variables ─── */
:root {
  --kmc-bg:           #ffffff;
  --kmc-page-bg:      #f3f4f8;
  --kmc-surface:      #fafbff;
  --kmc-surface2:     #f4f5fb;
  --kmc-border:       #e4e8f4;
  --kmc-border-light: #eef0f8;
  --kmc-accent:       #f59e0b;
  --kmc-accent-dark:  #d97706;
  --kmc-accent-deep:  #92400e;
  --kmc-accent-bg:    #fffbeb;
  --kmc-accent-bg2:   #fef3c7;
  --kmc-teal:         #0891b2;
  --kmc-indigo:       #4f46e5;
  --kmc-text:         #111827;
  --kmc-text2:        #374151;
  --kmc-muted:        #9ca3af;
  --kmc-success:      #10b981;
  --kmc-radius:       14px;
  --kmc-radius-sm:    10px;
  --kmc-font:         'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;
  --kmc-mono:         'SF Mono', 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  --kmc-shadow:       0 2px 20px rgba(0,0,0,0.06);
  --kmc-shadow-card:  0 1px 4px rgba(0,0,0,0.06);
}

/* ─── Wrapper ─── */
.kmc-wrap {
  font-family: var(--kmc-font);
  background: var(--kmc-bg);
  border: 1px solid var(--kmc-border);
  border-radius: 20px;
  padding: 0;
  max-width: 1060px;
  margin: 24px auto;
  color: var(--kmc-text);
  box-shadow: var(--kmc-shadow);
  overflow: hidden;
}

/* ─── Hero Header ─── */
.kmc-hero {
  position: relative;
  background: linear-gradient(118deg, #fffdf5 0%, #fff8e8 50%, #fff3d0 100%);
  border-bottom: 1px solid #f0d9a8;
  padding: 24px 28px 20px;
  overflow: hidden;
  min-height: 108px;
  display: flex;
  align-items: center;
}

/* Subtle radial warmth behind the character */
.kmc-hero::before {
  content: '';
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 55%;
  background: radial-gradient(ellipse 70% 90% at 90% 50%, rgba(245,158,11,0.10) 0%, transparent 70%);
  pointer-events: none;
}

/* Fade mask so character blends into the panel */
.kmc-hero::after {
  content: '';
  position: absolute;
  right: 110px; top: 0; bottom: 0;
  width: 160px;
  background: linear-gradient(to right, rgba(255,252,240,0.95), transparent);
  z-index: 2;
  pointer-events: none;
}

.kmc-hero-text {
  flex: 1;
  position: relative;
  z-index: 3;
}

.kmc-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--kmc-accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.kmc-hero-badge::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.8);
  animation: kmc-pulse 1.5s ease-in-out infinite;
}

@keyframes kmc-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.7); }
}

.kmc-hero-title {
  margin: 0 0 9px;
  font-size: clamp(18px, 3vw, 26px);
  font-weight: 900;
  color: #1c1200;
  line-height: 1.2;
  letter-spacing: -0.5px;
}

.kmc-hero-title em {
  font-style: normal;
  color: var(--kmc-accent-dark);
}

.kmc-hero-steps {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.kmc-hero-step {
  display: flex;
  align-items: center;
  gap: 5px;
  background: #fff;
  border: 1px solid #f0d9a8;
  border-radius: 999px;
  padding: 4px 11px 4px 5px;
  font-size: 11.5px;
  color: var(--kmc-accent-deep);
  box-shadow: 0 1px 3px rgba(245,158,11,0.08);
}

.kmc-hero-step-num {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--kmc-accent);
  color: #fff;
  font-size: 10px; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.kmc-hero-arr {
  color: #d4b483;
  font-size: 14px;
  font-weight: 700;
}

.kmc-hero-char {
  position: absolute;
  right: 0;
  bottom: 0;
  height: 130px;
  z-index: 3;
  pointer-events: none;
  /* slight warm tint via CSS filter */
  filter: drop-shadow(0 2px 12px rgba(245,158,11,0.18));
}

/* ─── Body Container ─── */
.kmc-body {
  padding: 20px 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ─── Panel ─── */
.kmc-panel {
  background: var(--kmc-surface);
  border: 1px solid var(--kmc-border);
  border-radius: var(--kmc-radius);
  padding: 18px 20px;
}

.kmc-step-title {
  margin: 0 0 15px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--kmc-muted);
  display: flex;
  align-items: center;
  gap: 9px;
}

.kmc-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--kmc-accent);
  color: #fff;
  font-size: 11px; font-weight: 900;
  flex-shrink: 0;
}

/* ─── Gift Card Grid ─── */
.kmc-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

@media (min-width: 420px) { .kmc-card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 600px) { .kmc-card-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 780px) { .kmc-card-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@media (min-width: 960px) { .kmc-card-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }

.kmc-card {
  appearance: none;
  border: 1.5px solid var(--kmc-border);
  border-radius: var(--kmc-radius-sm);
  padding: 10px 8px;
  background: #fff;
  cursor: pointer;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s, transform 0.08s;
  color: var(--kmc-text);
  box-shadow: var(--kmc-shadow-card);
}

.kmc-card:hover {
  border-color: #fcd34d;
  background: #fffdf5;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(245,158,11,0.12);
}

.kmc-card:active { transform: scale(0.97); }

.kmc-card.is-selected {
  border-color: var(--kmc-accent);
  background: var(--kmc-accent-bg);
  box-shadow: 0 0 0 1.5px var(--kmc-accent), 0 4px 14px rgba(245,158,11,0.18);
}

.kmc-card-img {
  width: 40px; height: 40px;
  border-radius: 8px;
  background: var(--kmc-surface2);
  border: 1px solid var(--kmc-border-light);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.kmc-card-img img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 7px;
}

.kmc-card-title {
  font-size: 10.5px;
  line-height: 1.35;
  font-weight: 700;
  color: var(--kmc-text2);
}

/* ─── Help text ─── */
.kmc-help {
  margin-top: 12px;
  color: var(--kmc-muted);
  font-size: 11.5px;
  line-height: 1.65;
}

/* ─── Amount Slider ─── */
.kmc-amount-display {
  font-size: 38px;
  font-weight: 900;
  font-family: var(--kmc-mono);
  letter-spacing: -1.5px;
  color: var(--kmc-accent-dark);
  line-height: 1;
  margin-bottom: 10px;
}

.kmc-amount-display-unit {
  font-size: 16px;
  font-weight: 400;
  color: var(--kmc-muted);
  margin-left: 4px;
}

.kmc-amount-slider {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 520px;
}

.kmc-amount-slider input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 3px;
  background: #e5e7eb;
  outline: none;
  cursor: pointer;
  background-image: linear-gradient(var(--kmc-accent), var(--kmc-accent));
  background-size: 30% 100%;
  background-repeat: no-repeat;
}

.kmc-amount-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--kmc-accent);
  border: 3px solid #fff;
  box-shadow: 0 1px 6px rgba(245,158,11,0.45), 0 0 0 1px var(--kmc-accent);
  cursor: pointer;
  transition: box-shadow 0.15s;
}

.kmc-amount-slider input[type="range"]::-webkit-slider-thumb:hover {
  box-shadow: 0 2px 10px rgba(245,158,11,0.5), 0 0 0 4px rgba(245,158,11,0.15);
}

.kmc-amount-slider input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px;
  border: none; border-radius: 50%;
  background: var(--kmc-accent);
  cursor: pointer;
}

.kmc-amount-minmax {
  display: flex;
  justify-content: space-between;
  color: var(--kmc-muted);
  font-size: 11px;
  font-family: var(--kmc-mono);
}

/* ─── Sites Panel ─── */

/* Desktop table header – hidden on mobile */
.kmc-sites-head { display: none; }

/* ── Mobile: stacked card layout ── */
.kmc-site-row {
  display: block;
  padding: 14px 0;
  border-bottom: 1px solid var(--kmc-border-light);
  transition: background 0.12s;
}

.kmc-site-row:hover { background: rgba(245,158,11,0.025); }
.kmc-site-row:last-child { border-bottom: none; }
.kmc-site-row--hidden { display: none !important; }

/* Top-ranked row gets a subtle gold tint */
.kmc-site-row.kmc-rank-1 {
  background: linear-gradient(to right, rgba(253,224,71,0.06), transparent);
  border-radius: 10px;
  padding: 14px 10px;
  margin: 0 -4px;
}

.kmc-sites-col-site { margin-bottom: 10px; }

.kmc-site-cell {
  display: flex;
  flex-direction: row;
  gap: 10px;
  align-items: center;
}

.kmc-site-img {
  width: 88px; height: 26px;
  border-radius: 6px;
  background: #fff;
  border: 1px solid var(--kmc-border);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.kmc-site-img img { width: 100%; height: 100%; object-fit: contain; }

.kmc-site-name {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--kmc-text);
  line-height: 1.3;
}

.kmc-site-name p { margin: 0; }

/* Rank badge */
.kmc-rank-badge {
  display: inline-block;
  background: var(--kmc-accent-bg2);
  color: var(--kmc-accent-deep);
  border: 1px solid #fcd34d;
  font-size: 9px; font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  letter-spacing: 0.5px;
  margin-left: 5px;
  vertical-align: middle;
}

/* Mobile 2×2 data grid */
.kmc-site-data-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.kmc-site-data-cell {
  background: var(--kmc-surface2);
  border: 1px solid var(--kmc-border);
  border-radius: 8px;
  padding: 8px 10px;
}

.kmc-site-data-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--kmc-muted);
  margin-bottom: 3px;
}

/* Rates */
.kmc-rate {
  font-size: 15px;
  font-weight: 700;
  font-family: var(--kmc-mono);
  color: var(--kmc-teal);
}

.kmc-note {
  margin-top: 2px;
  color: var(--kmc-muted);
  font-size: 10px;
  line-height: 1.4;
}

/* Payout amounts */
.kmc-money {
  font-size: 15px;
  font-weight: 700;
  font-family: var(--kmc-mono);
  color: var(--kmc-indigo);
}

/* Highest payout: amber */
.kmc-site-row.kmc-rank-1 .kmc-money {
  color: var(--kmc-accent-dark);
  font-size: 16px;
}

/* ── Desktop: 5-column table layout ── */
@media (min-width: 640px) {
  .kmc-sites-head {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1.1fr 1.1fr;
    gap: 10px;
    padding: 0 0 10px;
    border-bottom: 1.5px solid var(--kmc-border);
    color: var(--kmc-muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    margin-bottom: 2px;
  }

  .kmc-site-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1.1fr 1.1fr;
    gap: 10px;
    align-items: center;
  }

  .kmc-site-row.kmc-rank-1 { padding: 12px 10px; }

  .kmc-sites-col-site { margin-bottom: 0; }

  /* Undo mobile card wrappers */
  .kmc-site-data-grid  { display: contents; }
  .kmc-site-data-cell  { background: none; border: none; border-radius: 0; padding: 0; }
  .kmc-site-data-label { display: none; }
}

/* ─── Empty / loading states ─── */
.kmc-sites-empty {
  color: var(--kmc-muted);
  font-size: 13px;
  padding: 12px 0;
}

/* ─── Responsive tweaks ─── */
@media (max-width: 440px) {
  .kmc-wrap      { margin: 16px 0; border-radius: 16px; }
  .kmc-hero      { padding: 18px 16px 16px; min-height: 96px; }
  .kmc-body      { padding: 16px 14px 22px; }
  .kmc-hero-char { height: 110px; }
  .kmc-amount-display { font-size: 30px; }
  .kmc-site-img  { width: 72px; height: 22px; }
}

@media (min-width: 640px) {
  .kmc-hero-char { height: 140px; }
}
