:root {
  --bg: #0f172a;
  --card: #111827;
  --red: #ef4444;
  --blue: #3b82f6;
  --green: #22c55e;
  --accent: #facc15;
  --text: #f8fafc;
  --muted: #94a3b8;
  --line: rgba(148, 163, 184, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(59, 130, 246, 0.22), transparent 32rem),
    radial-gradient(circle at bottom right, rgba(250, 204, 21, 0.12), transparent 30rem),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(17, 24, 39, 0.78);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(32px, 5vw, 54px);
  line-height: 1.05;
}

.hero-copy {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.7;
}

.hero-badge {
  min-width: 168px;
  padding: 18px;
  border: 1px solid rgba(250, 204, 21, 0.3);
  border-radius: 20px;
  background: rgba(250, 204, 21, 0.08);
  text-align: center;
}

.hero-badge span {
  display: block;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.hero-badge strong {
  display: block;
  margin-top: 6px;
  font-size: 18px;
}

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

.card {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(17, 24, 39, 0.9);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.2);
}

.result-card,
.log-card {
  grid-column: 1 / -1;
}

.card-header {
  display: flex;
  gap: 14px;
  margin-bottom: 20px;
}

.step {
  display: inline-flex;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: rgba(59, 130, 246, 0.16);
  color: var(--blue);
  font-weight: 900;
}

.card h2 {
  margin-bottom: 6px;
  font-size: 20px;
}

.card p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.6;
}

.upload-box {
  display: flex;
  min-height: 190px;
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px dashed rgba(59, 130, 246, 0.7);
  border-radius: 22px;
  background: rgba(15, 23, 42, 0.7);
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.upload-box:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.upload-box.is-dragging {
  border-color: var(--accent);
  background: rgba(250, 204, 21, 0.08);
  box-shadow: inset 0 0 0 1px rgba(250, 204, 21, 0.28);
}

.upload-box input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-icon {
  display: inline-flex;
  width: 54px;
  height: 54px;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  background: var(--blue);
  color: var(--text);
  font-size: 34px;
  font-weight: 300;
}

.upload-box small,
.helper-text {
  color: var(--muted);
}

.helper-text {
  margin-top: 14px;
  font-size: 13px;
}

.upload-status {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.66);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.image-analysis-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.image-analysis-actions button {
  cursor: pointer;
  border: 1px solid rgba(34, 197, 94, 0.45);
  border-radius: 14px;
  background: var(--green);
  color: #04130a;
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 900;
}

.image-analysis-actions button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.image-analysis-actions span {
  flex: 1 1 220px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.image-analysis-actions span.is-success {
  color: #86efac;
}

.image-analysis-actions span.is-error {
  color: #fecaca;
}

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

.empty-preview {
  grid-column: 1 / -1;
  padding: 18px;
  border: 1px dashed rgba(148, 163, 184, 0.24);
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.42);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  text-align: center;
}

.preview-card {
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.78);
}

.preview-image {
  position: relative;
  aspect-ratio: 16 / 10;
  background: #020617;
}

.preview-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.order-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  display: inline-flex;
  min-width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(2, 6, 23, 0.78);
  color: var(--accent);
  font-size: 13px;
  font-weight: 900;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.preview-body {
  padding: 14px;
}

.file-name {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-meta {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.preview-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-top: 12px;
}

.preview-actions button {
  cursor: pointer;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 11px;
  background: rgba(15, 23, 42, 0.9);
  color: var(--text);
  padding: 9px 8px;
  font-size: 12px;
  font-weight: 900;
}

.preview-actions button:hover:not(:disabled) {
  border-color: var(--blue);
  color: var(--blue);
}

.preview-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.preview-actions .delete-button {
  border-color: rgba(239, 68, 68, 0.35);
  color: #fecaca;
}

.preview-actions .delete-button:hover {
  border-color: var(--red);
  color: var(--red);
}

.upload-error {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: 14px;
  background: rgba(239, 68, 68, 0.08);
  color: #fecaca;
  font-size: 13px;
  line-height: 1.5;
}

.result-review-panel {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 20px;
  background: rgba(15, 23, 42, 0.5);
}

code {
  color: var(--accent);
}

.form-grid,
.settings-grid,
.metric-grid {
  display: grid;
  gap: 14px;
}

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

.result-string {
  overflow-wrap: anywhere;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.66);
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.6;
}

