/* Fogcarver: one palette ("fog chart"), EB Garamond with its old-style figures, ink-line icons. */
@font-face {
  font-family: "Fog Serif";
  src: url("fonts/fog-serif.woff2") format("woff2");
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Fog Serif";
  src: url("fonts/fog-serif-italic.woff2") format("woff2");
  font-weight: 400 800;
  font-style: italic;
  font-display: swap;
}

:root {
  --sea: #A8BEBB;
  --fog: #F2F3EE;
  --paper: #E8EAE1;
  --paper-2: #DFE2D7;
  --ink: #1F2B2A;
  --pencil: #5E6B67;
  --rule: rgba(31, 43, 42, 0.22);
  --vermilion: #C2432D;
  --vermilion-dark: #9E3322;
  --top: var(--shell-top, 0px);
  --right: var(--shell-right, 0px);
  --bottom: var(--shell-bottom, 0px);
  --left: var(--shell-left, 0px);
  --col: min(520px, calc(100vw - var(--left) - var(--right)));
  --serif: "Fog Serif", "EB Garamond", Georgia, serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--sea);
  color: var(--ink);
  font: 500 18px/1.35 var(--serif);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}
canvas#c { position: fixed; left: 0; top: 0; width: 100%; height: 100%; display: block; touch-action: none; }
[hidden] { display: none !important; }

svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ico { width: 22px; height: 22px; vertical-align: -3px; margin: 0 3px 0 10px; }
.ico.on { fill: var(--vermilion); stroke: var(--ink); }
.ico.star { margin: 0 1px; width: 20px; height: 20px; }

button, a.list-row {
  font: inherit;
  color: var(--ink);
  cursor: pointer;
}
button:focus-visible, a:focus-visible { outline: 2px solid var(--vermilion); outline-offset: 2px; }
button:disabled { opacity: 0.55; cursor: default; }

.primary, .secondary, .reward, .quiet {
  min-height: 52px;
  padding: 10px 18px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 19px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 120ms ease-out, background-color 120ms ease-out;
  white-space: nowrap;
}
.primary:active, .secondary:active, .reward:active { transform: translateY(1px) scale(0.985); }
.primary { background: var(--vermilion); border: 1.5px solid var(--vermilion-dark); color: var(--paper); }
.secondary { background: rgba(232, 234, 225, 0.88); border: 1.5px solid var(--ink); }
.reward {
  background: var(--paper);
  border: 1.5px dashed var(--ink);
  font-weight: 500;
  font-size: 17px;
  white-space: normal;
  text-align: center;
}
.quiet { background: transparent; border: 0; color: var(--pencil); font-weight: 500; }
.wide { width: 100%; }

.icon-btn {
  width: 48px; height: 48px;
  display: inline-grid; place-items: center;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  background: rgba(232, 234, 225, 0.9);
  padding: 0;
}
.icon-btn:active { transform: scale(0.95); }

/* intro wordmark (first launch) */
.intro {
  position: fixed; inset: 0; display: grid; place-items: center; pointer-events: none;
  font: italic 600 52px/1 var(--serif); color: var(--ink); opacity: 0;
}
.intro.on { animation: intro 2.2s ease-out forwards; }
@keyframes intro { 0% { opacity: 0; letter-spacing: 0.08em; } 25% { opacity: 1; } 65% { opacity: 1; } 100% { opacity: 0; letter-spacing: 0.02em; } }

/* play HUD */
.hud {
  position: fixed;
  top: calc(var(--top) + 8px);
  left: calc(var(--left) + 12px);
  right: calc(var(--right) + 12px);
  height: 52px;
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.hud > * { pointer-events: auto; }
.scorebox { justify-self: center; display: flex; align-items: baseline; gap: 6px; }
.score { font-size: 40px; font-weight: 600; line-height: 1; min-width: 1.4em; text-align: right; }
.pennant svg { width: 22px; height: 22px; vertical-align: -2px; }
.pennant.on svg { fill: var(--vermilion); }
.par { font-size: 22px; color: var(--pencil); }
.hud .left { display: flex; align-items: center; gap: 4px; font-size: 22px; padding: 0 6px; }
.undo { position: fixed; width: 52px; height: 52px; }
.undo.hint { animation: hint 0.6s ease-in-out 4; }
@keyframes hint { 50% { transform: scale(1.14); background: var(--fog); box-shadow: 0 0 0 6px rgba(194, 67, 45, 0.25); } }

/* screens */
.screen {
  position: fixed;
  top: 0; bottom: 0;
  left: 50%;
  width: var(--col);
  transform: translateX(-50%);
  padding: calc(var(--top) + 14px) 18px calc(var(--bottom) + 16px);
  display: flex;
  flex-direction: column;
  pointer-events: none;
}
.screen > * { pointer-events: auto; }
.screen.paper { pointer-events: auto; width: 100%; max-width: none; left: 0; transform: none; background: var(--paper); padding-left: calc(var(--left) + 18px); padding-right: calc(var(--right) + 18px); }
.screen.paper > * { width: 100%; max-width: 560px; margin-left: auto; margin-right: auto; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; }
.top .spacer { width: 48px; }
.wordmark { margin: 0; font: italic 600 40px/1 var(--serif); letter-spacing: 0.01em; }
.title { margin: 0; font: 600 28px/1.1 var(--serif); }
.sub { margin: 2px 0 0; color: var(--pencil); font-style: italic; font-size: 17px; min-height: 1em; }
.dayline { display: flex; align-items: baseline; gap: 14px; margin-top: 4px; }
.dayname { font-size: 24px; font-weight: 600; }
.streak { color: var(--pencil); font-style: italic; }
.mapslot { flex: 1; min-height: 160px; pointer-events: none; }
.actions { display: grid; gap: 10px; }
.actions .row, .buttons .row, .offer .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.buttons .row { grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); }
.row svg { width: 22px; height: 22px; }
.scoreline { margin: 0; display: flex; align-items: baseline; justify-content: center; font-size: 22px; }
.scoreline .big { font-size: 46px; font-weight: 600; line-height: 1; }
#homeDone { background: rgba(232, 234, 225, 0.8); border-radius: 12px; padding: 6px 10px; }

