:root {
  --ink: #f4ecd8;
  --dim: #b5a58f;
  --cyan: #ffd98a;
  --pink: #d9342b;
  --enemy: #ff7a5c;
  --amber: #e8bd55;
  --bg: #120a1c;
  --panel: rgba(24, 14, 26, 0.93);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink);
  font-family: "Yu Gothic UI", "Meiryo", "Segoe UI", system-ui, -apple-system, sans-serif; user-select: none; }
canvas#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
[hidden] { display: none !important; }

#hud { position: fixed; inset: 0; pointer-events: none; font-variant-numeric: tabular-nums; }
#crosshair { position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px; border-radius: 50%;
  background: var(--cyan); box-shadow: 0 0 0 1px #000a, 0 0 6px var(--cyan); }
#scope { position: absolute; inset: 0; --lens: 44vmin; }
#scope.optic { --lens: 34vmin; }
#scope .lens { position: absolute; inset: 0; }
#scope.sniper .lens, #scope.optic .lens {
  background: radial-gradient(circle at center,
    transparent calc(var(--lens) - 3vmin),
    rgba(0, 0, 0, 0.65) calc(var(--lens) - 0.8vmin),
    #03050a var(--lens)); }
#scope .reticle { position: absolute; left: 50%; top: 50%; display: none; fill: none; stroke-linecap: round; }
#scope.sniper .sniper-only, #scope.optic .optic-only, #scope.holo .holo-only { display: block; }
#scope .sniper-only { width: calc(var(--lens) * 2); height: calc(var(--lens) * 2); margin: calc(var(--lens) * -1); stroke: #d8ecff; stroke-width: 0.45; }
#scope .sniper-only .dot { fill: #ff3048; stroke: none; }
#scope .optic-only { width: calc(var(--lens) * 2); height: calc(var(--lens) * 2); margin: calc(var(--lens) * -1); stroke: #d8ecff; stroke-width: 0.6; }
#scope .optic-only .chevron { stroke: #ffc53d; stroke-width: 1.4; }
#scope .holo-only { width: 72px; height: 72px; margin: -36px; }
#scope .holo-only .ring { stroke: #ff3048; stroke-width: 3; opacity: 0.9; }
#scope .holo-only .dot { fill: #ff3048; }

#hitmarker { position: absolute; left: 50%; top: 50%; width: 26px; height: 26px; margin: -13px; opacity: 0;
  transform: rotate(45deg);
  background:
    linear-gradient(#fff, #fff) center top / 2px 8px no-repeat,
    linear-gradient(#fff, #fff) center bottom / 2px 8px no-repeat,
    linear-gradient(#fff, #fff) left center / 8px 2px no-repeat,
    linear-gradient(#fff, #fff) right center / 8px 2px no-repeat; }
#vignette { position: absolute; inset: 0; opacity: 0;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(255, 30, 70, 0.75) 100%); }

#topbar { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); display: flex; align-items: stretch; gap: 2px; }
#topbar > span { min-width: 46px; padding: 6px 10px; font-size: 24px; font-weight: 800; text-align: center; background: #000b; }
#topbar .us { color: var(--cyan); }
#topbar .them { color: var(--enemy); }
#clock { min-width: 86px; padding: 4px 10px; text-align: center; background: #000b; line-height: 1.1; }
#timer { display: block; font-size: 22px; font-weight: 700; }
#clock.armed #timer { color: var(--enemy); }
#phase { font-size: 11px; color: var(--dim); letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
#role { position: absolute; top: 74px; left: 50%; transform: translateX(-50%); padding: 2px 10px; font-size: 13px; color: var(--ink); background: #0008; white-space: nowrap; }

#feed { position: absolute; top: 14px; right: 16px; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 14px; }
#feed div { padding: 3px 9px; background: #000a; }
#feed .me { background: rgba(217, 52, 43, 0.5); }

#banner { position: absolute; top: 22%; left: 50%; transform: translateX(-50%); padding: 10px 24px; font-size: 26px; font-weight: 800;
  text-align: center; background: #000c; white-space: nowrap; }
#banner.win { color: var(--cyan); }
#banner.lose { color: var(--enemy); }

#prompt { position: absolute; left: 50%; top: 60%; transform: translateX(-50%); padding: 6px 14px; font-size: 16px; font-weight: 700; background: #000b; white-space: nowrap; }
#progress { position: absolute; left: 50%; top: calc(60% + 40px); width: 240px; height: 8px; margin-left: -120px; background: #fff3; }
#progressfill { height: 100%; width: 0; background: var(--amber); }

#hpbox { position: absolute; left: 24px; bottom: 22px; width: 220px; }
#hp { font-size: 42px; font-weight: 800; line-height: 1; }
#armor { margin-left: 8px; font-size: 16px; font-weight: 700; color: var(--amber); }
#hpbar, #speedbar { position: relative; height: 7px; margin-top: 6px; background: #fff2; }
#hpfill { height: 100%; width: 100%; background: var(--cyan); }
#hpfill.low { background: var(--pink); }

#speedbox { position: absolute; left: 50%; bottom: 22px; width: 240px; margin-left: -120px; text-align: center; }
#speed { font-size: 28px; font-weight: 800; }
#speedbox small { margin-left: 4px; color: var(--dim); }
#speedfill { height: 100%; width: 0; background: var(--dim); }
#speedfill.fast { background: var(--amber); box-shadow: 0 0 10px var(--amber); }
#speedmark { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--amber); }
#bonus { min-height: 20px; font-size: 14px; font-weight: 800; letter-spacing: .08em; color: var(--amber); visibility: hidden; }
#bonus.on { visibility: visible; }

#ammobox { position: absolute; right: 24px; bottom: 22px; text-align: right; }
#money { font-size: 16px; font-weight: 800; color: var(--amber); }
#weapon { color: var(--dim); font-size: 14px; letter-spacing: .1em; text-transform: uppercase; }
#ammo { font-size: 42px; font-weight: 800; line-height: 1; }

#deathmsg, #pausemsg { position: absolute; left: 50%; top: 32%; transform: translateX(-50%); padding: 10px 20px;
  background: #000b; font-size: 18px; font-weight: 700; text-align: center; white-space: pre-line; }
#deathmsg { top: auto; bottom: 150px; width: max-content; max-width: calc(100% - 32px); font-size: 15px; }

#buy { position: absolute; left: 24px; top: 50%; transform: translateY(-50%); width: 300px; padding: 14px 16px; background: var(--panel); border-left: 3px solid var(--amber); }
#buy h2 { margin: 0 0 8px; font-size: 15px; color: var(--amber); }
.buyrow { display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: center; width: 100%; padding: 6px 8px; margin-top: 3px;
  font: inherit; font-size: 15px; text-align: left; color: var(--ink); background: #fff1; border: 0; }
.buyrow b { color: var(--cyan); }
.buyrow.owned { background: rgba(232, 189, 85, 0.22); }
.buyrow.poor { color: var(--dim); }
.buyrow.poor b { color: var(--dim); }
.buyrow i { font-style: normal; color: var(--amber); }
.buyrow.poor i { color: var(--dim); }

#board { position: absolute; left: 50%; top: 12%; transform: translateX(-50%); width: min(560px, calc(100% - 32px));
  padding: 16px 20px; background: var(--panel); }
#board h2 { margin: 0 0 10px; font-size: 20px; }
#board table { width: 100%; border-collapse: collapse; font-size: 15px; }
#board td { padding: 3px 6px; border-top: 1px solid #fff1; }
#board td.num { width: 52px; text-align: right; }
#board tr.us td:first-child { color: var(--cyan); }
#board tr.them td:first-child { color: var(--enemy); }
#board tr.me td { font-weight: 800; }
#board tr.head td { color: var(--dim); font-size: 12px; border-top: 0; padding-top: 10px; }

@media (max-width: 700px) {
  #hpbox { left: 16px; width: 110px; }
  #ammobox { right: 16px; }
  #speedbox { bottom: 96px; width: 160px; margin-left: -80px; }
  #hp, #ammo { font-size: 32px; }
  #feed { top: 104px; right: 12px; }
  #buy { left: 12px; width: min(300px, calc(100% - 24px)); }
  #banner { font-size: 20px; }
  #role { white-space: normal; text-align: center; width: 92%; }
}

#pausemsg { pointer-events: auto; }
#quit { display: block; margin: 8px auto 0; padding: 5px 14px; font: inherit; font-size: 14px; color: var(--ink); background: #fff2; border: 1px solid #fff4; cursor: pointer; }
#quit:hover { background: #fff3; }

.second { width: 100%; margin-top: 8px; padding: 10px; font: inherit; font-weight: 700; color: var(--ink); background: #fff1; border: 1px solid #fff4; cursor: pointer; }
.second:hover { background: #fff2; }
.second:disabled { opacity: .45; cursor: default; }
.second:focus-visible, #startmatch:focus-visible, #code:focus-visible, #invite:focus-visible, #bots:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.coderow { display: flex; gap: 8px; }
.pickrow { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pickrow select:disabled { opacity: .7; }
@media (max-width: 480px) { .pickrow { grid-template-columns: 1fr; gap: 0; } }
#startmatch:disabled { opacity: .5; cursor: not-allowed; }
#speedlines { position: absolute; inset: -30%; opacity: 0; pointer-events: none;
  background: repeating-conic-gradient(#fff0 0 5deg, #ffffff30 5deg 5.5deg, #fff0 5.5deg 11deg, #ffffff18 11deg 11.3deg);
  -webkit-mask-image: radial-gradient(circle, transparent 34%, #000 62%); mask-image: radial-gradient(circle, transparent 34%, #000 62%); }
body.parkour #hpbox, body.parkour #ammobox, body.parkour #bonus, body.parkour #topbar > span { display: none; }
.coderow input { flex: 1; min-width: 0; padding: 10px 12px; font: inherit; color: var(--ink); background: #fff1; border: 1px solid #fff3; }
.coderow .second { width: auto; margin-top: 0; padding: 10px 14px; white-space: nowrap; }
#code { text-transform: uppercase; letter-spacing: .14em; }

#lobby { position: fixed; inset: 0; display: flex; justify-content: center; padding: 16px; overflow: auto; background: rgba(4, 7, 16, 0.55); }
#lobby .panel { width: min(560px, 100%); }
#lobbycode { margin: 4px 0 0; font-size: 44px; font-weight: 800; letter-spacing: .14em; }
.players { margin-top: 16px; padding: 10px 12px; background: #fff1; }
.players h2 { margin: 0 0 6px; font-size: 16px; }
.players ul { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; min-height: 90px; align-content: start; margin: 0; padding: 0; list-style: none; font-size: 15px; }
.players li { padding: 2px 0; overflow-wrap: anywhere; }
.players li.you { font-weight: 800; color: var(--cyan); }
.players li small { margin-left: 6px; color: var(--amber); }
.players .hint { margin-top: 8px; }
.check { display: flex; align-items: center; gap: 8px; margin: 14px 0 0; font-size: 14px; color: var(--ink); }
#bots { accent-color: var(--pink); }
#startmatch { width: 100%; margin-top: 12px; padding: 13px; font: inherit; font-size: 18px; font-weight: 800; letter-spacing: .08em; color: var(--ink); background: var(--pink); border: 0; cursor: pointer; }
#startmatch:hover { background: #ef4a40; }
#lobbystatus { min-height: 20px; margin: 8px 0 0; font-size: 14px; color: var(--amber); }

@media (max-width: 480px) {
  #lobbycode { font-size: 32px; }
  .players ul { grid-template-columns: 1fr; min-height: 60px; }
}

#vote { position: fixed; inset: 0; display: flex; justify-content: center; padding: 16px; overflow: auto; background: rgba(4, 7, 16, 0.55); }
#vote .panel { width: min(1040px, 100%); }
#votehead { margin: 6px 0 12px; font-size: 22px; }
#votecards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.votecard { position: relative; display: flex; flex-direction: column; justify-content: flex-start; width: 100%; padding: 0 12px 12px; overflow: hidden; font: inherit; text-align: left; color: var(--ink); background: #fff1; border: 2px solid #fff3; cursor: pointer; }
.votecard:hover:not(:disabled) { background: #fff2; }
.votecard:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.votecard img { display: block; width: calc(100% + 24px); aspect-ratio: 16 / 9; margin: 0 -12px 10px; object-fit: cover; background: #0006; }
.votecard b { display: block; margin-bottom: 4px; font-size: 16px; }
.votecard span { display: block; font-size: 13px; line-height: 1.35; color: var(--dim); }
.votecard em { position: absolute; top: 8px; right: 8px; min-width: 34px; padding: 1px 8px; font-size: 22px; font-style: normal; font-weight: 800; text-align: center; color: var(--amber); background: var(--panel); }
.votecard em:empty { display: none; }
.votecard.mine { border-color: var(--cyan); background: #fff2; }
.votecard.winner { border-color: var(--amber); background: #e8bd5533; }
.votecard:disabled { cursor: default; }
.votecard.lost { opacity: .45; }

#loader { position: fixed; inset: 0; z-index: 50; overflow: hidden; background: linear-gradient(#0d0b2a, #2c1648 42%, #a23a4e 72%, #f08a50); transition: opacity .6s; }
#loader.gone { opacity: 0; pointer-events: none; }
#loader .hero { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; animation: heroin 9s ease-out both; }
#loader .shade { position: absolute; inset: 0; background: linear-gradient(#0a0612cc, #0a061200 38%, #0a061200 62%, #0a0612f2); }
#loader .title { position: absolute; top: 5vh; left: 0; right: 0; text-align: center; }
#loader .kanji { position: relative; display: inline-block; height: 1.15em; width: 2.1em; font-family: "Yu Mincho", "Hiragino Mincho ProN", "MS Mincho", serif; font-size: clamp(72px, 19vh, 190px); font-weight: 800; line-height: 1.15; color: var(--ink); text-shadow: 0 6px 30px #000c; }
#loader .part { position: absolute; left: 0; top: 0; white-space: nowrap; }
/* the two kanji are cut in half by one sword stroke, and the halves slide apart */
#loader .upper { clip-path: polygon(-5% -5%, 105% -5%, 105% 34%, -5% 66%); animation: cutup 1s .75s cubic-bezier(.2, .9, .3, 1) both; }
#loader .lower { clip-path: polygon(-5% 66%, 105% 34%, 105% 105%, -5% 105%); animation: cutdown 1s .75s cubic-bezier(.2, .9, .3, 1) both; }
#loader .cut { position: absolute; left: -22%; right: -22%; top: 50%; height: 5px; border-radius: 3px; background: #fff; box-shadow: 0 0 16px 5px #ffb08a, 0 0 46px 12px #d9342b; transform: rotate(-14.5deg) scaleX(0); transform-origin: left center; animation: slash .75s .45s ease-in both; }
#loader .name { margin: 2px 0 0; font-size: clamp(14px, 2.6vh, 24px); font-weight: 700; letter-spacing: .6em; text-indent: .6em; color: var(--amber); text-shadow: 0 2px 10px #000; animation: rise .6s 1.1s ease-out both; }
#loader .bottom { position: absolute; left: 50%; bottom: 5vh; width: min(620px, calc(100% - 32px)); transform: translateX(-50%); text-align: center; }
#loader p { margin: 0; }
#loadtip { min-height: 2.6em; font-size: 16px; line-height: 1.3; color: var(--ink); text-shadow: 0 2px 8px #000; }
#loader .bar { height: 5px; margin: 8px 0 8px; overflow: hidden; background: #fff2; }
#loadbar { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--pink), var(--amber)); box-shadow: 0 0 12px var(--amber); transition: width .25s linear; }
#loadtext { font-size: 13px; letter-spacing: .08em; color: var(--dim); }
#loader.failed #loadtext { font-size: 15px; letter-spacing: 0; color: var(--amber); }
#loader.failed #loadbar { background: var(--pink); box-shadow: none; }
@keyframes slash { 0% { transform: rotate(-14.5deg) scaleX(0); opacity: 1; } 75% { transform: rotate(-14.5deg) scaleX(1); opacity: 1; } 100% { transform: rotate(-14.5deg) scaleX(1); opacity: 0; } }
@keyframes cutup { from { transform: none; } to { transform: translate(-.05em, -.035em); } }
@keyframes cutdown { from { transform: none; } to { transform: translate(.05em, .035em); } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes heroin { from { transform: scale(1.07); } to { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { #loader * { animation-duration: .01s !important; animation-delay: 0s !important; } }

#menu { position: fixed; inset: 0; display: flex; justify-content: center; padding: 16px;
  overflow: auto; background: rgba(4, 7, 16, 0.55); }
.panel { position: relative; width: min(430px, 100%); margin: auto; padding: 24px 28px; background: var(--panel); border-top: 4px solid var(--pink); }
h1 { margin: 0; font-family: "Yu Mincho", "Hiragino Mincho ProN", "MS Mincho", serif; font-size: 64px; font-weight: 800; line-height: 1.05; letter-spacing: .04em; }
.logo { margin: 2px 0 0; font-size: 15px; font-weight: 700; letter-spacing: .42em; color: var(--amber); }
.seal { position: absolute; top: 28px; right: 28px; width: 46px; padding: 5px 0; font-family: "Yu Mincho", "Hiragino Mincho ProN", "MS Mincho", serif; font-size: 18px; font-weight: 800; line-height: 1.15;
  text-align: center; writing-mode: vertical-rl; color: var(--ink); background: var(--pink); border-radius: 4px; }
.tag { margin: 8px 0 14px; color: var(--dim); }
label { display: block; margin: 12px 0 5px; font-size: 13px; color: var(--dim); }
#name { width: 100%; padding: 10px 12px; font: inherit; color: var(--ink); background: #fff1; border: 1px solid #fff3; }
#name:focus-visible, #play:focus-visible, #sens:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
#play { width: 100%; margin-top: 14px; padding: 13px; font: inherit; font-size: 18px; font-weight: 800; letter-spacing: .08em;
  color: var(--ink); background: var(--pink); border: 0; cursor: pointer; }
#play:hover { background: #ef4a40; }
#play:disabled { opacity: .6; cursor: wait; }
#status { min-height: 20px; margin: 8px 0 0; font-size: 14px; color: var(--amber); }
#sens { width: 100%; accent-color: var(--cyan); }
#quality, #mode, .pickrow select { width: 100%; padding: 8px 10px; font: inherit; color: var(--ink); background: #2a1a2c; border: 1px solid #fff3; }
#quality:focus-visible, #mode:focus-visible, .pickrow select:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.keys { display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; margin: 14px 0 0; font-size: 14px; }
.keys dt { font-weight: 700; color: var(--cyan); }
.keys dd { margin: 0; color: var(--ink); }
.hint { margin: 14px 0 0; font-size: 13px; color: var(--dim); }
#gpu { margin-top: 6px; font-size: 12px; }
