/* Fidgital World — cube game
   The game is laid out on a fixed 1194 x 834 stage (the Canva frame size)
   and scaled to fit any screen, so it looks the same on iPad, laptop and phone. */

:root {
  --cream: #FBF1DE;
  --cream-deep: #F3DFB4;
  --yellow: #E9AB2E;
  --yellow-dark: #C98E1A;
  --green: #4C7D3A;
  --maroon: #8E1A2C;
  --navy: #26476F;
  --ink: #1D1D1D;
  --btn-text: #ECECEC;
  --white: #FFFFFF;
  --stage-w: 1194px;
  --stage-h: 834px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--cream);
  font-family: "Roboto", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
button:focus-visible { outline: 4px solid var(--navy); outline-offset: 4px; }

#viewport {
  position: fixed; inset: 0;
  background: var(--cream);
}

#stage {
  position: absolute; left: 50%; top: 50%;
  width: var(--stage-w); height: var(--stage-h);
  transform: translate(-50%, -50%);
  transform-origin: center center;
  background: var(--cream);
  overflow: hidden;
}

/* ---------- Screens ---------- */
.screen {
  position: absolute; inset: 0;
  opacity: 0; visibility: hidden;
  transition: opacity .25s ease, visibility 0s linear .25s;
}
.screen.active { opacity: 1; visibility: visible; transition: opacity .25s ease; }

/* ---------- Splash / logo ---------- */
.splash-tap {
  position: absolute; inset: 0; width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.logo { display: flex; flex-direction: column; align-items: center; gap: 44px; }
.logo-mark {
  display: grid; grid-template-columns: repeat(2, 80px); grid-template-rows: repeat(3, 80px); gap: 5px;
}
.logo-mark span {
  background: var(--yellow); border: 1.5px solid var(--ink); border-radius: 5px;
  animation: drop .5s cubic-bezier(.3,1.4,.6,1) both;
}
.logo-mark span:nth-child(2) { animation-delay: .08s; }
.logo-mark span:nth-child(3) { animation-delay: .16s; }
.logo-mark span:nth-child(4) { animation-delay: .24s; }
@keyframes drop { from { transform: translateY(-40px); opacity: 0; } to { transform: none; opacity: 1; } }

.logo-word { font-size: 50px; font-weight: 700; letter-spacing: -.5px; line-height: 1; }
.logo-word .outline { color: var(--white); -webkit-text-stroke: 1.4px var(--ink); paint-order: stroke fill; }
.logo-word .fill { color: var(--yellow); }

.tap-hint {
  position: absolute; bottom: 90px; margin: 0;
  font-size: 22px; color: #9b8a66; letter-spacing: 1px;
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- Faded background shapes ---------- */
.decor { position: absolute; inset: 0; pointer-events: none; }
.decor .sq {
  position: absolute; width: 60px; height: 60px;
  background: var(--cream-deep); border: 1px solid #E6CE9C; border-radius: 4px; opacity: .85;
}
.decor .cube3d { position: absolute; opacity: .26; filter: saturate(.6); }

/* ---------- Pill buttons ---------- */
.menu-stack {
  position: absolute; left: 50%; top: 106px; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 35px;
}
.menu-stack.low { top: 238px; }

.pill {
  width: 482px; height: 96px; border-radius: 48px;
  background: var(--yellow);
  font-size: 46px; font-weight: 500; color: var(--btn-text);
  text-shadow: 0 0 1px #000, 1px 1px 0 #6d6d6d, 0 2px 3px rgba(0,0,0,.35);
  box-shadow:
    inset 0 0 10px rgba(255,255,255,.55),
    inset 0 -4px 8px rgba(0,0,0,.12),
    4px 5px 0 rgba(0,0,0,.55);
  transition: transform .08s ease, box-shadow .08s ease, filter .15s;
}
.pill:hover { filter: brightness(1.04); }
.pill:active { transform: translate(3px, 4px); box-shadow: inset 0 0 10px rgba(255,255,255,.4), 1px 1px 0 rgba(0,0,0,.55); }
.pill.green { background: var(--green); font-size: 50px; }
.pill.maroon { background: var(--maroon); }
.pill.navy { background: var(--navy); }
.pill.small { width: auto; min-width: 200px; height: 72px; padding: 0 36px; font-size: 32px; }
.pill:disabled { opacity: .45; cursor: default; }
.menu-stack.mid { top: 300px; }

/* Shared face renderers (FW.ui.face) */
.face-img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.grid2d { display: grid; gap: 3px; }
.grid2d .c {
  width: var(--cell); height: var(--cell);
  background: var(--yellow); border: 1.5px solid var(--ink); border-radius: 4px;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.08);
}
.grid2d .e { width: var(--cell); height: var(--cell); }

.link-btn { font-size: 22px; color: var(--maroon); text-decoration: underline; }

/* Confetti (FW.ui.confetti) */
.confetti { position: absolute; inset: 0; pointer-events: none; z-index: 12; overflow: hidden; }
.confetti span {
  position: absolute; top: -20px; width: 14px; height: 20px; border-radius: 3px;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translate(var(--drift), 900px) rotate(var(--spin)); opacity: .9; }
}

