/* Who Is Napoleon? — UI painted on Manor Farm's tarred barn wall, with propaganda-red notices.
   Tokens: tar (wall), whitewash (painted letters), barn red (power/danger), straw (Napoleon/gold). */
:root {
  --tar: #1f1a17;
  --tar-2: #2b231e;
  --tar-edge: #0f0c0a;
  --whitewash: #f2ead7;
  --whitewash-dim: #b9b09b;
  --red: #a5281b;
  --red-deep: #6e170f;
  --straw: #e8b641;

  --f-display: "Big Shoulders Display", "Barlow Condensed", sans-serif;
  --f-brush: "Sriracha", "Barlow Condensed", cursive;
  --f-ui: "Barlow Condensed", system-ui, sans-serif;
  --track: .04em;
}
html[lang="zh-Hans"] { --f-display: "Noto Sans SC", sans-serif; --f-brush: "Ma Shan Zheng", "Noto Sans SC", serif; --f-ui: "Barlow Condensed", "Noto Sans SC", sans-serif; --track: 0; }
html[lang="zh-Hant"] { --f-display: "Noto Sans TC", sans-serif; --f-brush: "LXGW WenKai TC", "Noto Sans TC", serif; --f-ui: "Barlow Condensed", "Noto Sans TC", sans-serif; --track: 0; }
html[lang="ja"]      { --f-display: "Noto Sans JP", sans-serif; --f-brush: "Yuji Boku", "Noto Sans JP", serif; --f-ui: "Barlow Condensed", "Noto Sans JP", sans-serif; --track: 0; }
html[lang="ko"]      { --f-display: "Noto Sans KR", sans-serif; --f-brush: "Nanum Brush Script", "Noto Sans KR", cursive; --f-ui: "Barlow Condensed", "Noto Sans KR", sans-serif; --track: 0; }

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; background: #6aa84f; font-family: var(--f-ui); color: var(--whitewash); user-select: none; -webkit-user-select: none; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
[hidden] { display: none !important; }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--straw); outline-offset: 2px; }

/* Tarred planks: horizontal boards with dark seams and faint grain */
.plank {
  background:
    repeating-linear-gradient(0deg, transparent 0 25px, rgba(0,0,0,.45) 25px 27px),
    repeating-linear-gradient(90deg, rgba(255,255,255,.018) 0 1px, transparent 1px 9px),
    linear-gradient(180deg, var(--tar-2), var(--tar));
  border: 2px solid var(--tar-edge);
  box-shadow: 0 6px 0 rgba(0,0,0,.35);
}
.painted { font-family: var(--f-brush); color: var(--whitewash); text-shadow: 0 0 1px rgba(242,234,215,.7), 1px 1px 0 rgba(0,0,0,.4); }
.eyebrow { font-family: var(--f-ui); font-weight: 700; font-size: 12px; letter-spacing: .22em; text-transform: uppercase; color: var(--whitewash-dim); }
.eyebrow.gold { color: var(--straw); }

/* ---------- Commandment board (signature) ---------- */
#board { position: fixed; top: 8px; left: 50%; transform: translateX(-50%); min-width: 220px; max-width: min(440px, 52vw); padding: 3px 16px 5px; text-align: center; pointer-events: none; z-index: 2; }
#board .eyebrow { display: block; color: var(--red); letter-spacing: .3em; font-size: 10px; }
#board .eyebrow span { color: var(--whitewash-dim); }
#board .paint { position: relative; display: inline-block; margin-top: 1px; }
#ruleName { display: inline-block; font-size: 21px; line-height: 1.1; }
/* the explanation shows for a few seconds after each new rule, then the board shrinks back to the name */
#board small { display: none; font-size: 13px; font-weight: 500; color: var(--whitewash-dim); line-height: 1.2; margin-top: 1px; }
#board.fresh small { display: block; animation: fadeIn .3s; }
#reign { display: inline-block; margin-top: 3px; padding: 0 8px; font-family: var(--f-display); font-weight: 900; font-size: 14px; letter-spacing: var(--track); color: var(--tar); background: var(--straw); }
#reign.me { background: var(--red); color: var(--whitewash); }
#reign .rs { display: none; }
/* Squealer's repaint: a red brush stroke crosses out the old law, then the new law is painted in */
#board .strike { position: absolute; left: -6px; right: -6px; top: 50%; height: 9px; margin-top: -4px; background: var(--red); transform: scaleX(0) rotate(-2deg); transform-origin: left center; border-radius: 4px 2px 5px 3px; }
#board.crossing .strike { animation: strike .35s ease-in forwards; }
#board.painting #ruleName { animation: paintIn .7s steps(14) both; }
@keyframes strike { to { transform: scaleX(1) rotate(-2deg); } }
@keyframes paintIn { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }

