/* The page around the game: a header and the game in a framed 16:9 box. */
:root {
  --bg: #E9ECFA;
  --ink: #26307A;
  --action: #4F45E6;
  --frame: #26307A;
  --frame-light: #4F45E6;
  --bar-h: 80px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); overflow: hidden; }
body {
  display: flex; flex-direction: column;
  font-family: system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  /* A tunnel's depth: light at its mouth around the game, rings fading outward. */
  background:
    repeating-radial-gradient(ellipse at 50% 52%, rgba(79, 69, 230, 0) 0 46px, rgba(79, 69, 230, 0.045) 47px 48px),
    radial-gradient(ellipse at 50% 52%, #FFFFFF 0%, var(--bg) 42%, #CBD1F2 100%);
}
.bar, .stage-wrap { position: relative; z-index: 1; }

/* Cards on the walls of the tunnel, in perspective toward the game's frame. */
.tunnel {
  position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none;
  perspective: 760px; perspective-origin: 50% 52%;
}
.tc {
  position: absolute; width: clamp(64px, 7vw, 136px);
  transform-style: preserve-3d;
  transform: translate(-50%, -50%) translateZ(var(--z)) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) rotateZ(var(--rz, 0deg));
}
.tc img {
  display: block; width: 100%; height: auto;
  filter: drop-shadow(0 14px 18px rgba(38, 48, 122, 0.25));
  animation: fawra-drift var(--t, 9s) ease-in-out infinite alternate;
  animation-delay: var(--d, 0s);
}
.tc.near { --z: 60px; }
.tc.mid { --z: -260px; opacity: 0.85; }
.tc.mid img { filter: blur(1px) drop-shadow(0 10px 14px rgba(38, 48, 122, 0.2)); }
.tc.far { --z: -620px; opacity: 0.55; }
.tc.far img { filter: blur(2.5px); }
/* Walls: left cards face right, right ones face left, top ones face down, bottom ones up.
   Each card is placed in depth so it lands in the margin around the frame (never behind it)
   and clear of the round buttons; positions were worked out from where it should land. */
.tc1 { left: 7.6%; top: 63.1%; --ry: 52deg; --rz: -16deg; --t: 8s; }
.tc2 { left: 92.4%; top: 37.3%; --ry: -52deg; --rz: 14deg; --t: 10s; --d: -3s; }
.tc3 { left: 9.5%; top: 91.6%; --rx: 48deg; --rz: 22deg; --t: 11s; --d: -5s; }
.tc4 { left: 91.4%; top: 89.8%; --rx: 46deg; --ry: -30deg; --rz: -12deg; --t: 9s; --d: -2s; }
.tc5 { left: 32.5%; top: 8.7%; --rx: -54deg; --rz: 28deg; --t: 12s; --d: -6s; }
.tc6 { left: 68.4%; top: 7.8%; --rx: -50deg; --rz: -24deg; --t: 10s; --d: -1s; }
.tc7 { left: -11.7%; top: 33.2%; --ry: 64deg; --rz: 8deg; --t: 13s; }
.tc8 { left: 113.1%; top: 70.8%; --ry: -64deg; --rz: 36deg; --t: 12s; --d: -4s; }
.tc9 { left: 43.3%; top: 112.4%; --rx: 58deg; --rz: -18deg; --t: 14s; --d: -7s; }
.tc10 { left: 58.1%; top: -11.1%; --rx: -58deg; --rz: 12deg; --t: 11s; --d: -2s; }
.tc11 { left: -17.2%; top: -31.5%; --rx: -40deg; --ry: 40deg; --rz: -30deg; --t: 15s; }
.tc12 { left: 122.6%; top: -26.1%; --rx: -40deg; --ry: -40deg; --rz: 20deg; --t: 14s; --d: -5s; }
.tc13 { left: -9.9%; top: 131.9%; --rx: 50deg; --ry: 30deg; --rz: 40deg; --t: 16s; --d: -8s; }
.tc14 { left: 111.7%; top: 133.7%; --rx: 50deg; --ry: -30deg; --rz: -36deg; --t: 13s; --d: -3s; }
@keyframes fawra-drift {
  from { transform: translate3d(0, 0, 0) rotate(0deg); }
  to { transform: translate3d(0, -12px, 40px) rotate(4deg); }
}
@media (prefers-reduced-motion: reduce) { .tc img { animation: none; } }
/* Expanded or on a phone: the game covers everything, no tunnel to draw. */
.expanded .tunnel { display: none; }

