/* ================= RTX ON =================
   Photoreal tiles, volumetric fog, god rays, chrome. For a grid of squares.
   Everything is scoped to body.rtx and toggled by js/rtx.js. */

body.rtx {
  background: #020504 url("../images/rtx/hall.webp") center / cover no-repeat fixed;
}

/* Fog, god rays and grain sit behind the game, above the backdrop. */
body.rtx::before,
body.rtx::after {
  content: "";
  position: fixed;
  inset: -10%;
  pointer-events: none;
  z-index: 0;
}

body.rtx::before {
  background:
    radial-gradient(60% 40% at 30% 70%, rgba(47, 224, 122, 0.16), transparent 70%),
    radial-gradient(50% 35% at 75% 30%, rgba(160, 255, 210, 0.10), transparent 70%),
    repeating-linear-gradient(115deg, transparent 0 60px, rgba(120, 255, 180, 0.05) 60px 140px, transparent 140px 260px);
  filter: blur(18px);
  animation: rtx-fog 18s ease-in-out infinite alternate;
}

body.rtx::after {
  inset: 0;
  opacity: 0.09;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  animation: rtx-grain 0.5s steps(3) infinite;
}

@keyframes rtx-fog {
  from { transform: translate3d(-3%, 1%, 0) scale(1); }
  to { transform: translate3d(3%, -2%, 0) scale(1.08); }
}

@keyframes rtx-grain {
  33% { transform: translate(-8px, 5px); }
  66% { transform: translate(6px, -7px); }
}

/* ---------- The game window: titanium + carbon, chrome bevel, green rim light ---------- */

