:root {
  --ink: #f8fbff;
  --ink-muted: #c8d4e5;
  --ink-soft: #9baec4;
  --night: #07111f;
  --night-deep: #030813;
  --navy-glass: rgba(5, 15, 30, 0.42);
  --navy-action: rgba(4, 13, 28, 0.58);
  --navy-journal: rgba(5, 14, 28, 0.31);
  --line: rgba(220, 237, 255, 0.22);
  --line-quiet: rgba(220, 237, 255, 0.12);
  --gold: #ffd49a;
  --ember: #ff9a74;
  --jade: #75d9ae;
  --rose: #ff9a9e;
  --radius: 18px;
  --shadow: 0 18px 45px rgba(1, 5, 13, 0.26);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  color: var(--ink);
  background: var(--night-deep);
  font-family: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
}

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

button,
input,
textarea {
  font: inherit;
}

#bg-canvas {
  position: fixed;
  inset: 0;
  display: block;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
}

/* Login intentionally uses only this static, zero-GPU composition. */
#bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(ellipse 78% 42% at 74% 33%, rgba(232, 144, 130, 0.31), transparent 72%),
    linear-gradient(180deg, #17264e 0%, #523d69 45%, #122d3e 72%, #061421 100%);
}

#bg::before,
#bg::after {
  position: absolute;
  content: "";
  inset: auto -8% -7%;
  pointer-events: none;
}

#bg::before {
  height: 46vh;
  background: #0b2630;
  clip-path: polygon(0 66%, 18% 48%, 31% 57%, 50% 20%, 65% 58%, 81% 46%, 100% 63%, 100% 100%, 0 100%);
  opacity: 0.88;
}

#bg::after {
  height: 28vh;
  background: linear-gradient(180deg, rgba(118, 176, 195, 0.38), #07131e 62%);
  clip-path: polygon(0 33%, 100% 33%, 100% 100%, 0 100%);
}

/* Dashboard composition */
#app {
  position: relative;
  z-index: 1;
  width: min(1360px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 1rem clamp(1rem, 3vw, 2.5rem) 3rem;
}

.site-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  min-height: 84px;
  padding: 0.5rem 0;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.72);
}

.brand-lockup h1,
#auth-card h1 {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(1.75rem, 3vw, 2.55rem);
  font-weight: 700;
  letter-spacing: -0.05em;
  line-height: 0.9;
}

.eyebrow {
  margin: 0 0 0.42rem;
  color: var(--gold);
  font-size: 0.67rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem 0.9rem;
  color: var(--ink-muted);
  font-size: 0.77rem;
  font-weight: 700;
}

.phase-label,
nav a {
  border: 1px solid var(--line-quiet);
  border-radius: 999px;
  background: rgba(3, 10, 23, 0.18);
  padding: 0.38rem 0.65rem;
  color: var(--ink);
  text-decoration: none;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

nav a {
  color: var(--gold);
}

nav a:hover {
  border-color: rgba(255, 212, 154, 0.65);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(300px, 410px) minmax(220px, 1fr) minmax(260px, 340px);
  align-items: start;
  gap: clamp(1rem, 2.8vw, 2.5rem);
}

.surface,
.journal-surface,
#auth-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.13);
}

.surface {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.10), transparent 48%), var(--navy-glass);
  backdrop-filter: blur(10px) saturate(1.24);
  -webkit-backdrop-filter: blur(10px) saturate(1.24);
}

.action-surface {
  grid-column: 1;
  padding: clamp(1.2rem, 2.4vw, 1.75rem);
  background: linear-gradient(110deg, rgba(3, 10, 24, 0.73), rgba(5, 19, 36, 0.36) 72%, rgba(255, 255, 255, 0.04)), var(--navy-action);
}

.action-surface::after {
  position: absolute;
  content: "";
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.09), transparent 35%);
  pointer-events: none;
}

.expedition-surface {
  grid-column: 3;
  padding: 1.15rem;
  background: linear-gradient(225deg, rgba(4, 13, 27, 0.58), rgba(5, 19, 35, 0.23)), var(--navy-glass);
}

.surface h2 {
  position: relative;
  z-index: 1;
  margin: 0;
  color: var(--ink);
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.48rem;
  font-weight: 600;
  letter-spacing: -0.035em;
}

