/* Layout: one phone-shaped column floating in deep space — opponent on top, board in the middle, you at the bottom (as at a real table). */
:root {
  --void: #04020d;
  --nebula: #160a36;
  --panel: rgba(18, 10, 44, 0.72);
  --panel-edge: rgba(150, 120, 255, 0.22);
  --ink: #ece8ff;
  --ink-dim: #a49cc9;
  --x: #2ef2ff;      /* X: electric cyan */
  --o: #ff38d8;      /* O: neon magenta */
  --flare: #fff27a;  /* warnings, the clock running out */
  --font-display: "Unbounded", "Arial Black", system-ui, sans-serif;
  --font-ui: "Chakra Petch", "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}
html, body { height: 100%; }
body {
  background: var(--void);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
#space { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.app {
  position: relative;
  height: 100%;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-left: max(12px, env(safe-area-inset-left, 0px));
  padding-right: max(12px, env(safe-area-inset-right, 0px));
  padding-block: 10px;
  box-sizing: border-box;
}
/* --- top bar --- */
.top { display: flex; align-items: center; gap: 10px; }
.brand { display: flex; flex-direction: column; line-height: 1; min-width: 0; }
.brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 22px;
  letter-spacing: 0.02em;
  background: linear-gradient(90deg, var(--x), #b7a6ff 55%, var(--o));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand span { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-dim); margin-top: 4px; }
.scorebox {
  margin-left: auto;
  display: flex; flex-direction: column; align-items: center;
  padding: 5px 12px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--panel-edge);
}
.score { font-family: var(--font-display); font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }
.score .sx { color: var(--x); } .score .so { color: var(--o); }
.scorebox small { font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-dim); }
.iconbtn {
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--panel-edge);
  background: var(--panel); color: var(--ink); display: grid; place-items: center; cursor: pointer;
}
.iconbtn:hover { border-color: rgba(180, 160, 255, 0.5); }
.iconbtn svg { width: 20px; height: 20px; }
:focus-visible { outline: 2px solid var(--flare); outline-offset: 2px; }

