:root {
  --paper: #f6efe0; --paper2: rgba(246, 239, 224, .7); --ink: #120d0b; --red: #c8302c; --gold: #d8b36a; --line: rgba(246, 239, 224, .22);
  --serif: "Hoefler Text", Baskerville, "Iowan Old Style", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  --jp: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", "Songti SC", serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; font-family: var(--serif); color: var(--paper); background: #2a2216; user-select: none; -webkit-user-select: none; touch-action: none; }
canvas { position: fixed; inset: 0; display: block; width: 100%; height: 100%; }
body[data-screen="play"] canvas#game, body[data-screen="lobby"] canvas#game { cursor: none; }
[hidden] { display: none !important; }
button { font-family: var(--serif); color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input { font: 600 19px var(--serif); color: var(--paper); background: rgba(10, 8, 6, .35); border: 0; border-bottom: 1.5px solid var(--line); padding: 10px 4px; outline: none; width: 100%; border-radius: 0; }
input:focus { border-bottom-color: var(--paper); }
input::placeholder { color: rgba(246, 239, 224, .35); }
h4 { margin: 22px 0 10px; font: 600 12px var(--sans); letter-spacing: .22em; text-transform: uppercase; color: var(--gold); }

/* ---------- the menu column on the left, over the live scene ---------- */
.side { position: absolute; left: 0; top: 0; bottom: 0; width: min(460px, 36vw); padding: 44px 46px 70px; display: flex; flex-direction: column; overflow: auto; touch-action: pan-y;
  background: linear-gradient(90deg, rgba(12, 8, 5, .86) 0%, rgba(12, 8, 5, .72) 62%, rgba(12, 8, 5, 0) 100%); }
#title, #lobby { position: fixed; inset: 0; pointer-events: none; }
#title > *, #lobby > * { pointer-events: auto; }
.logo { position: relative; margin-bottom: 34px; animation: rise .9s cubic-bezier(.2, .9, .3, 1) both; }
.bigk { position: absolute; left: -24px; top: -40px; font: 900 220px/1 var(--jp); color: var(--red); opacity: .85; pointer-events: none; mix-blend-mode: screen; filter: drop-shadow(0 0 30px rgba(200, 48, 44, .45)); }
h1 { position: relative; margin: 0; font: 700 64px/.92 var(--serif); letter-spacing: .04em; text-transform: uppercase; text-shadow: 0 4px 30px rgba(0, 0, 0, .6); }
.tag { position: relative; margin: 14px 0 0; font: italic 17px var(--serif); color: var(--paper2); }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } }

/* menu items: big words; a red brush stroke sweeps in behind the one you point at */
.menu { display: flex; flex-direction: column; gap: 4px; }
.menu > button, .joinRow > button { position: relative; text-align: left; padding: 12px 18px 12px 16px; margin-left: -16px; animation: rise .7s both; background-image: var(--brush-red); background-repeat: no-repeat; background-position: left center; background-size: 0% 100%; transition: background-size .28s cubic-bezier(.3, .9, .3, 1), transform .2s; }
.menu > button:nth-child(2) { animation-delay: .08s } .menu > :nth-child(3) { animation-delay: .16s }
.menu > button:hover, .menu > button:focus-visible, .joinRow > button:hover { background-size: 100% 100%; transform: translateX(6px); outline: none; }
.menu b { display: block; font: 700 34px/1.1 var(--serif); letter-spacing: .01em; text-shadow: 0 2px 14px rgba(0, 0, 0, .5); }
.menu small { display: block; font: 15px var(--sans); color: var(--paper2); margin-top: 3px; }
.joinRow { display: flex; align-items: center; gap: 14px; animation: rise .7s .16s both; }
.joinRow > button { margin-left: -16px; animation: none; }
#code { width: 130px; text-align: center; letter-spacing: .35em; font-weight: 800; font-size: 22px; text-transform: uppercase; }
.me { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px; margin-top: 34px; padding-top: 22px; border-top: 1px solid var(--line); animation: rise .7s .24s both; }
.me span, .pick span { display: block; font: 600 11px var(--sans); letter-spacing: .2em; text-transform: uppercase; color: var(--gold); margin-bottom: 8px; }
#cols { display: flex; gap: 9px; height: 44px; align-items: center; }
#cols button { width: 28px; height: 28px; border-radius: 50%; background: var(--c); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .25); transition: transform .15s; }
#cols button.on { box-shadow: 0 0 0 3px rgba(12, 8, 5, .9), 0 0 0 5px var(--paper); transform: scale(1.12); }
#status { min-height: 20px; margin: 16px 0 0; color: var(--gold); font-style: italic; }
.hint { position: absolute; right: 26px; bottom: 60px; margin: 0; font: 14px var(--sans); color: var(--paper); text-shadow: 0 1px 8px rgba(0, 0, 0, .8); letter-spacing: .04em; }
.hint b { color: var(--gold); font-weight: 600; }

