:root {
  --bg: #02040a;
  --ink: #cfefff;
  --dim: #5b7b93;
  --line: rgba(80, 200, 255, .25);
  --cyan: #3ef3ff;
  --hot: #ff4fd8;
  --font: 'Orbitron', 'Segoe UI', sans-serif;
  --mono: 'Share Tech Mono', ui-monospace, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--mono); overflow: hidden; }
canvas#screen { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; cursor: grab; }
canvas#screen:active { cursor: grabbing; }
#crt { position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background:
    repeating-linear-gradient(to bottom, rgba(0,0,0,0) 0 2px, rgba(0,0,0,.22) 2px 3px),
    radial-gradient(ellipse at center, rgba(0,0,0,0) 55%, rgba(0,0,0,.65) 100%);
}
.hidden { display: none !important; }
button, select, input { font-family: var(--mono); font-size: 14px; color: var(--ink); background: rgba(10, 30, 45, .7); border: 1px solid var(--line); border-radius: 4px; padding: 6px 12px; }
button { cursor: pointer; text-transform: uppercase; letter-spacing: .08em; transition: all .15s; }
button:hover { border-color: var(--cyan); color: #fff; box-shadow: 0 0 12px rgba(62,243,255,.5), inset 0 0 8px rgba(62,243,255,.2); }
button.ghost { background: transparent; }
button.big { width: 100%; font-family: var(--font); font-size: 22px; font-weight: 900; padding: 14px; margin-top: 14px; color: var(--cyan); border-color: var(--cyan); text-shadow: 0 0 10px var(--cyan); box-shadow: 0 0 18px rgba(62,243,255,.35), inset 0 0 18px rgba(62,243,255,.15); }
button.mini { font-size: 11px; padding: 2px 8px; }
input { outline: none; }
input:focus { border-color: var(--cyan); box-shadow: 0 0 8px rgba(62,243,255,.4); }

/* ---------------- HUD */
header#top { position: fixed; top: 0; left: 0; right: 0; height: 64px; z-index: 11; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; pointer-events: none;
  background: linear-gradient(to bottom, rgba(2,4,10,.85), rgba(2,4,10,0)); }
header#top > * { pointer-events: auto; }
.logo { font-family: var(--font); font-weight: 900; font-size: 24px; letter-spacing: .28em; color: var(--cyan); text-shadow: 0 0 6px var(--cyan), 0 0 22px rgba(62,243,255,.6); }
.logo span { font-family: var(--mono); font-size: 12px; letter-spacing: .1em; color: var(--dim); text-shadow: none; margin-left: 14px; }
/* in the row (not over it): with many buttons the clock moves aside instead of covering them */
#clock { text-align: center; flex: 0 0 auto; margin: 0 16px; }
#time { font-family: var(--font); font-size: 30px; font-weight: 700; color: #fff; text-shadow: 0 0 10px var(--cyan); letter-spacing: .1em; }
#status { font-size: 11px; letter-spacing: .4em; color: var(--dim); }
.viewctl { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--dim); }
.viewctl select, .viewctl button { font-size: 12px; padding: 4px 10px; }
.viewctl button, .viewctl .btnlink { white-space: nowrap; }
.sndctl { position: relative; display: flex; align-items: center; gap: 4px; }
.sndpanel { position: absolute; top: calc(100% + 6px); left: 0; z-index: 5; display: flex; flex-direction: column; gap: 6px; padding: 8px 10px;
  background: rgba(4,8,18,.94); border: 1px solid rgba(62,243,255,.35); border-radius: 4px; box-shadow: 0 0 14px rgba(62,243,255,.15); white-space: nowrap; }
.sndpanel.hidden { display: none; }
.sndpanel > div { display: flex; align-items: center; gap: 8px; }
.sndpanel button { min-width: 92px; }
.sndctl button { text-transform: none; }
.sndctl button.off { color: var(--dim); }
.sndctl input[type=range] { width: 70px; accent-color: var(--cyan); padding: 0; background: none; border: none; }
.sndctl input[type=range]:disabled { opacity: .35; }

