/* Paperika engine overlays. The game fills whatever element it is mounted in. */
.pe-root {
  --pe-ink: #2a3a8f;
  --pe-paper: #fcfaf4;
  --pe-hand: "Chalkboard SE", "Comic Sans MS", "Comic Neue", system-ui, sans-serif;
  position: relative; overflow: hidden; background: #efe9dd;
  font-family: var(--pe-hand); user-select: none; -webkit-user-select: none;
}
.pe-canvas { display: block; width: 100%; height: 100%; touch-action: manipulation; }

.pe-tag {
  position: absolute; z-index: 5; pointer-events: none;
  font: 600 16px/1.2 var(--pe-hand); color: var(--pe-ink);
  background: var(--pe-paper); padding: 7px 12px; border-radius: 10px;
  box-shadow: 0 3px 0 rgba(42,58,143,.15), 0 6px 14px rgba(40,30,20,.18);
  transform: translate(-50%, -100%) rotate(-1.5deg); white-space: nowrap;
  transition: opacity .2s; opacity: 0;
}
.pe-tag.show { opacity: 1; }
.pe-tag kbd {
  font: 700 13px/1 var(--pe-hand); color: var(--pe-paper); background: var(--pe-ink);
  border-radius: 6px; padding: 3px 7px; margin-right: 6px;
}
.pe-bubble { font-size: 20px; transform: translate(-50%, -100%) rotate(2deg); }

.pe-hint {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 4;
  font: 15px/1.4 var(--pe-hand); color: #6d6457; background: rgba(252,250,244,.88);
  padding: 6px 14px; border-radius: 999px; pointer-events: none; transition: opacity .8s;
  box-shadow: 0 2px 8px rgba(40,30,20,.12); white-space: nowrap; max-width: calc(100% - 32px);
  overflow: hidden; text-overflow: ellipsis;
}

