:root {
  --bg-0: #0f1419;
  --bg-1: #172029;
  --bg-2: #24303b;
  --panel: rgba(19, 25, 31, 0.88);
  --line: rgba(255, 255, 255, 0.14);
  --text-main: #f2f6fa;
  --text-soft: #b6c2cf;
  --accent: #ff7a1a;
  --accent-2: #ffb14a;
  --ok: #38c172;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: "Rajdhani", sans-serif;
  color: var(--text-main);
  background:
    radial-gradient(1200px 500px at 20% -10%, rgba(255, 122, 26, 0.35), transparent 60%),
    radial-gradient(900px 400px at 85% -20%, rgba(255, 177, 74, 0.2), transparent 60%),
    linear-gradient(160deg, var(--bg-0), var(--bg-1) 40%, var(--bg-2));
}

.bg-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(transparent 95%, rgba(255, 255, 255, 0.03) 96%),
    linear-gradient(90deg, transparent 95%, rgba(255, 255, 255, 0.03) 96%);
  background-size: 28px 28px;
  opacity: 0.25;
}

.page {
  position: relative;
  z-index: 1;
  width: min(1200px, 96%);
  margin: 20px auto 32px;
  display: flex;
  flex-direction: column;
}

.home-page {
  position: relative;
  z-index: 1;
  width: min(1020px, 96%);
  margin: 24px auto 34px;
  display: grid;
  gap: 14px;
}

.home-hero {
  padding: 16px;
  text-align: center;
}

.home-hero-art {
  display: block;
  width: min(100%, 900px);
  margin: 0 auto 10px;
  border-radius: 12px;
}

.home-hero h1 {
  margin: 0 0 4px;
  font-family: "Bebas Neue", sans-serif;
  letter-spacing: 1px;
  font-size: clamp(2rem, 4vw, 3rem);
}

.home-hero p {
  margin: 0;
  color: var(--text-soft);
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.home-card {
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(150deg, rgba(255, 122, 26, 0.12), rgba(12, 18, 24, 0.86) 36%);
  padding: 16px;
  color: var(--text-main);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

.home-card:hover {
  border-color: rgba(255, 177, 74, 0.7);
  transform: translateY(-1px);
}

.home-card h2 {
  margin: 0 0 8px;
  color: var(--accent-2);
}

.home-card p {
  margin: 0 0 12px;
  color: var(--text-soft);
}

.home-card span {
  display: inline-block;
  border: 1px solid rgba(255, 177, 74, 0.6);
  border-radius: 999px;
  padding: 6px 10px;
  color: #111;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  font-weight: 700;
}

.hero {
  display: flex;
  gap: 16px;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 18px 22px;
  border: 1px solid var(--line);
  background: linear-gradient(130deg, rgba(255, 122, 26, 0.14), rgba(10, 15, 20, 0.8) 35%);
  border-radius: 14px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

.hero h1 {
  margin: 0;
  font-family: "Bebas Neue", sans-serif;
  letter-spacing: 1.1px;
  font-size: clamp(2.2rem, 4.6vw, 3.2rem);
}

.hero-title-wrap {
  flex: 1;
  min-width: 0;
}

.hero-art {
  display: block;
  width: 100%;
  max-width: 1040px;
  border-radius: 12px;
}

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

.hero p {
  margin: 0;
  color: var(--text-soft);
  font-size: 1rem;
}

.hero-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
}

.dashboard {
  padding: 14px 16px 18px;
  margin-bottom: 12px;
  order: 2;
}

.dashboard h2 {
  margin: 0 0 10px;
  font-size: 1.2rem;
  color: var(--accent-2);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.dash-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(12, 17, 22, 0.8);
  padding: 10px;
}

.dash-card h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.dash-stat {
  display: flex;
  justify-content: space-between;
  margin-bottom: 2px;
  color: var(--text-soft);
}

.dash-stat strong {
  color: var(--text-main);
}

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  padding: 12px;
  margin-bottom: 12px;
  order: 3;
}

.control-group label {
  display: block;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 6px;
}

.view-tabs {
  display: flex;
  gap: 8px;
}

.view-tab {
  border: 1px solid #3b4d61;
  background: #263240;
  color: var(--text-main);
  border-radius: 8px;
  padding: 9px 12px;
  cursor: pointer;
  font-weight: 700;
}

.view-tab.active {
  border-color: transparent;
  color: #111;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
}

select,
input[type="text"],
input[type="password"] {
  width: 100%;
  background: #111820;
  color: var(--text-main);
  border: 1px solid #2a3947;
  border-radius: 8px;
  padding: 10px 11px;
  font-size: 1rem;
}

.table-panel {
  padding: 0;
  overflow: hidden;
  order: 4;
}

.map-panel {
  margin-top: 12px;
  padding: 12px;
  order: 5;
}

.simple-panel {
  margin-top: 12px;
  padding: 12px;
  order: 6;
}

.simple-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}

.simple-group label {
  display: block;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 6px;
}

.simple-hint {
  margin-top: 10px;
  color: var(--text-soft);
}

