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

/* ── Design tokens ──────────────────────────────────────────────── */
:root {
  /* Surfaces — Material dark elevation system */
  --bg:           #0F1117;
  --surface:      #1A1D27;
  --surface-2:    #22263A;
  --surface-3:    #2A2F46;

  /* Borders */
  --outline:      rgba(255, 255, 255, 0.07);
  --outline-md:   rgba(255, 255, 255, 0.13);

  /* Text */
  --on-bg:        #E4E6F0;
  --on-surface:   #C8CADB;
  --on-muted:     #7A7F9A;
  --on-faint:     #3E4260;

  /* Green — car win */
  --green:        #4ADE80;
  --green-tint:   rgba(74, 222, 128, 0.10);
  --green-border: rgba(74, 222, 128, 0.30);

  /* Amber — cash win */
  --amber:        #FBBF24;
  --amber-tint:   rgba(251, 191, 36, 0.10);
  --amber-border: rgba(251, 191, 36, 0.28);

  /* Red — error */
  --red:          #F87171;
  --red-tint:     rgba(248, 113, 113, 0.08);
  --red-border:   rgba(248, 113, 113, 0.22);

  --radius:       12px;
  --radius-sm:    8px;
  --radius-xs:    6px;
  --transition:   0.18s ease;
}

/* ── Base ───────────────────────────────────────────────────────── */
html { height: 100%; }

body {
  min-height: 100vh;
  background: var(--bg);
  font-family: 'Manrope', system-ui, sans-serif;
  color: var(--on-bg);
  padding: 0 1rem 4rem;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app {
  max-width: 560px;
  margin: 0 auto;
}

/* ── Header ─────────────────────────────────────────────────────── */
.header {
  padding: 3rem 0 2rem;
  text-align: center;
}

.header-brand {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--on-muted);
  margin-bottom: 1rem;
}

.header-title {
  font-size: clamp(2rem, 6.5vw, 2.75rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.1;
  color: var(--on-bg);
  margin-bottom: 0.75rem;
}

.header-sub {
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--on-muted);
  line-height: 1.65;
  max-width: 380px;
  margin: 0 auto;
}

/* ── Card base ──────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 0.75rem;
}

/* ── Input card ─────────────────────────────────────────────────── */
.card-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--on-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 0.75rem;
}

.count-badge {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--on-faint);
  background: var(--surface-2);
  border: 1px solid var(--outline);
  padding: 0.18rem 0.55rem;
  border-radius: 99px;
  transition: color var(--transition), border-color var(--transition);
}
.count-badge.active { color: var(--green); border-color: rgba(74, 222, 128, 0.22); }
.count-badge.warn   { color: var(--amber); border-color: rgba(251, 191, 36, 0.22); }

textarea {
  display: block;
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--outline);
  border-radius: var(--radius-sm);
  color: var(--on-bg);
  font-family: 'Manrope', system-ui, sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.9;
  padding: 0.875rem 1rem;
  resize: vertical;
  min-height: 108px;
  max-height: 260px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  caret-color: var(--green);
}
textarea::placeholder { color: var(--on-faint); font-weight: 400; }
textarea:focus {
  border-color: rgba(74, 222, 128, 0.38);
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.07);
}

.input-hint {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--on-faint);
  line-height: 1.5;
}

.warn-box {
  display: none;
  margin-top: 0.6rem;
  padding: 0.6rem 0.875rem;
  background: var(--amber-tint);
  border: 1px solid var(--amber-border);
  border-radius: var(--radius-xs);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--amber);
  line-height: 1.5;
}
.warn-box.show { display: block; }

/* ── Action row ─────────────────────────────────────────────────── */
.action-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* ── Buttons ────────────────────────────────────────────────────── */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex: 1;
  padding: 0.8rem 1.25rem;
  background: var(--green);
  color: #0A1F0A;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: opacity var(--transition), transform 0.1s, box-shadow var(--transition);
}
.btn-primary:hover:not(:disabled) {
  opacity: 0.9;
  box-shadow: 0 4px 20px rgba(74, 222, 128, 0.22);
}
.btn-primary:active:not(:disabled) { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.28; cursor: not-allowed; }

