* { box-sizing: border-box; margin: 0; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #2a2118; overscroll-behavior: none; }
body { font-family: "Marker Felt", "Chalkboard SE", "Comic Sans MS", system-ui, sans-serif; color: #2b2118; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none; }
:root { --l: max(10px, env(safe-area-inset-left)); --r: max(10px, env(safe-area-inset-right)); --b: max(8px, env(safe-area-inset-bottom)); }
#cv { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
img { pointer-events: none; }

/* la peau carton */
.paper { background: #f2ece0; border: 2.5px solid #2b2118; border-radius: 5px; box-shadow: 2px 3px 0 #0007; }
.btn { width: 46px; height: 46px; padding: 0; display: grid; place-items: center; }
.btn img { width: 34px; height: 34px; object-fit: contain; }
.btn:active, .ob:active, .pc:active, .gcard:active, .add:active { transform: translateY(2px); box-shadow: 1px 1px 0 #0007; }

#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > * { position: absolute; pointer-events: auto; }
.mini { left: var(--l); top: 8px; width: 150px; height: 98px; padding: 0; overflow: hidden; }
#mm { width: 100%; height: 100%; display: block; touch-action: none; }
#menu { left: calc(var(--l) + 158px); top: 8px; width: 38px; height: 38px; }
#menu img { width: 26px; height: 26px; }
#res { left: 50%; top: 6px; transform: translateX(-50%) rotate(-1deg); display: flex; gap: 14px; align-items: center; padding: 2px 14px; background: #fff7cfe6; box-shadow: 1px 2px 0 #0005; pointer-events: none !important; white-space: nowrap; }
#res span { display: flex; align-items: center; gap: 3px; font-size: 16px; }
#res img { width: 22px; height: 22px; object-fit: contain; }
#res .full { color: #c8372d; }
#res .clock { font-size: 13px; opacity: .7; }

#groups { right: var(--r); top: 8px; display: flex; flex-direction: column; gap: 5px; }
.grp { display: flex; gap: 3px; height: 40px; }
.grp .add { width: 20px; padding: 0; font-weight: 900; font-size: 16px; }
.gcard { width: 48px; padding: 0; position: relative; overflow: hidden; }
.gcard .pic { position: absolute; inset: 2px 4px 2px; width: calc(100% - 8px); height: calc(100% - 4px); object-fit: contain; }
.gcard i { position: absolute; left: 3px; top: 1px; font: 900 9px/1 system-ui, sans-serif; font-style: normal; }
.gcard b { position: absolute; right: 3px; bottom: 0; font-size: 14px; color: #fff; -webkit-text-stroke: 3px #2b2118; paint-order: stroke; }
.gcard.empty { background: #f2ece070; border-style: dashed; }

#left { left: var(--l); bottom: var(--b); display: flex; flex-direction: column; gap: 7px; }
#left .btn:nth-child(2) { transform: rotate(-2deg); }

#bottom { left: calc(var(--l) + 58px); right: calc(var(--r) + 116px); bottom: var(--b); display: flex; align-items: flex-end; gap: 6px; pointer-events: none !important; }
#bottom > * { pointer-events: auto; }
.cards { display: flex; gap: 5px; }
.pc { width: 76px; height: 94px; padding: 0; position: relative; overflow: hidden; }
.pc:nth-child(odd) { transform: rotate(-1.5deg); }
.pc:nth-child(even) { transform: rotate(1deg); }
.pc .nm { position: absolute; left: 0; right: 0; top: 2px; text-align: center; font-size: 11px; white-space: nowrap; overflow: hidden; }
.pc .pic { position: absolute; left: 6px; right: 6px; top: 17px; height: 52px; width: calc(100% - 12px); object-fit: contain; }
.pc .cost { position: absolute; left: 0; right: 0; bottom: 2px; display: flex; justify-content: center; align-items: center; gap: 1px; font-size: 12px; }
.pc .cost img { width: 14px; height: 14px; object-fit: contain; }
.pc .q { position: absolute; left: 3px; top: 16px; background: #2b2118; color: #f2ece0; font-size: 11px; padding: 0 4px; border-radius: 3px; }
.pc .bar { position: absolute; left: 0; right: 0; bottom: 19px; height: 5px; background: #2b211833; }
.pc .bar i { display: block; height: 100%; background: #5fbf4a; }
.pc.off { filter: grayscale(1); opacity: .6; }
.info { padding: 4px 10px; display: flex; flex-direction: column; font-size: 13px; min-width: 110px; }
.info b { font-size: 15px; }
.info.enemy { background: #ffd9d4; }
.selrow { display: flex; gap: 4px; flex-wrap: wrap; max-width: 100%; }
.su { width: 46px; height: 46px; position: relative; overflow: hidden; padding: 0; }
.su .pic { position: absolute; left: 3px; top: 5px; width: calc(100% - 6px); height: calc(100% - 8px); object-fit: contain; }
.su b { position: absolute; right: 2px; bottom: -1px; font-size: 14px; color: #fff; -webkit-text-stroke: 3px #2b2118; paint-order: stroke; }
.su .hp { position: absolute; left: 0; right: 0; top: 0; height: 4px; background: #2b2118; z-index: 1; }
.su .hp i { display: block; height: 100%; background: #5fbf4a; }

#orders { right: var(--r); bottom: var(--b); display: flex; align-items: flex-end; gap: 7px; pointer-events: none !important; }
#orders > * { pointer-events: auto; }
.o4 { display: grid; grid-template-columns: 48px 48px; gap: 7px; }
.o2, .o1 { display: flex; gap: 7px; }
.ob { width: 48px; height: 48px; padding: 0; display: grid; place-items: center; font-size: 26px; font-weight: 900; }
.ob img { width: 34px; height: 34px; object-fit: contain; }
.ob.x { background: #f7c9c3; }
.ob.ok { background: #5fbf4a; color: #fff; -webkit-text-stroke: 1px #2b2118; }
.ob.on { background: #ffd23f; }
.ob.off { opacity: .45; filter: grayscale(1); }
.o4 .ob:nth-child(odd) { transform: rotate(1.5deg); }

#hint { left: 50%; bottom: calc(var(--b) + 106px); transform: translateX(-50%); padding: 4px 14px; font-size: 14px; white-space: nowrap; background: #2b2118e6; color: #f2ece0; border-radius: 5px; pointer-events: none !important; }
#toasts { left: 50%; top: 40px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none !important; }
.toast { padding: 3px 12px; font-size: 14px; white-space: nowrap; animation: pop .25s; pointer-events: auto; }
.toast.bad { background: #ffd9d4; }
@keyframes pop { from { transform: scale(.6) rotate(-4deg); opacity: 0; } }

/* écrans */
.screen { position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; background: #1b1814d9; overflow: auto; padding: 10px var(--r) 10px var(--l); }
.panel { padding: 14px 18px; max-width: 420px; width: 100%; text-align: center; margin: auto; }
.panel.wide { max-width: 860px; }
.panel h1 { font-size: 34px; line-height: 1; transform: rotate(-1.5deg); }
.panel h2 { font-size: 28px; margin-bottom: 8px; }
.panel p { margin-bottom: 10px; }
.lead { font-size: 14px; margin: 4px 0 10px; }
.big { display: block; width: 100%; margin-top: 8px; padding: 9px 12px; font-size: 18px; }
#factions { display: flex; gap: 8px; }
.fac { flex: 1; padding: 8px 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; background: #fbf7ee; }
.fac.on { background: color-mix(in srgb, var(--c) 22%, #fbf7ee); outline: 3px solid var(--c); transform: rotate(-1deg); }
.fac .emb { width: 46px; height: 46px; object-fit: contain; }
.fac b { font-size: 17px; }
.fac em { font-size: 12px; font-style: normal; opacity: .8; }
.fac .row { display: flex; gap: 2px; align-items: flex-end; height: 40px; margin: 2px 0; }
.fac .row img { height: 36px; width: auto; }
.fac .row img:last-child { height: 40px; }
.fac small { font-size: 11px; line-height: 1.25; font-family: system-ui, sans-serif; }
.line { display: flex; gap: 10px; align-items: center; margin-top: 10px; }
.line .big { margin: 0; flex: 1; font-size: 20px; background: #5fbf4a; color: #fff; -webkit-text-stroke: 1px #2b2118; }
.seg { display: flex; border: 2.5px solid #2b2118; border-radius: 5px; overflow: hidden; }
.seg button { border: 0; background: #fbf7ee; padding: 8px 10px; font-size: 14px; }
.seg button + button { border-left: 2px solid #2b2118; }
.seg button.on { background: #2b2118; color: #f2ece0; }
.help { margin-top: 10px; text-align: left; font-size: 12px; font-family: system-ui, sans-serif; }
.help summary { cursor: pointer; font-family: "Marker Felt", "Chalkboard SE", sans-serif; font-size: 14px; }
.help p { margin: 6px 0 0; }

#rotate { display: none; position: fixed; inset: 0; z-index: 20; align-items: center; justify-content: center; background: #1b1814; padding: 20px; text-align: center; font-size: 18px; }
@media (orientation: portrait) and (max-width: 820px) { #rotate { display: flex; } }
@media (max-height: 430px) {
  .panel.wide { padding: 8px 12px; }
  .panel h1 { font-size: 26px; }
  .lead { margin: 2px 0 6px; }
}
