/* ==========================================================================
   layout.css — the design stage

   SCALING MODEL
   -------------
   Everything is authored on a fixed 720 x 1332 design stage, taken straight
   off the reference artwork. main.js sets

       --s = min(viewportWidth / 720, viewportHeight / 1332)

   and scales #app by it. Consequences:

     · every component keeps its exact designed size and position, on every
       phone — the layout has no reflow path, so it cannot overflow
     · the wheel is always 82.8% of the stage width, the board always 63.1%,
       exactly as in the reference
     · on taller devices the design stage simply grows below 1332 and the
       extra room becomes felt: the header stays pinned to the top, the board
       and controls stay pinned to the bottom, and the wheel centres in the
       space between them

   Every length in this file is a DESIGN pixel, not a device pixel.
   ========================================================================== */

#viewport{
  position:fixed;inset:0;overflow:hidden;
  background:
    radial-gradient(112% 58% at 50% 34%, var(--felt-hi) 0%, var(--felt-mid) 44%, var(--felt-lo) 76%, var(--felt-edge) 100%),
    var(--felt-lo);
}
/* Felt weave. Plain alpha, no mix-blend-mode: blending forces an extra
   full-viewport compositing pass every time the wheel canvas repaints. */
#viewport::after{
  content:"";position:absolute;inset:0;pointer-events:none;z-index:1;
  background-image:radial-gradient(rgba(0,0,0,.10) 1px, transparent 1.2px);
  background-size:6px 6px;
}

#app{
  position:absolute;left:50%;top:0;
  width:720px;margin-left:-360px;
  height:1332px;                      /* overwritten by main.js */
  transform-origin:top center;
  transform:scale(var(--s,.5));
  z-index:2;
}

/* ---------------------------- UPPER HUD ---------------------------------- */
#topHud{
  position:absolute;left:18px;right:18px;top:16px;height:84px;
  display:flex;align-items:center;justify-content:space-between;gap:12px;
  z-index:20;
}

#topBalCard{
  display:flex;flex-direction:column;justify-content:center;
  min-width:214px;height:78px;padding:0 18px;
  border-radius:16px;
  background:linear-gradient(180deg, rgba(16,46,32,.95), rgba(4,18,12,.99));
  border:2.5px solid rgba(246,207,110,.7);
  box-shadow:0 6px 14px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.3), 0 0 16px rgba(246,207,110,.18);
  user-select:none;
}
.topHudLbl{
  font-size:12px;font-weight:900;letter-spacing:.1em;
  color:var(--gold);text-transform:uppercase;line-height:1;margin-bottom:4px;
  text-shadow:0 1px 2px rgba(0,0,0,.8);
}
.topHudVal{
  font-family:var(--font-board);font-size:27px;font-weight:900;
  color:#ffffff;letter-spacing:.02em;line-height:1;
  text-shadow:0 2px 5px rgba(0,0,0,.8), 0 0 8px rgba(255,255,255,.2);
}