/* 3-2-1 countdown (FW.ui.countdown) */
.countdown {
  position: absolute; inset: 0; z-index: 9; display: grid; place-items: center;
  background: rgba(251, 241, 222, .92);
}
.cd-num {
  font-size: 220px; font-weight: 900; color: var(--yellow);
  -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill;
  animation: pop .7s ease both;
}
@keyframes pop { from { transform: scale(.3); opacity: 0; } 40% { transform: scale(1.12); opacity: 1; } to { transform: scale(1); } }

/* ---------- Round icon buttons ---------- */
.round-row {
  position: absolute; left: 50%; top: 632px; transform: translateX(-50%);
  display: flex; gap: 62px;
}
.round {
  width: 96px; height: 96px; border-radius: 50%;
  background: #EDEDED; border: 2px solid #cfcfcf;
  box-shadow: inset 0 0 8px rgba(255,255,255,.9), 3px 4px 0 rgba(0,0,0,.45);
  display: grid; place-items: center;
  transition: transform .08s;
}
.round:active { transform: translate(2px, 3px); box-shadow: 1px 1px 0 rgba(0,0,0,.45); }
.round:disabled { opacity: .35; cursor: default; transform: none; }
.round svg { width: 38px; height: 38px; fill: #fafafa; stroke: #555; stroke-width: .9; }
.round svg path[fill="none"] { stroke: #555; }

/* ---------- Back button ---------- */
.back-btn {
  position: absolute; left: 44px; top: 44px; z-index: 2;
  height: 48px; padding: 0 22px; border-radius: 24px;
  background: #EDEDED; border: 2px solid #c9c9c9;
  font-size: 20px; font-weight: 700; letter-spacing: .5px; color: #e9e9e9;
  text-shadow: 0 0 1px #000, 1px 1px 0 #777;
  box-shadow: inset 0 0 6px rgba(255,255,255,.9), 2px 3px 0 rgba(0,0,0,.4);
}
.back-btn:active { transform: translate(2px, 2px); box-shadow: 0 1px 0 rgba(0,0,0,.4); }

/* ---------- Intro screens ---------- */
.intro { text-align: center; }
.intro-title { margin: 72px 0 0; font-size: 36px; font-weight: 700; color: var(--maroon); }
.intro-text { margin: 28px 0 0; font-size: 34px; font-weight: 400; }
.intro-img { position: absolute; left: 50%; top: 280px; width: 360px; transform: translateX(-50%); }
.intro .pill { position: absolute; left: 50%; top: 644px; transform: translateX(-50%); }
.intro .pill:active { transform: translate(calc(-50% + 3px), 4px); }

/* ---------- Modal + toast ---------- */
.modal {
  position: absolute; inset: 0; z-index: 10;
  background: rgba(40, 30, 10, .35);
  display: grid; place-items: center;
}
.modal[hidden] { display: none; }
.modal-box {
  width: 600px; background: var(--cream); border-radius: 28px; padding: 40px 48px;
  box-shadow: 6px 8px 0 rgba(0,0,0,.35); text-align: center;
}
.modal-box h2 { margin: 0 0 18px; font-size: 34px; color: var(--maroon); }
.modal-box p { font-size: 24px; line-height: 1.45; margin: 0 0 12px; }
.modal-actions { display: flex; gap: 20px; justify-content: center; margin-top: 26px; }
.modal-actions .pill { width: 220px; height: 72px; font-size: 32px; }
.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 26px; padding: 14px 6px; border-bottom: 1px solid #ead9b5;
}
.toggle {
  width: 84px; height: 44px; border-radius: 22px; background: #cfc6b4; position: relative; transition: background .2s;
}
.toggle::after {
  content: ""; position: absolute; top: 4px; left: 4px; width: 36px; height: 36px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s;
}
.toggle[aria-checked="true"] { background: var(--green); }
.toggle[aria-checked="true"]::after { transform: translateX(40px); }

.toast {
  position: absolute; left: 50%; bottom: 40px; transform: translateX(-50%); z-index: 11;
  background: var(--ink); color: #fff; font-size: 22px; padding: 14px 28px; border-radius: 30px;
}
.toast[hidden] { display: none; }

/* ---------- Portrait phones: ask to rotate ---------- */
.rotate-hint { display: none; }
@media (orientation: portrait) and (max-width: 700px) {
  .rotate-hint {
    position: fixed; inset: 0; z-index: 20;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px;
    background: var(--cream); font-size: 20px; color: var(--ink); text-align: center; padding: 24px;
  }
  .rotate-phone {
    width: 56px; height: 96px; border: 5px solid var(--yellow); border-radius: 12px;
    animation: turn 2s ease-in-out infinite;
  }
  @keyframes turn { 40%, 100% { transform: rotate(-90deg); } }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
