/* Copyright (c) 2026 Mayan Rajesh. All rights reserved.
   Shoalfolk - proprietary. See LICENSE. */

:root {
  --deep: #061b2e;
  --foam: #f4f7f5;
  --ink: #0d1b26;
  --paper: #f6f1e6;
  --muted: #8a9aa6;
  /* the notch and the home bar, on the phones that have them */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  /* dvh follows the phone's address bar as it hides and shows; the vh above it
     is the fallback for browsers that have not got dvh yet */
  height: 100vh;
  height: 100dvh;
  background: var(--deep);
  font-family: "Trebuchet MS", Verdana, sans-serif;
  color: var(--foam);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  /* a game underneath a browser that scrolls, zooms and pulls to refresh is
     not a game anyone can aim in */
  overscroll-behavior: none;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

#ui {
  position: absolute;
  inset: 0;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}

#score, #time {
  position: absolute;
  top: calc(18px + var(--safe-t));
  font-size: 12px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .8);
  text-shadow: 0 1px 4px rgba(6, 20, 34, .55);
}
#score { left: calc(26px + var(--safe-l)); }
#time { right: calc(26px + var(--safe-r)); text-align: right; }

#score b, #time b {
  display: block;
  font-weight: 700;
  letter-spacing: 0;
  color: #fff;
  text-shadow: 0 2px 10px rgba(6, 20, 34, .5);
  font-variant-numeric: tabular-nums;
}
#score b { font-size: 42px; line-height: 1.02; }
#time b { font-size: 27px; line-height: 1.1; }

/* the last ten seconds of daylight */
#time.low b { color: #ffcf8d; animation: pulse .9s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }

#combo {
  position: absolute;
  left: 0; right: 0; top: 34%;
  text-align: center;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: .01em;
  color: #fff;
  text-shadow: 0 2px 18px rgba(0, 0, 0, .55);
  opacity: 0;
  transform: translateY(8px) scale(.98);
  transition: opacity .3s, transform .3s;
}
#combo.show { opacity: 1; transform: none; }

/* --- the thumb oars ------------------------------------------------------- */
/* Sized to a thumb, not to a cursor: 64px is about the smallest target anyone
   can hit reliably while also watching the water. */
#touch {
  position: absolute;
  left: calc(14px + var(--safe-l));
  right: calc(14px + var(--safe-r));
  bottom: calc(16px + var(--safe-b));
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}
#touch[hidden] { display: none; }

.rowbtn {
  pointer-events: auto;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .28);
  background: rgba(9, 32, 52, .42);
  backdrop-filter: blur(3px);
  color: rgba(255, 255, 255, .9);
  font: 700 30px/1 "Trebuchet MS", Verdana, sans-serif;
  touch-action: none;
  transition: background .1s, transform .1s;
}
.rowbtn.on { background: rgba(24, 74, 112, .7); transform: scale(.94); }

/* --- the card ------------------------------------------------------------- */
#card {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(14px + var(--safe-t)) 14px calc(14px + var(--safe-b));
  pointer-events: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: radial-gradient(120% 90% at 50% 40%, rgba(10, 42, 69, .35), rgba(4, 16, 28, .78));
  backdrop-filter: blur(2px);
}
#card.hidden { display: none; }

.sheet {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .5), rgba(255, 255, 255, 0) 40%),
    var(--paper);
  color: var(--ink);
  padding: 32px 36px 26px;
  border-radius: 14px;
  width: 100%;
  max-width: 500px;
  margin: auto;
  text-align: center;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .45), inset 0 0 0 1px rgba(255, 255, 255, .5);
}

/* --- the wordmark --------------------------------------------------------- */
/* The mark and the name read as one lockup: the mark carries the colour, the
   name carries the weight, and the two halves of the name are set differently
   so it has a shape of its own rather than being a heading that happens to be
   the title. */
.logo {
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  line-height: 1;
}
.logo .mark {
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 11px;
  box-shadow: 0 3px 10px rgba(8, 32, 52, .28);
}
.logo .word {
  font-size: 38px;
  font-weight: 700;
  letter-spacing: -.015em;
  color: #102c40;
}
.logo .word em {
  font-style: normal;
  font-weight: 400;
  color: #4d7f8d;
}
.sheet p { margin: 8px 0; line-height: 1.58; color: #3b4d5c; }
.sheet .lede { margin: 0 0 12px; color: var(--muted); font-size: 13px; letter-spacing: .04em; }
.sheet .record { color: var(--muted); font-size: 13px; letter-spacing: .03em; }
.sheet .record b { color: var(--ink); font-weight: 600; }
.sheet .record.best b { color: #b4562f; }
.sheet .big { font-size: 58px; font-weight: 700; margin: 6px 0 0; color: var(--ink); line-height: 1; }

#namerow {
  margin: 16px auto 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}
#namerow label {
  font-size: 13px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}