#capture { position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%) rotate(-1.5deg); padding: 2px 12px; font-family: var(--f-display); font-weight: 900; font-size: 17px; letter-spacing: var(--track); text-transform: uppercase; color: var(--whitewash); background: var(--red); border: 2px solid var(--red-deep); box-shadow: 4px 4px 0 rgba(0,0,0,.35); pointer-events: none; white-space: nowrap; }

/* ---------- HUD ---------- */
#stats { position: fixed; left: 16px; top: 10px; pointer-events: none; text-shadow: 3px 3px 0 var(--tar); }
#stats .weight { font-family: var(--f-display); font-weight: 900; line-height: .9; }
#stats .weight b { font-size: 56px; }
#stats .weight span { font-size: 22px; margin-left: 4px; color: var(--straw); }
#stats .sub { font-size: 17px; font-weight: 600; letter-spacing: .03em; }

#lb { position: fixed; right: 12px; top: 10px; width: 220px; padding: 8px 12px 10px; pointer-events: none; }
#lb ol { list-style: none; font-size: 16px; font-weight: 600; line-height: 1.35; margin-top: 3px; counter-reset: lb; }
#lb li { display: flex; gap: 6px; white-space: nowrap; padding: 0 4px; }
#lbList li::before { counter-increment: lb; content: counter(lb); width: 16px; color: var(--whitewash-dim); }
#lb li .n { flex: 1; overflow: hidden; text-overflow: ellipsis; }
#lb li .v { font-variant-numeric: tabular-nums; color: var(--whitewash-dim); }
#lb li .k { font-variant-numeric: tabular-nums; color: #ff8a6a; }
#lb li .k.top { color: #ffb347; font-weight: 800; }
#koTxt .ks { display: none; }
#lb li.me { background: var(--red); }
#lb li.me .v { color: var(--whitewash); }
#lb li.nap .n { color: var(--straw); }
#lb li.nap .n::before { content: '♛ '; }
#hof { margin-top: 8px; padding-top: 6px; border-top: 2px dashed rgba(242,234,215,.18); }
#hof li .v { color: var(--straw); }

#mapWrap { position: fixed; right: 12px; bottom: 12px; display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none; }
#minimap { width: 170px; height: 170px; border-radius: 50%; background: rgba(31,26,23,.55); border: 4px solid var(--tar); box-shadow: 0 0 0 2px rgba(242,234,215,.35); }
#mapIn { font-size: 14px; font-weight: 700; letter-spacing: .04em; color: var(--whitewash); background: var(--tar); padding: 0 8px; }
#mapIn.soon { background: var(--red); }

#feed { position: fixed; left: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 3px; pointer-events: none; font-size: 15px; font-weight: 600; }
#feed div { background: rgba(31,26,23,.85); border-left: 4px solid var(--whitewash-dim); padding: 1px 10px; animation: fadeIn .2s; transition: opacity .5s; }
#feed div.mine { border-left-color: var(--red); background: rgba(110,23,15,.9); }