#hist{
  flex:1;height:56px;
  display:flex;align-items:center;gap:8px;
  padding:0 10px;overflow:hidden;
  border-radius:12px;
  background:rgba(0,0,0,.82);
  border:2px solid rgba(255,255,255,.18);
  box-shadow:inset 0 4px 9px rgba(0,0,0,.8);
}
.hchip{
  flex:0 0 auto;width:38px;height:38px;border-radius:8px;
  display:grid;place-items:center;
  font-size:19px;font-weight:900;color:#fff;
  border:1px solid rgba(255,255,255,.25);
  box-shadow:inset 0 -3px 4px rgba(0,0,0,.6), 0 2px 6px rgba(0,0,0,.4);
  animation:histIn .3s var(--ease-pop);
}
@keyframes histIn{from{transform:scale(.3);opacity:0}to{transform:scale(1);opacity:1}}
.c-red{background:linear-gradient(180deg,#e23a46,var(--ruby-lo));}
.c-black{background:linear-gradient(180deg,#333a41,#0a0d10);}
.c-green{background:linear-gradient(180deg,#2fbe78,#046b3f);}

#topActions{
  display:flex;align-items:center;gap:10px;
}

.topHudBtn{
  height:78px;width:78px;min-width:78px;padding:0;
  border-radius:18px;
  display:grid;place-items:center;
  border:2.5px solid rgba(255,255,255,.32);
  background:linear-gradient(180deg, rgba(52,156,108,.82), rgba(6,72,44,.95));
  background-color:#0b663b;
  box-shadow:0 5px 0 rgba(3,44,26,.9), 0 10px 20px rgba(0,0,0,.45), inset 0 2px 0 rgba(255,255,255,.35);
  cursor:pointer;
  transition:transform .12s ease, filter .15s ease, background .2s ease, border-color .2s ease;
  user-select:none;
}
.topHudBtn i, .topHudBtn svg{
  display:grid;place-items:center;
  width:32px;height:32px;stroke-width:2.3;
}
.topHudBtn svg{width:32px;height:32px;}
.topHudBtn:active{
  transform:translateY(4px);
  filter:brightness(1.2);
  box-shadow:0 1px 0 rgba(3,44,26,.9);
}
.topHudBtn.muted{
  background:linear-gradient(180deg, rgba(175,48,58,.85), rgba(88,14,22,.98));
  background-color:#7a1a24;
  border-color:rgba(255,180,190,.6);
  box-shadow:0 5px 0 rgba(48,6,12,.9), 0 10px 20px rgba(0,0,0,.45), inset 0 2px 0 rgba(255,255,255,.35);
  color:#ffe6e6;
}

/* --------------------------- WHEEL STAGE -------------------------------- */
/* Spans the gap between the upper HUD and the bottom cluster; the wheel is a
   fixed 596 design px and simply centres in whatever room that leaves. */
#wheelStage{
  position:absolute;left:0;right:0;top:108px;bottom:528px;
  display:grid;place-items:center;
  transform-origin:50% 50%;
  transition:transform var(--dur-cam) var(--ease-cam);
  will-change:transform;
}
#wheelBox{position:relative;line-height:0;}
/* No CSS filter here on purpose. filter:drop-shadow() on a canvas is
   re-evaluated on EVERY frame because the canvas content changes, which was
   costing more than the wheel draw itself. The shadow is baked into the
   cached bitmap instead (see wheel.js). */
/* Three stacked pieces, all centred on the same point:
     #wheelShadow  a plain div carrying the drop shadow. It is STATIC — a
                   directional shadow baked into the rotating bitmap orbits
                   with it, which is what made the spinning disc look
                   lopsided. As a DOM element it is composited once.
     #wheelStatic  the bowl, rim, deflectors and ball track. Painted once.
     #wheelCv      the rotor and the ball. Redrawn every frame.

   The canvas box is 5% larger than the 596px wheel so the antialiased outer
   edge is never clipped flat at the bitmap boundary — flat chords at the
   edge stop a rotating disc from reading as circular. The extra is
   transparent. Sizes are set by main.js; these are pre-layout defaults. */
#wheelBox > *{
  position:absolute;left:50%;top:50%;
  transform:translate(-50%,-50%);
}
#wheelShadow{
  width:596px;height:596px;border-radius:50%;
  background:#2c1409;
  box-shadow:0 24px 38px rgba(0,0,0,.5), 0 6px 14px rgba(0,0,0,.4);
  z-index:0;
}
#wheelStatic{display:block;width:626px;height:626px;z-index:1;}
#wheelCv{
  display:block;width:626px;height:626px;z-index:2;
  backface-visibility:hidden;
}
/* #wheelBox must still take up the canvas box, so one child stays in flow */
#wheelBox{width:626px;height:626px;}

/* The winning-number disc. Hidden until a result lands, so the metal turret
   cross painted on the rotor shows through — that is the wheel's resting
   state in the reference. 130px = 0.217R, measured off the reference. */
#hub{
  position:absolute;left:50%;top:50%;z-index:3;
  width:130px;height:130px;
  transform:translate(-50%,-50%) scale(.4);
  border-radius:50%;
  display:grid;place-items:center;
  pointer-events:none;
  opacity:0;visibility:hidden;
  background:radial-gradient(62% 62% at 34% 26%, #6a747d 0%, #262c33 52%, #0c1014 100%);
  border:3px solid rgba(255,255,255,.22);
  box-shadow:
    inset 0 3px 9px rgba(255,255,255,.3),
    inset 0 -11px 20px rgba(0,0,0,.75),
    0 6px 14px rgba(0,0,0,.55);
  transition:opacity .25s ease, transform .35s var(--ease-pop), visibility .25s;
}
#hub.on{
  opacity:1;visibility:visible;
  transform:translate(-50%,-50%) scale(1);
}
#hubNum{
  font-family:var(--font-board);font-weight:700;line-height:1;
  font-size:64px;color:var(--cream);
  text-shadow:0 3px 6px rgba(0,0,0,.85);
  transition:color .25s ease;
}
#hub.pop{animation:hubPop .55s var(--ease-cam);}
@keyframes hubPop{
  0%  {transform:translate(-50%,-50%) scale(.4)}
  55% {transform:translate(-50%,-50%) scale(1.18)}
  100%{transform:translate(-50%,-50%) scale(1)}
}

/* ------------------------- BOTTOM CLUSTER ------------------------------- */
/* Pinned to the bottom of the stage. Children are positioned from the bottom
   edge using the reference offsets, so the whole cluster travels together
   during the camera move. */
