/* PULSO: midnight field, pale rings, a coral heart. Round shapes, system type, nothing square. */
:root {
  --bg: #0c1024; --ink: #e4e8ff; --dim: #9aa2c8; --heart: #ff5a7a; --line: rgba(228, 232, 255, 0.16);
  --panel: rgba(12, 16, 36, 0.8); --ui: system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); 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 field */
#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.bottom { align-items: flex-end; }
#ui:empty { display: none; }
.panel { pointer-events: auto; width: min(460px, 100%); max-height: 100%; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 26px; padding: clamp(18px, 4.5vw, 30px); backdrop-filter: blur(9px); -webkit-backdrop-filter: blur(9px); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45); display: flex; flex-direction: column; gap: 14px; }
.panel.sheet { width: min(420px, 100%); gap: 12px; padding: 16px 18px; }
h1, h2, h3, p { margin: 0; }
h2 { font-size: 22px; font-weight: 800; letter-spacing: 0.02em; }
h3 { font-size: 12px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--dim); }
.logo { font-size: clamp(58px, 17vw, 92px); font-weight: 800; letter-spacing: 0.1em; line-height: 1; text-align: center; margin-right: -0.1em; }
.logo i { display: inline-block; position: relative; width: 0.74em; height: 0.74em; margin-left: 0.02em; border: 0.14em solid currentColor; border-top-color: transparent; border-radius: 50%; }
.logo i::after { content: ""; position: absolute; left: 50%; top: -0.15em; width: 0.17em; height: 0.17em; margin-left: -0.085em; border-radius: 50%; background: var(--heart); box-shadow: 0 0 0.3em var(--heart); }
.tag { text-align: center; color: var(--dim); font-size: 17px; margin-top: -4px; }
.sub { color: var(--dim); font-size: 14px; }
.how { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: #c9cfee; }
.panel.home { gap: 12px; }
.panel { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.keys { color: var(--dim); font-size: 14px; }
kbd { display: inline-block; min-width: 1.7em; text-align: center; font: 700 12px var(--ui); color: var(--ink); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 7px; padding: 2px 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: #ff9aae; }
.or { display: flex; align-items: center; gap: 12px; color: var(--dim); font-size: 13px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- buttons, inputs */
.btns { display: flex; flex-direction: column; gap: 10px; }
.btns.row { flex-direction: row; }
.btns.row .btn { flex: 1; }
.btn { font: 700 16px var(--ui); color: var(--ink); background: rgba(228, 232, 255, 0.08); border: 1px solid var(--line); border-radius: 999px; padding: 12px 20px; cursor: pointer; transition: transform 0.08s, background 0.15s; }
.btn:hover { background: rgba(228, 232, 255, 0.16); }
.btn:active { transform: scale(0.97); }
.btn.big { font-size: 19px; font-weight: 800; padding: 14px 22px; color: #1a0710; background: var(--heart); border-color: var(--heart); box-shadow: 0 8px 26px rgba(255, 90, 122, 0.3); }
.btn.big:hover { background: #ff7590; }
.btn small { display: block; font-size: 12px; font-weight: 600; opacity: 0.75; }
.btn[disabled] { opacity: 0.4; cursor: default; box-shadow: none; }
.btn[disabled]:active { transform: none; }
.levels { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.lv { font: 700 13px var(--ui); color: var(--dim); background: rgba(228, 232, 255, 0.05); border: 1px solid var(--line); border-radius: 14px; padding: 7px 2px; cursor: pointer; min-width: 0; }
.lv small { display: block; font-size: 10px; font-weight: 600; opacity: 0.7; letter-spacing: 0.04em; }
.lv:hover { color: var(--ink); }
.lv.on { color: #1a0710; background: var(--ink); border-color: var(--ink); }
input { font: 500 16px var(--ui); color: var(--ink); background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line); border-radius: 14px; padding: 11px 14px; width: 100%; min-width: 0; }
input:focus { outline: 2px solid var(--heart); 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: 5px 10px; font-size: 14px; border-radius: 10px; }
.col { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 8px; align-items: center; }
.row .btn { flex: none; padding: 11px 16px; 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(228, 232, 255, 0.05); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; cursor: pointer; margin-top: 8px; }
.item span { color: var(--dim); font-size: 13px; white-space: nowrap; }

/* ---------- the room */
.invite { display: flex; flex-direction: column; gap: 7px; background: rgba(255, 90, 122, 0.1); border: 1px solid rgba(255, 90, 122, 0.4); border-radius: 18px; padding: 12px 14px; }
.invite small { color: #ffc2cd; font-size: 13px; }
.invite input { font-size: 13px; padding: 9px 12px; }
.players { display: flex; flex-direction: column; gap: 6px; }
.pl, .result li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 14px; background: rgba(228, 232, 255, 0.05); }
.pl i, .result li i, .chip i { flex: none; width: 14px; height: 14px; border-radius: 50%; }
.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: 1px solid var(--line); border-radius: 999px; padding: 0 7px; }
.pl em.off { color: #ff9aae; border-color: rgba(255, 154, 174, 0.4); }
.pl span, .result li span { margin-left: auto; font-weight: 800; font-variant-numeric: tabular-nums; }
.pl .kar + .won { margin-left: 12px; }
.pl .won::before { content: "★ "; color: var(--heart); font-weight: 400; }
.pl .kar { font-weight: 600; color: var(--dim); }
.pl .kar::before { content: "◆ "; font-size: 0.8em; color: #ffd23f; }
.avatar { flex: none; display: block; border-radius: 6px; }
.kd { font-style: normal; font-size: 13px; font-weight: 700; color: var(--dim); min-width: 5.2em; text-align: right; white-space: nowrap; }
.kd.up { color: #9dff6a; } .kd.down { color: #ff9aae; }
a.btn { display: block; text-align: center; text-decoration: none; }
.result { display: flex; flex-direction: column; gap: 10px; }
.result h2 { text-align: center; font-size: 26px; }
.result ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.result li.win { background: rgba(255, 90, 122, 0.18); outline: 1px solid rgba(255, 90, 122, 0.5); }
.score { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.score b { font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; }
.score span { color: var(--dim); }

/* ---------- while playing */
#hud { position: fixed; inset: 0; pointer-events: none; padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left)); display: flex; align-items: flex-start; gap: 10px; }
#hud .tl { display: flex; flex-direction: column; line-height: 1.1; min-width: 5.2em; }
#hud .tl b { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
#hud .tl span { font-size: 12px; font-weight: 700; letter-spacing: 0.12em; color: var(--dim); }
#hud .tr { margin-left: auto; display: flex; gap: 8px; pointer-events: auto; }
#hud .tr button { width: 40px; height: 40px; border-radius: 50%; font: 700 16px var(--ui); color: var(--ink); background: rgba(12, 16, 36, 0.55); border: 1px solid var(--line); cursor: pointer; }
#hud .tr button.off { color: var(--dim); text-decoration: line-through; }
.chips { flex: 1; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; max-width: 11em; font-size: 13px; font-weight: 700; background: rgba(12, 16, 36, 0.55); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px 3px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip.out { opacity: 0.55; font-weight: 500; }
.chip.out i { background: transparent !important; outline: 2px solid var(--dim); outline-offset: -2px; }
#toast { position: fixed; left: 50%; bottom: max(22px, env(safe-area-inset-bottom)); transform: translateX(-50%); max-width: calc(100% - 24px); text-align: center; font-size: 15px; font-weight: 600; background: rgba(12, 16, 36, 0.8); border: 1px solid var(--line); border-radius: 999px; padding: 8px 18px; pointer-events: none; }
.hint { display: none; position: fixed; bottom: max(20px, env(safe-area-inset-bottom)); font-size: 30px; color: var(--ink); opacity: 0.22; pointer-events: none; }
.hint.l { left: 22px; } .hint.r { right: 22px; }
@media (pointer: coarse) { body.playing .hint { display: block; } }
@media (max-height: 520px) { .how, .tag { display: none; } .logo { font-size: 48px; } .panel { gap: 10px; } }
