:root {
  --gray: #555555;
  --dark-gray: #333333;
  --success: #44cc11;
  --failure: #e05d44;
}

.badge {
  display: inline-flex;
  font-family: system-ui, sans-serif;
  font-size: 11px;
  font-weight: 500;
  line-height: 20px;
  border-radius: 3px;
  overflow: hidden;
}

.badge-label {
  padding: 0 8px;
  background: var(--gray);
  color: #fff;
}

.badge-value {
  padding: 0 8px;
  color: #fff;
}

.badge-action {
  padding: 0 6px;
  background: #444;
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 11px;
  line-height: 20px;
}

.badge-action:hover {
  background: var(--dark-gray);
}

.badge-value.success {
  background: var(--success);
}

.badge-value.failure {
  background: var(--failure);
}

.badge-value.solved {
  background: #29bf12;
  color: #111;
}

.badge-value.unsolved {
  background: #656d4a;
}

body {
  margin: 0;
  font-family: system-ui, sans-serif;
  background: #1a1a1a;
  color: #f0ead2;
}

.flashes {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(420px, calc(100vw - 32px));
}

.flashes li {
  padding: 12px 16px;
  border-radius: 6px;
  background: #1a1a1a;
  border: 1px solid #333;
  color: #f0ead2;
  font-size: 14px;
  line-height: 1.4;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  animation: flash-in 0.22s ease-out, flash-out 0.4s ease-in 5s forwards;
}

.flashes li.success { border-color: #29bf12; border-left: 4px solid #29bf12; }
.flashes li.warning { border-color: #e05d44; border-left: 4px solid #e05d44; }

@keyframes flash-in {
  from { transform: translateX(12px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

@keyframes flash-out {
  to { transform: translateX(12px); opacity: 0; visibility: hidden; }
}

#layout {
  display: grid;
  grid-template-columns: minmax(380px, 460px) 1fr;
  gap: 16px;
  padding: 16px;
  min-height: 100vh;
  box-sizing: border-box;
}

#sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;

  header h1 {
    margin: 0;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 20px;
    line-height: 1.3;
    color: #f0ead2;

    .sep {
      color: var(--gray);
    }

    .prompt {
      color: var(--success);
    }
  }
}

#overview {
  .stats {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    margin-bottom: 6px;
  }

  .stat strong {
    color: #fff;
  }

  .progress {
    height: 8px;
    background: var(--dark-gray);
    border-radius: 4px;
    overflow: hidden;
  }

  .bar {
    height: 100%;
    background: var(--success);
    transition: width 250ms ease-out;
  }
}

#challenges {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;

  th,
  td {
    text-align: left;
    padding: 6px 8px;
    border-bottom: 1px solid var(--dark-gray);
  }

  th {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--gray);
    font-weight: 600;
  }

  tbody tr {
    cursor: pointer;
  }

  tbody tr:hover {
    background: var(--dark-gray);
  }

  tr.solved td:first-child::before {
    content: "✓ ";
    color: var(--success);
  }

  td.row-actions {
    text-align: right;
    width: 1%;
    white-space: nowrap;
  }

  td.row-actions .badge-action {
    border-radius: 3px;
    padding: 2px 8px;
  }
}

#map {
  position: relative;
  align-self: start;
  justify-self: start;
  aspect-ratio: 1 / 1;
  width: max-content;
  max-width: 100%;
  overflow: auto;

  >img {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
  }

  .pin {
    position: absolute;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;

    .circle {
      padding: 4px 10px;
      border-radius: 6px;
      background: rgba(0, 0, 0, 0.78);
      color: #f0ead2;
      font-size: 12px;
      font-weight: 600;
      white-space: nowrap;
      border: 1px solid #f0ead2;
      transition: transform 150ms ease, background 150ms ease;
    }

    .circle:hover,
    .circle:active {
      transform: scale(1.12);
      background: rgba(0, 0, 0, 0.9);
    }

    &.solved .circle {
      background: var(--success);
      border-color: var(--success);
      color: #111;
    }

    &.solved .circle:hover,
    &.solved .circle:active {
      background: #29bf12;
      border-color: #29bf12;
      color: #111;
    }

    .label {
      margin-top: 4px;
      background: rgba(0, 0, 0, 0.7);
      color: white;
      padding: 2px 6px;
      border-radius: 4px;
      font-size: 12px;
      white-space: nowrap;
    }
  }
}