#dashBtn { display: none; position: fixed; left: 20px; bottom: 96px; width: 86px; height: 86px; border-radius: 50%; border: 4px solid var(--tar); background: var(--red); color: var(--whitewash); font-family: var(--f-display); font-weight: 900; font-size: 20px; text-transform: uppercase; touch-action: none; box-shadow: 4px 4px 0 var(--tar); }
@media (pointer: coarse) { #dashBtn { display: block; } #feed { bottom: 200px; } }
/* RAM button states: dark sweep while recharging, grey + badge when blocked, a pop when ready again */
#dashBtn::before { content: ''; position: absolute; inset: 0; border-radius: 50%; pointer-events: none; background: conic-gradient(from 180deg, transparent calc((1 - var(--cd, 0)) * 360deg), rgba(20,16,14,.62) 0); /* red refills clockwise from the bottom, like the ground arc */ opacity: 0; transition: opacity .1s; }
#dashBtn.cd::before { opacity: 1; }
#dashBtn.cd, #dashBtn.blocked { color: rgba(242,234,215,.55); }
#dashBtn.blocked, #dashBtn.blocked:active { background: #5a524b; }
#dashBtn[data-why]::after { content: attr(data-why); position: absolute; top: -8px; right: -8px; width: 34px; height: 34px; line-height: 30px; font-size: 18px; border-radius: 50%; background: var(--tar); border: 2px solid var(--whitewash-dim); }
#dashBtn.pop { animation: ramPop .28s ease-out; }
@keyframes ramPop { 0% { transform: scale(1); box-shadow: 4px 4px 0 var(--tar), 0 0 0 0 rgba(255,243,160,.9); } 50% { transform: scale(1.12); } 100% { transform: scale(1); box-shadow: 4px 4px 0 var(--tar), 0 0 0 18px rgba(255,243,160,0); } }

/* Announcements: a red propaganda band across the field */
#banner { position: fixed; top: 128px; left: 50%; transform: translateX(-50%) skewY(-2deg); width: max-content; max-width: min(92vw, 620px); padding: 5px 18px 7px; text-align: center; background: var(--red); border-top: 4px solid var(--tar); border-bottom: 4px solid var(--tar); box-shadow: 0 8px 0 rgba(0,0,0,.25); pointer-events: none; opacity: 0; }
#banner .head { display: block; font-family: var(--f-display); font-weight: 900; font-size: clamp(18px, 2.2vw, 26px); line-height: 1.05; letter-spacing: var(--track); text-transform: uppercase; }
#banner .sub { display: block; font-size: clamp(13px, 1.2vw, 15px); font-weight: 600; margin-top: 1px; }
#banner.show { animation: banner 3s ease forwards; }
@keyframes banner { 0% { opacity: 0; clip-path: inset(0 100% 0 0); } 12% { opacity: 1; clip-path: inset(0 0 0 0); } 82% { opacity: 1; } 100% { opacity: 0; } }

#toasts { position: fixed; bottom: 128px; left: 16px; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; pointer-events: none; max-width: min(360px, 60vw); }
#toasts div { background: var(--tar); color: var(--straw); border: 2px solid var(--tar-edge); border-left: 4px solid var(--straw); padding: 1px 12px; font-weight: 700; font-size: 16px; letter-spacing: .02em; animation: toast 2.6s ease forwards; box-shadow: 3px 3px 0 rgba(0,0,0,.3); }
@keyframes toast { 0% { opacity: 0; transform: translateX(-12px); } 10% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; } }
@keyframes fadeIn { from { opacity: 0; } }

/* Napoleon picks a commandment */
#choice { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); width: min(780px, 94vw); text-align: center; animation: fadeIn .3s; z-index: 3; }
#choice h3 { display: inline-block; font-family: var(--f-display); font-weight: 900; font-size: 22px; letter-spacing: var(--track); text-transform: uppercase; background: var(--straw); color: var(--tar); padding: 2px 14px; margin-bottom: 8px; }
#choiceCards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
#choiceCards button { position: relative; text-align: left; padding: 10px 14px 12px; cursor: pointer; transition: transform .12s, border-color .12s; }
#choiceCards button:hover, #choiceCards button:focus-visible { transform: translateY(-4px); border-color: var(--red); }
#choiceCards .painted { display: block; font-size: 22px; line-height: 1.1; padding-right: 22px; }
#choiceCards .d { display: block; font-size: 15px; font-weight: 500; color: var(--whitewash-dim); line-height: 1.2; margin-top: 4px; }
#choiceCards kbd { position: absolute; top: 8px; right: 10px; font-family: var(--f-display); font-weight: 900; font-size: 16px; color: var(--tar); background: var(--straw); padding: 0 6px; }

