/* Red / white / black theme inspired by eventscrew.com */
:root {
  --red: #e41115;
  --red-dark: #a80c0f;
  --black: #111111;
  --ink: #1a1a1a;
  --bg: #ffffff;
  --page: #ececec;
  --panel: #f2f2f2;
  --panel2: #e6e6e6;
  --line: #d9d9d9;
  --text: #1a1a1a;
  --muted: #6b6f78;
  --ok: #1f9d55;
  --bad: #e41115;
  --cell: 36px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%;
  background: var(--page); color: var(--text);
  font-family: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}
body { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; overflow: hidden; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
h1, h2, .logo { font-family: "Outfit", "Poppins", system-ui, sans-serif; }

.screen {
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  max-width: 560px; margin: 0 auto; background: var(--bg);
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  box-shadow: 0 0 40px rgba(0,0,0,.08);
}
.screen[hidden] { display: none; }

/* ---------- hub ---------- */
.tape { height: 8px; flex: none; background: var(--red); }
.hub-head { padding: 26px 20px 22px; text-align: center; background: var(--black); color: #fff; }
.logo {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 46px; font-weight: 900; line-height: 1; color: #fff;
}
.logo > span { color: #fff; font-weight: 300; letter-spacing: 3px; font-size: 38px; text-transform: lowercase; }
.logo > .logo-mark {
  background: var(--red); color: #fff; padding: 4px 12px 6px; border-radius: 6px;
  font-weight: 900; font-size: 46px; letter-spacing: 1px; text-transform: none;
}
.tag { color: #c9c9c9; margin: 12px 0 0; font-size: 14px; }
.jobs { flex: 1; overflow-y: auto; padding: 18px 16px; display: flex; flex-direction: column; gap: 14px; }
.job {
  display: grid; grid-template-columns: 64px 1fr; grid-template-rows: auto auto; gap: 4px 14px;
  text-align: left; padding: 16px; border-radius: 14px;
  background: #fff; border: 1px solid var(--line); border-left: 6px solid var(--red);
  box-shadow: 0 2px 10px rgba(0,0,0,.06);
  transition: transform .12s, box-shadow .12s;
}
.job:active { transform: scale(.98); }
@media (hover: hover) { .job:hover { box-shadow: 0 6px 18px rgba(228,17,21,.18); } }
.job-icon {
  grid-row: span 2; width: 64px; height: 64px; border-radius: 12px;
  display: grid; place-items: center; font-size: 34px; background: #fdeaea;
}
.job h2 { margin: 2px 0 4px; font-size: 19px; color: var(--ink); }
.job p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.4; }
.job-best { grid-column: 2; font-size: 13px; font-weight: 700; color: var(--red); }
.hub-foot { text-align: center; color: var(--muted); font-size: 13px; padding: 10px 0 16px; }

/* ---------- game chrome ---------- */
.bar {
  display: grid; grid-template-columns: 44px 1fr 44px; align-items: center;
  padding: 8px 10px; flex: none; background: var(--black); color: #fff;
  border-bottom: 4px solid var(--red);
}
.bar h1 { margin: 0; text-align: center; font-size: 18px; font-weight: 800; letter-spacing: .3px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 10px; background: var(--red); color: #fff;
  font-size: 22px; font-weight: 800; display: grid; place-items: center;
}
.hud {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 8px 12px 4px; flex: none;
}
.hud > div {
  background: var(--panel); border-radius: 10px; padding: 6px 4px; text-align: center;
}
.hud small { display: block; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; font-weight: 600; }
.hud b { font-size: 18px; font-variant-numeric: tabular-nums; color: var(--ink); }
.hud b.warn { color: var(--bad); animation: pulse .5s infinite alternate; }
@keyframes pulse { to { opacity: .45; } }

.play {
  flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center;
  padding: 6px 12px; position: relative;
}
.controls { display: flex; gap: 10px; padding: 8px 12px 12px; flex: none; }
.btn {
  flex: 1; padding: 14px 10px; border-radius: 12px; font-weight: 700; font-size: 16px;
  background: var(--red); color: #fff; box-shadow: 0 4px 0 var(--red-dark);
  transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--red-dark); }
.btn.ghost { background: var(--panel); color: var(--ink); box-shadow: 0 4px 0 #cfcfcf; }
.btn.ghost:active { box-shadow: 0 1px 0 #cfcfcf; }
.btn small { opacity: .75; font-weight: 600; }
.btn:disabled { opacity: .45; pointer-events: none; }
.status {
  text-align: center; font-size: 14px; color: var(--muted); padding: 2px 12px; min-height: 22px; flex: none;
}
.status b { color: var(--ink); }

/* ---------- lorry ---------- */
.trailer {
  --c: var(--cell);
  background: #fff; border-radius: 12px 12px 6px 6px; padding: 0 8px 8px;
  border: 2px solid #cfcfcf;
  box-shadow: inset 0 -10px 0 -4px var(--red), 0 10px 26px rgba(0,0,0,.18);
}
.trailer .cab {
  height: 30px; margin: 0 -8px 8px; border-radius: 10px 10px 0 0;
  background: var(--black); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 900; letter-spacing: 3px; font-size: 13px;
}
.trailer .cab span { background: var(--red); padding: 1px 10px; border-radius: 4px; }
.trailer .doors {
  height: 6px; margin: 6px -2px 0; border-radius: 3px;
  background: repeating-linear-gradient(-45deg, var(--red) 0 6px, #fff 6px 12px);
}
.trailer.drive { animation: driveOff .9s ease-in forwards; }
.trailer.arrive { animation: arriveIn .45s ease-out; }
@keyframes driveOff { 20% { transform: translateY(8px); } to { transform: translateY(-130vh); } }
@keyframes arriveIn { from { transform: translateY(60vh); opacity: 0; } }

.board {
  display: grid; grid-template-columns: repeat(6, var(--c));
  background: #2a2a2a; border-radius: 4px; touch-action: none;
}
.cell {
  width: var(--c); height: var(--c);
  border: 2px solid rgba(255,255,255,.05);
  display: grid; place-items: center; font-size: calc(var(--c) * .55);
}
.cell.full { border-color: rgba(0,0,0,.45); }
.cell.ok { background: rgba(61,220,132,.5) !important; }
.cell.bad { background: rgba(228,17,21,.55) !important; }
.cell.pop { animation: pop .25s ease-out; }
@keyframes pop { from { transform: scale(.6); } }

.tray {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 6px 12px; height: 112px; flex: none;
}
.slot {
  position: relative; background: var(--panel); border-radius: 12px; border: 2px dashed #cfcfcf;
  touch-action: none; display: flex; flex-direction: column; align-items: center; justify-content: center;
  overflow: hidden;
}
.slot .lbl { position: absolute; bottom: 4px; left: 0; right: 0; text-align: center; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 4px; }
.slot.lift { opacity: .25; }
.slot .rot { position: absolute; top: 4px; right: 6px; font-size: 12px; color: var(--red); }
.piece { position: relative; margin-bottom: 12px; }
.piece i {
  position: absolute; display: grid; place-items: center; font-style: normal;
  border: 2px solid rgba(0,0,0,.35);
}
.piece.spin { animation: spin .18s ease-out; }
@keyframes spin { from { transform: rotate(-90deg); } }
.drag-ghost {
  position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none; opacity: .9;
  filter: drop-shadow(0 10px 12px rgba(0,0,0,.4));
}

/* ---------- crowd ---------- */
.levels { display: flex; gap: 6px; padding: 8px 12px 0; flex: none; }
.levels button {
  flex: 1; border-radius: 10px; padding: 6px 0 4px; background: var(--panel); border: 2px solid transparent;
  font-weight: 800; font-size: 15px; line-height: 1.1; color: var(--ink);
}
.levels button small { display: block; font-size: 10px; color: var(--red); letter-spacing: 1px; font-weight: 600; }
.levels button.on { border-color: var(--red); background: #fff; }
.levels button:disabled { opacity: .35; }
.brief { text-align: center; padding: 8px 14px 0; font-size: 14px; flex: none; color: var(--muted); }
.brief b { color: var(--red); }
#c-canvas { touch-action: none; border-radius: 10px; box-shadow: 0 0 0 3px var(--black); }

/* ---------- power ---------- */
.pgrid { display: grid; gap: 3px; background: var(--black); padding: 3px; border-radius: 10px; box-shadow: 0 0 0 3px var(--black), 0 10px 26px rgba(0,0,0,.18); }
.ptile {
  position: relative; background: #262626; border-radius: 6px; overflow: hidden; touch-action: manipulation;
}
.ptile .spin { position: absolute; inset: 0; transition: transform .16s ease-out; }
.ptile svg { width: 100%; height: 100%; display: block; }
.ptile svg .w { stroke: #555; stroke-width: 16; stroke-linecap: round; fill: none; transition: stroke .2s; }
.ptile svg .k { fill: #555; transition: fill .2s; }
.ptile.on svg .w { stroke: var(--red); }
.ptile.on svg .k { fill: var(--red); }
.ptile.on { background: #331416; }
.ptile .dev {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
  font-size: 50%; filter: grayscale(1) brightness(.6); transition: filter .25s;
}
.ptile .dev span {
  background: #161616; border-radius: 30%; width: 56%; height: 56%; display: grid; place-items: center;
  box-shadow: 0 0 0 2px #555;
}
.ptile.on .dev { filter: none; }
.ptile.on .dev span { background: #fff; box-shadow: 0 0 0 2px var(--red), 0 0 14px var(--red); }
.ptile.src .dev { filter: none; }
.ptile.src .dev span { background: var(--red); box-shadow: 0 0 0 2px #fff; }
.pgrid.won .ptile { animation: glow .6s ease-out; }
@keyframes glow { 50% { background: #6a1517; } }

/* ---------- toast + modal ---------- */
.toast {
  position: fixed; left: 50%; top: calc(14px + env(safe-area-inset-top)); z-index: 90;
  transform: translate(-50%, -150%); transition: transform .25s;
  background: var(--black); color: #fff; font-weight: 700; padding: 10px 16px; border-radius: 10px;
  border-left: 6px solid var(--red);
  max-width: 90vw; text-align: center; box-shadow: 0 8px 20px rgba(0,0,0,.3);
}
.toast.show { transform: translate(-50%, 0); }
.modal {
  position: fixed; inset: 0; z-index: 80; background: rgba(17,17,17,.65);
  display: grid; place-items: center; padding: 20px;
}
.modal[hidden] { display: none; }
.card {
  width: 100%; max-width: 380px; background: #fff; border-radius: 16px; padding: 22px 20px 18px;
  border-top: 8px solid var(--red); animation: rise .25s ease-out; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0,0,0,.3);
}
@keyframes rise { from { transform: translateY(30px); opacity: 0; } }
.card h2 { margin: 0 0 10px; font-size: 22px; color: var(--ink); }
.card p, .card li { color: #44474d; line-height: 1.5; font-size: 15px; }
.card ul { padding-left: 20px; margin: 8px 0; }
.card .big { font-size: 44px; font-weight: 900; color: var(--red); text-align: center; margin: 8px 0 2px; }
.card .stars { font-size: 40px; text-align: center; letter-spacing: 6px; color: var(--red); }
.card .stars .off { color: #dedede; }
.card .badge { text-align: center; font-weight: 800; color: var(--ok); }
.card table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 15px; }
.card td { padding: 6px 0; border-bottom: 1px solid var(--line); }
.card td:last-child { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.modal-btns { display: flex; gap: 10px; margin-top: 16px; }

@media (max-height: 640px) {
  .hub-head { padding: 16px 20px 14px; }
  .logo { font-size: 38px; }
  .tray { height: 96px; }
  .btn { padding: 11px 8px; }
}