.bar {
  height: var(--bar-h); flex: none;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
}
/* Big enough to read as the brand on a computer screen (owner, 2026-11-23). */
.brand img { height: 68px; width: auto; display: block; }
.expand {
  font: inherit; font-size: 14px; font-weight: 700; color: #fff;
  background: var(--action); border: 0; border-radius: 999px;
  padding: 9px 18px; cursor: pointer;
  box-shadow: 0 4px 14px rgba(79, 69, 230, 0.3);
}
.expand:hover { filter: brightness(1.08); }
.expand:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.controls { position: relative; }
/* Under the full-screen button: a column of round buttons beside the frame. */
.tools {
  position: absolute; top: calc(100% + 12px); left: 0;
  display: flex; flex-direction: column; gap: 10px; z-index: 5;
}
.tool {
  width: 44px; height: 44px; border-radius: 50%; padding: 0;
  display: grid; place-items: center; cursor: pointer;
  background: #fff; color: var(--action);
  border: 1.5px solid rgba(79, 69, 230, 0.25);
  box-shadow: 0 4px 12px rgba(38, 48, 122, 0.12);
}
.tool svg { width: 22px; height: 22px; fill: currentColor; }
.tool svg path[fill="none"] { fill: none; }
.tool .off { display: none; }
.tool[aria-pressed="false"] { color: #8C8FB0; background: #F1F2FA; }
.tool[aria-pressed="false"] .on { display: none; }
.tool[aria-pressed="false"] .off { display: block; }
.tool:hover:not(:disabled) { border-color: var(--action); }
.tool:focus-visible { outline: 3px solid var(--action); outline-offset: 2px; }
.tool:disabled { opacity: 0.45; cursor: default; }
/* Expanded: the same buttons sit in the header beside the shrink button. */
.expanded .controls { display: flex; align-items: center; gap: 10px; }
.expanded .tools { position: static; flex-direction: row; }
.expanded .tool { width: 38px; height: 38px; }
.expand .when-big { display: none; }
.expanded .expand .when-small { display: none; }
.expanded .expand .when-big { display: inline; }

.stage-wrap {
  flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  /* The left lane keeps the round buttons clear of the frame. */
  padding: 0 16px 20px 76px;
}
/* As wide as the window allows (the game is wide, like a phone on its side),
   up to 1600 px; the height stays as it was: the game at most 720 px tall. */
.stage {
  --rim: 20px;   /* the bezel's width, to the screen */
  position: relative;
  width: min(1600px, 100%);
  height: min(100%, 760px);
  border-radius: 32px;
  /* The bezel: lit from above, a sheen across its top, darker toward the bottom. */
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16) 0%, rgba(255, 255, 255, 0) 9%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.035) 0 2px, rgba(255, 255, 255, 0) 2px 7px),
    linear-gradient(165deg, #4A42D4 0%, #2E2B9A 30%, #1F2373 62%, #13164A 100%);
  box-shadow:
    inset 0 1.5px 0 rgba(255, 255, 255, 0.55),        /* bevel: light on the top edge */
    inset 0 -3px 0 rgba(8, 10, 40, 0.55),             /* bevel: the bottom edge in shade */
    inset 1.5px 0 0 rgba(255, 255, 255, 0.12), inset -1.5px 0 0 rgba(0, 0, 0, 0.18),
    0 0 0 1px #0E1140,                                 /* a crisp outer edge */
    0 2px 0 #10133F,                                   /* the frame's thickness under it */
    0 6px 0 rgba(16, 19, 63, 0.55),
    0 28px 60px -12px rgba(23, 27, 85, 0.6),           /* lifted off the page */
    0 0 90px rgba(106, 97, 245, 0.32);                 /* a soft glow around it */
}
/* A thin gold trim just inside the bezel, like the gold edges of the cards. */
.stage::before {
  content: ""; position: absolute; inset: calc(var(--rim) - 6px);
  border-radius: 23px; padding: 2px; pointer-events: none; z-index: 1;
  background: linear-gradient(135deg, #FBE9AE 0%, #C9973A 22%, #FFF3C9 48%, #B07C25 74%, #F2D489 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  box-shadow: 0 0 10px rgba(242, 212, 137, 0.35);
}
/* The screen sits a little sunk into the bezel. */
.stage::after {
  content: ""; position: absolute; inset: var(--rim);
  border-radius: 18px; pointer-events: none; z-index: 3;
  box-shadow:
    inset 0 0 0 1px rgba(10, 12, 45, 0.55),
    inset 0 7px 16px -6px rgba(10, 12, 45, 0.45),
    inset 0 -4px 12px -6px rgba(10, 12, 45, 0.3);
}
/* Gold studs set into the middle of the top and bottom edges. */
.stud {
  position: absolute; left: 50%; width: 12px; height: 12px; z-index: 4; pointer-events: none;
  transform: translate(-50%, -50%) rotate(45deg); border-radius: 2px;
  background: linear-gradient(135deg, #FFF3C9, #D4A64A 55%, #9A6B1E);
  box-shadow: 0 0 0 1.5px #171B55, 0 0 10px rgba(242, 212, 137, 0.6);
}
.stud-top { top: calc(var(--rim) / 2 - 2px); }
.stud-bottom { top: calc(100% - var(--rim) / 2 + 1px); }
.stud-left, .stud-right { top: 50%; width: 9px; height: 9px; }
.stud-left { left: calc(var(--rim) / 2); }
.stud-right { left: calc(100% - var(--rim) / 2); }
#game {
  position: absolute; inset: var(--rim);
  border-radius: 18px; overflow: hidden;
  background: var(--bg);
}

/* Expanded: the frame grows with the game to fill everything under the header
   bar, which keeps the shrink button (owner, 2026-11-23: the frame stays, so
   nothing runs off the screen's edge). */
.expanded .stage-wrap { padding: 0 12px 12px; }
.expanded .stage { width: 100%; height: 100%; }

/* A phone's browser: no room for a frame, the game fills the screen. */
@media (max-width: 820px), (max-height: 480px) {
  .bar, .tunnel { display: none; }
  .stage-wrap { padding: 0; }
  .stage { position: fixed; inset: 0; width: auto; height: auto; border-radius: 0; padding: 0; box-shadow: none; }
  #game, #fawra-loading { inset: 0; border-radius: 0; }
  .stage::before, .stage::after, .stud { display: none; }
}

/* Shown while the game downloads; removed on its first frame. */
#fawra-loading {
  position: absolute; inset: var(--rim); border-radius: 18px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: var(--bg); transition: opacity 250ms ease-out; z-index: 2;
}
#fawra-loading img { width: min(200px, 30%); height: auto; }
#fawra-loading p { margin: 0; color: var(--ink); font-size: 14px; }
.bar-load {
  width: min(180px, 30%); height: 6px; border-radius: 3px;
  background: rgba(79, 69, 230, 0.15); overflow: hidden;
}
.bar-load::after {
  content: ""; display: block; width: 40%; height: 100%; border-radius: 3px;
  background: var(--action); animation: fawra-slide 1.1s ease-in-out infinite;
}
@keyframes fawra-slide { 0% { transform: translateX(160%); } 100% { transform: translateX(-260%); } }
@media (prefers-reduced-motion: reduce) { .bar-load::after { animation: none; width: 100%; } }

