/* ============================================================
   DISCONNECTIONS: styles
   ============================================================ */

:root {
  --dc-cream: #F5F2EC;
  --dc-green: #537758;
  --dc-green-soft: #e4ece3;
  --dc-red: #A24B3C;
  --dc-red-soft: #f2e2de;
  --dc-ink: #2b2b2b;

  /* For "one away".  */
  --dc-gold-warm: #8A6A1F;

  /* The reveal color. Set per puzzle by the difficulty field. */
  --dc-accent: #9A7B2F;
  --dc-accent-soft: #f1e9d4;
}

/* Difficulty tiers 1-4, easiest to hardest. */

.diff-1 { --dc-accent: #9A7B2F; --dc-accent-soft: #f1e9d4; }  /* yellow */
.diff-2 { --dc-accent: #6B7A3C; --dc-accent-soft: #e8ecdb; }  /* olive  */
.diff-3 { --dc-accent: #46708C; --dc-accent-soft: #dce8ef; }  /* blue   */
.diff-4 { --dc-accent: #6A4C7C; --dc-accent-soft: #e9e0ef; }  /* purple */

.game-header {
  text-align: center;
}

.game-header h1 {
  margin-bottom: 0.3rem;
  letter-spacing: 0.02em;
}

.tagline {
  margin: 0.3rem 0 0.2rem;
  opacity: 0.8;
  line-height: 1.35;
}

.game {
  width: 55vw;
  max-width: 34rem;
}

/* ---------- status bar: puzzle number, guesses, hint ---------- */

.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 0.2rem 0 1.2rem;
  padding-bottom: 0.9rem;
  border-bottom: thin dashed rgba(43, 43, 43, 0.35);
}

.puzzle-no {
  font-weight: bold;
}

/* The difficulty block. */
.difficulty-pip {
  display: inline-block;
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 4px;
  background: var(--dc-accent);
  border: 1px solid var(--dc-accent);
  flex: none;
}

.message.quiet {
  font-weight: normal;
  opacity: 0.7;
  font-size: 0.9rem;
}

.guess-dots {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
  opacity: 0.85;
}

.dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  border: 1px solid var(--dc-green);
  background: var(--dc-green);
  display: inline-block;
}

.dot.spent {
  background: transparent;
  border-color: rgba(43, 43, 43, 0.4);
}

/* ---------- buttons ---------- */

button {
  font-family: inherit;
  font-size: inherit;
  color: var(--dc-ink);
  cursor: pointer;
}

.btn {
  background: rgba(245, 242, 236, 0.9);
  border: thin solid var(--dc-ink);
  border-radius: 14px;
  padding: 0.45rem 1rem;
  transition: background 0.15s ease, transform 0.08s ease;
}

.btn:hover:not(:disabled) {
  background: var(--dc-green-soft);
  border-color: var(--dc-green);
  color: var(--dc-green);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.btn-primary {
  font-weight: bold;
  border-color: var(--dc-green);
  color: var(--dc-green);
}

.btn-primary:hover:not(:disabled) {
  background: var(--dc-green);
  color: var(--dc-cream);
}

/* ---------- the three groups ---------- */

.group {
  border: thin dashed rgba(43, 43, 43, 0.5);
  border-radius: 20px;
  padding: 0.8rem 0.9rem 1rem;
  margin-bottom: 1rem;
  background: rgba(255, 255, 255, 0.25);
}

.group-name {
  font-size: 0.95rem;
  font-weight: bold;
  text-align: center;
  margin: 0 0 0.7rem;
  min-height: 1.2em;
  letter-spacing: 0.03em;
}

.group-name.unknown {
  opacity: 0.4;
  font-weight: normal;
  font-style: italic;
  letter-spacing: 0.12em;
}

.group-name.revealed {
  color: var(--dc-green);
}

.terms {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.term {
  background: rgba(245, 242, 236, 0.92);
  border: thin solid var(--dc-ink);
  border-radius: 14px;
  padding: 0.7rem 0.4rem;
  text-align: center;
  line-height: 1.2;
  min-height: 2.9rem;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.term:hover:not(:disabled) {
  border-color: var(--dc-green);
  background: var(--dc-green-soft);
}

.term.selected {
  background: var(--dc-green);
  border-color: var(--dc-green);
  color: var(--dc-cream);
  font-weight: bold;
}

.term:disabled {
  cursor: default;
}

/* revealed states */

.term.was-disconnection {
  background: var(--dc-accent-soft);
  border-color: var(--dc-accent);
  color: var(--dc-accent);
  font-weight: bold;
}

.term.was-true {
  opacity: 0.75;
}

.group.solved {
  border-color: var(--dc-green);
  background: rgba(228, 236, 227, 0.4);
}

/* ---------- controls ---------- */

.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-top: 1.2rem;
}

.hint-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.hint-note {
  font-size: 0.82rem;
  opacity: 0.65;
}

.message {
  text-align: center;
  margin: 1rem 0 0;
  min-height: 1.4em;
  font-weight: bold;
}

.message.wrong {
  color: var(--dc-red);
}

.message.close {
  color: var(--dc-gold-warm);
}

/* ---------- the reveal ---------- */

.hidden-group {
  border: thin solid var(--dc-accent);
  border-radius: 20px;
  padding: 0.8rem 0.9rem 1rem;
  margin: 1.2rem 0 0;
  background: var(--dc-accent-soft);
}

.hidden-group .group-name {
  color: var(--dc-accent);
}

.hidden-group .terms {
  grid-template-columns: repeat(3, 1fr);
}

.outcome {
  text-align: center;
  margin: 0 0 0.4rem;
}

.outcome h2 {
  margin: 0.2rem 0;
}

.score-line {
  font-size: 1.1rem;
  font-weight: bold;
  color: var(--dc-green);
  margin: 0.2rem 0 0.1rem;
}

.score-detail {
  font-size: 0.85rem;
  opacity: 0.7;
  margin: 0.1rem 0 0.8rem;
}

.end-actions {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin: 1.2rem 0 0.4rem;
}

/* ---------- share block ---------- */

.share-box {
  border: thin dashed var(--dc-ink);
  border-radius: 16px;
  padding: 0.8rem 1rem;
  margin: 1rem 0 0;
  background: rgba(255, 255, 255, 0.35);
  text-align: center;
}

.share-text {
  font-family: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
  font-size: 0.95rem;
  line-height: 1.5;
  white-space: pre;
  margin: 0 0 0.7rem;
}

.copied-note {
  font-size: 0.85rem;
  color: var(--dc-green);
  min-height: 1.2em;
  margin: 0.4rem 0 0;
}

/* ---------- stats ---------- */

.stats {
  margin: 1.4rem 0 0;
  padding-top: 1rem;
  border-top: thin dashed rgba(43, 43, 43, 0.35);
}

.stats h3 {
  text-align: center;
  margin: 0 0 0.8rem;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  text-align: center;
  margin-bottom: 1.2rem;
}

.stat-num {
  font-size: 1.5rem;
  font-weight: bold;
  line-height: 1.1;
}

.stat-label {
  font-size: 0.75rem;
  opacity: 0.7;
  line-height: 1.15;
}

.dist h4 {
  font-size: 0.85rem;
  text-align: center;
  opacity: 0.75;
  margin: 0 0 0.6rem;
  font-weight: normal;
}

.bar-row {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
  font-size: 0.85rem;
}

.bar-label {
  text-align: right;
  opacity: 0.8;
}

.bar {
  background: var(--dc-green);
  color: var(--dc-cream);
  border-radius: 8px;
  padding: 0.15rem 0.45rem;
  font-size: 0.8rem;
  min-width: 1.6rem;
  text-align: right;
  transition: width 0.3s ease;
}

.bar.loss-bar {
  background: var(--dc-red);
}

.bar.empty {
  background: transparent;
  color: var(--dc-ink);
  opacity: 0.5;
  text-align: left;
  padding-left: 0.15rem;
}

/* ---------- archive ---------- */

.archive-link {
  font-size: 0.82rem;
  opacity: 0.75;
}

.archive-link:hover {
  opacity: 1;
}

.archive-tag {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.55;
  border: thin dashed;
  border-radius: 10px;
  padding: 0.05rem 0.4rem;
}

.archive-summary {
  text-align: center;
  font-size: 0.85rem;
  opacity: 0.7;
  margin: 0 0 1rem;
}

.archive-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.archive-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  border: thin solid rgba(43, 43, 43, 0.5);
  border-radius: 16px;
  padding: 0.6rem 0.9rem;
  background: rgba(255, 255, 255, 0.3);
  color: var(--dc-ink);
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.archive-row:link,
.archive-row:visited {
  color: var(--dc-ink);
  text-decoration: none;
}

.archive-row:hover {
  border-color: var(--dc-green);
  background: var(--dc-green-soft);
  text-decoration: none;
}

.archive-row.played {
  border-color: var(--dc-accent);
  background: var(--dc-accent-soft);
}

.archive-row.played:hover {
  border-color: var(--dc-accent);
  background: var(--dc-accent-soft);
  filter: brightness(0.97);
}

.archive-main {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.archive-no {
  font-weight: bold;
}

.archive-date {
  font-size: 0.85rem;
  opacity: 0.7;
}

.archive-result {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  white-space: nowrap;
}

.archive-score {
  font-weight: bold;
  color: var(--dc-accent);
}

.archive-time {
  font-size: 0.8rem;
  opacity: 0.6;
}

.archive-lost {
  color: var(--dc-red);
  font-size: 0.9rem;
}

.archive-todo {
  color: var(--dc-green);
  font-weight: bold;
  font-size: 0.9rem;
}

.archive-note {
  font-size: 0.8rem;
  opacity: 0.6;
  text-align: center;
  line-height: 1.4;
  margin: 1.2rem 0 0;
}

.nothing-new {
  padding: 1rem 0 0.5rem;
}

.nothing-new p {
  line-height: 1.45;
  max-width: 26rem;
  margin: 0.5rem auto;
}

/* ---------- motion ---------- */

/* A wrong guess nudges the board sideways and back. */
@keyframes dc-shake {
  0%, 100% { transform: translateX(0); }
  15%      { transform: translateX(-7px); }
  30%      { transform: translateX(6px); }
  45%      { transform: translateX(-4px); }
  60%      { transform: translateX(3px); }
  80%      { transform: translateX(-1px); }
}

.board.shake {
  animation: dc-shake 0.42s ease-in-out;
}

/* The reveal arrives one group at a time. */
@keyframes dc-rise {
  from { opacity: 0; transform: translateY(9px); }
  to   { opacity: 1; transform: translateY(0); }
}

.revealing .group,
.revealing .hidden-group,
.revealing .outcome,
.revealing .share-box,
.revealing .stats {
  animation: dc-rise 0.4s ease-out backwards;
}

/* ---------- help button and popup ---------- */

.help-btn {
  background: transparent;
  border: thin solid var(--dc-ink);
  border-radius: 50%;
  width: 1.6rem;
  height: 1.6rem;
  line-height: 1;
  padding: 0;
  font-size: 0.9rem;
  opacity: 0.7;
}

.help-btn:hover {
  opacity: 1;
  border-color: var(--dc-green);
  color: var(--dc-green);
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(43, 43, 43, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;
  z-index: 50;
}

.modal {
  background: var(--dc-cream);
  border: thin dashed var(--dc-ink);
  border-radius: 20px;
  padding: 1.2rem 1.5rem 1.4rem;
  max-width: 30rem;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  animation: dc-rise 0.22s ease-out;
}

.modal h2 {
  margin: 0 0 0.8rem;
  text-align: center;
}

.modal p {
  line-height: 1.45;
  margin: 0.7rem 0;
}

.modal .close-row {
  text-align: center;
  margin-top: 1.2rem;
}

.modal dl {
  margin: 0.9rem 0 0;
}

.modal dt {
  font-weight: bold;
  margin-top: 0.7rem;
}

.modal dd {
  margin: 0.15rem 0 0;
  padding-left: 0;
  line-height: 1.4;
}

/* Anyone who's asked their system to calm down gets no motion. */
@media (prefers-reduced-motion: reduce) {
  .board.shake,
  .revealing .group,
  .revealing .hidden-group,
  .revealing .outcome,
  .revealing .share-box,
  .revealing .stats,
  .modal {
    animation: none;
  }
  .btn, .term, .bar {
    transition: none;
  }
}

/* ---------- author error box ---------- */

.puzzle-error {
  border: thin solid var(--dc-red);
  background: var(--dc-red-soft);
  border-radius: 16px;
  padding: 1rem 1.2rem;
}

.puzzle-error h2 {
  margin-top: 0;
  color: var(--dc-red);
}

.puzzle-error ul {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
}

.puzzle-error li {
  margin-bottom: 0.4rem;
  line-height: 1.35;
}

/* ---------- small screens ---------- */

@media (max-width: 600px) {
  .game {
    width: 90vw;
    padding: 1vw 3vw;
  }
  .statusbar {
    justify-content: center;
  }
  .controls {
    justify-content: center;
  }
  .hidden-group .terms {
    grid-template-columns: 1fr;
  }
  .stat-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.9rem 0.5rem;
  }
  .term {
    padding: 0.65rem 0.3rem;
    font-size: 0.95rem;
  }
}