.surface h3 {
  color: var(--ink);
  font-size: 0.88rem;
}

#deadline-banner {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 0.13rem;
  margin: 1.1rem 0;
  padding: 0.78rem 0.9rem;
  border-left: 2px solid var(--gold);
  border-radius: 0 10px 10px 0;
  background: rgba(3, 10, 22, 0.34);
}

#deadline-label,
.char-count,
.shot-meta,
.shot-user,
.record-card p,
#auth-subtitle,
.switch {
  color: var(--ink-muted);
}

#deadline-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

#deadline-countdown {
  color: var(--gold);
  font-family: "Manrope", sans-serif;
  font-size: 1.48rem;
  font-weight: 800;
  letter-spacing: -0.06em;
}

#my-shot-card,
#others-list,
#record-list {
  position: relative;
  z-index: 1;
}

#my-shot-card textarea,
#evidence-form input,
#auth-card input {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  border: 1px solid rgba(222, 238, 255, 0.28);
  border-radius: 10px;
  outline: none;
  background: rgba(1, 7, 17, 0.46);
  padding: 0.72rem 0.8rem;
  color: var(--ink);
  line-height: 1.45;
}

#my-shot-card textarea {
  min-height: 104px;
  resize: vertical;
}

#my-shot-card textarea:focus,
#evidence-form input:focus,
#auth-card input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(255, 212, 154, 0.18);
}

.char-count {
  margin: 0.42rem 0 0;
  font-size: 0.75rem;
}

#my-shot-card button,
#evidence-form button,
#auth-card button {
  margin-top: 0.85rem;
  border: 1px solid rgba(255, 226, 181, 0.65);
  border-radius: 10px;
  background: linear-gradient(135deg, #ffd69e, #ed9c70);
  padding: 0.68rem 1rem;
  color: #25120d;
  font-weight: 800;
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease;
}

#my-shot-card button:hover,
#evidence-form button:hover,
#auth-card button:hover {
  box-shadow: 0 7px 18px rgba(255, 155, 105, 0.3);
  transform: translateY(-1px);
}

.shot-description {
  margin: 1rem 0 0.25rem;
  color: var(--ink);
  font-size: 1.03rem;
  font-weight: 600;
  line-height: 1.55;
}

.shot-meta,
.evidence-status {
  font-size: 0.8rem;
}

#evidence-section {
  margin-top: 1rem;
  border-top: 1px solid var(--line-quiet);
  padding-top: 0.9rem;
}

.evidence-status a,
#others-list a {
  color: var(--gold);
  overflow-wrap: anywhere;
}

#no-shot-message p {
  margin: 1rem 0 0;
  color: var(--ink-muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

#others-list {
  display: grid;
  gap: 0.15rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

#others-list li {
  border-top: 1px solid var(--line-quiet);
  padding: 0.8rem 0 0.72rem;
  color: var(--ink);
  font-size: 0.84rem;
  line-height: 1.45;
}

.shot-desc {
  font-weight: 600;
}

.shot-user {
  display: inline-block;
  margin-top: 0.25rem;
  font-size: 0.73rem;
}

.journal {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 1rem;
  margin-top: clamp(7rem, 17vh, 13rem);
}

.journal-surface {
  overflow: hidden;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent 42%), var(--navy-journal);
  backdrop-filter: blur(7px) saturate(1.14);
  -webkit-backdrop-filter: blur(7px) saturate(1.14);
}

.journal-surface summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  cursor: pointer;
  list-style: none;
  padding: 1rem 1.15rem;
}

.journal-surface summary::-webkit-details-marker {
  display: none;
}

.journal-surface summary span {
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.2rem;
}

.journal-surface summary small {
  color: var(--ink-soft);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.journal-surface[open] summary {
  border-bottom: 1px solid var(--line-quiet);
}

#ledger-table,
#record-list {
  padding: 0.5rem 1.15rem 1.15rem;
}

#ledger-table {
  overflow-x: auto;
}

#ledger-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.79rem;
}

#ledger-table th,
#ledger-table td {
  border-bottom: 1px solid var(--line-quiet);
  padding: 0.55rem 0.45rem;
  text-align: center;
}

