/* Alliance — war-planning board, matched to youtube.com/watch?v=MMjpej5Bcpo */
@font-face { font-family: "Caslon"; src: url(../fonts/libre-caslon-400.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Caslon"; src: url(../fonts/libre-caslon-700.woff2) format("woff2"); font-weight: 700; font-display: swap; }

:root {
    --chalk: #3e6a48;
    --grid-line: #466c4c;
    --tile: #6a9072;
    --tile-dark: #2f5236;
    --cream: #f0e9dc;
    --paper-ink: #2b2622;
    --paper-muted: #8a7f73;
    --tag: #151515;
    --badge: #9e2438;
    --heart: #d8283c;
    --move: #2e7d8f;
    --attack: #b5202b;
    --give: #3c7f35;
    --range: #9b7b2c;
    --sun: #e9b51f;
    --green-ink: #2f6b3c;
    --red-ink: #a3261a;
    --white: #fbf8f1;
    --serif: "Caslon", Georgia, "Times New Roman", serif;
    --sans: Verdana, "DejaVu Sans", sans-serif;
    --chalk-texture: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.012 .9' numOctaves='2' seed='4'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
    background: var(--chalk) var(--chalk-texture);
    color: var(--white);
    font: 17px/1.35 var(--serif);
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--white); outline-offset: 2px; }

/* cream paper with a slightly torn edge (filter #rough is injected by board.js) */
.paper { position: relative; isolation: isolate; color: var(--paper-ink); }
.paper::before {
    content: ""; position: absolute; inset: 0; z-index: -1;
    background: var(--cream); border-radius: 8px;
    filter: url(#rough) drop-shadow(0 2px 0 rgba(0, 0, 0, .22));
}
/* black label with an optional crimson number, the board's name-tag look */
.tag { display: inline-flex; align-items: stretch; background: var(--tag); color: var(--white); white-space: nowrap; border: 0; padding: 0; }
.tag > span { padding: 0 .5em; display: flex; align-items: center; }
.tag > b { background: var(--badge); font: 700 .8em var(--sans); padding: 0 .45em; display: flex; align-items: center; }
.tag > b:empty { display: none; }

/* ---------- board ---------- */
.stage { position: fixed; inset: 0; }
.scroller { position: absolute; inset: 0; overflow: auto; display: flex; padding: 90px 330px 150px 32px; touch-action: none; scrollbar-width: none; }
.scroller::-webkit-scrollbar { display: none; }
.scroller.dragging { cursor: grabbing; }

.board {
    --gap: calc(var(--cell) * .14);
    position: relative;
    display: grid;
    grid-template-columns: repeat(var(--dim), var(--cell));
    gap: var(--gap);
    padding: var(--gap);
    width: max-content;
    margin: auto;
    background: var(--grid-line);
}
.cell {
    width: var(--cell); height: var(--cell);
    padding: 0; border: 0; border-radius: 2px;
    background: var(--tile);
    position: relative;
}
.cell.in-range { background: var(--tile-dark); }
.cell.player { background: none; }
.cell.player img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 2px; box-shadow: 0 0 0 2px #1b2a1e; }
.cell.me img { box-shadow: 0 0 0 3px var(--white); }
.cell.selected { outline: 3px solid var(--white); outline-offset: 3px; z-index: 1; }
.cell.voted img { box-shadow: 0 0 0 3px var(--cream), 0 0 0 6px var(--badge); }
.board.jury .cell.player img { filter: saturate(.75); }

/* name tags, placed beside flags by board.js so they never overlap */
.labels { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.labels .tag { position: absolute; height: max(15px, calc(var(--cell) * .58)); font-size: clamp(10px, calc(var(--cell) * .32), 16px); }
.labels .tag.picked { background: var(--white); color: var(--tag); }
.status { position: absolute; z-index: 2; padding: 4px 8px 3px; text-align: center; font: clamp(10px, calc(var(--cell) * .27), 13px)/1.1 var(--sans); letter-spacing: .03em; white-space: nowrap; }
.hearts { display: flex; gap: 2px; justify-content: center; margin-bottom: 1px; }
.hearts svg { width: clamp(11px, calc(var(--cell) * .4), 17px); aspect-ratio: 24 / 22; }

/* white notes that float off a player after an action */
.pop { position: absolute; left: 50%; top: -4px; z-index: 6; pointer-events: none; translate: -50% -100%; display: flex; align-items: center; gap: 3px; color: var(--white); font: 700 clamp(12px, calc(var(--cell) * .42), 18px) var(--sans); white-space: nowrap; text-shadow: 0 1px 2px #12261a, 0 0 8px rgba(18, 38, 26, .9); animation: pop 2s ease-out forwards; }
.pop svg { width: 1.05em; aspect-ratio: 24 / 22; filter: drop-shadow(0 1px 1px #12261a); }
@keyframes pop { 0% { opacity: 0; transform: translateY(6px); } 10% { opacity: 1; transform: none; } 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-18px); } }
.burst { position: absolute; inset: -18%; z-index: 6; pointer-events: none; animation: burst 1.6s ease-out forwards; }
.burst svg { width: 100%; height: 100%; display: block; }
@keyframes burst { 0% { opacity: 0; transform: scale(.4); } 15% { opacity: 1; transform: scale(1.1); } 70% { opacity: 1; transform: none; } 100% { opacity: 0; } }

/* arrows: smooth white curves with solid heads, drawn in when they change */
.arrows { position: absolute; inset: 0; pointer-events: none; overflow: visible; z-index: 5; filter: drop-shadow(0 0 1.5px rgba(14, 30, 19, .85)); } /* over tags, with a dark edge so crossings read cleanly */
.arrows .line { fill: none; stroke-width: 4; stroke-linecap: round; }
.arrows .head { stroke-width: 2; stroke-linejoin: round; }
.arrows .move { stroke: var(--white); }
.arrows .head.move { fill: var(--white); }
.arrows .aim { stroke: rgba(251, 248, 241, .75); }
.arrows .line.aim { stroke-width: 2.5; }
.arrows .head.aim { fill: rgba(251, 248, 241, .75); stroke: none; }
.arrows .attack { stroke: #d8333d; }
.arrows .head.attack { fill: #d8333d; }
.arrows .give { stroke: #6cc760; }
.arrows .head.give { fill: #6cc760; }
.arrows text { font: 15px var(--sans); fill: var(--white); paint-order: stroke; stroke: rgba(30, 50, 34, .75); stroke-width: 3px; }
.arrows.draw .line { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw .3s ease-out forwards; }
.arrows.draw .head, .arrows.draw text { opacity: 0; animation: appear .12s .24s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes appear { to { opacity: 1; } }

/* ---------- day (top left) ---------- */
.day { position: fixed; left: 24px; top: 18px; z-index: 10; display: flex; align-items: center; gap: 10px; }
.day .tag { font-size: 26px; height: 44px; }
.day .tag > span { padding: 0 .55em; }
.day .next { display: flex; align-items: center; gap: 7px; padding: 7px 13px 6px; font-size: 15px; white-space: nowrap; }
.day .next svg { width: 18px; height: 18px; }
.day .next b { font-family: var(--sans); font-size: 13px; }

/* ---------- action cards (bottom right) ---------- */
.actions { position: fixed; right: 24px; bottom: 18px; z-index: 10; display: flex; gap: 12px; }
.act {
    width: 116px; height: 98px;
    border: 0; background: none;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    padding: 8px 8px;
}
.act svg { flex: none; width: 46px; height: 38px; margin-bottom: 3px; fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.act strong { font-size: 15px; line-height: 1.05; text-align: center; white-space: nowrap; }
.act small { font: 11px var(--sans); color: var(--paper-muted); }
.act.move strong { color: var(--move); }
.act.attack strong { color: var(--attack); }
.act.give strong { color: var(--give); }
.act.upgrade strong { color: var(--range); }
.act.vote strong { color: var(--badge); }
.act[aria-disabled="true"] { cursor: default; opacity: .5; }
.act.lit { translate: 0 -6px; }
.act.lit::before { box-shadow: inset 0 0 0 3px var(--tag); }
.act.lit small { color: var(--paper-ink); font-weight: 700; }
.act.lit:active { translate: 0 -3px; }

.zoom { position: fixed; right: 24px; bottom: 138px; z-index: 10; display: flex; flex-direction: column; gap: 8px; }
.zoom button { width: 40px; height: 40px; border: 0; background: none; padding: 0; font-size: 22px; line-height: 1; }

/* the selected player's cut-out portrait, like the video's character shots */
.portrait { position: fixed; left: 28px; bottom: 34px; z-index: 9; pointer-events: none; }
.portrait[hidden] { display: none; }
.portrait .cut { width: 170px; height: 190px; background: var(--duo, #f08a9a); filter: url(#rough); }
.portrait .cut img { width: 100%; height: 100%; object-fit: cover; mix-blend-mode: multiply; filter: grayscale(1) contrast(2.4) brightness(1.15); }
.portrait .name { position: absolute; left: 10px; bottom: -12px; display: flex; align-items: center; gap: 8px; padding: 5px 12px; font-size: 19px; }
.portrait .name img { height: 19px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .3); }

/* ---------- reports: one paper sheet, grouped by day ---------- */
.reports { position: fixed; right: 24px; top: 18px; width: 290px; z-index: 11; display: flex; flex-direction: column; align-items: flex-start; max-height: calc(100dvh - 300px); }
.reports .head { font-size: 17px; height: 34px; margin-left: 14px; position: relative; z-index: 1; }
.reports .sheet { width: 100%; margin-top: -10px; padding: 18px 18px 12px; overflow: auto; min-height: 0; scrollbar-width: thin; }
.reports.closed .sheet { display: none; }
.sheet h3 { margin: 6px 0 4px; font-size: 16px; border-bottom: 1.5px solid var(--paper-ink); padding-bottom: 1px; }
.sheet h3 button { all: unset; cursor: pointer; display: flex; width: 100%; justify-content: space-between; align-items: baseline; }
.sheet h3 small { font: 11px var(--sans); color: var(--paper-muted); }
.sheet li em { font: normal 11px var(--sans); color: var(--paper-muted); }
.sheet h3:first-child { margin-top: 0; }
.sheet ol { list-style: none; margin: 0 0 10px; padding: 0; }
.sheet li { display: grid; grid-template-columns: 40px 1fr; gap: 6px; padding: 3px 0; font-size: 14.5px; line-height: 1.3; }
.sheet li time { font: 10.5px/2 var(--sans); color: var(--paper-muted); }
.sheet li.green { color: var(--green-ink); }
.sheet li.red { color: var(--red-ink); }
.sheet .empty { margin: 0; color: var(--paper-muted); }

/* Time Machine: the host sees every player's AP (badge) and hearts */
.replay .actions, .replay .reports, .replay .portrait { display: none; }
.labels .tag .hp { display: inline-flex; gap: 1px; margin-left: .4em; }
.labels .tag .hp svg { width: .85em; aspect-ratio: 24 / 22; }
.arrows .kill { stroke: var(--white); stroke-width: 5; }

.toast { position: fixed; left: 50%; top: 18px; translate: -50% 0; z-index: 60; padding: 8px 16px; font-size: 16px; }
.toast[hidden] { display: none; }

/* ---------- Time Machine controls ---------- */
.timeline { position: fixed; left: 50%; bottom: 18px; translate: -50% 0; z-index: 12; width: min(760px, calc(100vw - 32px)); padding: 12px 16px 10px; }
.timeline[hidden] { display: none; }
.timeline .caption { margin: 0 0 8px; font-size: 18px; min-height: 1.35em; }
.controls { display: flex; align-items: center; gap: 6px; }
.controls button:not(.tag) { flex: none; width: 34px; height: 34px; border: 0; border-radius: 4px; background: var(--tag); display: grid; place-items: center; padding: 0; }
.controls svg { width: 16px; height: 16px; fill: var(--white); }
.controls input[type="range"] { flex: 1; min-width: 60px; accent-color: var(--tag); }
.controls .count { font: 12px var(--sans); color: var(--paper-muted); min-width: 64px; text-align: right; }
.controls .tag { height: 32px; font-size: 14px; }
.bare .timeline, .bare .zoom { display: none; }
.hostonly { max-width: 460px; margin: 20vh auto; }
.hostonly[hidden] { display: none; }

/* ---------- pages: sign-up, rules, admin ---------- */
body.page { overflow: auto; min-height: 100%; }
a.tag { text-decoration: none; }
.tag.big { font-size: 26px; height: 44px; }
.tag.big > span { padding: 0 .55em; }
.tag:disabled { opacity: .4; cursor: default; }
.masthead { display: flex; justify-content: space-between; align-items: center; padding: 18px 24px; }
.masthead nav { display: flex; gap: 8px; }
.masthead nav .tag, .corner .tag { height: 30px; font-size: 15px; }
.corner { position: fixed; left: 24px; bottom: 18px; z-index: 10; display: flex; gap: 8px; }
.column { max-width: 560px; margin: 10px auto 60px; padding: 0 16px; display: flex; flex-direction: column; gap: 22px; }
.panel { padding: 20px 22px; }
.panel h2 { margin: 0 0 10px; font-size: 20px; }
.panel h3 { margin: 18px 0 6px; font-size: 17px; }
.panel p { margin: 0 0 10px; }
.panel label { display: block; margin-bottom: 12px; font-size: 15px; }
.panel input:not([type="file"]), .panel select { display: block; width: 100%; margin-top: 4px; padding: 8px 10px; font: 16px var(--serif); color: var(--paper-ink); background: #fffaf0; border: 1.5px solid var(--paper-ink); border-radius: 3px; }
.panel .tag.go { height: 40px; font-size: 17px; margin-top: 4px; }
.switch { display: flex; gap: 8px; margin-bottom: 16px; }
.switch .tag { height: 32px; font-size: 15px; }
.switch .tag:not(.on) { background: none; color: var(--paper-ink); box-shadow: inset 0 0 0 1.5px var(--paper-ink); }
.error { color: var(--red-ink); min-height: 1.3em; margin: 4px 0 !important; font-size: 14px; }
.you { display: flex; gap: 18px; align-items: center; }
.you .tag { height: 34px; font-size: 19px; }
.you .tag img { height: .85em; margin-right: .45em; }
.photo { width: 96px; height: 96px; flex: none; background: #f08a9a; filter: url(#rough); }
.photo img { width: 100%; height: 100%; object-fit: cover; mix-blend-mode: multiply; filter: grayscale(1) contrast(2.4) brightness(1.15); }
.photo.empty { background: var(--tile); }
.links { display: flex; gap: 16px; margin: 10px 0 0 !important; }
.link { all: unset; cursor: pointer; font-size: 15px; text-decoration: underline; text-underline-offset: 3px; }
.flags { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 7px; max-height: 270px; overflow: auto; margin: 12px 0 4px; padding: 3px; }
.flags button { padding: 0; border: 0; background: none; aspect-ratio: 4 / 3; }
.flags img { width: 100%; height: 100%; display: block; box-shadow: 0 0 0 1px rgba(0, 0, 0, .25); }
.flags button.on img { box-shadow: 0 0 0 3px var(--tag); }
.flags button:disabled { opacity: .22; cursor: default; }
.roster { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.roster .names { display: flex; flex-wrap: wrap; gap: 8px; }
.roster .names .tag { height: 28px; font-size: 15px; }
.roster .tag img { height: .85em; margin-right: .45em; }
.roster p { margin: 0; }
.rules h3 { margin-top: 20px; }
.rules p, .rules li { font-size: 16px; line-height: 1.45; }
.rules ul { margin: 0 0 10px; padding-left: 20px; }

@media (prefers-reduced-motion: reduce) {
    .pop, .burst { animation-duration: .01s; animation-delay: 1.4s; }
    .arrows.draw .line, .arrows.draw .head, .arrows.draw text { animation: none; stroke-dashoffset: 0; opacity: 1; }
}

/* ---------- phones ---------- */
@media (max-width: 760px) {
    .scroller { padding: 60px 8px 116px; }
    .day { left: 10px; top: 10px; gap: 6px; }
    .day .tag { font-size: 19px; height: 34px; }
    .day .next { font-size: 13px; padding: 5px 9px 4px; }
    .day .next svg { width: 15px; height: 15px; }
    .day .next .wide { display: none; }
    .actions { left: 8px; right: 8px; bottom: 10px; gap: 6px; }
    .act { flex: 1; min-width: 0; width: auto; height: 84px; padding: 6px 4px; }
    .act svg { width: 38px; height: 31px; margin-bottom: 2px; }
    .act strong { font-size: 12.5px; white-space: normal; }
    .act small { font-size: 10px; }
    .act.lit { translate: 0 -4px; }
    .act.vote { flex: 0 1 140px; margin-left: auto; }
    .zoom { right: 10px; bottom: 104px; flex-direction: row; }
    .zoom button { width: 36px; height: 36px; }
    .portrait { display: none; }
    .reports { right: 8px; top: 10px; width: min(300px, calc(100vw - 16px)); align-items: flex-end; max-height: 62dvh; }
    .reports .head { font-size: 15px; height: 34px; margin: 0; }
    .reports .sheet { margin-top: 6px; }
    .corner { left: 10px; bottom: 104px; }
    .masthead { padding: 12px 12px; }
    .you { gap: 14px; }
    .photo { width: 76px; height: 76px; }
}
