/* The page is the app: the canvas fills the screen, the three brass buttons
   sit along the bottom as on the phones (22 px in from the sides, above the
   home indicator), and nothing scrolls, zooms or selects. */
:root {
  --room: #0b0907;              /* the dark of the room beyond the table */
  --brass-hi: rgb(240, 216, 160);
  --brass-lo: rgb(140, 106, 52);
  --brass-line: rgba(236, 214, 164, 0.94);
  --brass-hair: rgba(214, 178, 108, 0.275);
  --glass: rgba(20, 15, 10, 0.588);
  --glass-pressed: rgba(74, 56, 28, 0.804);
  --text: rgba(236, 214, 164, 0.82);
  --text-quiet: rgba(214, 178, 108, 0.55);
  color-scheme: dark;
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--room);
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  font: 13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

canvas#coin {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  outline: none;
  opacity: 0;
  transition: opacity 600ms ease-out;
}
canvas#coin.shown { opacity: 1; }

/* --- the buttons ---------------------------------------------------------- */

.buttons {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0;
  pointer-events: none;
}
.brass {
  position: fixed;
  width: var(--size);
  height: var(--size);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  pointer-events: auto;
  touch-action: none;
  cursor: pointer;
  transition: transform 140ms ease-out;
  -webkit-tap-highlight-color: transparent;
}
/* As on the iPhone: the bottom edge sits max(safe area, 8) + 20 points up. */
#spin, #toss { bottom: calc(max(env(safe-area-inset-bottom, 0px), 8px) + 20px); }
#spin { left: calc(env(safe-area-inset-left, 0px) + 22px); }
#toss { right: calc(env(safe-area-inset-right, 0px) + 22px); }
/* Smaller, and level with the middles of the other two. */
#stand-up { left: calc(50% - 23px); bottom: calc(max(env(safe-area-inset-bottom, 0px), 8px) + 29px); }

.brass svg { display: block; width: 100%; height: 100%; overflow: visible; }
.brass .glass { fill: var(--glass); }
.brass.pressed .glass { fill: var(--glass-pressed); }
.brass.pressed { transform: scale(0.93); transition-duration: 60ms; }
.brass .ring { fill: none; stroke-width: 1.3; }
.brass .hairline { fill: none; stroke: var(--brass-hair); stroke-width: 0.6; }
.brass .sign { fill: none; stroke: var(--brass-line); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.brass:focus { outline: none; }
.brass:focus-visible { outline: 1px solid var(--brass-hi); outline-offset: 3px; }

/* --- the first-visit hint on a computer -------------------------------------- */

.hint {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 6px 12px;
  max-width: calc(100% - 32px);
  box-sizing: border-box;
  border-radius: 14px;
  background: var(--glass);
  color: var(--text-quiet);
  font-size: 12px;
  letter-spacing: 0.02em;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  transition: opacity 900ms ease-out;
}
.hint.gone { opacity: 0; }
.hint kbd {
  font: inherit;
  color: var(--text);
  padding: 0 4px;
  border: 1px solid var(--brass-hair);
  border-radius: 3px;
}

/* --- loading and failing ------------------------------------------------------ */

.loader {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 max(24px, env(safe-area-inset-left, 0px));
  text-align: center;
  color: var(--text);
  transition: opacity 500ms ease-out;
}
.loader.gone { opacity: 0; pointer-events: none; }
.loader .ring { width: 64px; height: 64px; margin-bottom: 8px; transform: rotate(-90deg); }
.loader .track { fill: var(--glass); stroke: rgba(140, 106, 52, 0.35); stroke-width: 1.3; }
.loader .hairline { fill: none; stroke: var(--brass-hair); stroke-width: 0.6; }
.loader .fill {
  fill: none;
  stroke: url(#brass-light);
  stroke-width: 1.3;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 200ms linear;
}
.loader .status { margin: 0; font-size: 14px; letter-spacing: 0.06em; }
.loader .detail {
  margin: 0;
  font-size: 12px;
  color: var(--text-quiet);
  font-variant-numeric: tabular-nums;
  max-width: 34em;
}
.loader.failed .ring { opacity: 0.35; }
.again {
  margin-top: 10px;
  padding: 8px 18px;
  border: 1.3px solid var(--brass-lo);
  border-radius: 18px;
  background: var(--glass);
  color: var(--text);
  font: inherit;
  letter-spacing: 0.04em;
  cursor: pointer;
}
.again:focus-visible { outline: 1px solid var(--brass-hi); outline-offset: 3px; }

.tick { position: fixed; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; left: -10px; top: -10px; }

@media (prefers-reduced-motion: reduce) {
  canvas#coin, .loader, .hint, .brass { transition: none; }
}
