:root {
  --bg: #16181e;
  --panel: #20232b;
  --panel-2: #1a1d24;
  --line: #3a3f4a;
  --fg: #f3f5f9;
  --muted: #a9b2c3;
  --ok: #8de16f;
  --warn: #ff6a70;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  font-family: "JetBrains Mono", "Fira Code", Menlo, monospace;
}

#game {
  width: 100%;
  height: 100%;
  display: block;
}

body.overlay-active #game {
  visibility: hidden;
}

#screenRoot {
  position: fixed;
  inset: 0;
}

.view {
  position: absolute;
  inset: 0;
}

.view.hidden {
  display: none !important;
}

.hidden {
  display: none !important;
}

#connectView {
  display: grid;
  place-items: center;
  background: #151820;
}

.card {
  width: min(500px, calc(100vw - 32px));
  display: grid;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
  box-sizing: border-box;
}

.card h1 {
  margin: 0 0 6px;
  font-size: 26px;
}

label {
  color: var(--muted);
  font-size: 12px;
}

input,
button {
  font: inherit;
}

input {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #12151b;
  color: var(--fg);
  padding: 9px 10px;
}

button {
  border: 1px solid #5d8c4d;
  border-radius: 7px;
  background: #243226;
  color: var(--fg);
  padding: 10px 12px;
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.7;
}

.error {
  min-height: 20px;
  color: var(--warn);
  font-size: 13px;
}

#lobbyView {
  background: #13161d;
  display: flex;
  flex-direction: column;
}

#scoreboardBar {
  flex: 0 0 auto;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
  overflow-x: auto;
}

#scoreTable {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

#scoreTable th,
#scoreTable td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 13px;
}

#scoreTable th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

#lobbyMain {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 10px;
  gap: 10px;
}

#countdownText {
  min-height: 34px;
  display: grid;
  place-items: center;
  font-size: 30px;
  font-weight: 700;
  color: var(--ok);
}

#chatPanel {
  flex: 1 1 auto;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f1218;
  display: flex;
  flex-direction: column;
}

#chatMessages {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 8px;
  font-size: 13px;
  line-height: 1.35;
}

.chat-line {
  margin: 0 0 4px;
  word-break: break-word;
}

.chat-system {
  color: #ffffff;
}

.chat-name {
  color: var(--ok);
}

#chatInputRow {
  display: flex;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding: 8px;
}

#chatInput {
  flex: 1 1 auto;
}

#lobbyActionRow {
  display: flex;
  gap: 10px;
  align-self: stretch;
}

#lobbyActionRow button {
  flex: 1 1 0;
  font-size: 15px;
  padding: 11px 10px;
}

#lobbyDialogBackdrop {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.42);
}

#lobbyDialogCard {
  width: min(540px, calc(100vw - 44px));
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #171b23;
  padding: 16px;
  box-sizing: border-box;
}

#lobbyDialogTitle {
  margin: 0 0 8px;
  font-size: 20px;
}

#lobbyDialogText {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-line;
}

#lobbyDialogCloseBtn {
  min-width: 110px;
}

#gameHud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  color: #e7ebf5;
  z-index: 5;
}

#aliveOthersText {
  position: absolute;
  top: 10px;
  left: 12px;
  font-size: 12px;
  letter-spacing: 0.2px;
  color: rgba(231, 235, 245, 0.86);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

#gameChatNotice {
  position: absolute;
  right: 14px;
  bottom: 128px;
  font-size: 11px;
  color: rgba(231, 235, 245, 0.75);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

#gameChatBox {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: min(420px, calc(100vw - 24px));
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(9, 11, 16, 0.5);
  backdrop-filter: blur(2px);
  pointer-events: auto;
}

#gameChatMessages {
  max-height: 116px;
  overflow: auto;
  padding: 8px;
  font-size: 12px;
  line-height: 1.3;
}

#gameChatMessages .chat-line {
  margin: 0 0 3px;
  color: rgba(233, 236, 243, 0.86);
}

#gameChatMessages .chat-system {
  color: #ffffff;
}

#gameChatInputRow {
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  padding: 7px;
}

#gameChatInput {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(10, 12, 18, 0.88);
  color: #f3f5f9;
  padding: 7px 8px;
}