.simple-results {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.simple-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(12, 17, 22, 0.78);
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.simple-card-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.simple-card-main strong {
  font-size: 1.08rem;
}

.simple-card-main .sub {
  color: var(--text-soft);
  font-size: 0.9rem;
}

.simple-card.checked {
  opacity: 0.6;
}

.map-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background-color: #0f161e;
  background-image: url("https://cpt-hedge.com/images/maps/season-2-dark.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

#mapSvg {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.hive-overlay {
  position: absolute;
  z-index: 6;
  pointer-events: none;
}

.hive-overlay img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.map-copy-hint {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(8, 12, 18, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  opacity: 0;
  display: none;
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
  z-index: 12;
}

.map-copy-hint.visible {
  display: block;
  opacity: 1;
  transform: translate(-50%, -50%);
}

.map-point {
  cursor: pointer;
  stroke: rgba(0, 0, 0, 0.55);
  stroke-width: 1.25;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.map-point.checked {
  opacity: 0.45;
}

.map-point.selected {
  stroke: #fff;
  stroke-width: 2.5;
}

.map-meta {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.level-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.legend-chip {
  font-size: 0.86rem;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.legend-chip.l1 { background: rgba(255, 0, 0, 0.35); }
.legend-chip.l2 { background: rgba(0, 255, 0, 0.35); }
.legend-chip.l3 { background: rgba(0, 100, 255, 0.35); }
.legend-chip.l4 { background: rgba(255, 255, 0, 0.35); }
.legend-chip.l5 { background: rgba(255, 0, 255, 0.35); }
.legend-chip.l6 { background: rgba(0, 255, 255, 0.35); }
.legend-chip.l7 { background: rgba(255, 165, 0, 0.35); }

.map-detail {
  flex: 1;
  min-width: 250px;
  text-align: right;
  color: var(--text-soft);
}

.map-detail-top {
  margin: 0 0 8px;
  min-height: 1.3rem;
}

.map-copy-status {
  margin: 0 0 8px;
  min-height: 1.2rem;
  color: var(--accent-2);
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.14s ease;
}

.map-copy-status.visible {
  opacity: 1;
}

.hive-align {
  margin: 0 0 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(12, 18, 24, 0.75);
}

.hive-align-readout {
  display: block;
  margin-bottom: 8px;
  color: var(--accent-2);
  font-weight: 700;
}

.hive-align-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.hive-save-status {
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(31, 44, 59, 0.6);
  color: var(--text-main);
  font-weight: 700;
  font-size: 0.92rem;
  line-height: 1;
}

.hive-save-status.unsaved {
  border-color: #d99a32;
  color: #ffd585;
}

.hive-save-status.saving {
  border-color: #5aa6ff;
  color: #9bcdff;
}

.hive-save-status.saved {
  border-color: #4ba777;
  color: #88ecb7;
}

.hive-save-status.error {
  border-color: #d05f5f;
  color: #ff9a9a;
}

.coord-cell {
  cursor: copy;
}

.map-detail button {
  margin-left: 8px;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 280px);
}

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

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  text-align: left;
  padding: 10px;
  background: #16212b;
  border-bottom: 1px solid var(--line);
  color: var(--accent-2);
  font-size: 1rem;
}

.sort-btn {
  all: unset;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: inherit;
  font-weight: 700;
}

.sort-icon {
  color: #8ea5bc;
  font-size: 0.9rem;
}

.sort-icon.active {
  color: var(--accent-2);
}

tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

tbody tr:nth-child(odd) {
  background: rgba(255, 255, 255, 0.03);
}

.check-cell {
  width: 90px;
}

.check-toggle {
  cursor: pointer;
  font-size: 1.05rem;
  user-select: none;
}

.check-toggle.locked {
  opacity: 0.8;
}

.check-toggle.checked {
  color: var(--ok);
}

.note-input {
  width: 100%;
  min-width: 180px;
}

.btn {
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 9px 12px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
}

.btn-accent {
  color: #111;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
}

.btn-checked {
  color: #062312;
  background: linear-gradient(120deg, #7fe7ac, #38c172);
}

.btn-muted {
  color: var(--text-main);
  background: #263240;
  border-color: #3b4d61;
}

.save-status {
  min-width: 110px;
  text-align: right;
  color: var(--text-soft);
}

.copy-toast {
  position: fixed;
  left: 50%;
  top: 78px;
  bottom: auto;
  transform: translate(-50%, -8px);
  background: rgba(0, 0, 0, 0.82);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  padding: 7px 14px;
  font-weight: 700;
  letter-spacing: 0.3px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
  z-index: 120;
}

.copy-toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.copy-toast.copy-action {
  pointer-events: auto;
  cursor: pointer;
  border-color: rgba(255, 177, 74, 0.9);
  box-shadow: 0 0 0 2px rgba(255, 177, 74, 0.22);
}

.copy-toast.near-touch {
  transform: translate(-50%, -118%);
}

.copy-toast.near-touch.visible {
  transform: translate(-50%, -128%);
}

.hidden {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.65);
  padding: 16px;
}

.modal-card {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  background: #141d26;
  border-radius: 12px;
  padding: 16px;
}

.modal-card h3 {
  margin: 0 0 6px;
  color: var(--accent-2);
}

.modal-card p {
  margin: 0 0 10px;
  color: var(--text-soft);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.code-error {
  margin-top: 8px;
  color: #ff6b6b;
  font-weight: 600;
}

@media (max-width: 700px) {
  .hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .hero-art {
    max-width: 100%;
  }

  .save-status {
    text-align: left;
  }

  .dashboard {
    order: 10;
    margin-top: 12px;
    margin-bottom: 0;
  }

  .simple-controls {
    grid-template-columns: 1fr;
  }

  .map-detail {
    min-width: 0;
    text-align: left;
  }
}
