:root {
  --bg: #eef6ef;
  --surface: #fbfdfb;
  --surface-strong: #ffffff;
  --text: #10211a;
  --muted: #466053;
  --line: #c8ddd0;
  --accent: #0f7a3b;
  --accent-strong: #0b5c2c;
  --accent-soft: #e4f5e8;
  --win: #0f7a3b;
  --draw: #d97706;
  --loss: #c2410c;
  --gold: #d4a11e;
  --gold-strong: #9a6a00;
  --gold-soft: #fff4bf;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0) 180px),
    linear-gradient(180deg, rgba(13, 122, 59, 0.06), rgba(13, 122, 59, 0) 260px),
    var(--bg);
  color: var(--text);
  font-family: "Pretendard", "Noto Sans KR", sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 14px;
}

.page-header h1 {
  margin: 0;
  font-size: 31px;
  line-height: 1.15;
  color: #0b3b22;
  display: flex;
  align-items: center;
  gap: 10px;
}

.title-icon {
  width: 28px;
  height: 42px;
  flex-shrink: 0;
}

.header-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

#save-status {
  color: var(--muted);
}

.status-icon {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid #cde0d3;
  background: #f4faf6;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.status-icon::before {
  font-size: 15px;
  line-height: 1;
}

.status-icon[data-state="loading"]::before {
  content: "…";
  color: var(--muted);
}

.status-icon[data-state="ready"]::before,
.status-icon[data-state="success"]::before {
  content: "✓";
  color: var(--win);
}

.status-icon[data-state="saving"]::before {
  content: "↻";
  color: var(--accent);
}

.status-icon[data-state="error"]::before {
  content: "!";
  color: var(--loss);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#save-button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  padding: 10px 15px;
  cursor: pointer;
  font-weight: 700;
}

#save-button:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.standings-panel,
.match-card,
.deck-controls {
  background: linear-gradient(180deg, var(--surface-strong), var(--surface));
  border: 1px solid var(--line);
  border-radius: 10px;
}

.standings-panel {
  display: grid;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 0 rgba(16, 33, 26, 0.04);
}

.standings-header-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.standings-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.standings-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}

.standings-header strong {
  font-size: 14px;
  color: #0b3b22;
}

.standings-header span {
  color: var(--muted);
  font-size: 14px;
}

.standings-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  cursor: pointer;
}

.standings-item {
  display: grid;
  gap: 6px;
  padding: 10px 8px;
  text-align: center;
  border: 1px solid #d9e8dd;
  border-radius: 8px;
  background: #f7fbf8;
}