/* result */
#result .mapslot { min-height: 140px; margin: 8px 0 10px; }
.card .primary, .card .secondary, .card .reward { min-height: 46px; padding: 6px 14px; }
.card .quiet { min-height: 40px; }
.stars { display: flex; }
.card {
  background: rgba(232, 234, 225, 0.94);
  border: 1px solid var(--rule);
  border-radius: 18px;
  padding: 12px 14px 14px;
  display: grid;
  gap: 10px;
  box-shadow: 0 6px 18px rgba(31, 43, 42, 0.12);
}
.breakdown { display: flex; justify-content: center; gap: 22px; color: var(--pencil); }
.breakdown span { display: inline-flex; align-items: center; gap: 5px; }
.breakdown b { font-weight: 600; color: var(--ink); font-size: 20px; }
.buttons { display: grid; gap: 8px; }
.offer { border-top: 1px solid var(--rule); padding-top: 10px; display: grid; gap: 8px; }
.offer p { margin: 0; font-size: 16px; color: var(--pencil); text-align: center; }
.offer .secondary { white-space: normal; font-size: 16px; }

/* Atlas and archive */
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 12px; }
.page { padding: 12px 0 14px; border-bottom: 1px solid var(--rule); }
.page h3, #archiveList h3 { margin: 6px 0 8px; font: italic 600 20px/1.2 var(--serif); }
.page.locked h3 { color: var(--pencil); }
.isles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.isle canvas { width: min(92px, 100%); height: auto; aspect-ratio: 1 / 1; }
.isle {
  position: relative; border: 1px solid var(--rule); border-radius: 12px; background: var(--paper-2);
  padding: 4px; display: grid; place-items: center; min-height: 120px;
}
.isle.done { background: #DDE5E1; }
.isle .num { position: absolute; top: 4px; left: 8px; font-size: 15px; color: var(--pencil); }
.isle .stars { position: absolute; bottom: 4px; display: flex; }
.isle .stars .ico { width: 15px; height: 15px; }
.isle.locked { opacity: 0.7; }
.note { margin: 6px 0; color: var(--pencil); font-size: 16px; font-style: italic; }
.note a { color: var(--ink); }
.page .reward { width: 100%; margin-top: 6px; }
.days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin-bottom: 8px; }
.day {
  min-height: 52px; border-radius: 10px; border: 1px solid var(--rule); background: var(--paper-2);
  display: grid; place-items: center; padding: 2px; line-height: 1.1;
}
.day .dnum { font-size: 17px; font-weight: 600; }
.day .dscore { font-size: 12px; color: var(--pencil); }
.day.played { background: #DDE5E1; }
.day.par { border-color: var(--vermilion); }
.day.par .dscore { color: var(--vermilion-dark); font-weight: 600; }
.day.open { border-style: dashed; border-color: var(--ink); }

/* sheets */
.sheet {
  position: fixed; inset: 0; background: rgba(31, 43, 42, 0.35);
  display: flex; align-items: flex-end; justify-content: center;
}
.panel {
  width: min(520px, 100%);
  max-height: 92%;
  overflow-y: auto;
  background: var(--paper);
  border-radius: 18px 18px 0 0;
  padding: 18px 18px calc(var(--bottom) + 18px);
  padding-left: calc(var(--left) + 18px);
  padding-right: calc(var(--right) + 18px);
  display: grid;
  gap: 8px;
  box-shadow: 0 -8px 24px rgba(31, 43, 42, 0.2);
}
.panel h2 { margin: 0 0 4px; font: 600 26px/1.2 var(--serif); }
.list-row {
  min-height: 52px; display: flex; align-items: center; justify-content: space-between;
  border: 0; border-bottom: 1px solid var(--rule); background: transparent; text-align: left;
  padding: 8px 2px; font-size: 18px; text-decoration: none;
}
.list-row.strong { font-weight: 600; }
.list-row .state { color: var(--pencil); font-style: italic; }
.what { margin: 4px 0 0; color: var(--pencil); font-size: 16px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--bottom) + 24px); transform: translate(-50%, 20px);
  max-width: min(440px, 90vw); background: var(--ink); color: var(--paper);
  padding: 10px 16px; border-radius: 12px; font-size: 16px; opacity: 0; pointer-events: none;
  transition: opacity 200ms ease-out, transform 200ms ease-out; text-align: center;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  .intro.on { animation: none; opacity: 0; }
  .undo.hint { animation: none; box-shadow: 0 0 0 4px rgba(194, 67, 45, 0.35); }
  .toast, .primary, .secondary, .reward { transition: none; }
}
/* the same when Reduce motion is on in Settings */
.reduce .intro.on { animation: none; opacity: 0; }
.reduce .undo.hint { animation: none; box-shadow: 0 0 0 4px rgba(194, 67, 45, 0.35); }
.reduce .toast, .reduce .primary, .reduce .secondary, .reduce .reward { transition: none; }

/* short phones: tighter type */
@media (max-height: 700px) {
  .wordmark { font-size: 34px; }
  .scoreline .big { font-size: 38px; }
  .primary, .secondary, .reward { min-height: 48px; font-size: 17px; }
}
