/* The web build's page (unity/Web/template): paper on the table, in the game's own palette (Theme.cs) —
   MenuPaper #726875 behind everything, Aubergine #2a1d2b outlines, Parchment #efe3cb card stock, Marigold #e29a26,
   AccentInk #9a550c. */
@font-face {
  font-family: "Fredoka Wego";
  src: url("FredokaWego-SemiBold.ttf") format("truetype");
  font-display: swap;
}
:root {
  /* MenuPaper, the plum-grey paper behind the title (ui-design-language "Surfaces"). The page and the canvas both wear
     it, so the hand-off from this page to the engine's first frame never flashes another colour (web audit F15). */
  --menu-paper: #726875;
  --paper-wash: radial-gradient(ellipse at 50% 40%, #7d7380 0%, var(--menu-paper) 55%, #655b68 100%) var(--menu-paper);
  --aubergine: #2a1d2b;
  --parchment: #efe3cb;
  --paper-white: #f6eede;
  --marigold: #e29a26;
  --accent-ink: #9a550c;
  --muted: #6c5560;
  --error: #c23b26;
  --on-table: #e9dcc8;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden;
  background: var(--paper-wash);
  color: var(--aubergine);
  font-family: "Fredoka Wego", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  /* A finger on the table never selects text, pops the long-press callout or zooms the page. */
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  overscroll-behavior: none; -webkit-text-size-adjust: 100%;
}
/* The canvas stays hidden until the engine runs: before its first frame a WebGL canvas shows whatever it was cleared
   to (Unity's default camera blue, F15), so the page's paper shows instead, and the canvas fades in over it. */
#unity-canvas {
  position: fixed; left: 0; top: 0; width: 100vw; height: 100vh; height: 100dvh;
  display: block; background: var(--paper-wash); outline: none;
  touch-action: none;
  opacity: 0; transition: opacity 0.4s ease;
}
body.engine #unity-canvas, body.playing #unity-canvas { opacity: 1; }
/* Buttons take a tap at once (no double-tap-to-zoom wait). */
.paper-button { touch-action: manipulation; }
/* The card scales with the screen (web audit F26): one font size, taken from the smaller of 0.9 % of the visible width
   and 1.6 % of its height (14 px on a phone held sideways, about 17 px at 1080p, 23 px on a 3440×1440 ultrawide, never
   above 30 px), and everything inside it — width, paddings, outlines, buttons, the bar, the notes — is sized in em
   from it, so the card keeps its proportions at every size instead of shrinking to a postage stamp. The vh terms
   still cap the vertical rhythm so the card fits a 360 px tall phone. */