.standings-rank {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.standings-rank-medal {
  display: inline-block;
  min-width: 1.25em;
  text-align: center;
}

.standings-label {
  color: #0b3b22;
  font-size: 14px;
  white-space: nowrap;
}

.standings-name {
  color: #0b3b22;
}

.standings-amount {
  font-weight: 700;
}

.standings-amount.positive {
  color: var(--win);
}

.standings-amount.negative {
  color: var(--loss);
}

.standings-amount.even {
  color: var(--muted);
}

.standings-amount.inactive {
  color: var(--muted);
  font-weight: 600;
}

.standings-caret {
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
  transition: transform 140ms ease;
}

.standings-panel.expanded .standings-caret {
  transform: rotate(180deg);
}

.standings-panel.expanded .standings-list {
  grid-template-columns: 1fr;
  gap: 6px;
}

.standings-panel.expanded .standings-item {
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  text-align: left;
}

.standings-panel.expanded .standings-rank {
  font-size: 12px;
}

.standings-panel.expanded .standings-name {
  min-width: 0;
}

.participants-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.participants-header strong {
  font-size: 14px;
  color: #0b3b22;
}

.participants-manage-button,
.participants-close-button,
.participants-done-button,
#add-player-button,
.participant-remove {
  border: 1px solid var(--line);
  background: #ffffff;
  color: #0b3b22;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
}

.participants-manage-button {
  min-width: 36px;
  padding: 6px 10px;
  font-weight: 700;
  line-height: 1;
}

.participant-remove:disabled {
  cursor: default;
  opacity: 0.45;
}

.participants-editor {
  display: grid;
  gap: 8px;
}

.participant-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.participant-input {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
  min-width: 0;
}

.participant-input:focus {
  outline: 2px solid rgba(15, 122, 59, 0.18);
  border-color: var(--accent);
}

.participants-modal {
  width: min(420px, calc(100vw - 24px));
  padding: 0;
  border: 0;
  background: transparent;
}

.participants-modal::backdrop {
  background: rgba(16, 33, 26, 0.28);
}

.participants-modal-card {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 16px;
  background: #fbfdfb;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 18px 42px rgba(16, 33, 26, 0.16);
}

.participants-close-button {
  min-width: 36px;
  padding: 6px 10px;
  line-height: 1;
}

.participants-modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.winner-row {
  position: relative;
  background: linear-gradient(90deg, var(--gold-soft), #f7fbef 22%, #e4f5e8 100%);
  border-bottom: 0;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: inset 0 0 0 2px rgba(212, 161, 30, 0.92);
}

.winner-row::after {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 7px;
  pointer-events: none;
}

.winner-row .player-name {
  font-weight: 800;
}

.winner-row .player-name,
.winner-row .pred-outcome,
.winner-row .score-value,
.winner-row .score-step,
.winner-row .player-lock-button {
  position: relative;
  z-index: 1;
}

.winner-row .player-name,
.winner-row .pred-outcome {
  color: var(--gold-strong);
}

.winner-row .pred-outcome {
  font-weight: 800;
}

.winner-row .score-value,
.winner-row .score-step,
.winner-row .player-lock-button {
  border-color: #d6c17c;
  background: rgba(255, 253, 241, 0.9);
}

.matches {
  display: block;
}

.deck-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
  box-shadow: 0 1px 0 rgba(16, 33, 26, 0.04);
}

.deck-controls button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  background: #f7fbf7;
  border-radius: 8px;
  cursor: pointer;
  font-size: 20px;
  color: #0b3b22;
}

.deck-controls button:disabled {
  cursor: default;
  opacity: 0.45;
}

.deck-status {
  display: grid;
  justify-items: center;
  gap: 4px;
}

.deck-status strong {
  font-size: 16px;
}

.deck-status span {
  color: var(--muted);
  font-size: 13px;
}

.match-card {
  padding: 16px 16px 14px;
  border-top: 4px solid var(--accent);
  box-shadow: 0 1px 0 rgba(16, 33, 26, 0.04);
  background:
    linear-gradient(180deg, rgba(244, 250, 246, 0.86), rgba(244, 250, 246, 0) 92px),
    linear-gradient(180deg, var(--surface-strong), var(--surface));
}

.match-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.match-info {
  min-width: 0;
}

.match-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.round-label {
  color: var(--accent-strong);
  font-size: 15px;
  margin-bottom: 6px;
  font-weight: 700;
}

