:root {
  color-scheme: light;
  font-family: Arial, Helvetica, sans-serif;
  background: #f4f2ed;
  color: #1f2933;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
}

button,
input {
  font: inherit;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0;
  display: grid;
  gap: 24px;
}

.page-header {
  min-width: 0;
}

.page-header h1 {
  margin: 0;
  color: #1f2933;
  font-size: clamp(1.8rem, 3.4vw, 3rem);
  line-height: 1.1;
}

.panel,
.raw-card,
.results {
  min-width: 0;
  background: #ffffff;
  border: 1px solid #d8d3c8;
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 10px 28px rgba(31, 41, 51, 0.08);
}

.intro {
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #276c63;
}

h1,
h2 {
  margin: 0;
  line-height: 1.15;
}

h2 {
  margin-bottom: 12px;
  font-size: 1.1rem;
}

.uploader {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.file-picker {
  display: grid;
  place-items: center;
  min-height: 92px;
  border: 2px dashed #7a8c87;
  border-radius: 8px;
  background: #f9faf7;
  color: #276c63;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  padding: 16px;
  width: 100%;
  min-width: 0;
  overflow: hidden;
}

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

.image-list {
  display: grid;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
}

.upload-item {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 36px;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-width: 0;
  min-height: 80px;
  border: 1px solid #d8d3c8;
  border-radius: 8px;
  padding: 8px;
  background: #fbfcf8;
}

.upload-details {
  min-width: 0;
}

.upload-item img {
  width: 64px;
  height: 64px;
  max-width: 100%;
  object-fit: cover;
  border-radius: 6px;
  background: #111827;
}

.upload-title {
  font-weight: 700;
  line-height: 1.25;
  min-width: 0;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.upload-meta {
  margin-top: 4px;
  font-size: 0.88rem;
  color: #52616b;
}

.upload-message {
  margin-top: 4px;
  color: #b42318;
  font-size: 0.88rem;
}

.upload-processing {
  border-color: #276c63;
}

.upload-done {
  border-color: #74aa8d;
}

.upload-failed {
  border-color: #d92d20;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.remove-upload {
  width: 32px;
  min-width: 32px;
  min-height: 32px;
  align-self: start;
  padding: 0;
  border-radius: 999px;
  background: #e7ece8;
  color: #234b46;
  font-size: 1.2rem;
  line-height: 1;
}

.remove-upload:hover {
  background: #dce5df;
}

.remove-upload:disabled {
  background: #e5e7eb;
  color: #9ca3af;
}

button {
  width: fit-content;
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  padding: 0 18px;
  background: #276c63;
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
}

button + button {
  background: #334e68;
}

.raw-actions button {
  background: #276c63;
}

button:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

.status {
  min-height: 1.4em;
  margin: 0;
  color: #52616b;
}

.status.error {
  color: #b42318;
}

.results {
  display: grid;
  gap: 24px;
}

.results > div {
  min-width: 0;
}

.winner-card {
  margin-bottom: 14px;
  border: 1px solid #d8d3c8;
  border-radius: 8px;
  background: #f9faf7;
  padding: 14px;
  font-weight: 700;
  color: #234b46;
}

.raw-json {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.raw-json summary {
  cursor: pointer;
  width: fit-content;
  font-size: 1.05rem;
  font-weight: 700;
  color: #234b46;
}

.raw-json pre,
.raw-json textarea {
  display: block;
  width: 100%;
  min-height: clamp(280px, 46vh, 620px);
  max-height: 70vh;
  border: 1px solid #21313d;
  overflow: auto;
  border-radius: 8px;
  background: #101820;
  color: #f8fafc;
  padding: 16px;
  line-height: 1.5;
  font: 0.9rem Consolas, "Courier New", monospace;
  white-space: pre-wrap;
}

.raw-json textarea {
  resize: vertical;
  background: #ffffff;
  color: #111827;
  outline: none;
  box-shadow: none;
}

.raw-json textarea:focus {
  border-color: #276c63;
  box-shadow: 0 0 0 3px rgba(39, 108, 99, 0.18);
}

.raw-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.raw-edit-error {
  margin: 10px 0 0;
  color: #b42318;
  font-size: 0.95rem;
}

.table-scroll {
  max-width: 100%;
  overflow-x: auto;
  scrollbar-gutter: stable;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  border-bottom: 1px solid #e5e0d6;
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  overflow-wrap: break-word;
}

th {
  background: #eef6f4;
  color: #234b46;
}

.score-value {
  display: inline-block;
  min-width: 3ch;
}

.wins-count {
  display: inline-block;
  min-width: 1.4ch;
}

.medal {
  display: inline-block;
  width: 0.82rem;
  height: 0.82rem;
  margin-left: 0.45rem;
  border-radius: 999px;
  vertical-align: -0.08em;
  box-shadow: inset 0 0 0 1px rgba(31, 41, 51, 0.22), 0 1px 2px rgba(31, 41, 51, 0.18);
}

.medal-gold {
  background: linear-gradient(135deg, #fff2a6, #d69a00);
}

.medal-silver {
  background: linear-gradient(135deg, #f8fafc, #a8b3c2);
}

.medal-bronze {
  background: linear-gradient(135deg, #f1c08a, #9a5a1f);
}

.narrow-label {
  display: none;
}

@media (max-width: 640px) {
  .shell {
    width: min(1180px, calc(100% - 20px));
    padding: 24px 0;
    gap: 18px;
  }

  .panel,
  .raw-card,
  .results {
    padding: 16px;
  }

  .winner-card {
    padding: 12px;
    font-size: 0.95rem;
  }

  .table-scroll {
    margin: 0 -8px;
    padding: 0 8px;
  }

  table {
    table-layout: auto;
  }

  th,
  td {
    padding: 10px 9px;
    white-space: nowrap;
    overflow-wrap: normal;
  }

  .wide-label {
    display: none;
  }

  .narrow-label {
    display: inline;
  }

  #scores-table {
    min-width: max-content;
  }

  #scores-table th,
  #scores-table td {
    text-align: center;
  }

  #scores-table .game-heading,
  #scores-table tbody td:not(:last-child) {
    min-width: 52px;
  }

  #scores-table thead th:first-child,
  #scores-table tbody th {
    position: sticky;
    left: 0;
    z-index: 3;
    width: 86px;
    min-width: 86px;
    max-width: 86px;
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
    box-shadow: 8px 0 12px -12px rgba(31, 41, 51, 0.45);
  }

  #scores-table thead th:last-child,
  #scores-table tbody td:last-child {
    position: sticky;
    right: 0;
    z-index: 3;
    width: 44px;
    min-width: 44px;
    text-align: center;
    box-shadow: -8px 0 12px -12px rgba(31, 41, 51, 0.45);
  }

  #scores-table thead th:first-child,
  #scores-table thead th:last-child {
    z-index: 4;
  }

  #scores-table tbody th,
  #scores-table tbody td:last-child {
    background: #f4fbf9;
  }

  #scores-table .medal {
    display: none;
  }

  .score-value {
    min-width: 0;
  }

  #summary-table {
    min-width: max-content;
  }

  #summary-table thead th:first-child,
  #summary-table tbody th {
    position: sticky;
    left: 0;
    z-index: 2;
    width: 86px;
    min-width: 86px;
    max-width: 86px;
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
    box-shadow: 8px 0 12px -12px rgba(31, 41, 51, 0.45);
  }

  #summary-table thead th:first-child {
    z-index: 3;
  }

  #summary-table tbody th {
    background: #f4fbf9;
  }

  #summary-table th:not(:first-child),
  #summary-table td:not(:first-child) {
    min-width: 64px;
    text-align: center;
  }
}