.pe-hearts {
  position: absolute; top: 12px; left: 14px; z-index: 6; display: none; gap: 4px;
  background: var(--pe-paper); padding: 6px 12px; border-radius: 12px; transform: rotate(-1.5deg);
  box-shadow: 0 6px 16px rgba(40,30,20,.2); font: 26px/1 var(--pe-hand);
}
.pe-hearts.show { display: flex; }
.pe-hearts span { color: #e0405a; text-shadow: 0 2px 0 rgba(120,20,40,.25); transition: color .3s, transform .3s; }
.pe-hearts span.lost { color: #d8d0c4; text-shadow: none; transform: scale(.8); }

.pe-msg {
  position: absolute; top: 12px; right: 14px; z-index: 7; max-width: 60%; display: none;
  background: #fff4d6; color: #6b4a00; padding: 8px 12px; border-radius: 10px; font-size: 14px;
  box-shadow: 0 4px 12px rgba(40,30,20,.18);
}
.pe-msg.show { display: block; }

/* a picture to look at closely (a letter, a map…) */
.pe-show, .pe-card {
  position: absolute; inset: 0; z-index: 10; display: grid; place-items: center; padding: 16px;
  background: rgba(40, 32, 24, .45); opacity: 0; pointer-events: none; transition: opacity .3s; box-sizing: border-box;
}
.pe-show.open, .pe-card.open { opacity: 1; pointer-events: auto; }
.pe-show .sheet {
  position: relative; background: #faf8f2; padding: 4.5% 4% 6%;
  width: min(560px, 86%, 62vh); box-sizing: border-box;
  box-shadow: 0 2px 0 #e8e2d4, 0 24px 60px rgba(20,14,8,.45); transform-origin: 50% 0%;
  transform: perspective(1100px) rotateX(78deg) scale(.35) rotate(-10deg);
  transition: transform .55s cubic-bezier(.2,.9,.25,1.15);
}
.pe-show.open .sheet { transform: perspective(1100px) rotateX(0) scale(1) rotate(-1.2deg); }
.pe-show .sheet img { display: block; width: 100%; height: auto; max-height: 70vh; object-fit: contain; }
.pe-show .close {
  position: absolute; top: -14px; right: -14px; width: 44px; height: 44px; border-radius: 50%;
  border: 0; background: var(--pe-ink); color: #fff; font: 700 22px/44px var(--pe-hand); cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,.3);
}
.pe-show .tip { position: absolute; left: 0; right: 0; bottom: 8px; text-align: center; font-size: 14px; color: #9a907f; }

.pe-card .sheet {
  background: #faf8f2; padding: 28px 34px 26px; border-radius: 4px; text-align: center; max-width: 420px;
  box-shadow: 0 24px 60px rgba(20,14,8,.45); transform: rotate(-1.5deg) scale(.8); transition: transform .4s cubic-bezier(.2,.9,.25,1.2);
  color: var(--pe-ink);
}
.pe-card.open .sheet { transform: rotate(-1.5deg) scale(1); }
.pe-card h2 { margin: 0 0 8px; font-size: 30px; }
.pe-card p { margin: 0 0 20px; font-size: 18px; color: #5a5470; line-height: 1.4; }
.pe-card button {
  font: 700 18px var(--pe-hand); color: #fff; background: var(--pe-ink); border: 0; border-radius: 999px;
  padding: 10px 22px; cursor: pointer; box-shadow: 0 4px 0 rgba(0,0,0,.2);
}
.pe-root button:focus-visible { outline: 3px solid #f5c84c; outline-offset: 2px; }

/* arcade worlds: score, timer and team; on-screen controls for touch screens */
.pe-hud { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 6; display: none; gap: 8px; }
.pe-hud.show { display: flex; }
.pe-hud span { background: var(--pe-paper); color: var(--pe-ink); font: 700 20px/1 var(--pe-hand); padding: 7px 12px; border-radius: 12px; box-shadow: 0 6px 16px rgba(40,30,20,.2); white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.pe-hud .team img { height: 26px; width: auto; }
.pe-pad { position: absolute; inset: auto 0 12px 0; z-index: 7; display: none; justify-content: space-between; align-items: flex-end; padding: 0 14px; pointer-events: none; }
.pe-pad.show { display: flex; }
.pe-padl, .pe-padr { display: flex; gap: 8px; align-items: flex-end; }
.pe-pad button { pointer-events: auto; width: 58px; height: 58px; border-radius: 50%; border: 0; background: rgba(252,250,244,.72); color: var(--pe-ink); font-size: 22px; box-shadow: 0 4px 12px rgba(40,30,20,.18); touch-action: none; user-select: none; -webkit-user-select: none; backdrop-filter: blur(2px); }
.pe-pad .jump, .pe-pad .act, .pe-pad .extra { width: 70px; height: 70px; font-size: 15px; font-weight: 700; }
.pe-pad .jump { background: rgba(252,250,244,.85); }
.pe-pad .act { background: var(--pe-ink); color: #fff; }
.pe-pad .extra { width: 60px; height: 60px; font-size: 13px; background: #f0b44c; color: #2a1f08; }
.pe-pad button[hidden] { display: none; }
.pe-extra { display: flex; gap: 8px; }
.pe-pad.show ~ .pe-hint { display: none; }
.pe-card button[hidden] { display: none; }
.pe-card .b2 { background: #fff; color: var(--pe-ink); box-shadow: 0 4px 0 rgba(0,0,0,.12), inset 0 0 0 2px var(--pe-ink); margin-left: 6px; }
.pe-card .choices { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.pe-card .choices:empty { display: none; }
/* a battle: the choices sit low, under the paper stage, and the stage stays visible */
.pe-card.low { place-items: end center; background: transparent; }
.pe-card.low .sheet { padding: 12px 18px 14px; transform: none; }
.pe-card.low h2 { font-size: 20px; margin-bottom: 2px; }
.pe-card.low p { margin-bottom: 8px; font-size: 16px; }
.pe-card.low .choices { flex-direction: row; flex-wrap: wrap; justify-content: center; }
.pe-hud .bag { pointer-events: auto; }
.pe-hud .bag button { border: 0; background: none; padding: 0 2px; cursor: pointer; }
/* a fight: each fighter's name, health and rounds won, in their colour; the time in the middle */
.pe-hud:has(.pe-fbar) { left: 12px; right: 12px; transform: none; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: nowrap; }
.pe-hud .pe-fbar { display: grid; white-space: normal; font: inherit; align-items: stretch; grid-template-columns: 1fr; gap: 3px; flex: 1 1 0; max-width: 42%; background: rgba(252,250,244,.92); border-radius: 10px; padding: 6px 10px 7px; box-shadow: 0 2px 8px rgba(40,30,20,.15); position: relative; }
.pe-hud .pe-fbar b { font: 700 15px "Chalkboard SE", "Comic Sans MS", system-ui, sans-serif; color: var(--c); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pe-hud .pe-fbar i { display: block; height: 12px; border-radius: 6px; background: var(--c); box-shadow: inset 0 0 0 2px rgba(255,255,255,.5); transition: width .25s; min-width: 0; }
.pe-hud .pe-fbar s { display: block; height: 12px; border-radius: 6px; background: rgba(0,0,0,.09); text-decoration: none; overflow: hidden; }
.pe-hud .pe-fbar em { font-style: normal; color: var(--c); font-size: 13px; letter-spacing: 2px; }
.pe-hud .pe-fbar u { text-decoration: none; font: 700 12px system-ui, sans-serif; color: #8a5a00; background: #ffe7a3; border-radius: 6px; padding: 1px 6px; justify-self: start; }
.pe-hud .pe-fbar:last-child { text-align: right; } .pe-hud .pe-fbar:last-child i { margin-left: auto; } .pe-hud .pe-fbar:last-child u { justify-self: end; }
.pe-hud .pe-ftime { font: 700 26px "Chalkboard SE", "Comic Sans MS", system-ui, sans-serif; color: #2a3a8f; background: rgba(252,250,244,.92); border-radius: 10px; padding: 4px 12px; box-shadow: 0 2px 8px rgba(40,30,20,.15); }
/* a fight on a tablet: each child's buttons on their own side, in their colour. A direction pad (▲ jumps, ▼ ducks)
   and A B C D like a game controller, each showing the move it does for this drawing. See-through until touched. */
.pe-fpad { position: absolute; inset: auto 0 10px 0; z-index: 7; display: none; justify-content: space-between; align-items: flex-end; padding: 0 12px; pointer-events: none; }
.pe-fpad.show { display: flex; }
.pe-fside { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; opacity: .45; transition: opacity .15s; }
.pe-fside:has(button.on) { opacity: .8; }
.pe-fside[data-side=right] { align-items: flex-end; }
.pe-fside .who { pointer-events: none; font: 700 13px "Chalkboard SE", "Comic Sans MS", system-ui, sans-serif; color: #fff; background: var(--c); border-radius: 999px; padding: 2px 10px; }
.pe-fside .grp { display: flex; gap: 18px; align-items: flex-end; }
.pe-fside button { pointer-events: auto; border-radius: 50%; border: 2px solid var(--c); background: rgba(252,250,244,.35); color: var(--c); padding: 0;
  font: 700 20px system-ui, sans-serif; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; display: grid; place-items: center; line-height: 1; }
.pe-fside button.on { transform: scale(.92); background: color-mix(in srgb, var(--c) 30%, transparent); }
/* the direction pad: a cross */
.pe-fside .mv { display: grid; grid-template-columns: repeat(3, 52px); grid-template-rows: repeat(3, 52px); }
.pe-fside .mv button { width: 52px; height: 52px; font-size: 18px; }
.pe-fside .mv .u { grid-area: 1 / 2; } .pe-fside .mv .l { grid-area: 2 / 1; } .pe-fside .mv .r { grid-area: 2 / 3; } .pe-fside .mv .d { grid-area: 3 / 2; }
/* A B C D: a diamond, A at the bottom (the quick hit, under the thumb) */
.pe-fside .ac { display: grid; grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(3, 56px); }
.pe-fside .ac button { width: 60px; height: 60px; justify-self: center; align-self: center; }
.pe-fside .ac .c { grid-area: 1 / 2; } .pe-fside .ac .d { grid-area: 2 / 1; } .pe-fside .ac .b { grid-area: 2 / 3; } .pe-fside .ac .a { grid-area: 3 / 2; width: 64px; height: 64px; background: color-mix(in srgb, var(--c) 35%, transparent); color: #fff; }
.pe-fside .ac b { font-size: 20px; } .pe-fside .ac small { font: 600 9px system-ui, sans-serif; max-width: 56px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: -10px; }
.pe-fpad.show ~ .pe-hint { display: none; }
@media (max-height: 420px) { .pe-fside .mv { grid-template-columns: repeat(3, 44px); grid-template-rows: repeat(3, 44px); } .pe-fside .mv button { width: 44px; height: 44px; } .pe-fside .ac { grid-template-columns: repeat(3, 48px); grid-template-rows: repeat(3, 48px); } .pe-fside .ac button { width: 50px; height: 50px; } .pe-fside .ac .a { width: 54px; height: 54px; } }