.btn-ghost {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0 1rem;
  background: transparent;
  color: var(--on-muted);
  border: 1px solid var(--outline);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}
.btn-ghost:hover:not(:disabled) {
  color: var(--on-bg);
  border-color: var(--outline-md);
  background: rgba(255, 255, 255, 0.03);
}
.btn-ghost.copied { color: var(--green); border-color: rgba(74, 222, 128, 0.25); }
.btn-ghost:disabled { opacity: 0.28; cursor: not-allowed; }

/* ── Progress card ──────────────────────────────────────────────── */
.progress-card {
  display: none;
}
.progress-card.show { display: block; }

.progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.875rem;
}

.progress-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--on-muted);
}

.progress-frac {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--green);
  font-variant-numeric: tabular-nums;
}

.progress-track {
  height: 3px;
  background: var(--outline);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 99px;
  width: 0%;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-status {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--on-faint);
}

/* ── Summary card ───────────────────────────────────────────────── */
.summary-card {
  display: none;
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  margin-bottom: 0.75rem;
  flex-direction: row;
  align-items: center;
  justify-content: space-around;
}
.summary-card.show { display: flex; }

.summary-stat { text-align: center; flex: 1; }

.summary-num {
  display: block;
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--on-muted);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.summary-car  .summary-num { color: var(--green); }
.summary-cash .summary-num { color: var(--amber); }
.summary-err               { color: var(--red); }

.summary-label {
  display: block;
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--on-faint);
  margin-top: 0.35rem;
}

.summary-divider {
  width: 1px;
  height: 38px;
  background: var(--outline);
  flex-shrink: 0;
}

/* ── Results container ──────────────────────────────────────────── */
.results {
  margin-bottom: 0.75rem;
}

/* ── Table wrapper ──────────────────────────────────────────────── */
.result-table-wrap {
  border: 1px solid var(--outline);
  border-radius: var(--radius);
  overflow: hidden;
}

.result-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

.result-table thead th {
  padding: 0.6rem 1rem;
  font-size: 0.67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--on-faint);
  text-align: left;
  background: var(--surface-2);
  border-bottom: 1px solid var(--outline);
}

/* ── Result row ─────────────────────────────────────────────────── */
.ri {
  border-bottom: 1px solid var(--outline);
  transition: background 0.3s, box-shadow 0.3s;
  animation: slideUp 0.26s ease backwards;
}
.ri:last-child { border-bottom: none; }

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

/* Won — car: inset left stripe via box-shadow (cross-browser safe on <tr>) */
.ri.s-car {
  background: var(--green-tint);
  box-shadow: inset 3px 0 0 var(--green);
}
/* Won — cash */
.ri.s-cash {
  background: var(--amber-tint);
  box-shadow: inset 3px 0 0 var(--amber);
}
/* Lost — fully readable, neutral */
.ri.s-lost { /* no special treatment — wins stand out by being loud, not by dimming losers */ }
/* Error */
.ri.s-error {
  background: var(--red-tint);
  box-shadow: inset 3px 0 0 var(--red);
}

/* ── Table cells ─────────────────────────────────────────────────── */
.result-table td {
  padding: 0.8rem 1rem;
  vertical-align: middle;
}

/* ID cell */
.ri-id {
  font-size: 0.9rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--on-muted);
}
.ri.s-car   .ri-id { color: var(--green); }
.ri.s-cash  .ri-id { color: var(--amber); }
.ri.s-lost  .ri-id { color: var(--on-muted); }
.ri.s-error .ri-id { color: var(--red); }

/* Status cell — shrink-wrap to badge content */
.ri-status {
  white-space: nowrap;
  width: 1%;
}

/* Detail cell */
.ri-detail {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--on-faint);
  line-height: 1.5;
}
.ri.s-car   .ri-detail { color: rgba(74, 222, 128, 0.65); }
.ri.s-cash  .ri-detail { color: rgba(251, 191, 36, 0.55); }
.ri.s-error .ri-detail { color: rgba(248, 113, 113, 0.65); }
.ri-detail strong { font-weight: 600; color: inherit; }

