/*
 * The browser game's screens, as approved on sheet 36 (docs/web-plan.md).
 * The colours are the app's (src/render/palette.ts); the keys are the app's
 * PushButton as CSS: a face over a darker slab, with a line of light on top.
 * Nothing here animates layout: the board is a canvas, and the fuse moves by
 * transform alone.
 */

/* The game's face: Coming Soon, which is Android's "casual" family (Apache 2.0; fonts/LICENSE-ComingSoon-Apache-2.0.txt). */
@font-face {
  font-family: "Coming Soon";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/ComingSoon-Regular.woff2") format("woff2");
}

:root {
  --void: #0b0b12;
  --ink: #ffffff;
  --muted: #c4c4da;
  --faint: #8a8aa8;
  --safe: #3dd68c;
  --alert: #ff2d6b;
  --ember-hot: #ffc24b;
  --gold: #ffd166;
  --quiet: #2c2c42;
  --live: #5eead4;
  --accent: #3dd68c;
  --font: "Coming Soon", "Segoe Print", "Comic Sans MS", cursive;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--void);
  color: var(--ink);
  font-family: var(--font);
  overscroll-behavior: none;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
}

button:disabled {
  cursor: default;
}

[hidden] {
  display: none !important;
}

#app {
  position: fixed;
  inset: 0;
}

.backdrop {
  position: absolute;
  inset: 0;
  /* Its own stacking context: the layers' z-index orders them inside it and never lifts one over the screens. */
  isolation: isolate;
  background-color: var(--void);
}

/* Two layers, so a change of world can fade one over the other (backdrop.ts). */
.backdrop .layer {
  position: absolute;
  inset: 0;
  background-repeat: no-repeat;
  opacity: 0;
  will-change: opacity;
}

.screens {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
}