.card {
  position: fixed; left: calc(var(--visible-left, 0px) + var(--visible-width, 100vw) / 2);
  top: calc(var(--visible-top, 0px) + var(--visible-height, 100dvh) / 2); transform: translate(-50%, -50%);
  font-size: clamp(14px, min(calc(var(--visible-width, 100vw) * 0.009), calc(var(--visible-height, 100vh) * 0.016)), 30px);
  width: min(34em, calc(var(--visible-width, 100vw) - 32px - env(safe-area-inset-left) - env(safe-area-inset-right))); max-height: calc(var(--visible-height, 100dvh) - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  padding: clamp(0.9em, 4vh, 1.8em) clamp(1.1em, 4vw, 2.2em);
  background: var(--parchment);
  border: max(4px, 0.3em) solid var(--aubergine); border-radius: 1.35em;
  box-shadow: 0 0.6em 0 rgba(28, 19, 29, 0.55), 0 1.3em 2.4em rgba(0, 0, 0, 0.35);
  display: flex; flex-direction: column; align-items: center; gap: clamp(0.6em, 2.4vh, 1.2em);
  text-align: center; transition: opacity 0.4s ease, transform 0.4s ease;
}
body.engine .card {
  top: auto; bottom: max(14px, env(safe-area-inset-bottom)); transform: translate(-50%, 0);
  width: min(28em, calc(var(--visible-width, 100vw) - 32px - env(safe-area-inset-left) - env(safe-area-inset-right))); padding: 0.6em 1.1em 0.7em; gap: 0.35em; border-width: max(3px, 0.24em);
}
body.engine .logo, body.engine .note { display: none; }
body.engine .stage { margin-top: 0.25em; }
body.playing .card { opacity: 0; transform: translate(-50%, 12px); pointer-events: none; }
.logo { width: 100%; height: auto; max-height: 34vh; object-fit: contain; }
.paper-button {
  font: inherit; font-size: 1.75em; letter-spacing: 0.02em;
  color: var(--aubergine); background: var(--marigold);
  border: max(3px, 0.14em) solid var(--aubergine); border-radius: 0.55em;
  padding: 0.33em 1.5em 0.4em; cursor: pointer;
  box-shadow: 0 0.2em 0 var(--aubergine);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.paper-button:hover { background: #eeaa3c; }
.paper-button:active { transform: translateY(0.14em); box-shadow: 0 0.06em 0 var(--aubergine); }
.paper-button:focus-visible { outline: max(3px, 0.14em) solid #3b76c4; outline-offset: max(3px, 0.14em); }
.loading { width: 100%; }
/* !important: .paper-button.secondary sets its own display, which kept "Play full screen" up under the loading bar. */
[hidden] { display: none !important; }
.bar {
  width: 100%; height: 1.55em; border: max(3px, 0.24em) solid var(--aubergine); border-radius: 0.8em;
  background: var(--paper-white); overflow: hidden;
}
.fill {
  height: 100%; width: 0%; background: var(--marigold);
  background-image: repeating-linear-gradient(-45deg, rgba(154, 85, 12, 0.18) 0 10px, transparent 10px 20px);
  border-right: max(2px, 0.18em) solid var(--aubergine); transition: width 0.25s ease;
}
.stage, .note { margin: 0.45em 0 0; font-size: 1.1em; color: var(--muted); }
.error { margin: 0; font-size: 1.05em; color: var(--error); }
.buttons { display: flex; flex-wrap: wrap; gap: 0.7em 0.85em; justify-content: center; align-items: center; }
.paper-button.secondary {
  font-size: 1.15em; padding: 0.4em 0.9em 0.5em; background: var(--paper-white);
  box-shadow: 0 0.25em 0 var(--aubergine); display: inline-flex; align-items: center; gap: 0.5em;
}
.paper-button.secondary:hover { background: #fff8ea; }
.full-glyph {
  width: 0.8em; height: 0.8em; border: max(2px, 0.15em) solid var(--aubergine); border-radius: 0.15em; display: inline-block;
  border-style: solid dashed;
}
.rotate { display: none; }
body:not(.playing):not(.engine) .rotate { pointer-events: none; }
/* Keep the installation hint visible on the start card while upright; rotate advice follows Play. */
body:not(.playing):not(.engine) .rotate { display: none; }
/* A phone held upright: the table is landscape, so ask for it sideways (the card stays readable underneath). */
@media (orientation: portrait) and (max-width: 820px) {
  .rotate {
    display: flex; position: fixed; left: var(--visible-left, 0px); top: var(--visible-top, 0px);
    width: var(--visible-width, 100vw); height: var(--visible-height, 100dvh); z-index: 10; align-items: center; justify-content: center;
    background: rgba(42, 29, 43, 0.78);
    padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  }
  .rotate-card {
    width: min(320px, calc(var(--visible-width, 100vw) - 32px - env(safe-area-inset-left) - env(safe-area-inset-right))); padding: 24px 20px; text-align: center;
    background: var(--parchment); border: 5px solid var(--aubergine); border-radius: 22px;
    box-shadow: 0 8px 0 rgba(28, 19, 29, 0.55);
  }
  .rotate-card p { margin: 16px 0 0; font-size: 20px; line-height: 1.3; }
  .phone {
    width: 46px; height: 78px; margin: 4px auto 0; border: 5px solid var(--aubergine); border-radius: 10px;
    background: var(--paper-white); position: relative; animation: turn 2.4s ease-in-out infinite;
  }
  .phone::after {
    content: ""; position: absolute; left: 50%; bottom: 5px; width: 10px; height: 4px; margin-left: -5px;
    border-radius: 2px; background: var(--aubergine);
  }
  @keyframes turn { 0%, 30% { transform: rotate(0deg); } 60%, 100% { transform: rotate(-90deg); } }
  @media (prefers-reduced-motion: reduce) { .phone { animation: none; transform: rotate(-90deg); } }
}
/* Reduced motion: the card steps down and lifts, and the canvas appears, at once — no fades, slides or bar easing. */
@media (prefers-reduced-motion: reduce) {
  .card, #unity-canvas, .fill, .paper-button { transition: none; }
}