/* ---------- Start & death screens: painted straight onto the barn wall ---------- */
.screen { position: fixed; inset: 0; display: flex; align-items: stretch; z-index: 5; }
.wall {
  width: min(560px, 100%); height: 100%; overflow-y: auto; padding: 22px 34px 28px;
  background:
    repeating-linear-gradient(0deg, transparent 0 46px, rgba(0,0,0,.5) 46px 49px),
    repeating-linear-gradient(90deg, rgba(255,255,255,.02) 0 1px, transparent 1px 11px),
    linear-gradient(90deg, rgba(31,26,23,.97), rgba(31,26,23,.93));
  border-right: 10px solid var(--tar-edge);
  box-shadow: 18px 0 40px rgba(0,0,0,.35);
}
.wall-top { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.wall-top .lang { margin-left: 8px; }
.lang { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--whitewash-dim); }
.lang select { background: var(--tar); border: 2px solid var(--whitewash-dim); padding: 2px 6px; font-size: 15px; letter-spacing: 0; text-transform: none; cursor: pointer; }

h1 { margin-top: 18px; font-family: var(--f-display); font-weight: 900; text-transform: uppercase; line-height: .85; letter-spacing: var(--track); }
h1 .t1 { display: block; font-size: 34px; color: var(--straw); }
h1 .t2 { display: inline-block; margin-top: 6px; font-size: clamp(58px, 11vw, 96px); padding: 4px 14px 2px; background: var(--red); transform: rotate(-2.5deg); box-shadow: 6px 6px 0 var(--tar-edge); }
.slogan { font-size: 21px; line-height: 1.3; margin: 22px 0 18px; max-width: 30ch; }

#name { width: 100%; font-size: 24px; font-weight: 600; padding: 6px 2px; color: var(--whitewash); background: transparent; border: 0; border-bottom: 3px solid var(--whitewash-dim); outline: none; letter-spacing: .02em; }
#name::placeholder { color: rgba(242,234,215,.35); }
#name:focus { border-bottom-color: var(--straw); }
.wall > .eyebrow { margin: 18px 0 8px; }

#species { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
#species button { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 8px; align-items: center; text-align: left; padding: 7px 9px; background: rgba(0,0,0,.25); border: 2px solid rgba(242,234,215,.25); cursor: pointer; transition: border-color .12s, background .12s; }
#species button:hover { border-color: var(--whitewash-dim); }
#species button { position: relative; }
#species button .e { grid-row: 1 / 3; width: 46px; height: 46px; object-fit: contain; margin: -4px 0; filter: drop-shadow(0 2px 0 rgba(0,0,0,.35)); }
#species button .dots { position: absolute; right: 6px; top: 5px; display: flex; gap: 3px; } /* top-right: clear of the perk text */
#species button .dots i { width: 5px; height: 5px; border-radius: 50%; background: rgba(242,234,215,.35); }
#species button .dots i.on { background: var(--straw); }
#species button .n { font-family: var(--f-display); font-weight: 900; font-size: 19px; letter-spacing: var(--track); text-transform: uppercase; line-height: 1; }
#species button .p { font-size: 13px; font-weight: 500; color: var(--whitewash-dim); line-height: 1.15; }
#species button.on { background: var(--red); border-color: var(--straw); }
#species button.on .p { color: var(--whitewash); }