/* ── Status badge ───────────────────────────────────────────────── */
.ri-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-xs);
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.04);
  color: var(--on-faint);
  border: 1px solid var(--outline);
  transition: all 0.3s;
}
.ri.s-checking .ri-badge {
  color: rgba(74, 222, 128, 0.5);
  border-color: rgba(74, 222, 128, 0.12);
  background: rgba(74, 222, 128, 0.05);
}
.ri.s-car .ri-badge {
  color: var(--green);
  background: rgba(74, 222, 128, 0.14);
  border-color: rgba(74, 222, 128, 0.28);
}
.ri.s-cash .ri-badge {
  color: var(--amber);
  background: rgba(251, 191, 36, 0.12);
  border-color: rgba(251, 191, 36, 0.26);
}
.ri.s-lost .ri-badge {
  color: var(--on-faint);
  opacity: 0.7;
}
.ri.s-error .ri-badge {
  color: var(--red);
  background: rgba(248, 113, 113, 0.08);
  border-color: rgba(248, 113, 113, 0.18);
}

/* ── Spinner ────────────────────────────────────────────────────── */
.spin {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(74, 222, 128, 0.12);
  border-top-color: var(--green);
  border-radius: 50%;
  flex-shrink: 0;
  animation: rotate 0.65s linear infinite;
}
@keyframes rotate { to { transform: rotate(360deg); } }

/* ── Reset button ───────────────────────────────────────────────── */
.reset-btn {
  display: none;
  width: 100%;
  padding: 0.75rem;
  background: transparent;
  color: var(--on-muted);
  border: 1px solid var(--outline);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
  margin-bottom: 0.75rem;
}
.reset-btn.show { display: block; }
.reset-btn:hover {
  color: var(--on-bg);
  border-color: var(--outline-md);
  background: rgba(255, 255, 255, 0.03);
}

/* ── Footer ─────────────────────────────────────────────────────── */
.footer {
  text-align: center;
  padding-top: 2rem;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--on-faint);
  letter-spacing: 0.04em;
}

/* ── Mobile responsive ──────────────────────────────────────────── */
@media (max-width: 500px) {

  body {
    padding: 0 0.75rem 3rem;
  }

  .header {
    padding: 2rem 0 1.25rem;
  }

  .header-title {
    font-size: clamp(1.7rem, 8vw, 2.25rem);
  }

  .header-sub {
    font-size: 0.83rem;
  }

  /* ── Summary: collapse to 2×2 grid ── */
  .summary-card.show {
    display: grid;
    grid-template-columns: 1fr 1fr;
    justify-items: center;
    padding: 0;
    overflow: hidden;
  }

  .summary-divider {
    display: none;
  }

  .summary-stat {
    width: 100%;
    text-align: center;
    padding: 1rem 0.5rem;
  }

  /* top-left: Autónyeremény */
  .summary-stat:nth-child(1) {
    border-right: 1px solid var(--outline);
    border-bottom: 1px solid var(--outline);
  }
  /* top-right: Készpénznyeremény */
  .summary-stat:nth-child(3) {
    border-bottom: 1px solid var(--outline);
  }
  /* bottom-left: Ellenőrzött */
  .summary-stat:nth-child(5) {
    border-right: 1px solid var(--outline);
  }
  /* bottom-right: Hiba — no extra borders */

  .summary-num {
    font-size: 1.875rem;
  }

  .summary-label {
    font-size: 0.6rem;
    letter-spacing: 0.05em;
  }

  /* ── Results table: card-style rows ── */
  .result-table thead {
    display: none;
  }

  .result-table tbody tr.ri {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    padding: 0.75rem 1rem;
    gap: 0.2rem 0.5rem;
  }

  .result-table td {
    padding: 0;
    vertical-align: middle;
  }

  .ri-id {
    grid-column: 1;
    grid-row: 1;
    align-self: center;
    font-size: 0.875rem;
  }

  .ri-status {
    grid-column: 2;
    grid-row: 1;
    align-self: center;
    width: auto;
  }

  .ri-detail {
    grid-column: 1 / -1;
    grid-row: 2;
    font-size: 0.73rem;
  }

  .ri-detail:empty {
    display: none;
  }

}

/* ── Very small screens: stack action buttons ── */
@media (max-width: 360px) {
  .action-row {
    flex-direction: column;
  }

  .btn-ghost {
    padding: 0.75rem 1rem;
    justify-content: center;
  }
}