.screen {
  position: relative;
  isolation: isolate;
  width: 100%;
  max-width: 640px;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: max(14px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}

.icon {
  width: 26px;
  height: 26px;
  display: block;
}

/* ---- Round keys and the top bar ---------------------------------------- */

.rkey {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(28, 28, 42, 0.92);
  display: grid;
  place-items: center;
  color: var(--ink);
  box-shadow: 0 4px 0 rgba(255, 255, 255, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  flex: none;
}

.rkey:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(255, 255, 255, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.rkey.small {
  width: 44px;
  height: 44px;
}

.rkey.small .icon {
  width: 22px;
  height: 22px;
}

.top {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 64px;
}

.top .slot {
  width: 98px;
  display: flex;
}

.titlebox {
  flex: 1;
  min-width: 0;
  text-align: center;
  line-height: 1;
}

.pill {
  display: inline-block;
  font-size: 14px;
  letter-spacing: 1px;
  padding: 5px 14px;
  border-radius: 999px;
  background: rgba(20, 20, 30, 0.85);
  color: var(--accent);
  margin-bottom: 4px;
  white-space: nowrap;
}

.lvl {
  display: block;
  font-size: clamp(28px, 9vw, 38px);
  color: var(--ink);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
  white-space: nowrap;
}

.rgroup {
  width: 98px;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

/* ---- The lesson -------------------------------------------------------- */

.coach {
  margin: 10px 12px 0;
  text-align: center;
  padding: 10px 16px;
  border-radius: 18px;
  background: rgba(14, 14, 22, 0.86);
  border: 1.5px solid rgba(255, 255, 255, 0.1);
}

.coach .ca {
  font-size: 20px;
}

.coach .cb {
  font-size: 15px;
  color: var(--muted);
  margin-top: 2px;
}

.hand {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.45));
  will-change: transform, opacity;
}

/* ---- The board on its tray --------------------------------------------- */

.stage {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
}

.tray {
  position: relative;
  padding: 12px;
  border-radius: 22px;
  border: 2px solid var(--accent);
  background-color: rgba(11, 11, 18, 0.36);
}

.tray .board {
  display: block;
  touch-action: none;
}

/* The frame-rate readout (?fps=1, W11). */
.perf {
  position: fixed;
  left: 6px;
  bottom: 6px;
  z-index: 50;
  padding: 3px 8px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.72);
  color: #c8f7e8;
  font: 12px/1.3 ui-monospace, Menlo, Consolas, monospace;
  pointer-events: none;
}

/* The board's frame (W9), laid over the tray's edge and drawn once for its size. */
.tray.framed {
  border-color: transparent;
}

.tray .frame {
  position: absolute;
  pointer-events: none;
}

/* ---- The fuse meter and the hint key ----------------------------------- */

.bottom {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 6px 4px 4px;
}

.fuse {
  position: relative;
  flex: 1;
  height: 26px;
  border-radius: 13px;
  background: rgba(20, 20, 30, 0.9);
  padding: 5px;
  overflow: visible;
}

.fuse .fill {
  display: block;
  height: 100%;
  border-radius: 8px;
  background: repeating-linear-gradient(-45deg, #5eead4 0 8px, #3fbfab 8px 14px);
  transform-origin: left center;
  will-change: transform;
}

.fuse.hot .fill {
  background: repeating-linear-gradient(-45deg, #ff6b8e 0 8px, #ff2d6b 8px 14px);
}

.fuse .spark {
  position: absolute;
  left: -4px;
  top: 50%;
  width: 18px;
  height: 18px;
  margin-top: -9px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff3c4 0 22%, #ffc24b 30%, #ff5a2b 62%, rgba(255, 90, 43, 0) 72%);
  box-shadow: 0 0 14px 6px rgba(255, 90, 43, 0.45);
  will-change: transform;
}

.hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.hintkey {
  position: relative;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: var(--gold);
  display: grid;
  place-items: center;
  color: #1b1b26;
  box-shadow: 0 5px 0 #8c7238;
}

.hintkey .icon {
  width: 32px;
  height: 32px;
}

.hintkey:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #8c7238;
}

.hintkey:disabled {
  opacity: 0.4;
}

.admark {
  position: absolute;
  right: -4px;
  top: -4px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #1b1b26;
  border: 2px solid var(--gold);
  display: grid;
  place-items: center;
  color: var(--gold);
}

.admark .icon {
  width: 15px;
  height: 15px;
}

.hintlabel {
  font-size: 14px;
  color: var(--gold);
  letter-spacing: 1px;
}

/* ---- Keys -------------------------------------------------------------- */

.key {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 52px;
  margin-top: 12px;
  padding: 0 14px;
  border-radius: 16px;
  font-size: 19px;
  letter-spacing: 1.2px;
  color: var(--void);
  background: var(--tone);
  box-shadow: 0 6px 0 var(--slab);
}

.key::before {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  top: 3px;
  height: 2px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.45);
}

.key .icon {
  width: 21px;
  height: 21px;
}

.key:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow: 0 2px 0 var(--slab);
}

.key:disabled {
  filter: saturate(0.4) brightness(0.8);
}

.key.go {
  --tone: var(--safe);
  --slab: #22774f;
}

.key.gold {
  --tone: var(--gold);
  --slab: #8c7238;
}

.key.again {
  --tone: var(--ember-hot);
  --slab: #8c6b2c;
}

.key.quiet {
  --tone: var(--quiet);
  --slab: #4a4a5e;
  color: var(--ink);
}

.keys2 {
  display: flex;
  gap: 12px;
}

/* ---- Cards over the board ---------------------------------------------- */

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 90px 22px 40px;
  background: rgba(11, 11, 18, 0.62);
  z-index: 5;
}

.card {
  width: 100%;
  max-width: 380px;
  border-radius: 26px;
  background: rgba(18, 18, 28, 0.96);
  border: 2.5px solid var(--accent);
  padding: 24px 20px 22px;
  text-align: center;
}

.card .mascot {
  width: 100px;
  height: 100px;
  display: block;
  margin: -80px auto 6px;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.45));
}

.big {
  font-size: 40px;
  color: var(--gold);
  letter-spacing: 1px;
  line-height: 1.05;
}

.big.alert {
  color: var(--alert);
  font-size: 32px;
  letter-spacing: 2px;
}

.big.plain {
  color: var(--ink);
  font-size: 32px;
}

.sub {
  font-size: 17px;
  margin: 8px 0 6px;
}

.sub.muted {
  color: var(--muted);
}

.stars {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 10px 0 14px;
}

.star {
  width: 52px;
  height: 52px;
  color: #33334a;
}

