/* Dark Navy Theme - Beacon's own identity, same structure as Daily Link Puzzle */
:root {
  --bg: #0c1220;
  --panel: #131b30;
  --panel-light: #1a2440;
  --border: rgba(233,237,243,0.16);
  --text: #e9edf3;
  --muted: rgba(233,237,243,0.55);
  --accent: #f2a94e;
  --accent-bright: #ffc978;
  --green: #4ade80;
  --orange: #fbbf24;

  /* territory colors (unique to Beacon's grid, not part of the chrome theme) */
  --t0:#3d5a99; --t1:#3f8f5c; --t2:#8a3f8a; --t3:#c07a2e;
  --t4:#2e9c8f; --t5:#a83f5c; --t6:#a8a83a; --t7:#5c5cc0;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: radial-gradient(circle at 50% -10%, #1a2540 0%, var(--bg) 60%);
  color: var(--text);
  display: flex;
  justify-content: center;
  min-height: 100vh;
}

.app {
  width: 100%;
  max-width: 500px;
  padding: 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
}

/* Header & Icons */
.header-top-row {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 10px;
    gap: 15px;
}

.streak-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 15px;
    font-weight: bold;
    color: var(--accent-bright);
    margin-right: 5px;
    text-shadow: 0 0 8px rgba(242,169,78,0.5);
}

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-weight: bold;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.icon-btn:hover { border-color: var(--accent); color: var(--accent-bright); background-color: var(--panel-light); }

.header h1 {
  font-size: clamp(1.5rem, 6.5vw, 2.3rem);
  margin: 0;
  font-weight: 600;
  color: var(--text);
}

.header p { margin: 5px 0 24px; color: var(--muted); }

/* Board */
.board {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-auto-rows: 1fr;
  gap: 3px;
  aspect-ratio: 1/1;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 18px;
  border: 1px solid var(--border);
}

