:root {
  --bg: #f5f5f4;
  --surface: #ffffff;
  --text: #1a1a18;
  --text-muted: #6b6b67;
  --border: rgba(0, 0, 0, 0.10);
  --accent: #534AB7;
  --accent-light: #EEEDFE;
  --winner: #534AB7;
  --winner-bg: #EEEDFE;
  --loser-opacity: 0.45;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1e1e1c;
    --surface: #2a2a28;
    --text: #e8e8e4;
    --text-muted: #9e9e96;
    --border: rgba(255, 255, 255, 0.08);
    --accent: #7F77DD;
    --accent-light: #26215C;
    --winner: #AFA9EC;
    --winner-bg: #26215C;
  }
}

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

html, body {
  height: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Yu Gothic UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
}

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(12px + var(--safe-top)) 12px calc(16px + var(--safe-bottom));
  max-width: 480px;
  margin: 0 auto;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.screen--center {
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 16px;
}

.title {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.3;
}

.desc {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
}

.meta {
  font-size: 12px;
  color: var(--text-muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 999px;
  padding: 14px 28px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  transition: transform 0.1s, opacity 0.15s;
}

.btn:active { transform: scale(0.98); }

.btn--secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn--block { width: 100%; }

.error-box {
  background: #fff0f0;
  color: #8b1a1a;
  border: 1px solid #f5c2c2;
  border-radius: var(--radius);
  padding: 16px;
  font-size: 14px;
  line-height: 1.5;
  text-align: left;
  width: 100%;
}

@media (prefers-color-scheme: dark) {
  .error-box {
    background: #3a2020;
    color: #ffb4b4;
    border-color: #5a3030;
  }
}

.progress-wrap {
  margin-bottom: 10px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.25s ease;
}

.round-header {
  text-align: center;
  margin-bottom: 8px;
}

.round-group {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-light);
  padding: 4px 12px;
  border-radius: 999px;
}

.compare {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
}

.card {
  flex: 1;
  position: relative;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color 0.15s, box-shadow 0.15s, opacity 0.2s, transform 0.1s;
  min-height: 0;
  padding: 0;
  text-align: left;
  font: inherit;
  color: inherit;
}

.card:active:not(.card--locked) {
  transform: scale(0.99);
}

.card--winner {
  border-color: var(--winner);
  box-shadow: 0 0 0 3px var(--winner-bg);
}

.card--loser {
  opacity: var(--loser-opacity);
}

.card--locked {
  pointer-events: none;
  cursor: default;
}

.card__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card__name {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  padding: 28px 14px 12px;
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  line-height: 1.35;
  color: #fff;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.72) 0%, rgba(0, 0, 0, 0.35) 55%, transparent 100%);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

.card__meta {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.85);
  font-weight: 400;
  margin-top: 2px;
}

.vs-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 6px 0;
  flex-shrink: 0;
}

.vs-divider__line {
  flex: 1;
  height: 1px;
  background: var(--border);
}

.vs-divider__badge {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
}

.summary-list {
  list-style: none;
  width: 100%;
  margin: 12px 0;
  max-height: 200px;
  overflow-y: auto;
  text-align: left;
  font-size: 13px;
}

.summary-list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.summary-list .winner { font-weight: 600; color: var(--accent); }

.json-box {
  width: 100%;
  margin-top: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  line-height: 1.45;
  max-height: 180px;
  overflow: auto;
  text-align: left;
  white-space: pre-wrap;
  word-break: break-all;
}

.copy-status {
  font-size: 13px;
  color: var(--accent);
  min-height: 20px;
}