#bottom{
  position:absolute;left:0;right:0;bottom:0;height:528px;
  transform-origin:50% 100%;
  transition:transform var(--dur-cam) var(--ease-cam), opacity .45s ease-in-out;
  will-change:transform,opacity;
}

#meters{
  position:absolute;left:16px;width:574px;top:10px;
  display:flex;justify-content:center;align-items:center;gap:12px;
  font-size:20px;font-weight:800;letter-spacing:.06em;
  color:var(--cream-dim);
}
#meters b{color:var(--gold);font-weight:900;letter-spacing:.01em;}
#meters .sep{opacity:.5;}

/* --------------------------- CAMERA STATES ------------------------------ */
/* In the video, the board and wheel are both visible on screen throughout the spin */
#app.focus #wheelStage{transform:scale(1.02);transition:transform var(--dur-cam) var(--ease-cam);}
#app.focus #bottom{opacity:.95;transition:opacity .3s ease;}
#app.busy #board{pointer-events:none;}
#app.busy .act, #app.busy #spinBtn, #app.busy #chipRail{pointer-events:none;opacity:.65;}

/* ==================== DESKTOP CASINO TABLE LAYOUT ==================== */
#app.desktop-mode {
  width: 1440px;
  margin-left: -720px;
}

#app.desktop-mode #topHud {
  left: 36px;
  right: 36px;
  top: 16px;
  height: 84px;
}

#app.desktop-mode #hist {
  max-width: 680px;
}

#app.desktop-mode #wheelStage {
  left: 40px;
  right: auto;
  width: 626px;
  top: 112px;
  bottom: 24px;
  display: grid;
  place-items: center;
}

#app.desktop-mode #bottom {
  left: auto;
  right: 40px;
  width: 710px;
  top: 112px;
  bottom: 24px;
  height: auto;
  position: absolute;
}

#app.desktop-mode #meters {
  position: absolute;
  left: 0;
  width: 580px;
  top: 0px;
  height: 40px;
  font-size: 22px;
}

#app.desktop-mode #board {
  position: absolute;
  left: 0;
  width: 580px;
  top: 48px;
  bottom: auto;
  height: 470px;
  grid-template-columns: 66px repeat(12, 1fr) 96px;
  gap: 4px;
}

#app.desktop-mode #board .cell.num {
  font-size: 50px;
}
#app.desktop-mode #board .cell.zero {
  font-size: 54px;
}
#app.desktop-mode #board .cell.side {
  font-size: 28px;
}
#app.desktop-mode #board .cell.dozen {
  font-size: 36px;
}
#app.desktop-mode #board .cell.even {
  font-size: 28px;
}
#app.desktop-mode #board .dia {
  width: 42px;
  height: 42px;
}

#app.desktop-mode #clearBtn {
  position: absolute;
  right: 12px;
  top: 48px;
  bottom: auto;
  width: 98px;
  height: 98px;
}

#app.desktop-mode #repeatBtn {
  position: absolute;
  right: 12px;
  top: 172px;
  bottom: auto;
  width: 98px;
  height: 98px;
}

#app.desktop-mode #dblBtn {
  position: absolute;
  right: 12px;
  top: 296px;
  bottom: auto;
  width: 98px;
  height: 98px;
}

#app.desktop-mode #spinBtn {
  position: absolute;
  right: 12px;
  top: 420px;
  bottom: auto;
  width: 104px;
  height: 104px;
}

#app.desktop-mode #rail {
  position: absolute;
  left: 0;
  width: 580px;
  top: 536px;
  bottom: auto;
  height: 98px;
}

#app.desktop-mode #chipRail {
  height: 90px;
  gap: 20px;
}

#app.desktop-mode .chipBtn {
  width: 68px;
  height: 68px;
  font-size: 22px;
}

#app.desktop-mode .cell:hover {
  filter: brightness(1.25);
  box-shadow: 0 0 16px rgba(246, 207, 110, 0.45);
  cursor: pointer;
}

#app.desktop-mode .chipBtn:hover {
  transform: translateY(-4px) scale(1.06);
  cursor: pointer;
}

#app.desktop-mode .topHudBtn:hover,
#app.desktop-mode .act:hover,
#app.desktop-mode #spinBtn:hover {
  filter: brightness(1.15);
  cursor: pointer;
}

@media (prefers-reduced-motion:reduce){
  #wheelStage,#bottom{transition-duration:1ms;}
}
/* CaiWin navigation shares the native HUD without expanding the stage. */
#topActions{gap:7px}.topHudBtn{height:64px;width:54px;min-width:54px;font-size:26px}.topHudBtn svg{width:27px;height:27px}
