@font-face { font-family: "Alfa Slab One"; src: url(assets/fonts/AlfaSlabOne-Regular.ttf); font-display: swap; }
@font-face { font-family: "Special Elite"; src: url(assets/fonts/SpecialElite-Regular.ttf); font-display: swap; }
@font-face { font-family: "Bangers"; src: url(assets/fonts/Bangers-Regular.ttf); font-display: swap; }
@font-face { font-family: "Patrick Hand"; src: url(assets/fonts/PatrickHand-Regular.ttf); font-display: swap; }
@font-face { font-family: "Press Start 2P"; src: url(assets/fonts/PressStart2P-Regular.ttf); font-display: swap; }
@font-face { font-family: "VT323"; src: url(assets/fonts/VT323-Regular.ttf); font-display: swap; }
@font-face { font-family: "Lilita One"; src: url(assets/fonts/LilitaOne-Regular.ttf); font-display: swap; }
@font-face { font-family: "Varela Round"; src: url(assets/fonts/VarelaRound-Regular.ttf); font-display: swap; }

:root {
  --paper: #efe5cf;
  --paper-hi: #faf4e6;
  --paper-2: #e3d4b4;
  --paper-3: #d5c29b;
  --desk: #b99b6b;
  --desk-dark: #8f7349;
  --desk-light: #c4a676;
  --on-desk: #2a221d;
  --on-desk-soft: rgba(42, 34, 29, .6);
  --font-scale: 1;
  --ink: #2a221d;
  --ink-soft: rgba(42, 34, 29, .6);
  --ink-faint: rgba(42, 34, 29, .14);
  --red: #c9432a;
  --red-dark: #9e3220;
  --ochre: #d6a13b;
  --display: "Alfa Slab One", Georgia, serif;
  --body: "Special Elite", "Courier New", monospace;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--desk) radial-gradient(ellipse at 50% 40%, var(--desk-light) 0%, var(--desk) 55%, var(--desk-dark) 100%);
  color: var(--ink);
  font: 16px/1.4 var(--body);
  overflow: hidden;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}
button { font: inherit; color: inherit; touch-action: manipulation; cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
input { font: inherit; color: inherit; user-select: text; -webkit-user-select: text; }
[hidden] { display: none !important; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

#app { position: fixed; inset: 0; }
.screen { position: absolute; inset: 0; }

/* ------------------------------------------------------------------ buttons */
.btn, .big, .pill, .icon {
  border: 3px solid var(--ink);
  background: var(--paper);
  box-shadow: 3px 3px 0 var(--ink);
  border-radius: 6px;
  transition: transform .06s, box-shadow .06s;
}
.btn:active, .big:active, .pill:active, .icon:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn { font-family: var(--display); font-size: calc(16px * var(--font-scale)); padding: 9px 16px; letter-spacing: .3px; }
.btn.primary, .big.primary { background: var(--red); color: var(--paper-hi); }
.btn.danger { background: var(--paper-hi); color: var(--red-dark); border-color: var(--red-dark); box-shadow: 3px 3px 0 var(--red-dark); }
.icon { width: 44px; height: 44px; display: grid; place-items: center; padding: 0; flex: none; }
.pill { height: 44px; min-width: 52px; padding: 0 10px; font-family: var(--display); flex: none; }
.link { background: none; border: 0; padding: 0; text-decoration: underline; color: var(--red-dark); }

/* ------------------------------------------------------------------ home */
#home { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.home {
  max-width: 620px; margin: 0 auto;
  padding: calc(18px + var(--safe-t)) calc(16px + var(--safe-r)) calc(28px + var(--safe-b)) calc(16px + var(--safe-l));
}
.logo { text-align: center; margin: 6px 0 20px; }
.logo h1, .loading-card h1 { margin: 0; font-family: var(--display); font-weight: 400; line-height: .95; }
.logo .l1, .loading-card .l1 { display: block; font-size: clamp(30px, 9vw, 52px); color: var(--paper-hi); text-shadow: 3px 3px 0 var(--ink); -webkit-text-stroke: 1.5px var(--ink); letter-spacing: 1px; transform: rotate(-2deg); }
.logo .l2, .loading-card .l2 { display: block; font-size: clamp(54px, 18vw, 104px); color: var(--red); text-shadow: 5px 5px 0 var(--ink); -webkit-text-stroke: 2px var(--ink); transform: rotate(-3deg); margin-top: 10px; }
.logo p { margin: 14px auto 0; max-width: 420px; color: var(--on-desk); }
.label { font: calc(18px * var(--font-scale)) var(--display); margin: 0 0 10px; letter-spacing: .5px; color: var(--on-desk); }

.maps { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.map-card {
  position: relative; text-align: left; padding: 11px 11px 10px; min-height: 92px;
  background: var(--paper); border: 3px solid var(--ink); border-radius: 8px; box-shadow: 5px 5px 0 var(--ink);
  display: flex; flex-direction: column; gap: 3px;
}
.map-card:active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--ink); }
.map-card b { font: calc(21px * var(--font-scale))/1.05 var(--display); }
.map-card small { color: var(--ink-soft); }
.map-card .lead { margin-top: auto; display: flex; align-items: center; gap: 6px; font-size: 14px; }
.map-card .lead img { width: 26px; height: 17px; object-fit: cover; border: 2px solid var(--ink); border-radius: 2px; }
.map-card.world { grid-column: 1 / -1; background: var(--red); color: var(--paper-hi); }
.map-card.world small { color: rgba(250, 244, 230, .8); }
.map-card.world b { font-size: 26px; }