.manual-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.45);
}

.result-review-grid {
  margin-top: 12px;
}

.result-cell {
  position: relative;
  display: inline-flex;
  width: 42px;
  height: 42px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  justify-self: center;
  border: 1px solid rgba(248, 250, 252, 0.12);
  border-radius: 999px;
  color: var(--text);
  font-size: 14px;
  font-weight: 900;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.25);
}

.result-cell::after {
  content: attr(data-number);
  position: absolute;
  right: -5px;
  bottom: -5px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: #020617;
  color: var(--muted);
  font-size: 10px;
  line-height: 18px;
}

.result-cell.value-r {
  background: var(--red);
}

.result-cell.value-b {
  background: var(--blue);
}

.result-cell.value-t {
  background: var(--green);
}

.result-cell.value-empty {
  background: #475569;
  color: #cbd5e1;
}

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

.rule-layout {
  display: grid;
  gap: 14px;
}

.rule-panel {
  padding: 18px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 20px;
  background: rgba(15, 23, 42, 0.55);
}

.rule-panel-main {
  border-color: rgba(250, 204, 21, 0.28);
  background: rgba(250, 204, 21, 0.06);
}

.rule-panel-single.is-disabled {
  opacity: 0.48;
}

.rule-panel-single.is-disabled select {
  cursor: not-allowed;
}

.rule-panel-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.rule-panel-title strong {
  color: var(--text);
  font-size: 16px;
  font-weight: 950;
}

.rule-panel-title span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  text-align: right;
}

.compact-settings-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.rule-panel-main > label {
  display: inline-block;
  width: min(260px, 100%);
  margin-right: 10px;
  margin-bottom: 14px;
  vertical-align: top;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.preset-grid button {
  min-height: 54px;
  cursor: pointer;
  border: 1px solid rgba(250, 204, 21, 0.28);
  border-radius: 16px;
  background: rgba(250, 204, 21, 0.08);
  color: var(--accent);
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.4;
  text-align: left;
}

.preset-grid button:hover,
.preset-grid button.is-active {
  border-color: var(--accent);
  background: rgba(250, 204, 21, 0.16);
}

label span {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.82);
  color: var(--text);
  outline: none;
  padding: 14px 16px;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 52%,
    calc(100% - 12px) 52%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 36px;
}

.rule-summary {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid rgba(59, 130, 246, 0.24);
  border-radius: 18px;
  background: rgba(59, 130, 246, 0.08);
  color: #bfdbfe;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.7;
}

.bet-steps {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.bet-step {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.72);
}

.bet-step span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.bet-step strong {
  display: block;
  margin-top: 6px;
  color: var(--accent);
  font-size: 15px;
}

.metric,
.summary-card {
  min-height: 118px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(15, 23, 42, 0.72);
}

.analysis-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.analysis-actions button {
  cursor: pointer;
  border: 1px solid rgba(34, 197, 94, 0.42);
  border-radius: 16px;
  background: var(--green);
  color: #052e16;
  padding: 13px 18px;
  font-weight: 950;
}

.analysis-actions button:hover {
  filter: brightness(1.08);
}

.analysis-actions span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.metric span,
.summary-card span {
  display: block;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.metric strong,
.summary-card strong {
  display: block;
  font-size: 28px;
}

.metric-blue strong {
  color: var(--blue);
}

.metric-green strong {
  color: var(--green);
}

.metric-red strong {
  color: var(--red);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.summary-card strong {
  font-size: clamp(20px, 2.4vw, 30px);
}

.summary-card .positive,
.profit-positive {
  color: var(--accent);
}

.summary-card .negative,
.profit-negative {
  color: var(--blue);
}

.summary-card .neutral,
.profit-neutral {
  color: var(--text);
}

.empty-result,
.empty-table {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.7;
  text-align: center;
}

.empty-result {
  grid-column: 1 / -1;
  padding: 30px;
  border: 1px dashed rgba(148, 163, 184, 0.24);
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.42);
}

.pattern-section,
.chart-section {
  margin-top: 18px;
}

.section-title-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.section-title-row h3 {
  margin: 0;
  font-size: 21px;
}

.section-title-row p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

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

.pattern-group {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(15, 23, 42, 0.72);
}

.pattern-group h4 {
  margin: 0 0 14px;
  font-size: 16px;
}

.pattern-group-red h4 {
  color: #fecaca;
}

.pattern-group-blue h4 {
  color: #bfdbfe;
}

.pattern-group-tie {
  grid-column: 1 / -1;
}

.pattern-group-tie h4 {
  color: #bbf7d0;
}

.pattern-stat-list {
  display: grid;
  gap: 10px;
}

.pattern-stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 14px;
  background: rgba(2, 6, 23, 0.36);
}