.btn-red { display: block; width: 100%; margin-top: 18px; padding: 10px; font-family: var(--f-display); font-weight: 900; font-size: 30px; letter-spacing: .06em; text-transform: uppercase; color: var(--whitewash); background: var(--red); border: 3px solid var(--tar-edge); box-shadow: 6px 6px 0 var(--tar-edge); cursor: pointer; transition: transform .08s, box-shadow .08s; }
.btn-red:hover { background: #b8301f; }
.btn-red:active { transform: translate(4px, 4px); box-shadow: 2px 2px 0 var(--tar-edge); }
.btn-ghost { display: block; width: 100%; margin-top: 10px; padding: 6px; font-weight: 700; font-size: 17px; letter-spacing: .08em; text-transform: uppercase; color: var(--whitewash-dim); background: none; border: 0; cursor: pointer; }
.btn-ghost:hover { color: var(--whitewash); }

#bestLine { margin-top: 12px; font-size: 17px; font-weight: 700; color: var(--straw); min-height: 1.2em; }
.how { list-style: none; margin-top: 16px; padding-top: 14px; border-top: 2px dashed rgba(242,234,215,.2); display: grid; gap: 5px; font-size: 16px; font-weight: 500; color: var(--whitewash-dim); }
.how li::before { content: '★ '; color: var(--red); }

/* Death notice */
#death { justify-content: center; align-items: center; background: rgba(15,12,10,.35); }
#death .wall { height: auto; max-height: 100%; width: min(460px, 94vw); border: 6px solid var(--tar-edge); text-align: center; padding: 26px 26px 20px; }
.stamp { display: inline-block; font-family: var(--f-display); font-weight: 900; font-size: 54px; line-height: 1; letter-spacing: var(--track); text-transform: uppercase; color: var(--red); border: 5px solid var(--red); padding: 4px 16px 2px; transform: rotate(-4deg); animation: stamp .35s cubic-bezier(.2, 1.6, .5, 1) both; }
@keyframes stamp { from { transform: rotate(-4deg) scale(2.2); opacity: 0; } }
#deathCause { margin: 16px 0 4px; font-size: 18px; font-weight: 500; line-height: 1.3; }
.deathStats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 14px 0; }
.deathStats div { padding: 6px 2px; border: 2px solid rgba(242,234,215,.2); }
.deathStats b { display: block; font-family: var(--f-display); font-weight: 900; font-size: 30px; line-height: 1.05; }
.deathStats span { font-size: 13px; font-weight: 600; color: var(--whitewash-dim); text-transform: uppercase; letter-spacing: .06em; }
#deathBest { font-weight: 700; font-size: 17px; color: var(--straw); min-height: 1.3em; }
.hint { margin-top: 4px; font-size: 13px; color: var(--whitewash-dim); }

