:root {
  --bg: #f2ede3;
  --ink: #1d1b18;
  --muted: #776f62;
  --rule: #d9d0bf;
  --accent: #000;
  --pad: clamp(20px, 4.5vw, 56px);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151411;
    --ink: #ebe4d6;
    --muted: #91887a;
    --rule: #2f2c26;
    --accent: #fff;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  /* Nothing here is worth copying; selection only gets in the way of playing. */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  /* The pick is the cursor everywhere, so reaching the strings feels like playing. */
  cursor: url("pick.svg?v=14") 9 26, auto;
}
a,
button,
button:disabled { cursor: url("pick.svg?v=14") 9 26, pointer; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}


.page {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr;
  padding: var(--pad) var(--pad) 0;
}

/* intro */
.intro { max-width: 36rem; padding-top: clamp(24px, 6vh, 72px); }

h1 {
  margin: 0 0 .4em;
  font: 400 clamp(2.7rem, 8vw, 5.4rem)/0.95 var(--serif);
  letter-spacing: -0.025em;
}

.lede {
  margin: 0 0 2rem;
  font-size: clamp(1.05rem, 1.6vw, 1.2rem);
  max-width: 31rem;
}
.lede a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  transition: color .2s, text-decoration-color .2s;
}
.lede a:hover,
.lede a:focus-visible { color: var(--accent); text-decoration-color: var(--accent); }

.links { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.links li { border-bottom: 1px solid var(--rule); }
.links a {
  display: grid;
  grid-template-columns: 7.5rem 1fr auto;
  align-items: baseline;
  gap: 1rem;
  padding: .85rem 0;
  color: inherit;
  text-decoration: none;
}
.links .name { font: 1.2rem var(--serif); }
.links .what { color: var(--muted); font-size: .92rem; }
.links .arrow { transition: transform .25s ease, color .25s; }
.links a:hover .name,
.links a:focus-visible .name { color: var(--accent); }
.links a:hover .arrow,
.links a:focus-visible .arrow { transform: translate(3px, -3px); color: var(--accent); }

a:focus-visible,
button:focus-visible,
canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* strings */
.play {
  display: flex;
  flex-direction: column;
  margin: clamp(28px, 6vh, 64px) calc(var(--pad) * -1) 0;
  min-height: 300px;
}
.play-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: baseline;
  gap: .5rem 1.5rem;
  padding: 0 var(--pad);
  font-size: .9rem;
  color: var(--muted);
}

.game { display: flex; align-items: baseline; gap: .9rem; flex-wrap: wrap; }
.game button {
  display: flex;
  flex-direction: column;
  align-items: center;
  font: inherit;
  color: var(--ink);
  background: none;
  border: 0;
  padding: 0;
}
.game .label { border-bottom: 1px solid currentColor; }
.game button:hover { color: var(--accent); }
.game button:disabled .label { color: var(--muted); border-bottom-style: dotted; }

/* a few notes drift up, softly, to hint at the button */
.ditty { display: block; width: 40px; height: 30px; margin-bottom: 2px; overflow: visible; }
.ditty .note { opacity: 0; transform-box: view-box; animation: drift 7.5s ease-out infinite; }
.ditty .n2 { animation-delay: 2.5s; }
.ditty .n3 { animation-delay: 5s; }
.playing .ditty .note { animation-duration: 3s; }
.playing .ditty .n2 { animation-delay: 1s; }
.playing .ditty .n3 { animation-delay: 2s; }

@keyframes drift {
  0% { opacity: 0; transform: translate(0, 4px) scale(.85); }
  25% { opacity: .55; }
  100% { opacity: 0; transform: translate(3px, -16px) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .ditty .note { animation: none; opacity: .35; }
}

.stage {
  position: relative;
  flex: 1;
  min-height: 240px;
}
canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: inherit;
  -webkit-tap-highlight-color: transparent;
}

/* 404 */
.lost { grid-template-rows: 1fr; padding-bottom: var(--pad); }
.lost .intro { align-self: center; padding-top: 0; }
.home {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-underline-offset: 4px;
}
.home:hover,
.home:focus-visible { color: var(--accent); text-decoration-color: var(--accent); }

@media (max-width: 560px) {
  .links a { grid-template-columns: 1fr auto; gap: .1rem 1rem; padding: .65rem 0; }
  .links .what { grid-column: 1; grid-row: 2; }
  .links .arrow { grid-column: 2; grid-row: 1; }

  /* On a phone everything fits in one screen: the name at the very top,
     all six strings above Safari's toolbar. The strings take whatever room is left. */
  .page { padding-top: 18px; }
  .intro { padding-top: 0; }
  h1 { margin-bottom: .3em; }
  .lede { margin-bottom: 1.25rem; }
  .play { margin-top: 12px; min-height: 0; }
  .stage { min-height: 170px; }
  .ditty { height: 24px; }
}

/* Short phones (iPhone SE and the like): a little tighter still. */
@media (max-width: 560px) and (max-height: 620px) {
  .page { padding-top: 14px; }
  h1 { font-size: 2.3rem; }
  .lede { font-size: .98rem; margin-bottom: .9rem; }
  .links a { padding: .45rem 0; }
  .links .name { font-size: 1.1rem; }
  .links .what { font-size: .84rem; }
  .play { margin-top: 6px; }
  .stage { min-height: 138px; }
  .ditty { height: 18px; }
}