.cell {
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  position: relative;
  transition: filter 0.15s ease;
  aspect-ratio: 1/1;
  min-width: 0;
  min-height: 0;
}
.cell:hover { filter: brightness(1.15); }
.cell.clue { cursor: default; }
.cell.conflict { animation: shake 0.35s ease; box-shadow: inset 0 0 0 3px #ff4d4d; }
.cell.clue.conflict .clue-badge { background: #ff4d4d; color: #1a0505; }
.cell.clue.satisfied .clue-badge { background: var(--green); color: #06210f; }

.cell .dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,0.75); }
.cell .beacon { width: 58%; height: 58%; animation: drop 0.22s cubic-bezier(.2,1.4,.4,1); }
.cell .beacon svg { width: 100%; height: 100%; display: block; }

.clue-badge {
  width: 60%; height: 60%; border-radius: 50%;
  background: rgba(0,0,0,0.55);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
  border: 1px solid rgba(255,255,255,0.3);
}

.t0{background:var(--t0);} .t1{background:var(--t1);} .t2{background:var(--t2);}
.t3{background:var(--t3);} .t4{background:var(--t4);} .t5{background:var(--t5);}
.t6{background:var(--t6);} .t7{background:var(--t7);}

@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
@keyframes drop {
  0% { transform: translateY(-40%) scale(0.6); opacity: 0; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

/* Input / Controls Area - reuses Daily Link's input-container pattern */
.input-container { display: flex; gap: 8px; margin-bottom: 15px; position: relative; }

.submit-btn {
  flex: 2;
  padding: 18px;
  background: var(--panel-light);
  border: 1px solid var(--border);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
}
.submit-btn:hover { border-color: var(--accent); }

/* Feedback */
.feedback { text-align: center; margin-top: 10px; }
.feedback-title { font-size: 14px; display: block; margin-bottom: 10px; color: var(--muted); min-height: 18px; }
.feedback-title.win { color: var(--green); font-weight: 700; }
.feedback-title.err { color: #ff4d4d; font-weight: 700; }

/* Stats & Footer */
.stats-container { display: flex; justify-content: space-around; margin: 10px 0 20px; }
.stat-box { display: flex; flex-direction: column; align-items: center; }
.stat-number { font-size: 24px; font-weight: bold; color: #fff; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 4px; }
.stats-header { margin: 20px 0 10px; color: #fff; font-size: 18px; font-weight: bold; text-transform: capitalize; }

.footer { margin-top: auto; padding: 30px 0 20px; color: #888; font-size: 15px; }
.footer p { margin: 0; }

/* Modal */
.modal {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.85); display: none;
  justify-content: center; align-items: center; z-index: 1000;
}
.modal.show { display: flex; }
.modal-content {
  background: var(--panel); border: 1px solid var(--border); padding: 30px;
  border-radius: 12px; text-align: center; max-width: 90%; width: 340px; position: relative;
}

/* Instructions */
.instructions-body { text-align: left; margin: 20px 0; font-size: 15px; line-height: 1.5; color: var(--muted); }
.highlight-text { color: #fff; font-weight: bold; margin-bottom: 15px; }
.instructions-sub-header { color: #fff; font-weight: bold; margin-top: 15px; margin-bottom: 5px; }
.legend-box { background: #151516; padding: 12px; border-radius: 8px; border: 1px solid var(--border); margin-bottom: 15px; font-size: 14px; }
.legend-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; color: #eee; }
.legend-row:last-child { margin-bottom: 0; }
.color-box { width: 24px; height: 24px; border-radius: 4px; display: flex; align-items:center; justify-content:center; border: 1px solid #444; flex-shrink: 0; font-size: 12px; font-weight:700; color:#fff; }
.swatch-territory { background: var(--t2); }
.swatch-clue { background: #000; }
.swatch-beacon { background: var(--panel-light); color: #f2a94e; }
.instructions-list { padding-left: 20px; margin-bottom: 0; }
.instructions-list li { margin-bottom: 8px; }

/* Buttons */
.share-btn { background: var(--green); color: #000; border: none; padding: 14px; font-weight: 700; font-size: 16px; border-radius: 6px; cursor: pointer; width: 100%; margin-top: 10px; }
.secondary-btn { background: transparent; color: #888; border: 1px solid var(--border); padding: 12px; font-size: 14px; border-radius: 6px; cursor: pointer; width: 100%; margin-top: 10px; }
.hidden { display: none !important; }

/* Speed comparison: checks-used distribution + percentile gauge side by side */
.speed-row {
  display: flex;
  gap: 28px;
  justify-content: center;
  align-items: flex-start;
  margin-bottom: 10px;
}
.speed-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}
.speed-col .stats-header { margin-top: 0; font-size: 15px; }

.gauge-scale-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin: 2px 0;
}

.percentile-track {
  position: relative;
  width: 22px;
  height: 130px;
  border-radius: 11px;
  background: linear-gradient(to top, #ff4d4d 0%, var(--orange) 50%, var(--green) 100%);
  border: 1px solid var(--border);
  margin: 4px 30px 4px 46px; /* room on both sides for the pointer label (right) and avg label (left) */
}

.percentile-avg-marker {
  position: absolute;
  left: 0; right: 0;
  border-top: 2px dashed rgba(255,255,255,0.75);
  transform: translateY(50%);
  transition: bottom 0.4s ease;
}
.avg-label {
  position: absolute;
  right: 100%;
  margin-right: 6px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
}

.percentile-pointer {
  position: absolute;
  left: 100%;
  transform: translateY(50%);
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  transition: bottom 0.4s ease;
}
.pointer-arrow {
  width: 0; height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-right: 7px solid #fff;
  margin-left: -1px;
}
.pointer-label {
  font-size: 12px;
  font-weight: 700;
  color: #0c1220;
  background: #fff;
  padding: 1px 6px;
  border-radius: 4px;
}

.percentile-caption {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  margin-top: 8px;
  max-width: 120px;
}


.distribution-container { width: 100%; max-width: 300px; margin: 0 auto 20px; display: flex; flex-direction: column; gap: 6px; }
.dist-row { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: bold; color: #fff; height: 24px; }
.dist-label { width: 44px; text-align: right; font-size: 11px; color: var(--muted); flex-shrink: 0; }
.dist-bar-container { flex-grow: 1; display: flex; justify-content: flex-start; }
.dist-bar {
    background-color: #3a3a3c; min-width: 24px; padding: 0 6px; text-align: right;
    display: flex; align-items: center; justify-content: flex-end; border-radius: 2px; width: 7%;
    color: #fff; font-size: 12px; transition: width 0.5s ease-in-out;
}
.dist-bar.highlight { background-color: var(--green); color: #000; }