/* --- player strips --- */
.strip {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px; border-radius: 14px;
  background: var(--panel); border: 1px solid var(--panel-edge);
  transition: border-color .3s, box-shadow .3s;
  position: relative;
}
.strip.active { border-color: var(--mc); box-shadow: 0 0 0 1px var(--mc), 0 0 22px -4px var(--mc); }
.avatar { position: relative; width: 46px; height: 46px; flex: none; }
.avatar svg.face { width: 46px; height: 46px; display: block; }
.avatar svg.ring { position: absolute; inset: -4px; width: 54px; height: 54px; transform: rotate(-90deg); }
.avatar svg.ring circle { fill: none; stroke-width: 3; }
.avatar svg.ring .track { stroke: rgba(255,255,255,0.08); }
.avatar svg.ring .bar { stroke: var(--mc); stroke-linecap: round; transition: stroke .2s; }
.avatar.low svg.ring .bar { stroke: var(--flare); }
.who { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.who b { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who small { color: var(--ink-dim); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pips { display: flex; gap: 5px; margin-left: auto; }
.pip { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--mc); opacity: .55; }
.pip.on { background: var(--mc); opacity: 1; box-shadow: 0 0 8px var(--mc); }
.markchip {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex: none;
  border: 1.5px solid var(--mc); color: var(--mc); font-family: var(--font-display); font-weight: 900; font-size: 18px;
  text-shadow: 0 0 10px var(--mc);
}
.clock { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13px; color: var(--ink-dim); min-width: 28px; text-align: right; }
.avatar.low + .who + .pips + .clock, .clock.low { color: var(--flare); }
.bubble {
  position: absolute; left: 66px; top: -14px; z-index: 3;
  padding: 5px 10px; border-radius: 10px 10px 10px 2px;
  background: #fff; color: #1a0b3d; font-weight: 700; font-size: 13px;
  box-shadow: 0 0 18px rgba(255, 56, 216, 0.6);
  opacity: 0; transform: translateY(6px) scale(.9); transition: opacity .2s, transform .2s; pointer-events: none;
}
.bubble.show { opacity: 1; transform: none; }
.thinking { display: inline-flex; gap: 3px; margin-left: 4px; vertical-align: middle; }
.thinking i { width: 4px; height: 4px; border-radius: 50%; background: var(--o); animation: blink 1s infinite; }
.thinking i:nth-child(2) { animation-delay: .15s; } .thinking i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 100% { opacity: .2 } 50% { opacity: 1 } }

/* --- board --- */
.boardwrap { flex: 1; min-height: 0; display: grid; place-items: center; position: relative; }
#board { display: block; touch-action: manipulation; cursor: crosshair; border-radius: 14px; }
.hint {
  position: absolute; left: 50%; bottom: 6px; transform: translateX(-50%);
  padding: 4px 12px; border-radius: 99px; font-size: 12px; font-weight: 600; letter-spacing: .02em;
  background: rgba(4, 2, 13, 0.85); border: 1px solid var(--panel-edge); color: var(--ink);
  white-space: nowrap; pointer-events: none; transition: opacity .2s;
}
.banner {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
}
.banner div {
  font-family: var(--font-display); font-weight: 900; font-size: clamp(26px, 8vw, 46px);
  letter-spacing: .02em; text-align: center; line-height: 1.05;
  color: #fff; text-shadow: 0 0 18px var(--bc), 0 0 42px var(--bc);
  opacity: 0; transform: scale(.6); transition: opacity .25s, transform .35s cubic-bezier(.2, 1.6, .4, 1);
}
.banner div small { display: block; font-family: var(--font-ui); font-weight: 600; font-size: 14px; letter-spacing: .14em; text-transform: uppercase; margin-top: 8px; }
.banner.show div { opacity: 1; transform: none; }

/* --- action bar --- */
.actions { display: flex; gap: 8px; }
.btn {
  flex: 1; height: 44px; border-radius: 12px; cursor: pointer;
  font-family: var(--font-ui); font-weight: 700; font-size: 14px; letter-spacing: .04em;
  color: var(--ink); background: var(--panel); border: 1px solid var(--panel-edge);
}
.btn:hover { border-color: rgba(180,160,255,.5); }
.btn.primary { background: linear-gradient(90deg, rgba(46,242,255,.22), rgba(255,56,216,.22)); border-color: rgba(200,180,255,.6); }
.btn:disabled { opacity: .4; cursor: default; }
.foot { text-align: center; font-size: 11px; color: var(--ink-dim); letter-spacing: .04em; }

/* --- sheets (settings, match end) --- */
.sheet {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: end center;
  background: rgba(4, 2, 13, 0.6); backdrop-filter: blur(4px);
  padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: max(12px, env(safe-area-inset-right, 0px));
  padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
}
.sheet .card {
  width: 100%; max-width: 520px; max-height: 88%; overflow: auto; box-sizing: border-box;
  background: linear-gradient(180deg, #170b3a, #0b0620); border: 1px solid var(--panel-edge); border-radius: 18px;
  padding: 18px; display: flex; flex-direction: column; gap: 16px;
  box-shadow: 0 -10px 60px rgba(120, 80, 255, 0.25);
}
.card h2 { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 20px; text-wrap: balance; }
.card h3 { margin: 0 0 8px; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-dim); font-weight: 600; }
.levels { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.level {
  display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: 12px; cursor: pointer; text-align: left;
  background: rgba(255,255,255,.03); border: 1px solid var(--panel-edge); color: var(--ink); font-family: var(--font-ui);
}
.level svg { width: 38px; height: 38px; flex: none; }
.level b { display: block; font-size: 14px; }
.level small { display: block; font-size: 11px; color: var(--ink-dim); }
.level[aria-pressed="true"] { border-color: var(--o); box-shadow: 0 0 0 1px var(--o), 0 0 18px -6px var(--o); }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  flex: 1; min-width: 64px; height: 38px; border-radius: 10px; cursor: pointer;
  background: rgba(255,255,255,.03); border: 1px solid var(--panel-edge); color: var(--ink); font-family: var(--font-ui); font-weight: 600;
}
.seg button[aria-pressed="true"] { border-color: var(--x); box-shadow: 0 0 0 1px var(--x); color: var(--x); }
.note { font-size: 12px; color: var(--ink-dim); line-height: 1.45; margin: 0; }
.endscore { font-family: var(--font-display); font-weight: 900; font-size: 44px; text-align: center; font-variant-numeric: tabular-nums; }
.endscore .sx { color: var(--x); text-shadow: 0 0 16px var(--x); } .endscore .so { color: var(--o); text-shadow: 0 0 16px var(--o); }
.row { display: flex; gap: 8px; }
.soon { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 12px; border: 1px dashed var(--panel-edge); font-size: 13px; color: var(--ink-dim); }
.soon b { color: var(--ink); }

@media (max-height: 640px) {
  .avatar, .avatar svg.face { width: 38px; height: 38px; }
  .avatar svg.ring { width: 46px; height: 46px; }
  .strip { padding: 5px 10px; }
  .foot { display: none; }
}
.avatar img.face.photo { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; display: block; border: 2px solid var(--mc); box-sizing: border-box; }
/* Online client screens: sign-in, lobby, waiting room, connection and toasts. */
.screen {
  position: relative; min-height: 100%; max-width: 520px; margin: 0 auto; box-sizing: border-box;
  display: flex; flex-direction: column; gap: 14px; overflow-y: auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 14px 24px;
}
body:has(#scrLobby:not([hidden])), body:has(#scrWait:not([hidden])), body:has(#scrSignin:not([hidden])) { overflow-y: auto; }
.screen.center { justify-content: center; }
.hero { text-align: center; display: flex; flex-direction: column; gap: 8px; }
.logo {
  margin: 0; font-family: var(--font-display); font-weight: 900; font-size: clamp(44px, 14vw, 72px); letter-spacing: .02em;
  background: linear-gradient(90deg, var(--x), #b7a6ff 55%, var(--o)); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 18px rgba(150, 120, 255, .45));
}
.tag { margin: 0; color: var(--ink-dim); letter-spacing: .06em; }
.panel {
  background: var(--panel); border: 1px solid var(--panel-edge); border-radius: 16px; padding: 16px;
  backdrop-filter: blur(3px);
}
.stack { display: flex; flex-direction: column; gap: 12px; }
.centertext { text-align: center; align-items: center; }
.panel h2 { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 17px; text-wrap: balance; }
.panel h3, .label { margin: 0; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-dim); font-weight: 600; }
.input {
  height: 46px; border-radius: 12px; border: 1px solid var(--panel-edge); background: rgba(4, 2, 13, .6); color: var(--ink);
  font-family: var(--font-ui); font-size: 16px; padding: 0 14px; min-width: 0; flex: 1;
}
.input:focus { outline: 2px solid var(--x); outline-offset: 1px; }
.input.code { text-transform: uppercase; letter-spacing: .2em; font-weight: 700; }
.btn.big { flex: none; height: 52px; font-size: 16px; }
.btn.danger { border-color: rgba(255, 90, 120, .7); color: #ffd0da; }
.seg.two button { height: auto; padding: 10px; display: flex; flex-direction: column; gap: 2px; text-align: center; }
.seg.two button small { font-weight: 500; font-size: 11px; color: var(--ink-dim); }
.link { background: none; border: 0; color: var(--ink-dim); text-decoration: underline; font-family: var(--font-ui); font-size: 13px; cursor: pointer; align-self: center; padding: 8px; }
.invite { padding: 10px 14px; border-radius: 12px; border: 1px solid var(--x); color: var(--x); font-weight: 600; font-size: 14px; }
.bigcode {
  font-family: var(--font-display); font-weight: 900; font-size: clamp(30px, 10vw, 44px); letter-spacing: .14em;
  color: #fff; text-shadow: 0 0 14px var(--x), 0 0 30px var(--o); font-variant-numeric: tabular-nums;
}
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; word-break: break-all; }
.seatrow { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 12px; border: 1px solid var(--panel-edge); }
.seatrow .face, .seatrow img { width: 38px; height: 38px; border-radius: 50%; flex: none; }
.seatrow b { display: block; }
.seatrow small { color: var(--ink-dim); font-size: 12px; }
.seatrow.empty { border-style: dashed; color: var(--ink-dim); }
.seatrow .tagpill { margin-left: auto; font-size: 11px; padding: 3px 8px; border-radius: 99px; border: 1px solid var(--panel-edge); color: var(--ink-dim); }
.reacts { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.reacts button {
  flex: none; height: 32px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--panel-edge);
  background: var(--panel); color: var(--ink); font-family: var(--font-ui); font-weight: 600; font-size: 13px; cursor: pointer;
}
.reacts button:disabled { opacity: .4; }
.strip .bubble { left: 66px; }
#stripMe .bubble { top: auto; bottom: -14px; border-radius: 2px 10px 10px 10px; }
.strip.away { opacity: .6; }
.conn {
  position: fixed; z-index: 30; left: 50%; transform: translateX(-50%); top: calc(env(safe-area-inset-top, 0px) + 8px);
  padding: 6px 14px; border-radius: 99px; background: rgba(255, 242, 122, .95); color: #1a0b3d; font-weight: 700; font-size: 13px;
}
.toast {
  position: fixed; z-index: 30; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 18px); transform: translateX(-50%) translateY(20px);
  max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 12px; background: #fff; color: #1a0b3d; font-weight: 600; font-size: 14px;
  box-shadow: 0 0 24px rgba(255, 56, 216, .5); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translateX(-50%); }

/* Universal menu slot (social layer): the menu mounts into #socialMenu, moved into the current header. */
.menuslot { display: contents; }
.social-menu:empty { display: none; }
.social-menu { display: flex; align-items: center; margin-left: auto; }
.top .social-menu + .iconbtn, .top .social-menu ~ .scorebox { margin-left: 0; }
.row.center { justify-content: center; }
.seg.col { flex-direction: column; }
.seg.col button { text-align: left; padding: 0 14px; }
.input.area { height: auto; padding: 10px 14px; resize: vertical; font-size: 15px; }
.rules { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; line-height: 1.45; font-size: 14px; }
.rules b { color: var(--x); }

/* Voice: hold to talk (as Domino), with a ring counting down 3 seconds. */
.voice-btn {
  position: relative; flex: none; height: 44px; min-width: 82px; padding: 0 14px; border-radius: 22px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: rgba(46, 242, 255, .12); border: 1px solid var(--x); color: var(--x);
  font-family: var(--font-ui); font-weight: 700; font-size: 14px; touch-action: none; user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.voice-ring {
  position: absolute; inset: -3px; border-radius: 25px; pointer-events: none;
  background: conic-gradient(var(--ring, var(--x)) calc(var(--frac, 1) * 360deg), transparent 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
  opacity: 0;
}
.voice-btn.recording { background: rgba(255, 56, 120, .25); border-color: #ff3878; color: #fff; }
.voice-btn.recording .voice-ring { opacity: 1; --ring: #ff3878; }
.voice-btn.cooling .voice-ring { opacity: .7; }
.voice-btn.cooling { opacity: .75; }
.voice-btn:disabled, .voice-btn.muted { opacity: .45; cursor: default; border-style: dashed; }
.avatar.tap { padding: 0; border: 0; background: none; cursor: pointer; border-radius: 50%; }
.wave { display: none; align-items: center; gap: 2px; height: 16px; margin-left: -4px; }
.wave i { width: 3px; height: 6px; border-radius: 2px; background: var(--mc); animation: wave .7s ease-in-out infinite; }
.wave i:nth-child(2) { animation-delay: .1s; } .wave i:nth-child(3) { animation-delay: .2s; } .wave i:nth-child(4) { animation-delay: .3s; }
.strip.speaking .wave { display: inline-flex; }
@keyframes wave { 0%, 100% { height: 4px; } 50% { height: 16px; } }
@media (prefers-reduced-motion: reduce) { .wave i { animation: none; height: 10px; } }
.mutedtag { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--flare); margin-left: 6px; }
.stack > .btn { flex: none; }
