/* ASOMA: sun-bleached paper over a dusty street. Ink brown, slab letters, wooden edges. */
:root {
  --ink: #3b2416; --paper: #f6e7bd; --paper2: #ecd9a6; --dim: #7a5a3c; --red: #b8432f; --red2: #96392a; --line: rgba(59, 36, 22, 0.28);
  --ui: system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --slab: "Rockwell", "Roboto Slab", "Rockwell Nova", Georgia, "Times New Roman", serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #e3b877; color: var(--ink); font: 400 16px/1.45 var(--ui); overflow: hidden; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
.hidden { display: none !important; }
a { color: var(--ink); text-underline-offset: 3px; }
#cv { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }

/* ---------- panels over the street */
#ui { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); pointer-events: none; }
#ui:empty { display: none; }
.panel { pointer-events: auto; width: min(470px, 100%); max-height: 100%; overflow: auto; background: linear-gradient(180deg, var(--paper), var(--paper2)); border: 3px solid var(--ink); border-radius: 14px; padding: clamp(16px, 4.2vw, 26px); box-shadow: 0 0 0 4px rgba(246, 231, 189, 0.35), 0 18px 50px rgba(40, 18, 6, 0.55); display: flex; flex-direction: column; gap: 13px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
h1, h2, h3, p { margin: 0; }
h2 { font: 900 24px/1.15 var(--slab); letter-spacing: 0.01em; }
h3 { font: 700 12px var(--ui); letter-spacing: 0.16em; text-transform: uppercase; color: var(--dim); }
.logo { display: flex; justify-content: center; gap: 0.04em; font: 900 clamp(58px, 17vw, 88px)/1 var(--slab); letter-spacing: 0.02em; color: var(--red); text-shadow: 0 3px 0 var(--ink), 3px 0 0 var(--ink), -3px 0 0 var(--ink), 0 -3px 0 var(--ink), 3px 3px 0 var(--ink), -3px 3px 0 var(--ink), 3px -3px 0 var(--ink), -3px -3px 0 var(--ink), 0 8px 0 rgba(59, 36, 22, 0.35); }
.logo span:nth-child(odd) { transform: translateY(0.06em) rotate(-3deg); }
.logo span:nth-child(even) { transform: translateY(-0.04em) rotate(3deg); }
.logo span:nth-child(3) { color: #2a9d8f; }
.tag { text-align: center; color: var(--dim); font: 700 16px var(--ui); margin-top: 2px; }
.sub { color: var(--dim); font-size: 14px; }
.how { border-top: 2px dashed var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 7px; font-size: 14px; }
.how b { font-family: var(--slab); color: var(--red); }
.panel.home { gap: 12px; }
.keys { color: var(--dim); font-size: 13px; }
kbd { display: inline-block; min-width: 1.7em; text-align: center; font: 700 12px var(--ui); color: var(--ink); background: rgba(255, 255, 255, 0.5); border: 1.5px solid var(--ink); border-bottom-width: 3px; border-radius: 6px; padding: 1px 6px; }
.foot { color: var(--dim); font-size: 13px; text-align: center; line-height: 1.9; overflow-wrap: anywhere; }
.foot a { color: var(--dim); }
.back { color: var(--dim); font-size: 14px; text-decoration: none; align-self: flex-start; }
.msg { min-height: 1.3em; font-size: 14px; color: var(--dim); text-align: center; }
.msg.bad { color: var(--red); font-weight: 600; }
.or { display: flex; align-items: center; gap: 12px; color: var(--dim); font-size: 13px; }
.or::before, .or::after { content: ""; flex: 1; height: 0; border-top: 2px dashed var(--line); }

/* ---------- buttons, inputs */
.btns { display: flex; flex-direction: column; gap: 10px; }
.btns.row { flex-direction: row; }
.btns.row .btn { flex: 1; }
.btn { display: block; text-align: center; text-decoration: none; font: 700 16px var(--ui); color: var(--ink); background: rgba(255, 255, 255, 0.42); border: 2.5px solid var(--ink); border-radius: 10px; padding: 11px 18px; cursor: pointer; box-shadow: 0 3px 0 var(--ink); transition: transform 0.06s, box-shadow 0.06s, background 0.15s; }
.btn:hover { background: rgba(255, 255, 255, 0.7); }
.btn:active { transform: translateY(3px); box-shadow: 0 0 0 var(--ink); }
.btn.big { font: 900 20px var(--slab); padding: 13px 20px; color: #fff3d6; background: var(--red); }
.btn.big:hover { background: #c9523c; }
.btn small { display: block; font: 600 12px var(--ui); opacity: 0.8; }
.btn[disabled] { opacity: 0.5; cursor: default; }
.btn[disabled]:active { transform: none; box-shadow: 0 3px 0 var(--ink); }
.levels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.lv { font: 700 13px var(--ui); color: var(--dim); background: rgba(255, 255, 255, 0.3); border: 2px solid var(--line); border-radius: 9px; padding: 7px 2px; cursor: pointer; min-width: 0; }
.lv:hover { color: var(--ink); border-color: var(--ink); }
.lv.on { color: var(--paper); background: var(--ink); border-color: var(--ink); }
input { font: 500 16px var(--ui); color: var(--ink); background: rgba(255, 255, 255, 0.55); border: 2px solid var(--ink); border-radius: 9px; padding: 10px 13px; width: 100%; min-width: 0; }
input:focus { outline: 3px solid rgba(184, 67, 47, 0.5); outline-offset: 1px; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--dim); }
label.inline { display: inline-flex; flex-direction: row; align-items: center; gap: 8px; }
label.inline input { width: 9.5em; padding: 4px 9px; font-size: 14px; border-width: 1.5px; }
.col { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 8px; align-items: center; }
.row .btn { flex: none; padding: 9px 14px; font-size: 15px; }
#code { text-transform: uppercase; letter-spacing: 0.2em; font-weight: 700; }
.item { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; width: 100%; text-align: left; font: 500 15px var(--ui); color: var(--ink); background: rgba(255, 255, 255, 0.35); border: 2px solid var(--line); border-radius: 9px; padding: 9px 13px; cursor: pointer; margin-top: 8px; }
.item span { color: var(--dim); font-size: 13px; white-space: nowrap; }

/* ---------- the room, and the result of a duel */
.invite { display: flex; flex-direction: column; gap: 7px; background: rgba(184, 67, 47, 0.12); border: 2px dashed var(--red); border-radius: 10px; padding: 11px 13px; }
.invite small { color: var(--red2); font-size: 13px; font-weight: 600; }
.invite input { font-size: 13px; padding: 8px 11px; }
.players { display: flex; flex-direction: column; gap: 6px; }
.pl, .result li { display: flex; align-items: center; gap: 10px; padding: 7px 11px; border-radius: 9px; background: rgba(255, 255, 255, 0.4); border: 2px solid var(--line); }
.pl i, .result li i { flex: none; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--ink); }
.pl svg, .result li svg, #hud .face svg { flex: none; border-radius: 6px; display: block; }
.pl b, .result li b { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl em { font-style: normal; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); border: 1.5px solid var(--line); border-radius: 999px; padding: 0 7px; }
.pl em.off { color: var(--red); border-color: var(--red); }
.pl small { color: var(--dim); font-size: 12px; white-space: nowrap; }
.pl span, .result li span { margin-left: auto; font: 900 18px var(--slab); font-variant-numeric: tabular-nums; }
.pl span::before { content: "★ "; color: var(--red); }
.tally { text-align: center; font-size: 14px; color: var(--dim); }
.tally b { font-family: var(--slab); color: var(--ink); }
.tally em { font-style: normal; font-size: 11px; text-transform: uppercase; color: var(--red); }
.result { display: flex; flex-direction: column; gap: 10px; }
.result h2 { text-align: center; font-size: 28px; color: var(--red); }
.result .sub { text-align: center; }
.result ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.result li.win { background: rgba(233, 196, 106, 0.55); border-color: var(--ink); }
.result li span { font-size: 26px; }
.final { display: flex; align-items: baseline; justify-content: center; gap: 14px; font: 900 54px/1 var(--slab); }
.final span { color: var(--dim); font-size: 34px; }
.karma { font-weight: 700; font-size: 13px; white-space: nowrap; border-radius: 999px; padding: 1px 9px; }
.karma.up { color: #1d5c2c; background: rgba(64, 160, 84, 0.25); }
.karma.down { color: var(--red2); background: rgba(184, 67, 47, 0.18); }
.karma.wait { color: var(--dim); }

/* ---------- while playing */
#hud { position: fixed; inset: 0 0 auto 0; pointer-events: none; padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left)); display: flex; align-items: flex-start; gap: 8px; }
#hud .who { flex: 1 1 0; min-width: 0; display: flex; align-items: center; gap: 8px; background: rgba(59, 36, 22, 0.78); border: 2px solid var(--ink); border-radius: 12px; padding: 5px 10px; color: var(--paper); }
#hud .who.opp { justify-content: flex-end; text-align: right; }
#hud .who > div { min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
#hud .who b { font: 900 15px var(--slab); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#hud .face:empty { display: none; }
.stars { font-size: 15px; letter-spacing: 1px; white-space: nowrap; }
.stars i { font-style: normal; color: rgba(246, 231, 189, 0.25); }
.stars i.on { color: #ffd166; text-shadow: 0 0 6px rgba(255, 209, 102, 0.7); }
#hud .mid { flex: none; align-self: center; font: 900 14px var(--slab); color: var(--paper); background: rgba(59, 36, 22, 0.78); border-radius: 999px; padding: 3px 12px; white-space: nowrap; }
#hud .mid:empty { display: none; }
#hud .tr { flex: none; display: flex; gap: 6px; pointer-events: auto; }
#hud .tr button { width: 38px; height: 38px; border-radius: 10px; font: 700 16px var(--ui); color: var(--paper); background: rgba(59, 36, 22, 0.78); border: 2px solid var(--ink); cursor: pointer; }
#hud .tr button.off { color: rgba(246, 231, 189, 0.45); text-decoration: line-through; }
#toast { position: fixed; left: 50%; top: max(64px, calc(env(safe-area-inset-top) + 58px)); transform: translateX(-50%); max-width: calc(100% - 24px); text-align: center; font: 700 15px var(--ui); color: var(--paper); background: rgba(59, 36, 22, 0.88); border: 2px solid var(--ink); border-radius: 999px; padding: 7px 16px; pointer-events: none; }
@media (max-width: 520px) { #hud .mid { display: none; } #hud .who { padding: 4px 8px; } #hud .who b { font-size: 13px; } .stars { font-size: 13px; letter-spacing: 0; } }
@media (max-height: 560px) { .how, .tag { display: none; } .logo { font-size: 46px; } .panel { gap: 9px; padding: 14px; } }