#players { position: fixed; top: 76px; right: 16px; width: 270px; z-index: 2; display: flex; flex-direction: column; gap: 10px; }
.pcard { position: relative; padding: 10px 12px 10px 16px; background: rgba(4, 12, 20, .62); border: 1px solid rgba(255,255,255,.08); border-left: 3px solid var(--c); border-radius: 4px; backdrop-filter: blur(3px); box-shadow: -4px 0 18px -6px var(--c); }
.pcard.dead { opacity: .35; filter: grayscale(1); }
.pcard .nm { font-family: var(--font); font-weight: 700; font-size: 15px; color: var(--c); text-shadow: 0 0 8px var(--c); display: flex; justify-content: space-between; align-items: baseline; }
.pcard .tag { font-family: var(--mono); font-size: 10px; letter-spacing: .1em; color: var(--dim); }
.pcard .tag.live { color: #7dff9a; }
.pcard .stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; margin-top: 6px; font-size: 11px; color: var(--dim); }
.pcard .stats b { display: block; font-size: 16px; color: #fff; font-weight: 400; }
.pcard .bar { height: 3px; background: rgba(255,255,255,.08); margin-top: 8px; }
.pcard .bar i { display: block; height: 100%; background: var(--c); box-shadow: 0 0 8px var(--c); transition: width .4s; }
.pcard .say { margin-top: 8px; font-size: 12px; color: #fff; line-height: 1.4; border-top: 1px dashed rgba(255,255,255,.1); padding-top: 6px; min-height: 0; }
.pcard .say:empty { display: none; }

#feed { position: fixed; left: 16px; bottom: 16px; width: 420px; max-height: 32vh; z-index: 2; overflow: hidden; pointer-events: none;
  mask-image: linear-gradient(to top, #000 70%, transparent); -webkit-mask-image: linear-gradient(to top, #000 70%, transparent); }
#log { display: flex; flex-direction: column; justify-content: flex-end; gap: 3px; font-size: 13px; }
#log div { padding: 2px 8px; background: rgba(2,8,14,.55); border-left: 2px solid var(--c, #456); animation: slidein .35s ease-out; }
#log .t { color: var(--dim); margin-right: 8px; }
#log .say { color: #fff; }
#log .say b { color: var(--c); }
#log .kill { color: #ffb3a0; }
#log .sys, #log .win { color: var(--cyan); letter-spacing: .15em; }
#log .elim { color: #ff6060; }
@keyframes slidein { from { transform: translateX(-20px); opacity: 0; } }

#seats .vsel { font-size: 11px; padding: 2px 4px; max-width: 210px; }
#seats .vname { font-size: 11px; color: var(--dim); }

#banner { position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%); z-index: 2; pointer-events: none; font-family: var(--font); font-weight: 900; font-size: 72px; letter-spacing: .2em; color: #fff; text-shadow: 0 0 12px var(--cyan), 0 0 40px var(--cyan); opacity: 0; transition: opacity .4s; white-space: nowrap; }
#banner.on { opacity: 1; }

a.btnlink { font-size: 12px; padding: 4px 10px; color: var(--ink); text-decoration: none; border: 1px solid var(--line); border-radius: 4px; background: rgba(10,30,45,.7); letter-spacing: .08em; }
a.btnlink:hover { border-color: var(--cyan); color: #fff; box-shadow: 0 0 12px rgba(62,243,255,.5); }
a.btnlink.wide { display: block; text-align: center; margin-top: 18px; padding: 10px; font-size: 14px; }

/* ---------------- overlays */
.overlay { position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at center, rgba(2,6,14,.55), rgba(2,4,10,.92)); overflow-y: auto; padding: 20px; }
.panel { width: min(1080px, 100%); background: rgba(4, 10, 18, .82); border: 1px solid var(--line); border-radius: 8px; padding: 28px 32px; box-shadow: 0 0 60px rgba(62,243,255,.08), inset 0 0 40px rgba(62,243,255,.04); }
.panel.small { width: min(560px, 100%); }
.panel h1 { margin: 0; font-family: var(--font); font-weight: 900; font-size: 44px; letter-spacing: .3em; color: var(--cyan); text-shadow: 0 0 10px var(--cyan), 0 0 36px rgba(62,243,255,.5); }
.panel .sub { color: var(--dim); margin: 6px 0 22px; }
/* the rooms cannot run (e.g. the server's daily usage limit): shown at the top of the title screen */
.svcdown { margin: -10px 0 18px; padding: 10px 14px; border: 1px solid #ff4f6d; border-radius: 6px; background: rgba(255, 79, 109, 0.12); color: #ffd0d8; line-height: 1.6; }
.panel h2 { font-family: var(--font); font-size: 14px; letter-spacing: .2em; color: #fff; margin: 0 0 12px; }
.panel h2 small { color: var(--dim); font-family: var(--mono); letter-spacing: 0; }
.panel h3 { font-size: 13px; color: var(--dim); font-weight: 400; margin: 18px 0 6px; }
.cols { display: grid; grid-template-columns: 1fr 1.25fr; gap: 32px; }
@media (max-width: 860px) { .cols { grid-template-columns: 1fr; } }
#seats { list-style: none; padding: 0; margin: 0 0 14px; display: flex; flex-direction: column; gap: 6px; min-height: 40px; }
#seats li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid rgba(255,255,255,.08); border-left: 3px solid var(--c); border-radius: 4px; background: rgba(255,255,255,.02); }
#seats li .n { font-family: var(--font); color: var(--c); text-shadow: 0 0 8px var(--c); flex: 1; }
#seats li .k { font-size: 11px; color: var(--dim); }
#seats li .k.live { color: #7dff9a; }
#seats li.me { background: rgba(62,243,255,.06); }
#seats .empty { color: var(--dim); border-style: dashed; border-left: 1px dashed rgba(255,255,255,.1); justify-content: center; }
.row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; flex-wrap: wrap; }
.row input { flex: 1; min-width: 120px; }
.hint { font-size: 12px; color: var(--dim); }
.kv { font-size: 13px; color: var(--dim); margin-bottom: 8px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
code { color: #fff; background: rgba(255,255,255,.06); padding: 2px 6px; border-radius: 3px; word-break: break-all; }
pre { white-space: pre-wrap; word-break: break-all; font-size: 12px; background: rgba(0,0,0,.45); border: 1px solid rgba(255,255,255,.08); padding: 10px 12px; border-radius: 4px; margin: 6px 0; color: #bfe9ff; max-height: 220px; overflow: auto; }
.tabs { display: flex; gap: 4px; margin-top: 10px; flex-wrap: wrap; }
.tabs button { font-size: 11px; padding: 4px 10px; text-transform: none; }
.tabs button.on { border-color: var(--cyan); color: var(--cyan); }
h2.rph { margin-top: 22px !important; display: flex; align-items: center; gap: 8px; }
h2.rph .btnlink { margin-left: auto; font-family: var(--mono); letter-spacing: .05em; font-size: 11px; padding: 2px 8px; }
#lobbyReplays { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
#lobbyReplays a { display: grid; grid-template-columns: 92px 1fr; gap: 0 10px; padding: 6px 10px; border: 1px solid rgba(255,255,255,.08); border-radius: 4px; color: var(--ink); text-decoration: none; font-size: 12px; background: rgba(255,255,255,.02); }
#lobbyReplays a:hover { border-color: var(--cyan); background: rgba(62,243,255,.07); }
#lobbyReplays .d { color: var(--dim); grid-row: span 2; align-self: center; }
#lobbyReplays .vs b { font-weight: 400; }
#lobbyReplays .w { color: var(--dim); font-size: 11px; }
#lobbyReplays .empty { color: var(--dim); font-size: 12px; padding: 6px 2px; }
#lobbyRooms { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
#lobbyRooms a { display: grid; grid-template-columns: 1fr auto; gap: 0 10px; padding: 6px 10px; border: 1px solid rgba(255,255,255,.08); border-radius: 4px; color: var(--ink); text-decoration: none; font-size: 12px; background: rgba(255,255,255,.02); }
#lobbyRooms a:hover { border-color: var(--cyan); background: rgba(62,243,255,.07); }
#lobbyRooms .cur a { border-color: rgba(62,243,255,.35); }
#lobbyRooms .id { font-family: var(--mono); }
#lobbyRooms .st { color: var(--dim); font-size: 11px; text-align: right; }
#lobbyRooms .st-playing { color: var(--cyan); }
#lobbyRooms .vs { grid-column: span 2; font-size: 11px; }
#lobbyRooms .vs b { font-weight: 400; }
#lobbyRooms .dim, #lobbyRooms .empty { color: var(--dim); font-size: 11px; }
/* attract-mode demo (full screen, after the title is left alone) */
#demoTag { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 11; pointer-events: none; font-family: var(--mono); font-size: 12px; letter-spacing: .08em; color: var(--ink); background: rgba(2,6,14,.7); border: 1px solid var(--line); border-radius: 999px; padding: 5px 14px; white-space: nowrap; max-width: calc(100vw - 32px); overflow: hidden; text-overflow: ellipsis; }
#demoTag small { color: var(--dim); letter-spacing: 0; margin: 0 6px 0 4px; }
#demoTag b { font-weight: 400; }
#demoTag i { color: var(--dim); font-style: normal; margin: 0 2px; }
#demoTag .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #ff4d6d; margin-right: 7px; vertical-align: 1px; box-shadow: 0 0 6px #ff4d6d; animation: demoBlink 1.6s infinite; }
@keyframes demoBlink { 50% { opacity: .25; } }
#soundHint { position: fixed; left: 50%; bottom: 52px; transform: translateX(-50%); z-index: 12; font-size: 13px; padding: 7px 18px; border-radius: 999px; border: 1px solid var(--cyan); color: var(--cyan); background: rgba(2,10,20,.85); box-shadow: 0 0 14px rgba(62,243,255,.35); cursor: pointer; animation: hintPulse 2.4s ease-in-out infinite; }
#soundHint:hover { background: rgba(62,243,255,.15); }
@keyframes hintPulse { 50% { box-shadow: 0 0 22px rgba(62,243,255,.6); } }
#hostInfo { margin: 6px 0 0; }
#hostInfo.host-you { color: var(--cyan); }
#hostInfo.host-here { color: #ffb84d; }
button:disabled, select:disabled { opacity: .45; cursor: not-allowed; }
.tsbox { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.6); }
.tsbox .panel { width: auto; min-width: 320px; padding: 18px 20px; text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.tsbox p { margin: 0; color: var(--dim); font-size: 13px; }
#resultTitle { text-align: center; margin-bottom: 18px !important; }
#resultTable { width: 100%; border-collapse: collapse; font-size: 14px; }
#resultTable td, #resultTable th { padding: 6px 8px; border-bottom: 1px solid rgba(255,255,255,.06); text-align: right; }
#resultTable td:first-child, #resultTable th:first-child { text-align: center; width: 3em; }
#resultTable td:nth-child(2), #resultTable th:nth-child(2) { text-align: left; }
#resultTable th { color: var(--dim); font-weight: 400; font-size: 12px; }

@media (max-width: 700px) {
  #players { width: auto; left: 16px; top: 70px; flex-direction: row; overflow-x: auto; }
  .pcard { min-width: 200px; }
  #feed { width: calc(100vw - 32px); }
  .logo span, .viewctl label { display: none; }
  /* the buttons do not fit: they scroll sideways, and "遊び方" comes first so a newcomer sees it */
  .viewctl { min-width: 0; overflow-x: auto; flex-shrink: 1; }
  .viewctl > * { flex-shrink: 0; }
  #guideLink { order: -1; }
}
#seats li .rdy { font-size: 10px; font-family: var(--mono); color: #7dff9a; border: 1px solid #7dff9a; border-radius: 3px; padding: 1px 5px; text-shadow: 0 0 6px #7dff9a; }
#seats li .docs { font-size: 10px; font-family: var(--mono); border: 1px solid currentColor; border-radius: 3px; padding: 1px 5px; white-space: nowrap; }
#seats li .docs.ok { color: #7dd3ff; }
#seats li .docs.old { color: #ffb347; }
#lobbyChat { list-style: none; padding: 6px 8px; margin: 0 0 12px; max-height: 120px; overflow-y: auto; border: 1px solid rgba(255,255,255,.08); border-radius: 4px; background: rgba(255,255,255,.02); font-size: 12px; display: flex; flex-direction: column; gap: 3px; }
#lobbyChat b { color: var(--cyan); font-weight: 400; margin-right: 6px; }
#lobbyChat .empty { color: var(--dim); }

/* beta mark next to the name, and the 日本語 / EN switch (i18n.js) */
.beta { font-size: .55em; letter-spacing: 0; margin-left: .25em; vertical-align: super; color: var(--hot); text-shadow: 0 0 6px currentColor; }
.langsw { display: inline-flex; gap: 0; margin-left: 6px; }
.langsw button { font: 12px var(--mono); padding: 4px 8px; background: transparent; color: var(--dim); border: 1px solid rgba(62,243,255,.35); cursor: pointer; }
.langsw button + button { border-left: none; }
.langsw button.on { color: var(--cyan); background: rgba(62,243,255,.12); }

/* the header row: logo, clock and buttons side by side; on narrower screens tighten it (no sideways scrolling
   here: it would clip the sound menu that opens below its button; phones scroll it, see max-width: 700px) */
@media (max-width: 1700px) {
  .logo { font-size: 20px; letter-spacing: .18em; }
  .viewctl { gap: 5px; }
  .viewctl select, .viewctl button, .viewctl .btnlink { padding: 4px 7px; }
}
@media (max-width: 1450px) {
  .viewctl select, .viewctl button, .viewctl .btnlink { font-size: 11px; padding: 4px 5px; }
  .logo span { display: none; }
  .viewctl label > span { display: none; }
  #clock { margin: 0 8px; }
}
@media (max-width: 1150px) and (min-width: 701px) {
  /* less room: the order / chat pop-up toggles go (keys I and K still switch them) */
  #cmdBtn, #sayBtn { display: none; }
}
@media (max-width: 700px) {
  /* phones: the clock keeps only the time, so the buttons keep some room */
  #status { display: none; }
  #time { font-size: 18px; letter-spacing: .04em; }
  #clock { margin: 0 6px; }
  header#top { padding: 0 10px; }
  .logo { font-size: 14px; letter-spacing: .08em; }
}