body.rtx .game {
  background: #15191b url("../images/rtx/panel.webp") center / 256px;
  border-color: #d9e4e8 #3a4448 #2a3236 #c7d3d8;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08),
    0 30px 80px rgba(0, 0, 0, 0.75),
    0 0 60px rgba(47, 224, 122, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

body.rtx .game-frame {
  transform: perspective(1400px) rotateX(5deg);
  transform-origin: 50% 100%;
}

body.rtx .header,
body.rtx .board-wrap {
  border-color: #0b0e0f #4b585d #5c6a70 #0b0e0f;
  background: rgba(0, 0, 0, 0.35);
}

body.rtx .lcd {
  box-shadow: 0 0 14px rgba(255, 40, 40, 0.45), inset 0 0 8px rgba(0, 0, 0, 0.8);
}

body.rtx .lcd .on {
  filter: drop-shadow(0 0 2px #ff2a2a) drop-shadow(0 0 6px rgba(255, 0, 0, 0.7));
}

body.rtx .face {
  background: linear-gradient(145deg, #e9eef0, #8d989c);
  border-color: #fff #4b5559 #4b5559 #fff;
  box-shadow: 0 0 14px rgba(255, 230, 80, 0.35);
}

/* ---------- Tiles ---------- */

body.rtx .cell {
  background: #9aa3a6 url("../images/rtx/tile.webp") center / 100% 100% no-repeat;
  border-color: transparent;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

body.rtx .cell.pressed {
  filter: brightness(0.7);
}

body.rtx .cell.open {
  background: #1b2022 url("../images/rtx/open.webp") center / 100% 100% no-repeat;
  border-color: transparent;
  box-shadow: inset 0 0 calc(var(--u) * 3) rgba(0, 0, 0, 0.8);
}

/* Neon, slightly bloomed numbers that read on dark metal. */
body.rtx .cell.open svg path { transition: fill 0.2s; }
body.rtx .cell.n1 svg path { fill: #4fa8ff; }
body.rtx .cell.n2 svg path { fill: #3dff8e; }
body.rtx .cell.n3 svg path { fill: #ff4d5e; }
body.rtx .cell.n4 svg path { fill: #b77dff; }
body.rtx .cell.n5 svg path { fill: #ffae3d; }
body.rtx .cell.n6 svg path { fill: #3dfff2; }
body.rtx .cell.n7 svg path { fill: #ffffff; }
body.rtx .cell.n8 svg path { fill: #c8c8c8; }
body.rtx .cell.open:is(.n1, .n2, .n3, .n4, .n5, .n6, .n7, .n8) svg {
  filter: drop-shadow(0 0 calc(var(--u) * 1.2) currentColor) drop-shadow(0 0 calc(var(--u) * 3) rgba(255, 255, 255, 0.25));
}
body.rtx .cell.n1 { color: #4fa8ff; }
body.rtx .cell.n2 { color: #3dff8e; }
body.rtx .cell.n3 { color: #ff4d5e; }
body.rtx .cell.n4 { color: #b77dff; }
body.rtx .cell.n5 { color: #ffae3d; }
body.rtx .cell.n6 { color: #3dfff2; }

/* Ray-traced silk flag and a real Persian rug instead of pixel art. */
body.rtx .cell.flagged svg,
body.rtx .cell.rug svg {
  opacity: 0;
}

body.rtx .cell.flagged::after,
body.rtx .cell.rug::after {
  content: "";
  position: absolute;
  inset: 4%;
  background: center / contain no-repeat;
  pointer-events: none;
}

body.rtx .cell.flagged::after {
  background-image: url("../images/rtx/flag.png");
  filter: drop-shadow(0 calc(var(--u) * 1) calc(var(--u) * 1.5) rgba(0, 0, 0, 0.6));
  animation: rtx-flag 2.4s ease-in-out infinite;
  transform-origin: 30% 90%;
}

body.rtx .cell.rug::after {
  background-image: url("../images/rtx/rug.png");
  filter: drop-shadow(0 calc(var(--u) * 1) calc(var(--u) * 2) rgba(0, 0, 0, 0.7));
}

body.rtx .cell.hit {
  background-color: #400;
  box-shadow: inset 0 0 calc(var(--u) * 8) rgba(255, 30, 30, 0.9), 0 0 calc(var(--u) * 8) rgba(255, 30, 30, 0.7);
}

@keyframes rtx-flag {
  50% { transform: rotate(-3deg) scale(1.02); }
}

/* ---------- The overlay: proof that the GPU is suffering ----------
   Gameplay only, on wide screens, top-right under the RTX switch. Never over a panel or
   the board: hidden in the hub, post-match, credits, desktop, boot screens, chapter cards
   and in-game popups (store, HODL QTE). */

.rtx-osd {
  position: fixed;
  top: calc(max(12px, env(safe-area-inset-top)) + 46px);
  right: max(14px, env(safe-area-inset-right));
  z-index: 16;
  display: none;
  font-family: "Oswald", "Arial Narrow", sans-serif;
  text-align: right;
  pointer-events: none;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.9);
}

@media (min-width: 980px) {
  body.rtx.market-on .rtx-osd { display: block; }
  body.rtx:has(.hub:not([hidden])) .rtx-osd,
  body.rtx:has(.pm:not([hidden])) .rtx-osd,
  body.rtx:has(.credits:not([hidden])) .rtx-osd,
  body.rtx:has(.desktop:not([hidden])) .rtx-osd,
  body.rtx:has(.patch:not([hidden])) .rtx-osd,
  body.rtx:has(.logo-sequence:not([hidden])) .rtx-osd,
  body.rtx:has(.ccard:not([hidden])) .rtx-osd,
  body.rtx:has(.store:not([hidden])) .rtx-osd,
  body.rtx:has(.qte:not([hidden])) .rtx-osd,
  body.rtx.paused .rtx-osd { display: none; }
}

.rtx-badge {
  display: inline-block;
  padding: 2px 10px 3px;
  font-family: "Archivo Black", "Arial Black", sans-serif;
  font-size: 20px;
  letter-spacing: 0.04em;
  color: #0b0f0c;
  background: linear-gradient(90deg, #76ff03, #2fe07a);
  transform: skewX(-12deg);
  box-shadow: 0 0 22px rgba(118, 255, 3, 0.55);
}

.rtx-stats {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.35;
  color: #c9ffd9;
  letter-spacing: 0.06em;
}

.rtx-stats b { color: #ff4d5e; font-weight: 700; }

/* Hub background board gets the same treatment. */
body.rtx .hub .cell {
  background-image: url("../images/rtx/tile.webp");
  background-size: 100% 100%;
  border-color: transparent;
}

body.rtx .hub .cell.open {
  background-image: url("../images/rtx/open.webp");
}

@media (prefers-reduced-motion: reduce) {
  body.rtx::before,
  body.rtx::after,
  body.rtx .cell.flagged::after { animation: none; }
}

/* ---------- The switch itself: one control, reachable everywhere ----------
   Floats top-right (above the hub, post-match, credits and chapter cards; below toasts),
   sits above the taskbar on the Win95 desktop, bottom-left during play on narrow screens
   (the market strip owns the top there). In the hub, js/hub.js docks this same button in
   its top bar, or in the open panel's header (.docked). */

.rtx-toggle {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 48;
  min-height: 30px;
  padding: 6px 12px 7px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 3px;
  background: rgba(10, 14, 16, 0.8);
  color: #b4beb9;
  font-family: "Archivo Black", "Arial Black", sans-serif;
  font-size: 13px;
  line-height: 1.2;
  letter-spacing: 0.06em;
  white-space: nowrap;
  cursor: pointer;
  transform: skewX(-10deg);
  touch-action: manipulation;
  transition: color 0.2s, background 0.2s, box-shadow 0.2s;
}

.rtx-toggle:hover { color: #fff; }
.rtx-toggle:focus-visible { outline: 2px solid #ffd21a; outline-offset: 2px; }

.rtx-toggle.is-on {
  color: #0b0f0c;
  background: linear-gradient(90deg, #76ff03, #2fe07a);
  border-color: transparent;
  box-shadow: 0 0 18px rgba(118, 255, 3, 0.5);
}

body:has(.desktop:not([hidden])) .rtx-toggle:not(.docked) {
  top: auto;
  bottom: calc(env(safe-area-inset-bottom) + 52px);
}

.rtx-toggle.docked {
  position: relative;
  top: auto;
  right: auto;
  bottom: auto;
  left: auto;
  z-index: auto;
  flex: none;
  font-size: 12px;
}

.rtx-flash {
  position: fixed;
  inset: 0;
  z-index: 70;
  pointer-events: none;
  background: radial-gradient(circle at 50% 50%, #eaffef, rgba(118, 255, 3, 0.6) 40%, transparent 75%);
  animation: rtx-flash 0.7s ease-out forwards;
}

@keyframes rtx-flash {
  from { opacity: 1; }
  to { opacity: 0; }
}

@media (max-width: 979px) {
  .rtx-toggle { min-height: 28px; padding: 5px 10px; font-size: 11px; }
  body.market-on:not(:has(.pm:not([hidden]))):not(:has(.credits:not([hidden]))) .rtx-toggle:not(.docked) {
    top: auto;
    right: auto;
    bottom: max(12px, env(safe-area-inset-bottom));
    left: max(12px, env(safe-area-inset-left));
  }
}
