@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700;800&family=Instrument+Serif&display=swap");

:root {
  --paper: #f6f4ec;
  --panel: #fbfaf5;
  --ink: #172b2d;
  --teal: #12665b;
  --muted: #506663;
  --line: #dfdfd3;
  --mint: #e4eee7;
  --mono: ui-monospace, monospace;
  color-scheme: light;
  font: 500 15px/1.45 "DM Sans", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body, h1, h2, p { margin: 0; }
button, input, a { font: inherit; color: inherit; }
button, .share-links a {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 8px 14px;
  font-weight: 700;
  cursor: pointer;
}
button:disabled { cursor: default; }
button:hover:not(:disabled), .share-links a:hover { box-shadow: 0 0 0 2px #12665b30; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; }

.site-header { border-bottom: 1px solid var(--line); background: #fbfaf4; }
.header-inner {
  max-width: 910px;
  min-height: 54px;
  margin: auto;
  padding: 0 22px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-self: start;
  font-size: 23px;
  font-weight: 800;
  letter-spacing: -.055em;
  text-decoration: none;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 33px;
  height: 33px;
  border-radius: 50%;
  color: white;
  background: var(--teal);
  font-size: 21px;
  line-height: 1;
}
.compass {
  position: relative;
  width: 14px;
  height: 14px;
  border: 1px solid white;
  border-radius: 50%;
}
.compass::after {
  content: "";
  position: absolute;
  inset: 2px 4px;
  border: 1px solid white;
  border-top-width: 3px;
  transform: rotate(40deg);
  clip-path: polygon(50% 0, 100% 55%, 50% 100%, 0 55%);
}
.game-nav {
  display: flex;
  gap: 3px;
  align-items: center;
  justify-content: center;
  padding: 3px;
  border: 1px solid #e3e7dc;
  border-radius: 10px;
  background: #ebede4;
}
.game-nav a, .game-nav span {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  padding: 5px 11px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  text-decoration: none;
}
.game-nav a[aria-current="page"] {
  background: white;
  color: var(--ink);
  box-shadow: 0 1px 3px #172b2d13;
}
main {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: calc(100vh - 54px);
  padding-bottom: 32px;
}
.game-zone { position: relative; isolation: isolate; padding: 28px 18px 24px; }
.game-zone::before, .game-zone::after {
  content: "";
  position: absolute;
  width: 270px;
  height: 420px;
  border-radius: 48%;
  background: repeating-radial-gradient(ellipse closest-side, transparent 0 7px, var(--teal) 8px, transparent 9px 15px);
  opacity: .10;
  pointer-events: none;
  z-index: -1;
}
.game-zone::before { top: 4px; left: -145px; transform: rotate(-32deg); }
.game-zone::after { bottom: -34px; right: -150px; transform: rotate(35deg); }
.intro { text-align: center; margin-bottom: 18px; }
.intro p:last-child { color: var(--muted); }
.eyebrow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: 700 11px/1.4 var(--mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--teal);
}
.eyebrow::before, .eyebrow::after { content: ""; width: 18px; height: 1px; background: #8aa99b; }
h1 {
  margin: 6px 0 8px;
  font: 400 clamp(44px, 7vw, 66px)/.98 "Instrument Serif", Georgia, serif;
  letter-spacing: -.045em;
}
.game {
  max-width: 570px;
  margin: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 15px;
  box-shadow: 0 5px 0 #e7e7db;
  padding: 13px 24px 17px;
}
.game-meta, .actions, .dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.game-meta { justify-content: flex-end; min-height: 43px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.counter { color: var(--muted); font-size: 12px; white-space: nowrap; }
.counter strong { color: var(--teal); font: 800 19px/1 var(--mono); margin-right: 3px; }
.board { display: grid; gap: 8px; padding: 10px 0 14px; }
.row-label {
  text-transform: uppercase;
  text-align: center;
  letter-spacing: .15em;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  margin-bottom: 4px;
}
.tiles { display: flex; justify-content: center; flex-wrap: wrap; gap: 5px; }
.tile {
  display: grid;
  place-items: center;
  width: clamp(24px, 8.2%, 40px);
  aspect-ratio: 1;
  border: 1px solid #cfd6cd;
  border-bottom-width: 2px;
  border-radius: 6px;
  background: white;
  font-size: clamp(16px, 4vw, 24px);
  font-weight: 800;
  line-height: 1;
}
.tile.space { width: 9px; border: 0; background: transparent; }
.tile.hit, .key.hit { color: white; background: var(--teal); border-color: var(--teal); }
.board.failed .tile:not(.space) { color: var(--teal); background: var(--mint); }
.keyboard { display: grid; row-gap: 5px; max-width: 440px; margin: auto; }
.key-row { display: flex; justify-content: center; gap: 4px; }
.key {
  width: calc((100% - 36px)/10);
  min-height: 40px;
  padding: 0;
  min-width: 0;
  border-color: #cfd6cd;
  border-bottom-width: 2px;
  border-radius: 6px;
  font-size: 14px;
}
.key.miss { background: #dfe4e1; color: #465755; text-decoration: line-through; }
.actions { margin: 13px auto 0; max-width: 440px; }
.primary { color: white; background: var(--teal); border-color: var(--teal); }
.solve { min-width: 112px; min-height: 40px; }
.attempts { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.dots { display: inline-flex; gap: 4px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); }
.dot.spent { background: #d4dcd3; }

.scores { max-width: 606px; margin: 5px auto 0; padding-inline: 18px; }
.score-head { padding: 7px 0 10px; }
.score-head h2 {
  font: 400 30px/1.05 "Instrument Serif", Georgia, serif;
  letter-spacing: -.03em;
}
.scores table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); }
.scores th, .scores td { padding: 7px 14px; text-align: left; border-bottom: 1px solid var(--line); }
.scores th { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.scores th:last-child { text-align: right; }
.scores-empty { font-size: 13px; color: var(--muted); }

dialog {
  width: min(calc(100% - 24px), 410px);
  padding: 17px 19px 19px;
  background: #fffdf4;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 14px 50px #172b2d40;
}
dialog::backdrop { background: #172b2d55; }
.dialog-head h2 {
  font: 400 33px/1 "Instrument Serif", Georgia, serif;
  letter-spacing: -.03em;
}
.close { font-size: 22px; line-height: 1; padding: 4px 11px; background: transparent; }
form { display: grid; gap: 9px; margin-top: 11px; }
label { display: grid; gap: 4px; font-weight: 700; font-size: 13px; }
input { width: 100%; min-height: 44px; padding: 6px 9px; border: 1px solid #cbd3c9; border-radius: 6px; background: white; font-size: 16px; }
.error { color: #893624; font-size: 13px; }
.error:empty, .share-status:empty { display: none; }
.result-score {
  margin-top: 10px;
  font: 400 44px/1 "Instrument Serif", Georgia, serif;
  color: var(--teal);
}
.result-location, .share-status { color: var(--muted); margin: 8px 0; }
.share-links { display: flex; flex-wrap: wrap; gap: 6px; margin: 13px 0; }
.share-links a { display: inline-flex; align-items: center; text-decoration: none; }
.share-links a, .share-links button { font-size: 13px; padding-inline: 10px; }
#play-again { margin-top: 4px; }

@media (max-width: 560px) {
  .header-inner { grid-template-columns: 1fr auto; min-height: 53px; padding: 6px 10px; gap: 6px; }
  .brand { font-size: 22px; }
  .brand-mark { width: 29px; height: 29px; }
  .game-nav a, .game-nav span { padding-inline: 7px; font-size: 12px; }
  .game-zone { padding: 16px 10px; }
  .scores { padding-inline: 10px; }
  .intro { margin-bottom: 13px; }
  .intro p:last-child { font-size: 13px; }
  .game { padding: 7px 9px 11px; }
  .game-meta { padding-bottom: 5px; }
  .board { gap: 8px; padding: 9px 0 11px; }
  .actions { margin-top: 9px; }
}

@media (pointer: coarse) { .key, .solve { min-height: 44px; } }

.score-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.score-head span { font-size: 12px; color: var(--muted); text-align: right; }
.scores td:first-child:not(.scores-empty) { width: 60px; color: var(--muted); }
.scores td:last-child:not(.scores-empty) { text-align: right; }
.initials, #score-initials { font-family: var(--mono); letter-spacing: .14em; font-weight: 700; }
#score-initials { text-transform: uppercase; }
#show-scores { margin-top: 9px; background: transparent; }
.score-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
.admin { max-width: 850px; margin: auto; padding: 24px 18px; overflow: visible; }
.admin h2 { font: 400 30px/1 "Instrument Serif", Georgia, serif; }
.admin .quiet { color: var(--muted); font-size: 13px; }
.admin .login { max-width: 390px; }
.admin .queue { margin-top: 20px; }
.admin .queue-row { border: 1px solid var(--line); background: var(--panel); padding: 12px; border-radius: 8px; margin: 0; }
.admin .queue-row legend { font-weight: 800; }
.admin .queue-fields { display:grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.admin select { width:100%; min-height:44px; padding: 6px 9px; border:1px solid #cbd3c9; border-radius:6px; color:inherit; font:inherit; background:white; }
.admin .queue-actions { display:flex; flex-wrap:wrap; gap:8px; margin-top:10px; }
.admin .session-row { display:flex; justify-content:space-between; gap:10px; align-items:center; }
.admin .notice { min-height: 22px; color:var(--teal); }
@media(max-width:560px){ .admin .queue-fields {grid-template-columns: 1fr;} }
#slots { display:grid; gap:10px; }