#ledger-table th {
  color: var(--ink-muted);
  font-weight: 700;
  white-space: nowrap;
}

#ledger-table td:first-child {
  color: var(--ink-soft);
}

#ledger-table .kept,
#ledger-table .kept a {
  color: var(--jade);
}

#ledger-table .missed {
  color: var(--rose);
}

#ledger-table .no-shot {
  color: var(--ink-soft);
}

.record-card {
  border-bottom: 1px solid var(--line-quiet);
  padding: 0.85rem 0;
}

.record-card:last-child {
  border-bottom: 0;
}

.record-card h3 {
  margin: 0 0 0.25rem;
  color: var(--ink);
  font-size: 0.95rem;
}

.record-card p {
  margin: 0.2rem 0;
  font-size: 0.76rem;
}

.rate-bar {
  height: 12px;
  margin: 0.55rem 0;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(0, 4, 13, 0.5);
}

.rate-fill {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  min-width: 2px;
  border-radius: inherit;
  background: linear-gradient(90deg, #4abf91, #b7f4cf);
  padding-right: 0.35rem;
  transition: width 0.6s ease;
}

.rate-pct {
  color: #07170f;
  font-size: 0.62rem;
  font-weight: 800;
}

.streak {
  color: var(--gold) !important;
}

.error {
  margin: 0.5rem 0 0;
  color: #ffb0ad;
  font-size: 0.8rem;
  font-weight: 600;
}

.hidden {
  display: none !important;
}

/* Static login and invite route */
#auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

#auth-card {
  width: min(100%, 390px);
  padding: 2rem;
  background: linear-gradient(135deg, rgba(5, 14, 29, 0.72), rgba(10, 25, 42, 0.38));
  text-align: center;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

#auth-card h1 {
  color: var(--ink);
}

#auth-card h2 {
  margin: 1.5rem 0 1rem;
  color: var(--ink);
  font-size: 1.05rem;
}

#auth-subtitle {
  margin: 0.45rem 0 0;
  font-size: 0.82rem;
}

#auth-card label {
  display: block;
  margin: 0.85rem 0;
  color: var(--ink-muted);
  font-size: 0.8rem;
  font-weight: 700;
  text-align: left;
}

#auth-card button {
  width: 100%;
}

.switch {
  margin: 1rem 0 0;
  font-size: 0.78rem;
}

@keyframes pulse {
  50% { opacity: 0.58; }
}

.pulse {
  animation: pulse 1s ease-in-out infinite;
}

@media (max-width: 980px) {
  .dashboard-grid {
    grid-template-columns: minmax(280px, 1fr) minmax(250px, 0.8fr);
  }

  .action-surface { grid-column: 1; }
  .expedition-surface { grid-column: 2; }
  .journal { grid-template-columns: 1fr; margin-top: 3rem; }
}

@media (max-width: 680px) {
  #app {
    padding: 0.75rem 0.7rem 2rem;
  }

  .site-header {
    align-items: flex-start;
    min-height: 108px;
  }

  .site-header h1 {
    font-size: 1.9rem;
  }

  nav {
    max-width: 176px;
    gap: 0.35rem;
  }

  .dashboard-grid {
    display: block;
    padding-top: min(25vh, 180px);
  }

  .action-surface,
  .expedition-surface {
    margin-bottom: 0.8rem;
  }

  .action-surface {
    background: linear-gradient(145deg, rgba(3, 10, 24, 0.66), rgba(5, 19, 36, 0.38));
  }

  .journal {
    display: grid;
    margin-top: 1rem;
  }

  .journal-surface summary {
    padding: 0.9rem 1rem;
  }

  #ledger-table,
  #record-list {
    padding: 0.35rem 1rem 1rem;
  }

  #deadline-countdown {
    font-size: 1.3rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pulse { animation: none; }
  .rate-fill { transition: none; }
  #my-shot-card button,
  #evidence-form button,
  #auth-card button { transition: none; }
}

@supports not (backdrop-filter: blur(1px)) {
  .surface,
  .journal-surface,
  #auth-card {
    background: rgba(4, 13, 27, 0.86);
  }
}