/* Phone mode (a phone's browser, after its one tap): the game fills the phone on its side.
   Held upright, the game is turned a quarter turn to lie along the phone (iPhone Safari cannot
   lock the screen to landscape); held sideways, or locked by the browser, it just fills it. */
.phone-gate {
  position: fixed; inset: 0; z-index: 20; overflow-y: auto;
  display: grid; place-items: center; padding: 24px;
  background: rgba(233, 236, 250, 0.82);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.phone-gate[hidden] { display: none; }
.gate-card {
  width: min(340px, 100%); padding: 28px 24px 22px; border-radius: 28px; text-align: center;
  background: linear-gradient(165deg, #4A42D4 0%, #2E2B9A 40%, #1F2373 100%);
  box-shadow: inset 0 1.5px 0 rgba(255, 255, 255, 0.5), 0 0 0 1px #0E1140, 0 6px 0 #10133F,
    0 28px 60px -12px rgba(23, 27, 85, 0.6);
}
.gate-card img { width: 150px; height: auto; display: block; margin: 0 auto 20px; }
.gate-card p { margin: 16px 0 0; color: rgba(255, 255, 255, 0.82); font-size: 14px; line-height: 1.6; }
.gate-btn {
  width: 100%; min-height: 56px; border: 0; border-radius: 999px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font: inherit; font-size: 18px; font-weight: 800; color: #2B2296;
  background: linear-gradient(180deg, #FFFFFF, #E3E8F8);
  box-shadow: inset 0 1.5px 0 #fff, 0 4px 0 #9CA6D6, 0 10px 24px rgba(255, 255, 255, 0.25);
}
.gate-btn:active { transform: translateY(3px); box-shadow: inset 0 1.5px 0 #fff, 0 1px 0 #9CA6D6; }
.gate-btn svg { width: 26px; height: 26px; fill: currentColor; }
.gate-btn:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.gate-settings { display: grid; gap: 10px; margin: 0 0 16px; }
/* A phone on its side: a shorter card, the two switches side by side. */
@media (max-height: 500px) {
  .gate-card { width: min(520px, 100%); padding: 14px 20px 12px; }
  .gate-card img { width: 96px; margin-bottom: 10px; }
  .gate-settings { grid-template-columns: 1fr 1fr; margin-bottom: 12px; }
  .gate-card p { margin-top: 10px; font-size: 13px; }
}
.gate-toggle {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 48px; padding: 0 16px; border-radius: 14px; cursor: pointer;
  font: inherit; font-size: 16px; font-weight: 700; color: #fff;
  background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.22);
}
.gate-toggle .knob {
  position: relative; width: 46px; height: 26px; border-radius: 13px; flex: none;
  background: rgba(255, 255, 255, 0.25); transition: background-color .2s ease;
}
.gate-toggle .knob::after {
  content: ""; position: absolute; top: 3px; inset-inline-end: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; transition: inset-inline-end .2s ease;
}
.gate-toggle[aria-pressed="true"] .knob { background: #5BD08A; }
.gate-toggle[aria-pressed="false"] .knob::after { inset-inline-end: 23px; }
.gate-toggle:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

/* The page itself never scrolls or bounces under the game. */
html:has(body.phone), body.phone { overscroll-behavior: none; }
body.phone { position: fixed; inset: 0; overflow: hidden; }
body.phone .bar, body.phone .tunnel { display: none; }
body.phone .stage-wrap { padding: 0; }
body.phone .stage {
  position: fixed; left: 0; top: 0; right: auto; bottom: auto;
  width: 100vw; height: 100vh; width: 100dvw; height: 100dvh;
  border-radius: 0; box-shadow: none; background: var(--bg);
}
body.phone #game, body.phone #fawra-loading { inset: 0; border-radius: 0; }
body.phone .stage::before, body.phone .stage::after, body.phone .stud { display: none; }
@media (orientation: portrait) {
  body.phone .stage {
    width: 100vh; height: 100vw; width: 100dvh; height: 100dvw;
    transform-origin: top left;
    transform: translateX(100vw) rotate(90deg);
    transform: translateX(100dvw) rotate(90deg);
  }
}


/* Quick double taps never zoom the page (iPhone). */
html, body, .stage, #game { touch-action: manipulation; }

/* The loading screen when the game did not start in time (fawra_page.js). */
#fawra-loading.stuck .bar-load { display: none; }
#fawra-loading.stuck p { max-width: 34ch; text-align: center; line-height: 1.6; }
#fawra-loading .reload { font-size: 16px; padding: 10px 22px; }

/* Opened inside another app's browser: a strip that points to the real browser. */
.in-app {
  position: fixed; inset: 0 0 auto 0; z-index: 50;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: #26307A; color: #fff; font-size: 14px; line-height: 1.5;
}
.in-app[hidden] { display: none; }
.in-app p { margin: 0; flex: 1 1 220px; }
.in-app-btn { border: 0; border-radius: 999px; padding: 8px 16px; background: #fff; color: #26307A; font: inherit; font-weight: 700; }
.in-app-close { border: 0; background: none; color: #fff; font-size: 22px; line-height: 1; padding: 4px 8px; }