/* ---------- the dojo lobby ---------- */
#lobby .side { padding-top: 34px; }
#lobby header { display: flex; align-items: center; gap: 16px; }
.k { display: grid; place-items: center; flex: none; width: 54px; height: 54px; background: var(--red); color: var(--paper); font: 900 32px var(--jp); border-radius: 4px; transform: rotate(-4deg); box-shadow: inset 0 0 0 2px rgba(246, 239, 224, .3); }
h2 { margin: 0; font: 700 34px/1.05 var(--serif); }
#lobby header p { margin: 4px 0 0; color: var(--paper2); font: 15px var(--sans); line-height: 1.35; }
#lobCode { display: flex; align-items: center; justify-content: space-between; margin-top: 22px; padding: 12px 16px; background: rgba(246, 239, 224, .08); border-left: 3px solid var(--red); }
#lobCode small { display: block; font: 600 11px var(--sans); letter-spacing: .2em; text-transform: uppercase; color: var(--gold); }
#lobCode b { font: 800 38px var(--serif); letter-spacing: .2em; }
#copy { font: 600 14px var(--sans); padding: 9px 14px; border: 1px solid var(--line); border-radius: 2px; }
#copy:hover { background: var(--paper); color: var(--ink); }
#crew { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
#crew li { display: flex; align-items: center; gap: 12px; padding: 8px 0; font: 700 19px var(--serif); border-bottom: 1px solid rgba(246, 239, 224, .08); }
#crew li i { width: 10px; height: 26px; background: var(--c); transform: skewX(-14deg); flex: none; }
#crew li span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#crew li small { font: 600 11px var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--gold); }
#crewNote { margin: 8px 0 0; color: var(--paper2); font: italic 15px var(--serif); min-height: 18px; }
#maps { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
#maps button { position: relative; aspect-ratio: 16 / 9; overflow: hidden; background: #3a2e20 center / cover no-repeat; border-radius: 2px; text-align: left; box-shadow: inset 0 0 0 1px var(--line); transition: transform .15s; }
#maps button::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0, 0, 0, .1), rgba(0, 0, 0, .6)); }
#maps button:hover { transform: translateY(-2px); }
#maps button.on { box-shadow: inset 0 0 0 2px var(--paper), 0 0 0 2px var(--red); }
#maps span { position: absolute; z-index: 1; left: 9px; bottom: 22px; font: 900 20px var(--jp); text-shadow: 0 1px 6px #000; }
#maps small { position: absolute; z-index: 1; left: 9px; bottom: 6px; font: 600 12px var(--sans); text-shadow: 0 1px 6px #000; }
#maps i { position: absolute; inset: 0; display: grid; place-items: center; font: 900 46px var(--jp); color: rgba(246, 239, 224, .3); font-style: normal; }
.pick { display: flex; align-items: center; gap: 4px; margin-top: 14px; }
.pick span { flex: 1; margin: 0; }
.pick b { min-width: 92px; text-align: center; font: 700 21px var(--serif); }
.pick button { width: 40px; height: 40px; font: 400 30px/1 var(--serif); color: var(--paper2); border-radius: 50%; }
.pick button:hover { color: var(--paper); background: rgba(246, 239, 224, .1); }
.guest .hostonly { opacity: .55; pointer-events: none; }
.actions { margin-top: auto; padding-top: 26px; display: flex; flex-direction: column; gap: 6px; }
.go { position: relative; text-align: left; padding: 14px 22px; background: var(--brush-red) left center / 100% 100% no-repeat; transition: transform .2s; }
.go:hover { transform: translateX(6px) scale(1.02); }
.go b { font: 700 30px var(--serif); text-shadow: 0 2px 10px rgba(0, 0, 0, .4); }
.go small { font: 700 20px var(--jp); margin-left: 10px; color: rgba(246, 239, 224, .75); }
#waitHost { margin: 0; font: italic 18px var(--serif); color: var(--gold); }
.back { align-self: flex-start; font: 600 15px var(--sans); color: var(--paper2); padding: 8px 0; letter-spacing: .06em; }
.back:hover { color: var(--paper); }
#moves { position: absolute; right: 22px; bottom: 64px; width: 290px; background: rgba(12, 8, 5, .72); backdrop-filter: blur(6px); border-left: 3px solid var(--red); }
#movesBtn { width: 100%; text-align: left; padding: 12px 16px; }
#movesBtn b { font: 700 19px var(--serif); } #movesBtn small { font: 700 15px var(--jp); color: var(--red); margin-left: 8px; }
#moves ul, #moves p { display: none; }
#moves.open ul { display: block; list-style: none; margin: 0; padding: 0 16px; }
#moves.open p { display: block; margin: 8px 16px 14px; font: italic 14px var(--serif); color: var(--paper2); }
#moves li { display: flex; gap: 12px; align-items: center; padding: 7px 0; border-top: 1px solid rgba(246, 239, 224, .1); font: 13px var(--sans); color: var(--paper2); line-height: 1.3; }
#moves li > b { font: 900 25px var(--jp); width: 46px; text-align: center; flex: none; } #moves li > b.gold { color: var(--gold); } #moves li > b.red { color: #ff5a4a; font-size: 20px; }
#moves li strong { display: block; color: var(--paper); font: 700 16px var(--serif); }