@media (max-width: 1100px) {
  #lb { width: 180px; }
  #lb ol { font-size: 14px; }
  #board { min-width: 0; max-width: calc(100vw - 420px); padding: 5px 12px 7px; }
  #ruleName { font-size: 19px; }
}
@media (max-width: 700px) {
  #board { left: 12px; top: 78px; transform: none; max-width: calc(100vw - 186px); padding: 4px 10px 6px; text-align: left; }
  #ruleName { font-size: 19px; }
  #board small { display: none; }
  #lb { width: 150px; padding: 6px 8px; }
  #lb ol { font-size: 13px; }
  #minimap { width: 110px; height: 110px; }
  #stats .weight b { font-size: 40px; }
  #stats .sub { font-size: 14px; }
  .wall { padding: 16px 18px 24px; }
  #species { grid-template-columns: repeat(2, 1fr); }
  #choiceCards { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}

/* While the start wall covers the left side, centre the board and podium status over the visible farm */
@media (min-width: 701px) {
  body.menu #board, body.menu #capture { left: calc(min(560px, 100%) + (100% - min(560px, 100%)) / 2); }
}
@media (max-width: 700px) { body.menu #board, body.menu #capture { display: none; } }
/* Nanum Brush Script runs small: scale the painted lines up for Korean */
html[lang="ko"] .slogan, html[lang="ko"] #choiceCards .painted { font-size: 1.35em; }
html[lang="ko"] #ruleName { font-size: 26px; }

/* Sound (M) + music (N) toggles: start wall only, next to the language picker */
#mute, #music { width: 36px; height: 36px; font-size: 18px; line-height: 1; background: var(--tar); border: 2px solid var(--whitewash-dim); cursor: pointer; }
#mute:hover, #music:hover { border-color: var(--straw); }
#music.off { opacity: .45; text-decoration: line-through; }

body.choosing #capture { display: none; }
@media (max-width: 1100px) { #banner { top: 116px; } }
@media (max-width: 700px) { #banner { top: auto; bottom: 64px; max-width: 70vw; } #toasts { bottom: 200px; } }
@media (pointer: coarse) { #toasts { bottom: 280px; } }

/* Connection lost banner */
#net { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); padding: 8px 18px; font-family: var(--f-display); font-weight: 900; font-size: 22px; text-transform: uppercase; color: var(--whitewash); background: var(--red); border: 3px solid var(--tar-edge); box-shadow: 5px 5px 0 var(--tar-edge); z-index: 9; animation: fadeIn .3s; }

/* Play with friends / private farm on the start wall */
#roomLine { margin-top: 10px; }
.btn-outline { display: block; width: 100%; padding: 8px; font-family: var(--f-display); font-weight: 900; font-size: 20px; letter-spacing: .05em; text-transform: uppercase; color: var(--straw); background: transparent; border: 3px solid var(--straw); cursor: pointer; transition: background .12s, color .12s; }
.btn-outline:hover { background: var(--straw); color: var(--tar); }
.room-card { margin-bottom: 8px; padding: 8px 12px; border: 2px dashed var(--straw); text-align: center; }
.room-code { font-family: var(--f-display); font-weight: 900; font-size: 22px; letter-spacing: .04em; color: var(--whitewash); }
#roomLine .btn-ghost { margin-top: 4px; }

/* "+3 kg" rising above my animal */
#floats { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.float { position: absolute; left: 0; top: 0; font-family: var(--f-display); font-weight: 900; font-size: 22px; color: var(--straw); text-shadow: 2px 2px 0 var(--tar), -1px -1px 0 var(--tar), 1px -1px 0 var(--tar), -1px 1px 0 var(--tar); white-space: nowrap; will-change: transform, opacity; }
.float.big { font-size: 32px; color: #ffd84a; }
.float.loss { color: #ff6a4d; }

/* ---------- Game mode picker (start wall) ---------- */
#modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#modes button { text-align: left; padding: 7px 10px; background: rgba(0,0,0,.25); border: 2px solid rgba(242,234,215,.25); cursor: pointer; }
#modes button:hover { border-color: var(--whitewash-dim); }
#modes button .n { display: block; font-family: var(--f-display); font-weight: 900; font-size: 19px; letter-spacing: var(--track); text-transform: uppercase; line-height: 1.05; }
#modes button .p { display: block; font-size: 13px; color: var(--whitewash-dim); line-height: 1.15; }
#modes button.on { background: var(--red); border-color: var(--straw); }
#modes button.on .p { color: var(--whitewash); }

/* ---------- Team mode HUD ---------- */
#teamBar { position: fixed; top: 8px; left: 50%; transform: translateX(-50%); display: flex; align-items: stretch; z-index: 3; pointer-events: none; font-family: var(--f-display); font-weight: 900; box-shadow: 0 4px 0 rgba(0,0,0,.3); }
#teamBar .tb { display: flex; align-items: center; gap: 10px; padding: 3px 12px; font-size: 16px; text-transform: uppercase; letter-spacing: var(--track); }
#teamBar .tb i { font-style: normal; font-size: 22px; font-variant-numeric: tabular-nums; }
#teamBar .tb0 { background: #3fa34d; }
#teamBar .tb1 { background: #3b7fd6; }
#teamBar .lead { box-shadow: inset 0 -4px 0 var(--straw); }
#tClock { padding: 3px 12px; font-size: 22px; background: var(--tar); color: var(--whitewash); font-variant-numeric: tabular-nums; }
#tClock.soon { background: var(--red); }
body.team #board { top: 52px; }
body.team #banner { top: 172px; }
#myTeam { display: inline-block; margin-top: 4px; padding: 0 8px; font-weight: 700; font-size: 14px; letter-spacing: .05em; text-transform: uppercase; color: var(--whitewash); text-shadow: none; }
#matchEnd { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(15,12,10,.35); z-index: 6; pointer-events: none; }
#matchEnd .wall { height: auto; width: min(460px, 94vw); border: 6px solid var(--tar-edge); text-align: center; padding: 22px 24px; }
#meScore { margin: 14px 0 6px; font-family: var(--f-display); font-weight: 900; font-size: 38px; }
#meScore span { padding: 0 10px; }
#meMvp { font-weight: 700; font-size: 17px; color: var(--straw); }
#meNext { margin-top: 6px; font-size: 15px; color: var(--whitewash-dim); }
@media (max-width: 1100px) { body.team #banner { top: 160px; } }
@media (max-width: 700px) { #teamBar .tb b { display: none; } body.team #board { top: 118px; } }
@media (min-width: 701px) { body.menu #teamBar { left: calc(min(560px, 100%) + (100% - min(560px, 100%)) / 2); } }
@media (max-width: 700px) { body.menu #teamBar { display: none; } }

/* ---------- Touch screens (phones, tablets) ---------- */
#stick { position: fixed; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; border: 3px solid rgba(242,234,215,.5); background: rgba(31,26,23,.25); pointer-events: none; z-index: 4; }
#stickKnob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: rgba(242,234,215,.75); box-shadow: 0 3px 0 rgba(0,0,0,.3); }
.wall { touch-action: pan-y; }
@media (pointer: coarse) {
  #dashBtn { display: block; left: auto; right: 22px; bottom: 28px; width: 100px; height: 100px; font-size: 22px; }
  #dashBtn:active { transform: scale(.94); background: #c23523; }
  #feed { display: none; }
  #toasts { bottom: auto; top: 150px; left: 50%; transform: translateX(-50%); align-items: center; }
  #choiceCards kbd { display: none; }
  #capture { bottom: 140px; }
}
/* tablets / landscape: keep the desktop layout, park the RAM button left of the minimap */
@media (pointer: coarse) and (min-width: 701px) {
  #dashBtn { right: 200px; bottom: 30px; }
}
/* phones: compact HUD, minimap and buttons stacked top-right, RAM bottom-right */
@media (pointer: coarse) and (max-width: 700px) {
  #lbList li:nth-child(n+6), #hof { display: none; }
  #lb { width: 150px; }
  #mapWrap { top: 140px; bottom: auto; }
  #minimap { width: 100px; height: 100px; }
  #banner { bottom: 150px; }
  body.team #teamBar { left: 12px; top: 74px; transform: none; }
  body.team #board { top: 118px; }
}
/* short landscape phones */
@media (pointer: coarse) and (max-height: 500px) {
  #lbList li:nth-child(n+4), #hof { display: none; }
  #minimap { width: 100px; height: 100px; }
}

/* ---------- Room code, leave button, rotate tip ---------- */
.code-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-bottom: 8px; }
.code-row input { min-width: 0; padding: 6px 10px; font-family: var(--f-display); font-weight: 900; font-size: 20px; letter-spacing: .12em; text-transform: uppercase; color: var(--whitewash); background: rgba(0,0,0,.3); border: 2px solid var(--whitewash-dim); outline: none; }
.code-row input::placeholder { color: rgba(242,234,215,.35); letter-spacing: .04em; }
.code-row input:focus { border-color: var(--straw); }
.code-row .btn-outline { width: auto; padding: 6px 16px; }
.room-code { letter-spacing: .08em; }
#roomTag { font-size: 13px; font-weight: 700; letter-spacing: .08em; color: var(--whitewash-dim); background: var(--tar); padding: 0 8px; }
#exit { position: fixed; right: 12px; bottom: 216px; width: 40px; height: 40px; font-size: 20px; line-height: 1; background: var(--tar); border: 2px solid var(--tar-edge); box-shadow: 3px 3px 0 rgba(0,0,0,.3); cursor: pointer; }
#exit:hover { border-color: var(--whitewash-dim); }
#exit.armed { background: var(--red); border-color: var(--straw); animation: fadeIn .2s; }
#rotateTip { display: none; margin-top: 10px; font-size: 15px; font-weight: 600; color: var(--straw); }
#rotateTip::before { content: '📱↻ '; }
@media (pointer: coarse) and (orientation: portrait) and (max-width: 700px) { #rotateTip { display: block; } }
@media (max-width: 700px) { #exit { bottom: 150px; } }
@media (pointer: coarse) and (max-width: 700px) { #exit { top: 180px; bottom: auto; width: 36px; height: 36px; font-size: 18px; } }

/* ---------- Phones held sideways (short landscape screens) ---------- */
@media (pointer: coarse) and (max-height: 500px) and (orientation: landscape) {
  #stats .weight b { font-size: 34px; }
  #stats .sub { font-size: 13px; }
  #board { top: 6px; max-width: calc(100vw - 440px); padding: 3px 10px 5px; }
  #board small { display: none; }
  #ruleName { font-size: 17px; }
  #reign { font-size: 13px; margin-top: 2px; }
  #lb { width: 170px; padding: 5px 8px; top: 6px; }
  #lb ol { font-size: 13px; line-height: 1.25; }
  #mapWrap { right: 10px; bottom: 8px; top: auto; }
  #minimap { width: 92px; height: 92px; }
  #exit { top: auto; bottom: 8px; right: 112px; width: 36px; height: 36px; }
  #dashBtn { right: 18px; bottom: 140px; width: 88px; height: 88px; }
  #banner { top: 70px; bottom: auto; max-width: 52vw; }
  #banner .head { font-size: 18px; }
  #toasts { top: 70px; }
  #capture { bottom: 56px; font-size: 14px; }
  #choice { bottom: 6px; width: min(640px, 70vw); }
  #choiceCards { grid-template-columns: repeat(3, 1fr); }
  #choiceCards .painted { font-size: 16px; }
  #choiceCards .d { font-size: 12px; }
  body.team #teamBar { top: 6px; left: 50%; transform: translateX(-50%); }
  body.team #board { top: 44px; }
  .wall { padding: 12px 20px 20px; }
  h1 .t2 { font-size: 52px; }
  .slogan { font-size: 16px; margin: 12px 0; }
  #death .wall { padding: 14px 18px 12px; }
  .stamp { font-size: 38px; }
  .deathStats b { font-size: 22px; }
}
@media (pointer: coarse) and (max-height: 500px) and (orientation: landscape) {
  #mapIn { display: none; }                                   /* the room code stays; the rebuild countdown is also announced by banner */
  body.menu #board, body.menu #teamBar, body.menu #capture { display: none; }
}

/* ---------- Phones held upright: minimal HUD ----------
   left column: weight + rank, then the commandment; right column: top 3, minimap, leave.
   Banners run as a strip below both columns, toasts sit above the RAM row. */
@media (pointer: coarse) and (max-width: 700px) and (orientation: portrait) {
  #koTxt .kl { display: none; }
  #koTxt .ks { display: inline; }
  #board { top: 66px; max-width: calc(100vw - 186px); padding: 3px 10px 5px; }
  #board .eyebrow { display: none; }
  #ruleName { font-size: 17px; }
  #reign { margin-top: 3px; padding: 0 7px; font-size: 14px; }
  #reign .rl { display: none; }
  #reign .rs { display: inline; }
  #lb { top: 8px; width: 160px; padding: 4px 8px; }
  #lb li { gap: 4px; padding: 0 2px; }
  #lb h3, #lbList li:nth-child(n+4), #hof { display: none; }
  #lb ol { margin-top: 0; font-size: 13px; line-height: 1.3; }
  #mapWrap { top: 80px; bottom: auto; }
  #minimap { width: 92px; height: 92px; }
  #mapIn, #roomTag { display: none; }
  #banner { top: 232px; bottom: auto; max-width: 90vw; }
  #toasts { top: auto; bottom: 176px; }
  #toasts div { font-size: 14px; }
  body.team #board { top: 112px; }
  body.team #banner { top: 232px; }
  /* the team chip would sit under the score bar: mark my side of the bar instead */
  #myTeam { display: none !important; }
  #teamBar .tb.mine { outline: 3px solid var(--whitewash); outline-offset: -3px; }
  #teamBar .tb.mine i::before { content: '★ '; font-size: 15px; }
}

/* ---------- Start screen fits laptop heights: the play button is always in view ---------- */
/* it rides along the bottom of the wall while the options scroll under it */
#start #play { position: sticky; bottom: 12px; z-index: 3; }
/* shorter screens (laptops ~700–920 px tall): a tighter wall so the button sits above the fold */
@media (min-width: 701px) and (max-height: 920px) {
  #start .wall { padding: 14px 30px 18px; }
  #start h1 { margin-top: 6px; }
  #start h1 .t1 { font-size: 26px; }
  #start h1 .t2 { font-size: clamp(48px, 8.5vh, 80px); margin-top: 4px; }
  #start .slogan { font-size: 17px; margin: 12px 0 8px; }
  #start #name { font-size: 20px; padding: 4px 2px; }
  #start .wall > .eyebrow { margin: 10px 0 6px; }
  #modes button { padding: 5px 9px; }
  #modes button .n, #species button .n { font-size: 17px; }
  #species { gap: 6px; }
  #species button { padding: 4px 8px; }
  #species button .e { width: 38px; height: 38px; }
  #start .hint { margin-top: 2px; }
  #start .btn-red { margin-top: 12px; padding: 7px; font-size: 26px; }
}
@media (min-width: 701px) and (max-height: 760px) {
  #start .slogan { display: none; } /* the title says enough when space is tight */
  #start h1 { margin-bottom: 16px; } /* room for the tilted title box, which used to rest on the slogan */
  #modes button .p, #species button .p { font-size: 12px; }
}
