/* Wyrdhand: the page around the pixel canvas. Colours from the Wyrd 56 palette (art/palette/wyrd56.hex). */
@font-face { font-family: "Silkscreen"; src: url("assets/fonts/Silkscreen-Regular.ttf") format("truetype"); font-display: block; }
@font-face { font-family: "IM Fell English"; src: url("assets/fonts/IMFellEnglish-Regular.ttf") format("truetype"); font-display: swap; }

:root {
  --night: #07060b; --night-2: #0e0c16; --night-3: #161325; --violet: #3c3257; --violet-2: #5e2d76; --lilac: #c07ad0;
  --bone: #e4dcc2; --bone-2: #a69b84; --ember: #e8913a; --gold: #c09a3e; --blood: #962c2f;
  --accent: #e8913a; --text: #e4dcc2;
  --ctl-scale: 1; --ctl-opacity: .7;
  --sa-l: env(safe-area-inset-left, 0px); --sa-r: env(safe-area-inset-right, 0px);
  --sa-t: env(safe-area-inset-top, 0px); --sa-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--night); color: var(--text); overflow: hidden;
  font-family: "IM Fell English", Georgia, serif; overscroll-behavior: none; touch-action: none; user-select: none; -webkit-user-select: none; }
#app { position: fixed; inset: 0; }
#game { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); image-rendering: pixelated; image-rendering: crisp-edges; background: var(--night); }

.screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: calc(16px + var(--sa-t)) calc(16px + var(--sa-r)) calc(16px + var(--sa-b)) calc(16px + var(--sa-l));
  background: radial-gradient(ellipse at 50% 30%, rgba(60, 50, 87, .55), rgba(7, 6, 11, .96) 70%); overflow-y: auto; touch-action: pan-y; z-index: 20; text-align: center; }