.home-foot { display: flex; gap: 12px; justify-content: center; margin-top: 22px; flex-wrap: wrap; }
.credit { text-align: center; margin-top: 12px; color: var(--on-desk-soft); font-size: 14px; }
.credit .link { color: var(--on-desk); }
.makers {
  margin-top: 26px; padding: 14px 16px; background: var(--ink); border-radius: 8px; box-shadow: 4px 4px 0 rgba(42, 34, 29, .35);
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
}
.maker { display: flex; flex-direction: column; gap: 4px; color: rgba(250, 244, 230, .7); font-size: 13px; }
.maker img, .powered img, .loading-brand img { display: block; height: auto; }
.powered { background: none; border: 0; padding: 4px; border-radius: 6px; }
.powered:focus-visible { outline: 3px solid var(--ochre); }
.loading-brand { margin-top: 34px; padding: 12px 14px; background: var(--ink); border-radius: 8px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.update {
  margin-top: 18px; padding: 12px 14px; background: var(--ochre); border: 3px solid var(--ink); border-radius: 8px;
  box-shadow: 4px 4px 0 var(--ink); display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
}
.update p { margin: 0; flex: 1 1 200px; }
/* a newer version is out: covers everything until the player updates */
.force-update { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px;
  background: var(--desk) radial-gradient(ellipse at 50% 40%, var(--desk-light) 0%, var(--desk) 55%, var(--desk-dark) 100%); }
.force-card { max-width: 380px; width: 100%; text-align: center; padding: 26px 22px 22px; background: var(--paper);
  border: 3px solid var(--ink); border-radius: 10px; box-shadow: 6px 6px 0 var(--ink); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.force-card img { border: 3px solid var(--ink); border-radius: 18px; }
.force-card h2 { margin: 0; font: calc(28px * var(--font-scale)) var(--display); font-weight: 400; color: var(--red); }
.force-card p { margin: 0; }
.force-card .btn { width: 100%; padding: 12px 16px; font-size: calc(18px * var(--font-scale)); }
.update b { font-family: var(--display); font-weight: 400; }

/* ------------------------------------------------------------------ war screen */
#war { display: flex; flex-direction: column; }
.bar { flex: none; display: flex; gap: 8px; align-items: center; padding: 8px calc(10px + var(--safe-r)) 8px calc(10px + var(--safe-l)); }
.bar > * { min-width: 0; }
.bar.top { padding-top: calc(8px + var(--safe-t)); background: var(--paper-2); border-bottom: 3px solid var(--ink); }
.bar.bottom { padding-bottom: calc(10px + var(--safe-b)); background: var(--paper-2); border-top: 3px solid var(--ink); justify-content: center; }
.bar .title { flex: 1; display: flex; flex-direction: column; line-height: 1.1; overflow: hidden; }
.bar .title b { font: calc(19px * var(--font-scale)) var(--display); font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .title small { color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.big {
  flex: 1 1 0; max-width: 170px; min-height: 52px; padding: 4px 6px;
  font: calc(16px * var(--font-scale)) var(--display); text-transform: uppercase; letter-spacing: .5px;
}
.big span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.big.toggle.on { background: var(--ink); color: var(--ochre); }
#btn-pause .i-play { display: none; }
#btn-pause.paused .i-play { display: block; }
#btn-pause.paused .i-pause { display: none; }
#btn-pause.paused { background: var(--ochre); }

#stage-wrap { flex: 1; min-height: 0; position: relative; display: grid; place-items: center; overflow: hidden; }
#stage {
  display: block; background: var(--paper);
  border: 3px solid var(--ink); box-shadow: 6px 6px 0 var(--ink);
  touch-action: none;
}
#stage.panning { cursor: grabbing; }
@media (max-width: 560px) {
  #stage { border-width: 0; box-shadow: none; }
  .bar { gap: 6px; }
  .big { font-size: 13px; letter-spacing: 0; min-height: 50px; padding: 4px 2px; }
}

/* ------------------------------------------------------------------ sheets (dialogs) */
.sheet { position: fixed; inset: 0; background: rgba(42, 34, 29, .5); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.sheet-card {
  width: 100%; max-width: 600px; max-height: calc(92% - var(--safe-t)); display: flex; flex-direction: column;
  background: var(--paper); border: 3px solid var(--ink); border-bottom: 0; border-radius: 14px 14px 0 0;
  box-shadow: 0 -4px 0 var(--ink); padding-bottom: var(--safe-b);
  animation: rise .18s ease-out;
}
@keyframes rise { from { transform: translateY(40px); opacity: .4; } }
@media (min-width: 700px) and (min-height: 600px) {
  .sheet { align-items: center; }
  .sheet-card { border-bottom: 3px solid var(--ink); border-radius: 12px; box-shadow: 8px 8px 0 var(--ink); max-height: 88%; }
}
.sheet-card header { display: flex; align-items: center; gap: 10px; padding: 12px 12px 10px 18px; border-bottom: 2px dashed var(--ink-faint); }
.sheet-card header h2 { flex: 1; margin: 0; font: calc(22px * var(--font-scale)) var(--display); font-weight: 400; }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.sheet-body p { margin: 0; }
.sheet-body .actions { display: flex; gap: 10px; flex-wrap: wrap; }
.sheet-body .actions .btn { flex: 1 1 140px; min-height: 50px; }

.versus { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; }
.versus .vs { font: 26px var(--display); color: var(--red); text-shadow: 2px 2px 0 var(--ink); }
.slot {
  min-height: 62px; padding: 6px 8px; display: flex; align-items: center; gap: 8px; text-align: left;
  border: 3px dashed var(--ink-soft); border-radius: 8px; background: var(--paper-hi); overflow: hidden;
}
.slot.filled { border-style: solid; border-color: var(--ink); }
.slot.active { outline: 4px solid var(--ochre); outline-offset: 1px; }
.slot img { width: 40px; height: 27px; object-fit: cover; border: 2px solid var(--ink); border-radius: 3px; flex: none; }
.slot span { font: 16px/1.1 var(--display); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.slot em { font-style: normal; color: var(--ink-soft); }

.search { width: 100%; padding: 11px 12px; border: 3px solid var(--ink); border-radius: 8px; background: var(--paper-hi); outline: none; font-size: 17px; }
.search:focus { box-shadow: 0 0 0 3px var(--ochre); }

.list { flex: none; display: flex; flex-direction: column; border: 3px solid var(--ink); border-radius: 8px; background: var(--paper-hi); max-height: 42vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: none; border: 0; border-bottom: 1px solid var(--ink-faint); text-align: left; min-height: 48px; }
.row:last-child { border-bottom: 0; }
.row img { width: 40px; height: 27px; object-fit: cover; border: 2px solid var(--ink); border-radius: 3px; flex: none; }
.row .name { flex: 1; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row small { color: var(--ink-soft); white-space: nowrap; }
.row.on { background: rgba(214, 161, 59, .35); }
.row.dead .name { text-decoration: line-through; color: var(--ink-soft); }
.row:active { background: var(--paper-2); }
.empty { padding: 16px; color: var(--ink-soft); text-align: center; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 7px 11px; border: 2px solid var(--ink); border-radius: 20px; background: var(--paper-hi); font-size: 15px; }
.chip.on { background: var(--ink); color: var(--paper-hi); }
.chip.off { text-decoration: line-through; color: var(--ink-soft); background: var(--paper-2); }

.seg { display: flex; border: 3px solid var(--ink); border-radius: 8px; overflow: hidden; }
.seg button { flex: 1; border: 0; border-right: 2px solid var(--ink); background: var(--paper-hi); padding: 10px 4px; font: 15px var(--display); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--ink); color: var(--ochre); }

.tabs { display: flex; gap: 8px; }
.tabs button { flex: 1; padding: 10px; border: 3px solid var(--ink); border-radius: 8px; background: var(--paper-2); font: 16px var(--display); }
.tabs button.on { background: var(--red); color: var(--paper-hi); box-shadow: 3px 3px 0 var(--ink); }

.flag-grid { flex: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; max-height: 38vh; overflow-y: auto; padding: 2px 4px 6px 2px; }
.flag-grid button { padding: 4px 4px 6px; border: 2px solid var(--ink-faint); border-radius: 6px; background: var(--paper-hi); display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; line-height: 1.1; text-align: center; }
.flag-grid img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border: 2px solid var(--ink); border-radius: 3px; }
.flag-grid button.on { border-color: var(--red); background: rgba(201, 67, 42, .15); outline: 2px solid var(--red); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font: 15px var(--display); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0; }
.toggle-row b { font: 16px var(--display); font-weight: 400; }
.switch { width: 58px; height: 32px; border: 3px solid var(--ink); border-radius: 20px; background: var(--paper-2); position: relative; flex: none; padding: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: var(--paper-hi); border: 2px solid var(--ink); transition: left .12s; }
.switch.on { background: var(--red); }
.switch.on::after { left: 28px; }
.small { font-size: 14px; color: var(--ink-soft); }
hr { border: 0; border-top: 2px dashed var(--ink-faint); margin: 4px 0; width: 100%; }

/* ------------------------------------------------------------------ loading + toast */
.loading { position: fixed; inset: 0; display: grid; place-items: center; z-index: 20; background: var(--desk) radial-gradient(ellipse at 50% 40%, var(--desk-light) 0%, var(--desk) 55%, var(--desk-dark) 100%); color: var(--on-desk); }
.loading-card { text-align: center; width: min(86vw, 420px); }
.loading-card p { margin: 22px 0 10px; }
.progress { height: 16px; border: 3px solid var(--ink); border-radius: 10px; background: var(--paper-2); overflow: hidden; box-shadow: 3px 3px 0 var(--ink); }
.progress i { display: block; height: 100%; width: 0; background: var(--red); transition: width .15s; }

.toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%); z-index: 30;
  max-width: min(92vw, 520px); padding: 10px 16px; background: var(--ink); color: var(--paper-hi);
  border-radius: 8px; box-shadow: 4px 4px 0 rgba(42, 34, 29, .35); text-align: center; pointer-events: none;
}

.big.pulse { animation: pulse .7s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: scale(1.06) rotate(-1.5deg); box-shadow: 5px 5px 0 var(--ink); } }

/* recording */
#btn-camera { position: relative; }
.rec-dot { position: absolute; top: 5px; right: 5px; width: 11px; height: 11px; border-radius: 50%; background: var(--red); border: 2px solid var(--ink); animation: blink 1s steps(2) infinite; }
#btn-camera.on { background: var(--ink); color: var(--paper-hi); }
@keyframes blink { 50% { opacity: .25; } }
.video-chip {
  position: absolute; right: 14px; bottom: 14px; z-index: 5; display: flex; flex-direction: column; align-items: flex-start;
  padding: 9px 14px; background: var(--red); color: var(--paper-hi); border: 3px solid var(--ink); border-radius: 8px;
  box-shadow: 4px 4px 0 var(--ink); text-align: left; animation: rise .2s ease-out;
}
.video-chip b { font: 17px var(--display); font-weight: 400; }
.video-chip small { opacity: .85; }
.history { display: flex; flex-direction: column; gap: 0; border: 3px solid var(--ink); border-radius: 8px; background: var(--paper-hi); max-height: 56vh; overflow-y: auto; flex: none; }
.history div { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--ink-faint); }
.history img { width: 34px; height: 23px; object-fit: cover; border: 2px solid var(--ink); border-radius: 3px; flex: none; }
.history span { flex: 1; min-width: 0; }
.history small { color: var(--ink-soft); white-space: nowrap; }
.legal { display: flex; flex-direction: column; gap: 10px; font-family: Georgia, serif; line-height: 1.55; font-size: 16px; }
.legal p, .legal ul { margin: 0; }
.legal ul { padding-left: 22px; }
.legal li { margin: 3px 0; }
.legal .legal-sub { font-family: var(--body); color: var(--ink-soft); font-size: 14px; }
.legal-summary { padding: 12px 14px 10px; background: var(--paper-hi); border: 3px dashed var(--ink); border-radius: 8px; }
.legal-summary b { font: 17px var(--display); font-weight: 400; }
.legal-summary ul { margin-top: 6px; }
.legal h3 { font: 18px/1.2 var(--display); font-weight: 400; margin: 12px 0 0; display: flex; gap: 9px; align-items: center; }
.legal h3 span { display: inline-grid; place-items: center; min-width: 28px; height: 28px; padding: 0 5px; background: var(--ink); color: var(--ochre); border-radius: 6px; font-size: 15px; }

/* choice cards (auto sheet) */
.choice { display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 14px 16px; border: 3px solid var(--ink); border-radius: 10px; background: var(--paper-hi); box-shadow: 4px 4px 0 var(--ink); }
.choice b { font: 21px var(--display); font-weight: 400; }
.choice small { color: var(--ink-soft); font-size: 15px; }
.choice.hot { background: var(--red); color: var(--paper-hi); }
.choice.hot small { color: rgba(250, 244, 230, .85); }
.choice:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }

/* Look settings */
.looks { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.look { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 9px 6px; border: 3px solid var(--ink-faint); border-radius: 10px; background: var(--paper-hi); font-size: 15px; }
.look.on { border-color: var(--ink); box-shadow: 3px 3px 0 var(--ink); }
.look .sw { display: flex; width: 54px; height: 26px; border: 2px solid var(--ink); border-radius: 6px; overflow: hidden; }
.look .sw i { flex: 1; }
.look .fname { font-size: 20px; line-height: 1.1; }