.match-title {
  margin: 0 0 4px;
  font-size: 26px;
  line-height: 1.2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.match-time {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  font-weight: 600;
  white-space: pre-line;
  line-height: 1.45;
}

.match-entry-time {
  color: var(--accent-strong);
  font-weight: 800;
}

.market-pulse {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid #d9e8dd;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.68);
}

.market-pulse-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.market-pulse-header strong {
  color: #0b3b22;
  font-size: 13px;
}

.market-pulse-header span {
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.market-pulse-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.market-pulse-summary p {
  margin: 0;
  color: #355245;
  font-size: 12px;
  line-height: 1.35;
}

.market-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.market-badge.favorite {
  background: #e6f5ec;
  color: #1f6f47;
}

.market-badge.lean {
  background: #eef3f7;
  color: #315a73;
}

.market-badge.tight {
  background: #f3efe7;
  color: #7c5a2b;
}

.market-badge.draw-watch {
  background: #f1edf5;
  color: #6c4d83;
}

.market-pulse-bar {
  display: flex;
  width: 100%;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e6efe8;
}

.market-pulse-segment.home {
  background: #2f8f5b;
}

.market-pulse-segment.draw {
  background: #8aa290;
}

.market-pulse-segment.away {
  background: #d08a34;
}

.market-pulse-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.market-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}

.market-chip.home {
  background: #eef7f1;
  color: #1f6f47;
}

.market-chip.draw {
  background: #f0f3f1;
  color: #51665a;
}

.market-chip.away {
  background: #fcf3e8;
  color: #9c5f18;
}

.market-team-inline .team-inline-name,
.market-chip-label {
  font-size: 12px;
  font-weight: 700;
}

.market-team-inline .team-flag {
  width: 14px;
  height: 14px;
}

.market-chip-value {
  font-size: 12px;
}

.team-inline,
.team-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.team-meta {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
  line-height: 1.2;
}

.team-inline {
  max-width: 100%;
}

.team-label {
  justify-content: center;
}

.team-inline-name,
.team-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.team-separator {
  color: var(--muted);
  font-size: 17px;
  font-weight: 700;
}

.team-flag {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  border: 1px solid rgba(16, 33, 26, 0.1);
  flex-shrink: 0;
}

.team-inline-name {
  font-size: 24px;
  font-weight: 700;
}

.table-head {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 64px 38px;
  gap: 10px;
  padding: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  border-bottom: 1px solid var(--line);
  align-items: center;
}

.head-name {
  grid-column: 1;
  grid-row: 1 / 3;
  text-align: center;
}

.head-score-title {
  grid-column: 2;
  grid-row: 1;
  text-align: center;
}

.head-outcome {
  grid-column: 3;
  grid-row: 1 / 3;
  text-align: center;
}

.head-lock {
  grid-column: 4;
  grid-row: 1 / 3;
  text-align: center;
}

.head-team,
.head-score-separator {
  grid-row: 2;
  font-weight: 700;
  color: var(--accent-strong);
  text-align: center;
  font-size: 12px;
  line-height: 1.3;
}

.head-left-team {
  grid-column: 2;
  justify-self: start;
}

.head-score-separator {
  grid-column: 2;
  justify-self: center;
}

.head-right-team {
  grid-column: 2;
  justify-self: end;
}

.prediction-list {
  display: grid;
}

.prediction-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 64px 38px;
  gap: 10px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #ece9e6;
}

.prediction-row:last-child {
  border-bottom: 0;
}

.player-cell {
  display: grid;
  justify-items: center;
  gap: 2px;
  min-width: 0;
}

.player-name {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  text-align: center;
  white-space: nowrap;
  word-break: keep-all;
  font-size: 14px;
}

.score-cell {
  display: grid;
  justify-items: center;
  gap: 6px;
  min-width: 0;
}

.score-controls {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
}

.score-stepper {
  display: inline-flex;
  align-items: center;
}

.score-value {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  height: 36px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 16px;
  font-weight: 700;
  user-select: none;
  touch-action: none;
}

.score-value.is-editable {
  cursor: ns-resize;
}

.score-value.is-dragging {
  border-color: #79b592;
  background: #f3f9f4;
  color: #0b5c2c;
}

.score-separator {
  color: var(--muted);
  font-size: 17px;
  font-weight: 800;
  line-height: 1;
}

.player-meta {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
}

.lock-cell {
  display: flex;
  justify-content: center;
}

.player-lock-button {
  border: 1px solid #cfe0d5;
  background: #f8fcf9;
  color: #0b5c2c;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.player-lock-button:disabled {
  cursor: default;
  opacity: 0.45;
}