.screen[hidden], [hidden] { display: none !important; }
h1.logo.img { width: min(640px, 86vw); height: auto; image-rendering: pixelated; text-indent: -9999px; overflow: hidden; aspect-ratio: 5 / 1; background: url("assets/ui/logo.png") center / contain no-repeat; }
h1.logo { font-family: "IM Fell English", serif; font-weight: 400; font-size: clamp(44px, 11vw, 92px); letter-spacing: .06em; margin: 0;
  color: var(--bone); text-shadow: 0 0 18px rgba(232, 145, 58, .35), 0 3px 0 #3a1d4d; }
h2 { font-weight: 400; font-size: 28px; margin: 0; color: var(--bone); }
.tag { margin: 0 0 8px; color: var(--bone-2); font-style: italic; font-size: 18px; }
.small { font-size: 14px; color: var(--bone-2); max-width: 560px; }
.fine { opacity: .7; }
.menu { display: flex; flex-direction: column; gap: 10px; align-items: stretch; min-width: min(300px, 80vw); }
.btn { font: inherit; font-size: 20px; padding: 11px 22px; border-radius: 3px; border: 1px solid #8a6a24; color: var(--bone);
  background: linear-gradient(#2d2545, #161325); box-shadow: inset 0 1px 0 rgba(230, 207, 122, .2), 0 2px 0 #07060b; cursor: pointer; min-height: 48px; }
.btn:hover, .btn:focus-visible { border-color: var(--gold); outline: none; color: #fff; }
.btn.ghost { background: transparent; border-color: #3c3257; }
.title-foot, .pause-foot { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.icon-btn { font: 12px Silkscreen, monospace; width: 40px; height: 40px; border-radius: 50%; border: 1px solid rgba(192, 154, 62, .5);
  background: rgba(7, 6, 11, .55); color: var(--bone); }

/* ---- touch controls ---- */
#touch { position: absolute; inset: 0; z-index: 10; pointer-events: none; opacity: var(--ctl-opacity); }
#touch .stick-zone { position: absolute; left: 0; top: 18%; bottom: 0; width: 42%; pointer-events: auto; touch-action: none; }
.stick-ring { position: absolute; width: 104px; height: 104px; margin: -52px 0 0 -52px; border-radius: 50%; border: 2px solid rgba(228, 220, 194, .25);
  left: calc(80px + var(--sa-l)); top: 70%; transition: opacity .2s; opacity: .5; }
.stick-ring.on { opacity: 1; transition: none; }
.stick-knob { position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; background: rgba(228, 220, 194, .3); border: 1px solid rgba(228, 220, 194, .5); }
#touch .cluster { position: absolute; right: calc(10px + var(--sa-r)); bottom: calc(10px + var(--sa-b)); width: 270px; height: 250px;
  transform: scale(var(--ctl-scale)); transform-origin: 100% 100%; }
.tbtn { position: absolute; pointer-events: auto; touch-action: none; font: 10px Silkscreen, monospace; color: var(--bone);
  background: rgba(22, 19, 37, .72); border: 2px solid rgba(192, 154, 62, .55); }
.tbtn.down { background: rgba(232, 145, 58, .45); border-color: var(--ember); }
.tbtn.round { border-radius: 50%; width: 58px; height: 58px; }
.tbtn.big { width: 74px; height: 74px; font-size: 12px; }
.tbtn.small { width: 42px; height: 42px; font-size: 8px; }
/* the right-thumb cluster: Jump biggest in the corner, Hook beside it, Dash above it, and the three spell cards in the
   Spread's shape (left, top, right) above the Hook. Positions can be moved in Settings > Arrange controls. */
[data-arr="jump"] { right: 0; bottom: 0; }
[data-arr="attack"] { right: 82px; bottom: 0; width: 62px; height: 62px; }
[data-arr="dash"] { right: 0; bottom: 82px; width: 62px; height: 62px; }
[data-arr="heal"] { right: 154px; bottom: 0; }
[data-arr="interact"] { right: 10px; bottom: 154px; border-color: var(--gold); color: #f6c25b; }
.card-btn, .card { image-rendering: pixelated; }
/* The three spell cards: compact (40x56, ~40% of the old area), see-through while idle so the fight shows behind
   them, full strength while pressed or for a moment after any card press (.hot), and movable in Arrange controls. */
.card-btn { width: 40px; height: 56px; border-radius: 4px; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; padding: 2px 1px;
  background-size: cover; background-position: center; opacity: var(--card-idle, .5); transition: opacity .35s; }
#touch .cluster.hot .card-btn, .card-btn.down, #touch.arranging .card-btn { opacity: 1; transition: opacity .05s; }
.card-btn .cn { font-size: 6px; line-height: 1.05; text-align: center; text-shadow: 0 1px 0 #000, 0 0 2px #000; max-width: 38px; overflow: hidden; }
.card-btn .ci { font-size: 7px; color: #f6c25b; text-shadow: 0 1px 0 #000, 0 0 2px #000; }
.card-btn.poor { filter: grayscale(.8) brightness(.55); }
.card-btn.empty { opacity: .2; }
[data-arr="s0"] { right: 154px; bottom: 70px; }
[data-arr="s1"] { right: 112px; bottom: 104px; }
[data-arr="s2"] { right: 70px; bottom: 70px; }
#touch .topbar { position: absolute; top: calc(6px + var(--sa-t)); left: 50%; transform: translateX(-50%); display: flex; gap: 8px; pointer-events: auto; }
#touch.lefty .cluster { right: auto; left: calc(10px + var(--sa-l)); transform-origin: 0 100%; }
#touch.lefty .stick-zone { left: auto; right: 0; }
#touch.lefty .stick-ring { left: auto; right: calc(28px + var(--sa-r)); }
#touch.arranging .tbtn { outline: 2px dashed var(--gold); }
#arrange-bar { position: absolute; top: calc(8px + var(--sa-t)); left: 50%; transform: translateX(-50%); z-index: 30; display: flex; gap: 10px; align-items: center;
  background: rgba(7, 6, 11, .85); padding: 6px 12px; border: 1px solid var(--gold); font-size: 15px; }

#rotate { position: absolute; inset: 0; z-index: 40; background: rgba(7, 6, 11, .96); display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px; }
.rot-phone { width: 44px; height: 76px; border: 3px solid var(--bone-2); border-radius: 8px; margin: 0 auto 18px; animation: rot 2.4s ease-in-out infinite; }
@keyframes rot { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }

/* ---- the Spread table ---- */
#spread { justify-content: flex-start; gap: 8px; }
.spread-head { display: flex; gap: 14px; align-items: center; justify-content: center; width: 100%; flex-wrap: wrap; }
.spread-head .close { min-height: 40px; padding: 6px 16px; font-size: 17px; }
.candles { font: 11px Silkscreen, monospace; color: #f6c25b; }
.candles.over { color: var(--blood); }
.lock { color: #b9483a; margin: 0; }
.table { display: flex; gap: 10px; align-items: flex-end; justify-content: center; padding: 6px; border-radius: 6px; flex-wrap: nowrap;
  background: radial-gradient(ellipse, #2a1a1a 0%, #161325 70%); border: 1px solid #3c3257; }
.slot { display: flex; flex-direction: column; gap: 4px; align-items: center; padding: 6px; min-width: 96px; border-radius: 4px; border: 1px solid transparent; }
.slot.top { margin-bottom: 18px; }
.slot-name { font: 9px Silkscreen, monospace; color: var(--bone-2); }
.part { width: 92px; min-height: 30px; font-size: 14px; border: 1px dashed #52476e; border-radius: 3px; display: flex; align-items: center; justify-content: center;
  background: rgba(7, 6, 11, .5); color: var(--bone-2); cursor: pointer; padding: 3px; line-height: 1.05; }
.part.filled { border-style: solid; color: var(--bone); background: #211b34; }
.part.sel { border-color: #f6c25b; box-shadow: 0 0 8px rgba(246, 194, 91, .5); }
.part .k { font: 7px Silkscreen, monospace; display: block; color: var(--bone-2); }
.part.form.filled { border-color: #8c4aa0; } .part.essence.filled { border-color: var(--ember); } .part.omen.filled { border-color: #4f7aa6; }
.spell-line { min-height: 22px; font-size: 16px; color: #f6c25b; }
.hand { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; max-width: 720px; }
.card { width: 74px; height: 104px; border-radius: 5px; border: 1px solid #8a6a24; background: linear-gradient(#2d2545, #110e1b); display: flex; flex-direction: column;
  justify-content: space-between; align-items: center; padding: 5px 3px; cursor: pointer; font-size: 14px; position: relative; background-size: cover; background-position: center; }
.card .cost { position: absolute; top: 3px; right: 4px; font: 9px Silkscreen, monospace; color: #f6c25b; }
.card .kind { font: 7px Silkscreen, monospace; color: var(--bone-2); }
.card.form { border-color: #8c4aa0; } .card.essence { border-color: var(--ember); } .card.omen { border-color: #4f7aa6; }
.card.used { opacity: .45; } .card.pick { box-shadow: 0 0 10px rgba(246, 194, 91, .7); }
.card.dim { filter: grayscale(.9) brightness(.5); }
.card-info { min-height: 40px; max-width: 560px; font-size: 15px; color: var(--bone-2); }
.trumps { font-size: 14px; color: var(--bone-2); }

#settings .opts { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; font-size: 16px; text-align: left; max-width: 520px; }
#settings input[type=checkbox] { width: 20px; height: 20px; vertical-align: middle; accent-color: var(--ember); }
#settings input[type=range] { vertical-align: middle; accent-color: var(--ember); }

#sheet { position: absolute; inset: 0; z-index: 25; display: flex; align-items: center; justify-content: center; background: rgba(7, 6, 11, .7); padding: 16px; }
.sheet-card { max-width: 460px; background: linear-gradient(#e4dcc2, #c7bc9f); color: #211b34; border: 2px solid #5a4315; padding: 18px 20px; border-radius: 3px; text-align: center;
  box-shadow: 0 8px 30px #000; font-size: 18px; }
.sheet-card .btn { color: var(--bone); margin-top: 12px; }
.sheet-art { display: flex; justify-content: center; }
.sheet-art .card { cursor: default; color: var(--bone); width: 96px; height: 136px; margin-bottom: 8px; }
.sheet-text b { display: block; font-size: 22px; margin-bottom: 4px; }
#loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 20px; color: var(--bone-2); z-index: 30; background: var(--night); }

/* the shared bug and stats sheets pick up these */
:root { --cbug-bg: #161325; --cbug-text: #e4dcc2; --cbug-accent: #e8913a; }
@media (orientation: portrait) { .table { flex-wrap: wrap; } }

/* ---- M2: save slots, the map, rebinding, the Candlewick's folk, charms on the Spread ---- */
.slot-list { display: flex; flex-direction: column; gap: 8px; width: min(560px, 94vw); }
.save-slot { display: flex; gap: 10px; align-items: center; justify-content: space-between; border: 1px solid #3c3257; background: rgba(14, 12, 22, .8);
  padding: 8px 10px; border-radius: 3px; text-align: left; }
.save-slot .info { font-size: 15px; color: var(--bone-2); line-height: 1.25; }
.save-slot .info b { color: var(--bone); font-weight: 400; font-size: 17px; }
.save-slot .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.save-slot .btn { font-size: 15px; padding: 6px 12px; min-height: 40px; }
.code-row { display: flex; gap: 6px; width: min(560px, 94vw); }
.code-row input { flex: 1; font: 14px Georgia, serif; background: #0e0c16; color: var(--bone); border: 1px solid #3c3257; padding: 8px; min-width: 0; }
#map { justify-content: flex-start; padding-bottom: calc(8px + var(--sa-b)); }
.map-head { display: flex; gap: 14px; align-items: center; justify-content: center; width: 100%; }
.map-head .close { min-height: 40px; padding: 6px 16px; font-size: 17px; }
.map-area { font: 10px Silkscreen, monospace; color: #e6cf7a; }
#map-cv { flex: 1; width: 100%; min-height: 160px; image-rendering: pixelated; touch-action: none; border: 1px solid #263030; background: #07060b; }
.map-key { margin: 0; } .k-you { color: #e8913a; } .k-shrine { color: #f6c25b; } .k-secret { color: #86c08a; }
.bind-table { display: grid; grid-template-columns: auto 1fr 1fr; gap: 4px 10px; align-items: center; max-width: 520px; width: 94vw; font-size: 15px; text-align: left; }
.bind-table .h { font: 9px Silkscreen, monospace; color: var(--bone-2); }
.bind-table button { font: 11px Silkscreen, monospace; min-height: 34px; background: #161325; color: var(--bone); border: 1px solid #3c3257; border-radius: 3px; cursor: pointer; }
.bind-table button.wait { border-color: #f6c25b; color: #f6c25b; }
#talk { position: absolute; inset: 0; z-index: 26; display: flex; align-items: center; justify-content: center; background: rgba(7, 6, 11, .72); padding: 12px; }
.talk-card { width: min(560px, 96vw); max-height: 92vh; overflow-y: auto; touch-action: pan-y; background: linear-gradient(#211b34, #0e0c16); border: 1px solid #8a6a24;
  border-radius: 3px; padding: 12px 14px; box-shadow: 0 8px 30px #000; text-align: left; }
.talk-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.talk-who { font-size: 22px; color: var(--bone); } .talk-purse { font: 10px Silkscreen, monospace; color: #c09a3e; }
.talk-line { font-style: italic; color: var(--bone-2); margin: 6px 0 8px; font-size: 16px; }
.talk-list { display: flex; flex-direction: column; gap: 6px; }
.ware { display: flex; gap: 8px; align-items: center; border-top: 1px solid #2d2545; padding-top: 6px; }
.ware .card { width: 40px; height: 56px; flex: none; font-size: 0; padding: 0; }
.ware .card .kind, .ware .card .cost { display: none; }
.ware .what { flex: 1; font-size: 15px; color: var(--bone-2); line-height: 1.2; } .ware .what b { color: var(--bone); font-weight: 400; display: block; font-size: 16px; }
.ware .btn { font-size: 15px; padding: 6px 12px; min-height: 40px; white-space: nowrap; }
.ware .btn[disabled] { opacity: .45; }
.talk-msg { min-height: 18px; color: #e6cf7a; font-size: 15px; margin: 6px 0; }
.charm-row { display: flex; gap: 10px; align-items: center; justify-content: center; }
.part.charm.filled { border-color: #4a8a6a; }
.card.charm { border-color: #4a8a6a; } .card.trump, .card.item { border-color: #c09a3e; }
.card .rank { position: absolute; top: 3px; left: 4px; font: 9px Silkscreen, monospace; color: #e6cf7a; }
.talk-card { display: flex; flex-direction: column; overflow: hidden; }
.talk-list { overflow-y: auto; touch-action: pan-y; min-height: 0; flex: 1; }
.talk-head #talk-close { min-height: 38px; padding: 4px 14px; font-size: 16px; margin-left: auto; }
.talk-head { align-items: center; }