.pattern-stat-row span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.pattern-stat-row strong {
  color: var(--text);
  font-size: 15px;
  font-weight: 950;
}

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

.chart-card {
  min-height: 340px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(15, 23, 42, 0.72);
}

.chart-card h4 {
  margin: 0 0 14px;
  color: var(--text);
  font-size: 16px;
}

.chart-canvas-wrap {
  position: relative;
  height: 270px;
}

.chart-canvas-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

.table-wrap {
  overflow: auto;
  margin: 16px 0 0;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 18px;
  background: #020617;
}

.bet-log-table {
  width: 100%;
  min-width: 1080px;
  border-collapse: collapse;
  color: #dbeafe;
  font-size: 13px;
}

.bet-log-table th,
.bet-log-table td {
  padding: 13px 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.bet-log-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #0f172a;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.bet-log-table tr:hover td {
  background: rgba(59, 130, 246, 0.06);
}

.bet-log-table tr.is-failed td {
  background: rgba(239, 68, 68, 0.08);
}

.pattern-text {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.step-badge,
.status-badge,
.color-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 950;
}

.step-badge {
  min-width: 34px;
  height: 28px;
  background: rgba(148, 163, 184, 0.16);
  color: var(--text);
}

.step-badge.step-high {
  background: rgba(250, 204, 21, 0.18);
  color: var(--accent);
  box-shadow: 0 0 0 1px rgba(250, 204, 21, 0.25);
}

.color-badge {
  min-width: 32px;
  height: 28px;
  color: var(--text);
}

.color-badge.value-r {
  background: var(--red);
}

.color-badge.value-b {
  background: var(--blue);
}

.color-badge.value-t {
  background: var(--green);
}

.status-badge {
  padding: 7px 10px;
}

.status-win {
  background: rgba(250, 204, 21, 0.16);
  color: var(--accent);
}

.status-lose {
  background: rgba(59, 130, 246, 0.16);
  color: #93c5fd;
}

.status-set-failed {
  background: rgba(239, 68, 68, 0.16);
  color: #fecaca;
}

.status-set-end {
  background: rgba(148, 163, 184, 0.16);
  color: #cbd5e1;
}

.log-box {
  min-height: 160px;
  padding: 18px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 18px;
  background: #020617;
  color: #cbd5e1;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 14px;
  line-height: 1.7;
}

.safety-notice {
  margin-top: 18px;
  padding: 18px 20px;
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: 20px;
  background: rgba(239, 68, 68, 0.1);
  color: #fecaca;
  font-size: 14px;
  line-height: 1.7;
}

@media (max-width: 900px) {
  .hero,
  .dashboard-grid,
  .form-grid,
  .settings-grid,
  .compact-settings-grid,
  .metric-grid,
  .summary-grid,
  .pattern-stats-grid,
  .chart-grid,
  .preset-grid,
  .preview-grid {
    grid-template-columns: 1fr;
  }

  .rule-panel-main > label {
    display: block;
    width: 100%;
    margin-right: 0;
  }

  .rule-panel-title {
    display: block;
  }

  .rule-panel-title span {
    display: block;
    margin-top: 6px;
    text-align: left;
  }

  .chart-card {
    min-height: 300px;
  }

  .chart-canvas-wrap {
    height: 240px;
  }

  .section-title-row {
    display: block;
  }

  .section-title-row p {
    margin-top: 6px;
  }

  .pattern-group-tie {
    grid-column: auto;
  }

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

  .hero {
    display: block;
  }

  .hero-badge {
    margin-top: 20px;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding: 16px 0;
  }

  .hero,
  .card {
    border-radius: 20px;
    padding: 20px;
  }

  .card-header {
    flex-direction: column;
  }

  .analysis-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .manual-grid {
    grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  }

  .result-cell {
    width: 38px;
    height: 38px;
  }

  .bet-steps {
    grid-template-columns: 1fr;
  }

  .preview-actions {
    grid-template-columns: 1fr;
  }
}