#name {
  font: inherit;
  font-size: 16px;                 /* 16px or iOS zooms the page on focus */
  width: 9ch;
  padding: 7px 10px;
  text-align: center;
  color: var(--ink);
  background: #fff;
  border: 1px solid #cfd6cd;
  border-radius: 8px;
}
#name:focus { outline: 2px solid #2a5c7d; outline-offset: 1px; }
#namehint { flex-basis: 100%; font-size: 11px; color: var(--muted); letter-spacing: .03em; }

#controls { margin: 14px 0 0; font-size: 14px; }

#go {
  margin-top: 16px;
  background: var(--ink);
  color: var(--foam);
  border: 0;
  font: inherit;
  font-size: 17px;
  padding: 13px 32px;
  border-radius: 30px;
  cursor: pointer;
  min-height: 48px;
  transition: background .15s, transform .15s;
}
#go:hover { background: #21384b; transform: translateY(-1px); }
#go:active { transform: none; }

/* --- sharing -------------------------------------------------------------- */
.share {
  margin-top: 18px;
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
}
.share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid #d8d2c4;
  background: rgba(255, 255, 255, .7);
  color: #5c6b78;
  cursor: pointer;
  font: inherit;
  transition: background .15s, color .15s, border-color .15s;
}
.share-btn svg { width: 18px; height: 18px; fill: currentColor; }
.share-btn:hover { background: #fff; color: var(--ink); border-color: #b9b3a3; }
.share-btn:focus-visible { outline: 2px solid #2a5c7d; outline-offset: 2px; }
.share-btn.done { color: #2f6f4f; border-color: #2f6f4f; }

#copyright {
  margin: 16px 0 0;
  font-size: 11px;
  letter-spacing: .04em;
  color: #a6afa2;
}

/* The footer link, and the rights note it opens. The note is prose in a card
   already built for prose, so it takes the card's measure and marks itself off
   with a rule rather than a box. */
.linklike {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.linklike:hover { color: var(--ink); }
.linklike:focus-visible { outline: 2px solid #2a5c7d; outline-offset: 2px; border-radius: 2px; }

.licence {
  margin: 10px auto 0;
  max-width: 44ch;
  padding-top: 10px;
  border-top: 1px solid #e2ded1;
  text-align: left;
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted);
}
.licence p { margin: 0 0 8px; }
.licence p:last-child { margin: 0; }
.licence a { color: #2a5c7d; }

table.tally {
  margin: 16px auto 0;
  border-collapse: collapse;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
table.tally td, table.tally th { padding: 5px 14px; text-align: right; border-bottom: 1px solid #e2ded1; }
table.tally th { font-weight: normal; color: var(--muted); }
table.tally td:first-child, table.tally th:first-child { text-align: left; }

.key {
  display: inline-block;
  border: 1px solid #c3ccd3;
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 7px;
  font-size: 13px;
  margin: 0 2px;
  background: #fff;
}

/* --- small screens -------------------------------------------------------- */
/* The readouts and the card both come down a size, and the intro loses the
   line height it does not have room for. */
@media (max-width: 560px) {
  #score b { font-size: 32px; }
  #time b { font-size: 22px; }
  #score { left: calc(16px + var(--safe-l)); }
  #time { right: calc(16px + var(--safe-r)); }
  #combo { font-size: 26px; }
  .sheet { padding: 24px 20px 20px; border-radius: 12px; }
  .logo { gap: 10px; }
  .logo .mark { width: 34px; height: 34px; border-radius: 9px; }
  .logo .word { font-size: 30px; }
  .sheet p { font-size: 14px; line-height: 1.5; }
  .sheet .big { font-size: 46px; }
  table.tally { font-size: 13px; }
  table.tally td, table.tally th { padding: 4px 9px; }
}

/* A phone held sideways has almost no height to give away, so the card sheds
   the long introduction rather than becoming something you have to scroll. */
@media (max-height: 470px) and (orientation: landscape) {
  .sheet { padding: 14px 20px 12px; max-width: 700px; }
  .logo { gap: 8px; margin-bottom: 2px; }
  .logo .mark { width: 26px; height: 26px; border-radius: 7px; }
  .logo .word { font-size: 23px; }
  #intro, .sheet .lede, #namehint { display: none; }
  /* the day's total and the day's tally, side by side rather than stacked */
  #result {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 26px;
    flex-wrap: wrap;
  }
  .sheet .big { font-size: 40px; }
  table.tally { margin-top: 0; font-size: 12px; }
  table.tally td, table.tally th { padding: 3px 9px; }
  #namerow { margin: 6px auto 0; }
  #controls { margin-top: 4px; font-size: 13px; }
  #go { margin-top: 6px; padding: 9px 24px; min-height: 42px; font-size: 16px; }
  .share { margin-top: 6px; }
  .share-btn { width: 34px; height: 34px; }
  #copyright { margin-top: 6px; }
  .rowbtn { width: 54px; height: 54px; font-size: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  #time.low b { animation: none; }
  #combo, #go, .share-btn, .rowbtn { transition: none; }
}