.winner-crown {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.pred-outcome {
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  word-break: keep-all;
}

.pred-outcome.win {
  color: var(--win);
}

.pred-outcome.draw {
  color: var(--draw);
}

.pred-outcome.loss {
  color: var(--loss);
}

.result-row {
  border-top: 1px solid var(--line);
}

.result-row .score-value {
  background: #eff4ef;
  color: #6b7f73;
  cursor: default;
  touch-action: auto;
}

.result-row .lock-cell {
  min-height: 32px;
}

.result-summary {
  margin-top: 10px;
  background: linear-gradient(180deg, #fcfffd, #f1f8f3);
  border: 1px solid #cfe0d5;
  border-radius: 8px;
  padding: 12px;
  line-height: 1.6;
}

.result-summary.empty {
  background: #f6faf6;
  border-color: var(--line);
}

@media (max-width: 700px) {
  .app-shell {
    padding: 16px 12px 24px;
  }

  .page-header,
  .match-top {
    display: grid;
  }

  .page-header {
    gap: 10px;
    margin-bottom: 10px;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .page-header h1 {
    font-size: 24px;
  }

  .title-icon {
    width: 24px;
    height: 36px;
  }

  .header-meta {
    justify-content: flex-end;
    gap: 8px;
  }

  .status-icon {
    width: 30px;
    height: 30px;
  }

  #save-button {
    padding: 9px 12px;
  }

  .deck-controls {
    display: grid;
    grid-template-columns: 44px 1fr 44px;
    padding: 10px 12px;
  }

  .standings-panel {
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 10px;
  }

  .standings-header {
    align-items: start;
    gap: 6px;
  }

  .standings-header strong,
  .standings-header span {
    font-size: 12px;
    line-height: 1.35;
  }

  .standings-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .standings-panel.expanded .standings-list {
    grid-template-columns: 1fr;
  }

  .standings-item {
    padding: 8px 4px;
    gap: 4px;
  }

  .standings-rank {
    font-size: 11px;
  }

  .standings-label {
    font-size: 11px;
    line-height: 1.3;
    white-space: normal;
  }

  .standings-panel.expanded .standings-item {
    grid-template-columns: 32px minmax(0, 1fr) auto;
    padding: 8px 10px;
  }

  .standings-header-row,
  .participants-header {
    align-items: start;
  }

  .participants-manage-button,
  .participants-close-button,
  .participants-done-button,
  #add-player-button,
  .participant-remove,
  .participant-input {
    font-size: 13px;
  }

  .participants-modal-card {
    padding: 14px;
  }

  .match-card {
    padding: 12px;
  }

  .match-top {
    gap: 10px;
    margin-bottom: 10px;
    align-items: start;
  }

  .round-label,
  .match-time {
    font-size: 13px;
  }

  .match-title {
    margin-bottom: 2px;
    font-size: 21px;
    gap: 6px;
  }

  .match-title-row {
    gap: 8px;
  }

  .market-pulse {
    margin-bottom: 12px;
    padding: 8px 9px;
  }

  .market-pulse-header {
    align-items: start;
    gap: 6px;
  }

  .market-pulse-header strong,
  .group-standings-title,
  .market-pulse-header span,
  .group-standings-meta,
  .group-standings-rank,
  .group-standings-record,
  .team-insight-summary,
  .team-insight-subtitle,
  .team-player-name,
  .team-player-detail,
  .team-player-note,
  .match-insight-note,
  .market-pulse-summary p,
  .market-team-inline .team-inline-name,
  .market-chip-label,
  .market-chip-value {
    font-size: 11px;
  }

  .market-pulse-summary {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .market-badge {
    font-size: 10px;
  }

  .market-chip {
    gap: 5px;
    padding: 4px 7px;
  }

  .market-team-inline .team-flag {
    width: 12px;
    height: 12px;
  }

  .prediction-row {
    grid-template-columns: 78px minmax(0, 1fr) 50px 34px;
    gap: 6px;
    padding: 10px 0;
  }

  .table-head {
    grid-template-columns: 78px minmax(0, 1fr) 50px 34px;
    gap: 6px;
    padding-bottom: 6px;
    font-size: 11px;
  }

  .pred-outcome {
    font-size: 11px;
    text-align: center;
  }

  .player-name {
    gap: 4px;
    font-size: 13px;
  }

  .player-meta {
    font-size: 10px;
  }

  .score-controls {
    gap: 4px;
  }

  .score-value {
    min-width: 68px;
    height: 36px;
    padding: 0 8px;
    font-size: 16px;
  }

  .score-separator {
    font-size: 17px;
  }

  .score-stepper {
    gap: 3px;
  }

  .score-step {
    width: 20px;
    height: 20px;
    border-radius: 7px;
    font-size: 14px;
  }

  .score-value {
    min-width: 56px;
    height: 30px;
    padding: 0 5px;
    font-size: 14px;
  }

  .score-separator {
    font-size: 15px;
  }

  .player-lock-button {
    width: 28px;
    height: 28px;
    font-size: 13px;
  }

  .team-flag {
    width: 18px;
    height: 18px;
  }

  .team-inline-name {
    font-size: 19px;
  }

  .team-name {
    font-size: 11px;
  }

  .result-summary {
    padding: 10px;
    font-size: 13px;
    line-height: 1.5;
  }

  .winner-row::after {
    inset: 3px;
  }

  .winner-crown {
    width: 11px;
    height: 11px;
  }
}