/* ---------- in a match ---------- */
#plates { position: fixed; left: 0; right: 0; top: 10px; display: none; justify-content: center; align-items: flex-start; gap: 10px; pointer-events: none; }
body[data-screen="play"] #plates { display: flex; }
.plate { position: relative; width: 150px; padding: 7px 12px 8px 14px; background: linear-gradient(90deg, rgba(12, 8, 5, .85), rgba(12, 8, 5, .6)); border-left: 4px solid var(--c); transition: opacity .3s; }
.plate.ko { opacity: .45; }
.plate.me { box-shadow: 0 0 0 1px rgba(246, 239, 224, .5); }
.plate .nm { display: block; font: 700 16px var(--serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 34px; }
.plate .sc { position: absolute; right: 10px; top: 3px; font: 700 28px var(--serif); }
.plate .sc.lead { color: #ff6a55; }
.plate .hp { display: flex; gap: 3px; margin-top: 6px; }
.plate .hp i { flex: 1; height: 5px; background: rgba(246, 239, 224, .15); transition: background .2s; }
.plate .hp i.on { background: var(--paper); } .plate .hp.low i.on { background: #ff4a3a; }
.clock { width: 86px; text-align: center; padding-top: 2px; }
.clock b { display: block; font: 700 30px var(--serif); text-shadow: 0 2px 12px rgba(0, 0, 0, .7); }
.clock b.low { color: #ff5a4a; }
.clock small { display: block; font: 600 10px var(--sans); letter-spacing: .18em; text-transform: uppercase; color: var(--paper); text-shadow: 0 1px 6px #000; }
#banner { position: fixed; left: 50%; top: 46%; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; pointer-events: none; opacity: 0; }
#banner.show { animation: banner 1s cubic-bezier(.2, .9, .3, 1) both; }
#banner b { font: 900 150px/1 var(--jp); color: var(--paper); text-shadow: 0 6px 40px rgba(0, 0, 0, .6); padding: 0 70px; background: var(--brush-ink) center / 100% 70% no-repeat; }
#banner span { margin-top: 6px; font: 700 26px var(--serif); letter-spacing: .5em; text-transform: uppercase; text-shadow: 0 2px 12px #000; }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, -50%) scale(1.5); } 15% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -50%) scale(.96); } }
#hud { position: fixed; left: 14px; bottom: 14px; display: none; gap: 8px; }
body[data-screen="play"] #hud { display: flex; }
#hud button { width: 44px; height: 44px; border-radius: 50%; background: rgba(12, 8, 5, .65); color: var(--paper); font-size: 17px; }
#hud button:hover { background: var(--red); }
#hud button.off { opacity: .45; text-decoration: line-through; }
#feed { position: fixed; top: 86px; right: 14px; list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; pointer-events: none; }
#feed li { display: flex; align-items: center; gap: 10px; padding: 6px 14px; background: linear-gradient(270deg, rgba(12, 8, 5, .85), rgba(12, 8, 5, .4)); font: 700 15px var(--serif); animation: slide .3s cubic-bezier(.2, 1.2, .4, 1) both; transition: opacity .4s, transform .4s; }
#feed li em { font: 900 22px var(--jp); font-style: normal; color: #ff5a4a; }
#feed li small { font: 600 10px var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--gold); }
#feed li.mine { border-right: 3px solid var(--red); }
#feed li.out { opacity: 0; transform: translateX(30px); }
@keyframes slide { from { transform: translateX(60px); opacity: 0; } }
#dashBtn { display: none; position: fixed; right: 20px; bottom: 70px; width: 110px; height: 110px; border-radius: 50%; font: 900 40px/1 var(--jp); color: var(--paper); background: radial-gradient(circle at 40% 35%, #e0443a, #9e1f1a); box-shadow: 0 8px 26px rgba(0, 0, 0, .45), inset 0 0 0 3px rgba(246, 239, 224, .25); opacity: .9; }
#dashBtn small { display: block; font: 700 12px var(--sans); letter-spacing: .14em; margin-top: 3px; }
@media (pointer: coarse) { body[data-screen="play"] #dashBtn, body[data-screen="lobby"] #dashBtn { display: block; } }
#dashBtn:active { transform: scale(.92); }

/* ---------- results ---------- */
#results { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(ellipse at center, rgba(12, 8, 5, .35), rgba(12, 8, 5, .8)); }
#results .bar { position: absolute; left: 0; right: 0; height: 9vh; background: #000; animation: bars .6s cubic-bezier(.2, .9, .3, 1) both; }
#results .bar.top { top: 0; } #results .bar.bot { bottom: 0; transform-origin: bottom; }
@keyframes bars { from { transform: scaleY(0); } }
#results .inner { position: relative; width: min(560px, 92vw); text-align: center; padding-bottom: 40px; animation: rise .8s .2s both; }
#results .bigk { position: relative; display: block; left: 0; top: 0; font-size: 180px; margin-bottom: -40px; opacity: .9; }
#resT { position: relative; font-size: 56px; text-transform: uppercase; letter-spacing: .08em; text-shadow: 0 4px 30px #000; }
#resSub { font: italic 19px var(--serif); color: var(--paper2); margin: 8px 0 0; }
#podium { list-style: none; padding: 0; margin: 26px 0 14px; text-align: left; }
#podium li { display: flex; align-items: center; gap: 14px; padding: 10px 16px; border-bottom: 1px solid var(--line); animation: rise .5s both; }
#podium li:nth-child(1) { background: linear-gradient(90deg, rgba(200, 48, 44, .45), rgba(200, 48, 44, 0)); }
#podium li:nth-child(2) { animation-delay: .4s } #podium li:nth-child(3) { animation-delay: .5s } #podium li:nth-child(n+4) { animation-delay: .6s } #podium li:nth-child(1) { animation-delay: .3s }
#podium em { font: 900 24px var(--jp); font-style: normal; width: 28px; color: var(--gold); }
#podium i { width: 8px; height: 24px; background: var(--c); transform: skewX(-14deg); }
#podium span { flex: 1; font: 700 20px var(--serif); }
#podium b { font: 700 24px var(--serif); text-align: right; min-width: 56px; } #podium b small { display: block; font: 600 10px var(--sans); letter-spacing: .14em; color: var(--gold); text-transform: uppercase; }
.menu.row { flex-direction: row; justify-content: center; gap: 18px; }
.menu.row button { margin: 0; text-align: center; padding: 12px 26px; }
.menu.row b { font-size: 26px; }
#resWait { font: italic 18px var(--serif); color: var(--gold); }

#toast { position: fixed; top: 16px; left: 50%; transform: translate(-50%, -170%); display: flex; align-items: center; gap: 12px; padding: 8px 20px 8px 8px; background: rgba(12, 8, 5, .88); border-left: 3px solid var(--red); transition: transform .45s cubic-bezier(.2, 1.3, .4, 1); z-index: 9; }
#toast.show { transform: translate(-50%, 0); }
#toast .k { width: 38px; height: 38px; font-size: 22px; }
#toast p { margin: 0; font: 600 16px var(--serif); }

@media (max-width: 820px) {
  .side { top: auto; width: 100%; max-height: 62vh; padding: 26px 22px 60px; background: linear-gradient(0deg, rgba(12, 8, 5, .92) 0%, rgba(12, 8, 5, .8) 75%, rgba(12, 8, 5, 0) 100%); }
  #title .side { max-height: none; top: 0; justify-content: flex-end; }
  h1 { font-size: 46px; } .bigk { font-size: 150px; top: -20px; }
  .menu b { font-size: 27px; }
  .hint, #moves { display: none; }
  .plate { width: 108px; padding: 5px 8px 6px 10px; } .plate .nm { font-size: 13px; } .plate .sc { font-size: 22px; }
  #banner b { font-size: 100px; }
}
@media print { #hud, #dashBtn, #feed, #toast { display: none !important; } }

/* ---------- ways of battle ---------- */
#modes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
#modes button { position: relative; text-align: left; padding: 10px 12px 11px 54px; min-height: 66px; background: rgba(246, 239, 224, .06); border-radius: 2px; box-shadow: inset 0 0 0 1px var(--line); transition: transform .15s, background .2s; overflow: hidden; }
#modes button:hover { transform: translateY(-2px); background: rgba(246, 239, 224, .11); }
#modes button.on { background: var(--brush-red) center / 140% 120% no-repeat, rgba(200, 48, 44, .25); box-shadow: inset 0 0 0 2px var(--paper); }
#modes b { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); width: 40px; text-align: center; font: 900 22px/1 var(--jp); color: var(--paper); writing-mode: vertical-rl; letter-spacing: .05em; }
#modes span { display: block; font: 700 17px var(--serif); }
#modes small { display: block; margin-top: 2px; font: 12px/1.25 var(--sans); color: var(--paper2); }

/* ---------- match HUD for each way ---------- */
.plate { border-left-color: var(--t, var(--c)); }
.plate::after { content: ''; position: absolute; left: -4px; top: 0; width: 4px; height: 40%; background: var(--c); }
.plate.out { opacity: .3; filter: grayscale(1); }
.plate.hold { box-shadow: 0 0 0 2px #ffd27a, 0 0 18px rgba(255, 210, 122, .6); }
.plate .sc.lives { display: flex; gap: 3px; top: 9px; }
.plate .sc.lives i { width: 9px; height: 14px; background: rgba(246, 239, 224, .15); transform: skewX(-14deg); }
.plate .sc.lives i.on { background: #ff6a55; }
.clan { display: flex; gap: 6px; align-items: flex-start; padding: 0 0 0 0; }
.clan .cs { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 76px; height: 54px; background: var(--t); clip-path: polygon(0 0, 100% 0, 92% 100%, 8% 100%); box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .25); }
.clan .cs span { font: 600 9px var(--sans); letter-spacing: .16em; text-transform: uppercase; }
.clan .cs b { font: 800 30px/1 var(--serif); }
.clan:first-child { flex-direction: row-reverse; }
@media (max-width: 820px) { .clan .cs { min-width: 56px; height: 44px; } .clan .cs b { font-size: 22px; } }

/* ---------- the ink wipe between screens ---------- */
#wipe { position: fixed; inset: -30vh -40vw; pointer-events: none; z-index: 20; background: var(--brush-wipe) center / 100% 100% no-repeat; transform: translateX(-130%) skewX(-12deg); opacity: 0; }
#wipe.go { animation: wipe .6s cubic-bezier(.55, 0, .25, 1) both; }
@keyframes wipe { 0%, 12% { transform: translateX(0) skewX(-12deg); opacity: 1; } 100% { transform: translateX(135%) skewX(-12deg); opacity: 1; } }
