/* Game Designer — the page is intentionally bare. The card and the pencil are
   the interface, with a small fullscreen control and an end-game restart. */

/* Nunito, vendored rather than pulled from a CDN so the page works offline and
   travels as one folder. Its rounded terminals match the card artwork's
   lettering. Latin subset only, SIL Open Font License. */
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("vendor/fonts/nunito-700.woff2") format("woff2");
}
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("vendor/fonts/nunito-800.woff2") format("woff2");
}

:root {
  --ink: #2c2233;
  --teal: #00bec4;
  /* ui-rounded picks up SF Pro Rounded on Apple platforms if Nunito is slow. */
  --rounded: "Nunito", ui-rounded, "Avenir Next", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #ffffff;
  color: var(--ink);
  font-family: var(--rounded);
  overflow: hidden;
  overscroll-behavior: none;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: default;
}

#scene.point { cursor: pointer; }

/* No built-in cursor reads as "turn this over", so the card rims get a
   drawn one: a curved arrow pointing the way that edge will swing. The
   arrowhead is rotated onto the arc's tangent so it does not sit on top
   of the arc body. */
#scene.rot-r { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cg%3E%3Cg fill='none' stroke='%23ffffff' stroke-width='5.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6.49 18.68 A 9.6 5.2 0 0 1 23.96 16.49'/%3E%3Cpath d='M27.55 19.37 L21.22 18.78 L25.60 13.32 Z' fill='%23ffffff'/%3E%3C/g%3E%3Cg fill='none' stroke='%2317171c' stroke-width='2.3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6.49 18.68 A 9.6 5.2 0 0 1 23.96 16.49'/%3E%3Cpath d='M27.55 19.37 L21.22 18.78 L25.60 13.32 Z' fill='%2317171c'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E") 16 16, pointer; }
#scene.rot-l { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cg transform='translate(32,0) scale(-1,1)'%3E%3Cg fill='none' stroke='%23ffffff' stroke-width='5.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6.49 18.68 A 9.6 5.2 0 0 1 23.96 16.49'/%3E%3Cpath d='M27.55 19.37 L21.22 18.78 L25.60 13.32 Z' fill='%23ffffff'/%3E%3C/g%3E%3Cg fill='none' stroke='%2317171c' stroke-width='2.3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6.49 18.68 A 9.6 5.2 0 0 1 23.96 16.49'/%3E%3Cpath d='M27.55 19.37 L21.22 18.78 L25.60 13.32 Z' fill='%2317171c'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E") 16 16, pointer; }

.hidden { display: none !important; }

/* ---------------------------------------------------------------- */
/* Loader                                                            */
/* ---------------------------------------------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: #ffffff;
  z-index: 20;
}

.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(0, 190, 196, 0.2);
  border-top-color: var(--teal);
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- */
/* End of game                                                       */
/* ---------------------------------------------------------------- */

#endcard {
  position: fixed;
  left: 50%;
  /* top is solved in JS so the card, verdict and button centre as one stack. */
  top: 62%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 48px);
  z-index: 15;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
  animation: rise 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

#end-line {
  margin: 0;
  font-size: clamp(23px, 3.5vw, 35px);
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--ink);
}

/* Won: pick up the card's progress-track purple. Lost: its clock orange. */
#endcard.win #end-line { color: #8b3ed8; }
#endcard.lose #end-line { color: #e2704a; }

.action {
  appearance: none;
  border: 0;
  cursor: pointer;
  padding: 12px 30px;
  border-radius: 999px;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #fff;
  background: var(--ink);
  box-shadow: 0 10px 26px rgba(44, 34, 51, 0.22);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.action:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(44, 34, 51, 0.28);
}

.action:active { transform: translateY(0); }

#fullscreen-controls {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 30;
}

.viewport-button {
  appearance: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 10px;
  border: 1px solid rgba(44, 34, 51, 0.14);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  color: #68616b;
  cursor: pointer;
  transition: color 0.16s ease, background 0.16s ease;
}

.viewport-button:hover {
  color: var(--ink);
  background: #f5f1f8;
}

.viewport-button:focus-visible {
  outline: 2px solid #00878c;
  outline-offset: 3px;
}

.viewport-button:disabled { cursor: wait; }

.viewport-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#btn-fullscreen .icon-collapse,
#btn-fullscreen[aria-pressed="true"] .icon-expand { display: none; }
#btn-fullscreen[aria-pressed="true"] .icon-collapse { display: inline; }

#fullscreen-message {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(max(16px, env(safe-area-inset-bottom)) + 56px);
  z-index: 30;
  max-width: min(320px, calc(100% - 32px));
  margin: 0;
  padding: 12px 16px;
  border: 1px solid rgba(44, 34, 51, 0.14);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 4px 16px rgba(44, 34, 51, 0.1);
  font-size: 14px;
  line-height: 1.4;
}

@keyframes rise {
  from { opacity: 0; transform: translateX(-50%) translateY(16px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  #endcard { animation: none; }
  .spinner { animation-duration: 2s; }
  .viewport-button { transition: none; }
}