.star.on {
  color: var(--gold);
  filter: drop-shadow(0 2px 0 #8c7238);
}

.boxes {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 4px;
}

.box {
  min-width: 104px;
  padding: 8px 12px;
  border-radius: 14px;
  border: 2px solid rgba(255, 209, 102, 0.85);
}

.box b {
  display: block;
  font-size: 26px;
  font-weight: 400;
  line-height: 1;
}

.box span {
  font-size: 12px;
  letter-spacing: 1px;
}

.playbadge img {
  width: 190px;
  display: block;
  margin: 10px auto 0;
}

.flash {
  position: absolute;
  left: 50%;
  bottom: 110px;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(18, 18, 28, 0.95);
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  font-size: 16px;
  z-index: 6;
}

/* ---- Boards ------------------------------------------------------------ */

.hdr {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
}

.hdr .t {
  font-size: 28px;
}

.hdr .t.accent {
  color: var(--accent);
}

.scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px 2px 16px;
  scrollbar-width: none;
}

.screen.boards::before,
.screen.daily::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(11, 11, 18, 0.55);
  z-index: -1;
}

.worlds {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.world {
  position: relative;
  height: 132px;
  border-radius: 18px;
  background-size: cover;
  background-position: center 30%;
  overflow: hidden;
  border: 2.5px solid transparent;
  text-align: left;
}

.world.on {
  border-color: var(--wa);
}

.world::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.75));
}

.world img {
  position: absolute;
  left: 10px;
  top: 10px;
  width: 46px;
  z-index: 1;
}

.world .n {
  position: absolute;
  left: 12px;
  bottom: 30px;
  z-index: 1;
  font-size: 20px;
  color: var(--wa);
}

.world .c {
  position: absolute;
  left: 12px;
  bottom: 10px;
  z-index: 1;
  font-size: 14px;
  color: var(--ink);
}

.chapters {
  margin-top: 16px;
}

.chrow {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 14px;
  border-radius: 14px;
  background: rgba(28, 28, 42, 0.88);
  font-size: 15px;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 12px;
  text-align: left;
}

.chrow.done .st {
  color: var(--gold);
}

.chrow .icon {
  width: 18px;
  height: 18px;
  color: var(--faint);
}

.chapter {
  margin-bottom: 14px;
}

.chapter .h {
  font-size: 15px;
  color: var(--muted);
  margin: 2px 0 8px;
  letter-spacing: 1px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.b {
  position: relative;
  height: 62px;
  border-radius: 14px;
  background: #2c2c42;
  box-shadow: 0 4px 0 #44445a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.b small {
  font-size: 11px;
  color: var(--gold);
  letter-spacing: 1px;
}

.b.next {
  background: var(--safe);
  color: var(--void);
  box-shadow: 0 4px 0 #22774f;
}

.b.next small {
  color: var(--void);
}

.b.lock {
  opacity: 0.5;
  color: var(--faint);
}

.b .lk {
  position: absolute;
  right: 6px;
  top: 4px;
}

.b .lk .icon {
  width: 13px;
  height: 13px;
}

.b:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #44445a;
}

.dailyslot .key {
  margin-top: 6px;
}

.streak {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(11, 11, 18, 0.85);
  color: var(--ink);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 16px;
}

.streak .icon {
  width: 16px;
  height: 16px;
  color: #ff5a2b;
}

/* ---- The Daily's result ------------------------------------------------- */

.hero {
  display: block;
  margin: 0 auto;
}

.dailykeys {
  max-width: 420px;
  margin: 6px auto 0;
}

.fine {
  font-size: 14px;
  color: var(--faint);
  margin-top: 12px;
}

.center {
  text-align: center;
}

/* ---- The W1 harness (?harness=1) ---------------------------------------- */

#app.harness {
  display: flex;
  flex-direction: column;
}

#app.harness #board {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: block;
  touch-action: none;
}

#hud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 10px 16px 14px;
  font-size: 14px;
}

#hud button {
  color: var(--ink);
  background: #232334;
  border: 1px solid #2e2e45;
  border-radius: 10px;
  padding: 8px 12px;
}

#hud .status {
  width: 100%;
  text-align: center;
  color: var(--faint);
}
