* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; background: #07050f; color: #fff3dc;
  font-family: 'Fredoka', 'Trebuchet MS', sans-serif;
  overflow: hidden; user-select: none; -webkit-user-select: none; touch-action: none;
}
body { display: flex; align-items: center; justify-content: center; }
#wrap { width: min(100vw, calc(100vh * 16 / 9)); container-type: inline-size; position: relative; }
#stage { position: relative; width: 100%; aspect-ratio: 16 / 9; overflow: hidden; background: #000; cursor: none; box-shadow: 0 0 80px #000; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; }
#overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }

/* ---------- HUD buttons ---------- */
.hudbtn {
  position: absolute; z-index: 4; border: none; cursor: pointer; padding: 0; font-family: inherit;
  background: radial-gradient(circle at 40% 35%, #ffd765, #e88a2a 60%, #a8501c);
  border-radius: 50%; box-shadow: 0 0.3cqw 0 #5a2410, 0 0.5cqw 1.2cqw rgba(0,0,0,0.5);
  width: 6cqw; height: 6cqw; transition: transform 0.12s;
}
.hudbtn:hover { transform: scale(1.1) rotate(-6deg); }
.hudbtn:active { transform: scale(0.95); }
#bagBtn { left: 1.4cqw; bottom: 1.4cqw; }
#hintBtn { left: 8.4cqw; bottom: 1.4cqw; background: radial-gradient(circle at 40% 35%, #ff9a7a, #d8402a 60%, #8a1c10); }
#bagBtn.flash { animation: bagflash 0.9s ease-out; }
@keyframes bagflash { 0% { transform: scale(1.35); box-shadow: 0 0 3cqw #ffe9a0; } 100% { transform: scale(1); } }
.bagicon, .pepicon { display: block; width: 100%; height: 100%; background-size: 70%; background-position: center; background-repeat: no-repeat; }
.bagicon { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cpath d='M14 12 q6 -8 12 0' fill='none' stroke='%233a1408' stroke-width='3'/%3E%3Crect x='6' y='12' width='28' height='22' rx='4' fill='%23c8302a' stroke='%233a1408' stroke-width='2.5'/%3E%3Crect x='6' y='18' width='28' height='4' fill='%23f2c14e'/%3E%3Ccircle cx='20' cy='27' r='4' fill='%23ffd765' stroke='%233a1408' stroke-width='1.5'/%3E%3C/svg%3E"); }
.pepicon { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cpath d='M6 9 Q20 3 34 9 L20 36 Z' fill='%23ffd765' stroke='%233a1408' stroke-width='2.5' stroke-linejoin='round'/%3E%3Cpath d='M5 8 Q20 1 35 8 L33 12 Q20 6 7 12 Z' fill='%23d8913c' stroke='%233a1408' stroke-width='2'/%3E%3Ccircle cx='15' cy='16' r='3.2' fill='white' stroke='%233a1408' stroke-width='1.2'/%3E%3Ccircle cx='24' cy='16' r='3.2' fill='white' stroke='%233a1408' stroke-width='1.2'/%3E%3Ccircle cx='15.6' cy='16.5' r='1.4' fill='%23111'/%3E%3Ccircle cx='24.6' cy='16.5' r='1.4' fill='%23111'/%3E%3Cpath d='M16 22 Q20 26 24 22' fill='none' stroke='%233a1408' stroke-width='1.8' stroke-linecap='round'/%3E%3Ccircle cx='21' cy='29' r='2.5' fill='%23c4402a'/%3E%3Ccircle cx='11' cy='12' r='2' fill='%23c4402a'/%3E%3C/svg%3E"); }
#topBtns { position: absolute; top: 1.2cqw; right: 1.2cqw; z-index: 4; display: flex; gap: 0.8cqw; }
#topBtns .hudbtn { position: static; width: 3.6cqw; height: 3.6cqw; font-size: 1.9cqw; color: #3a1408; background: radial-gradient(circle at 40% 35%, #fff1c8, #e8c07a); box-shadow: 0 0.25cqw 0 #6a3a14; }
body.busy .hudbtn { opacity: 0.35; pointer-events: none; }
body.title .hudbtn, body.title #topBtns { display: none; }

/* ---------- pizza bag ---------- */
#bag {
  position: absolute; left: 50%; bottom: 2cqw; transform: translateX(-50%); z-index: 5; width: 76%;
  background: linear-gradient(#d23a30, #a8241e); border-radius: 2.2cqw; padding: 0.8cqw 1.2cqw 1cqw;
  box-shadow: 0 0 0 0.35cqw #3a1408, 0 1cqw 3cqw rgba(0,0,0,0.6), inset 0 0.4cqw 0 rgba(255,255,255,0.25);
  cursor: default; animation: bagopen 0.16s ease-out;
}
@keyframes bagopen { from { transform: translateX(-50%) translateY(3cqw) scale(0.92); opacity: 0; } }
.bagtop { display: flex; justify-content: space-between; align-items: center; color: #ffe9b0; font-weight: 700; font-size: 1.6cqw; padding: 0 0.4cqw 0.5cqw; letter-spacing: 0.05cqw; }
.bagtitle { text-shadow: 0 0.15cqw 0 #5a1008; }
#bagClose { background: none; border: none; color: #ffe9b0; font-size: 2.4cqw; cursor: pointer; line-height: 1; }
.bagbody { position: relative; display: flex; gap: 0.6cqw; align-items: center; background: #f2c14e; border-radius: 1.4cqw; padding: 0.8cqw; box-shadow: inset 0 0.3cqw 0.6cqw rgba(90,40,10,0.45); }
#bagGrid { flex: 1; display: grid; grid-template-columns: repeat(8, 1fr); gap: 0.6cqw; }
.slot { position: relative; aspect-ratio: 1; background: #fff4d6; border-radius: 1cqw; box-shadow: inset 0 -0.3cqw 0 #e8c88a, 0 0.15cqw 0 #b8782a; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.slot:empty { background: rgba(255,244,214,0.45); box-shadow: inset 0 0.2cqw 0.4cqw rgba(120,60,10,0.25); cursor: default; }
.slot canvas { width: 84%; height: 84%; }
.slot span { position: absolute; bottom: 104%; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 1.25cqw; font-weight: 600; color: #fff; background: #2a1020; padding: 0.15cqw 0.6cqw; border-radius: 0.6cqw; opacity: 0; pointer-events: none; transition: opacity 0.1s; z-index: 2; }
.slot:hover { transform: translateY(-0.2cqw); background: #fffbe8; }
.slot:hover span { opacity: 1; }
.arrow { position: relative; background: #fff4d6; border: 0.25cqw solid #3a1408; border-radius: 50%; color: #a8241e; font-size: 1.6cqw; cursor: pointer; width: 3.4cqw; height: 3.4cqw; flex: none; box-shadow: 0 0.2cqw 0 #3a1408; }
.arrow:hover { background: #fffbe8; transform: translateY(-0.1cqw); }
.arrow.off { visibility: hidden; }
.arrow[data-more]:not([data-more=""])::after { content: attr(data-more); position: absolute; top: -1.2cqw; left: 50%; transform: translateX(-50%); background: #ffd24a; color: #3a1408; font-size: 1.05cqw; font-weight: 700; padding: 0.05cqw 0.45cqw; border-radius: 0.8cqw; border: 0.15cqw solid #3a1408; white-space: nowrap; }
.slot.new { box-shadow: 0 0 0 0.3cqw #ffd24a, 0 0 1.4cqw #ffcf3a; animation: newitem 1.1s ease-in-out infinite alternate; }
@keyframes newitem { from { box-shadow: 0 0 0 0.25cqw #ffd24a, 0 0 0.6cqw #ffcf3a; } to { box-shadow: 0 0 0 0.35cqw #ffe27a, 0 0 1.8cqw #ffcf3a; } }
#bagEmpty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #8a4a1a; font-size: 1.8cqw; font-weight: 600; }
.baghint { text-align: center; color: #ffd8b0; font-size: 1.15cqw; margin-top: 0.5cqw; }

/* ---------- dialogue ---------- */
#dialog {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; padding: 1.2cqw 3cqw 1.6cqw;
  background: linear-gradient(rgba(14,8,28,0), rgba(14,8,28,0.88) 18%, rgba(14,8,28,0.95));
  display: flex; flex-direction: column; gap: 0.15cqw; cursor: default;
}
#dialog .dtitle { color: #ffd24a; font-family: 'Bangers', sans-serif; font-size: 2.4cqw; letter-spacing: 0.1cqw; margin-bottom: 0.3cqw; }
#dialog button {
  font-family: inherit; font-size: 1.9cqw; font-weight: 600; text-align: left; color: #b8a8ff; background: none; border: none;
  padding: 0.2cqw 0.8cqw; border-radius: 0.8cqw; cursor: pointer; line-height: 1.2; text-shadow: 0 0.15cqw 0 #000;
}
#dialog button:hover { color: #fff3a8; background: rgba(255,255,255,0.07); }
#dialog button::before { content: '\25B8  '; color: #6a5aa8; }
#dialog button:hover::before { color: #ffd24a; }
#dialog button.truth { color: #ffb0c8; }
#dialog button.dim { color: #7a7090; }
.hidden { display: none !important; }

/* ---------- screens ---------- */
.screen { position: absolute; inset: 0; z-index: 6; display: flex; align-items: center; justify-content: center; cursor: default; }
#title { background: radial-gradient(ellipse at 50% 45%, rgba(10,6,30,0), rgba(5,3,15,0.5)); }
.title-inner { text-align: center; margin-top: -4cqw; }
.logo { display: flex; flex-direction: column; align-items: center; transform: rotate(-3deg); }
.logo .l1 {
  font-family: 'Bangers', sans-serif; font-size: 10cqw; color: #ffd24a; letter-spacing: 0.4cqw; line-height: 0.95;
  -webkit-text-stroke: 0.35cqw #3a0f4a; text-shadow: 0 0.8cqw 0 #c8302a, 0 1.3cqw 0 #3a0f4a, 0 0 4cqw rgba(255,160,60,0.6);
  animation: wobble 3.2s ease-in-out infinite;
}
.logo .l2 { font-family: 'Bangers', sans-serif; font-size: 3.6cqw; color: #8ff0ff; letter-spacing: 0.25cqw; -webkit-text-stroke: 0.18cqw #1a0a3a; text-shadow: 0 0.4cqw 0 #1a0a3a; margin-top: 1.2cqw; }
@keyframes wobble { 0%,100% { transform: rotate(0deg) scale(1); } 50% { transform: rotate(1.5deg) scale(1.03); } }
.menu { margin-top: 3.4cqw; display: flex; flex-direction: column; gap: 0.9cqw; align-items: center; }
.screen button { font-family: inherit; cursor: pointer; }
.menu button, .panel-inner > button:not(.mode) {
  font-size: 2.6cqw; font-weight: 600; color: #3a1408; padding: 0.5cqw 3cqw; border: none; border-radius: 3cqw;
  background: linear-gradient(#ffe38a, #f2a83a); box-shadow: 0 0.4cqw 0 #8a4a14, 0 0.6cqw 1.4cqw rgba(0,0,0,0.4); min-width: 22cqw;
}
.menu button:hover, .panel-inner > button:not(.mode):hover { transform: translateY(-0.2cqw) scale(1.04); background: linear-gradient(#fff2b8, #ffbb4a); }
.screen button:disabled { opacity: 0.35; pointer-events: none; }
#how, #menu, #modes { background: rgba(8, 4, 20, 0.84); }
.panel-inner {
  width: 72%; background: linear-gradient(#2e1e58, #1c1238); border: 0.35cqw solid #ffd24a; border-radius: 2.4cqw;
  padding: 2.2cqw 3.6cqw; font-size: 1.85cqw; line-height: 1.4; color: #efe6ff; box-shadow: 0 1cqw 4cqw rgba(0,0,0,0.6);
  display: flex; flex-direction: column; align-items: center; gap: 0.6cqw;
}
.panel-inner.small { width: 40%; }
.panel-inner.how { align-items: stretch; }
.panel-inner h2 { margin: 0 0 0.6cqw; color: #ffd24a; font-family: 'Bangers', sans-serif; font-weight: 400; font-size: 4cqw; letter-spacing: 0.2cqw; text-align: center; }
.panel-inner p { margin: 0.3cqw 0; }
.panel-inner b { color: #ffd24a; }
.panel-inner .back { align-self: center; margin-top: 1cqw; }
.mode { width: 100%; text-align: left; background: rgba(255,255,255,0.06); border: 0.25cqw solid #6a5aa8; border-radius: 1.6cqw; padding: 1cqw 1.8cqw; color: #efe6ff; display: flex; flex-direction: column; gap: 0.2cqw; }
.mode b { font-family: 'Bangers', sans-serif; font-weight: 400; font-size: 3cqw; letter-spacing: 0.15cqw; color: #ffd24a; }
.mode span { font-size: 1.8cqw; }
.mode:hover { border-color: #ffd24a; background: rgba(255,210,74,0.12); }
.credits-inner { text-align: center; }
/* the end credits sit over the painted issue #48 cover, slowly drifting */
#credits { background: #0b0716; overflow: hidden; }
#credits::before { content: ''; position: absolute; inset: -4%; background: url('../assets/comic/f3.webp') center / cover no-repeat; filter: brightness(0.42) saturate(1.1); animation: credDrift 30s ease-in-out infinite alternate; }
#credits .credits-inner { position: relative; background: rgba(12, 6, 28, 0.72); }
@keyframes credDrift { from { transform: scale(1.02) translate(-1%, 0); } to { transform: scale(1.08) translate(1%, -1%); } }
.credits-inner .ct { color: #ffd24a; font-size: 2.2cqw; }
#book { background: rgba(8,4,20,0.86); z-index: 7; }
.panel-inner.book { width: 86%; max-height: 92%; align-items: stretch; }
.bookhint { text-align: center; color: #b8a8e8; font-size: 1.5cqw; }
#bookList { overflow-y: auto; max-height: 34cqw; display: flex; flex-direction: column; gap: 0.4cqw; padding-right: 0.5cqw; }
.bookrow { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2cqw; background: rgba(255,255,255,0.06); border-radius: 0.8cqw; padding: 0.5cqw 1cqw; font-size: 1.55cqw; line-height: 1.3; }
.bookrow .bb { color: #8ff0ff; }
.bookrow .cb { color: #ffd24a; }
.bookrow.truth .bb, .bookrow.truth .cb { color: #ffb0c8; }
.book .empty { text-align: center; color: #b8a8e8; }

/* ---------- loading: a bar on the title until the home world is in; a card when travelling somewhere not yet loaded */
#titleLoad { display: none; margin-top: 3cqw; width: 30cqw; margin-left: auto; margin-right: auto; }
body.loading #titleLoad { display: block; }
body.loading .title-inner .menu { display: none; }
.tl-label { font-size: 1.7cqw; color: #fff3dc; text-shadow: 0 0.2cqw 0 #1a0a3a; margin-bottom: 0.8cqw; }
.tl-bar, #loadcard .lc-bar { height: 1.3cqw; border-radius: 1cqw; background: rgba(26,10,58,0.75); border: 0.2cqw solid #ffd24a; overflow: hidden; }
#titleLoadFill, #loadcard .lc-fill { height: 100%; width: 0; background: linear-gradient(90deg, #ff9a3c, #ffd24a); transition: width 0.25s; }
#loadcard { position: absolute; inset: 0; z-index: 15; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.4cqw;
  background: radial-gradient(ellipse at 50% 50%, #2a1050, #07041a); opacity: 0; pointer-events: none; transition: opacity 0.25s; }
#loadcard.on { opacity: 1; pointer-events: auto; }
#loadcard .lc-title { font-family: 'Bangers', sans-serif; font-size: 3.6cqw; letter-spacing: 0.15cqw; color: #ffd24a; text-shadow: 0 0.3cqw 0 #1a0a3a; }
#loadcard .lc-bar { width: 34cqw; }
#loadcard .lc-tip { font-size: 1.5cqw; color: #cfe9ff; max-width: 50cqw; text-align: center; }

/* ---------- comic restyle: HUD badges with painted icons, and the choice menu as a comic panel */
#bagBtn, #hintBtn { width: 6.4cqw; height: 6.4cqw; background: #fff3dc; border: 0.32cqw solid #1d1028; border-radius: 50%;
  box-shadow: 0.35cqw 0.35cqw 0 #1d1028; overflow: visible; }
#bagBtn { left: 1.4cqw; bottom: 2.6cqw; background: radial-gradient(circle at 40% 35%, #fff8e6, #ffd9a0); }
#hintBtn { left: 9cqw; bottom: 2.6cqw; background: radial-gradient(circle at 40% 35%, #fff8e6, #ffc7a8); }
#bagBtn .bagicon, #hintBtn .pepicon { background-size: contain; background-position: center 55%; width: 78%; height: 78%; margin: 11%; }
#bagBtn .bagicon { background-image: url('../assets/ui/bag.webp'); }
#hintBtn .pepicon { background-image: url('../assets/ui/pep.webp'); background-position: center 40%; width: 86%; height: 86%; margin: 7%; }
#bagBtn::after, #hintBtn::after { position: absolute; left: 50%; bottom: -2.1cqw; transform: translateX(-50%); font-family: 'Bangers', sans-serif; font-size: 1.6cqw;
  letter-spacing: 0.1cqw; color: #ffd24a; -webkit-text-stroke: 0.25cqw #1d1028; paint-order: stroke fill; pointer-events: none; }
#bagBtn::after { content: 'BAG'; }
#hintBtn::after { content: 'HINT'; }
#bagBtn:hover, #hintBtn:hover { transform: scale(1.08) rotate(-4deg); }

#dialog { left: 17cqw; right: 2cqw; bottom: 1.6cqw; padding: 1cqw 1.8cqw 1.2cqw; background: #fff8e6; border: 0.35cqw solid #1d1028;
  border-radius: 1.2cqw; box-shadow: 0.5cqw 0.5cqw 0 rgba(29,16,40,0.9); gap: 0.1cqw; animation: dlgpop 0.22s cubic-bezier(.2,1.5,.4,1); }
@keyframes dlgpop { from { opacity: 0; transform: translateY(1.2cqw) scale(0.97); } }
#dialog .dtitle { color: #e8463a; -webkit-text-stroke: 0; text-shadow: none; }
#dialog button { color: #1d1028; text-shadow: none; padding: 0.3cqw 1cqw; border-radius: 0.6cqw; }
#dialog button::before { content: '\25B6  '; color: #e8463a; font-size: 0.8em; }
#dialog button:hover { color: #1d1028; background: #ffd24a; }
#dialog button:hover::before { color: #1d1028; }
#dialog button.truth { color: #c2185b; }
#dialog button.dim { color: #8a7f99; }
