* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #111;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #eee;
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #222;
  touch-action: none;
}

/* UI root */
#ui-root {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
}

/* Generic panels */
.menu-panel {
  position: absolute;
  inset: 0;
  pointer-events: auto;
}

.hidden {
  display: none !important;
}

/* Main menu */
#main-menu .menu-background {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.menu-bg-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#main-menu .menu-content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(to bottom, rgba(0,0,0,0.4), rgba(0,0,0,0.7));
  padding: 16px;
}

.menu-logo {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 16px;
  text-align: center;
  text-shadow: 0 2px 4px rgba(0,0,0,0.6);
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(260px, 100%);
}

/* Buttons */
.btn {
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 0.95rem;
  font-weight: 500;
  background: rgba(255,255,255,0.08);
  color: #f5f5f5;
  text-align: center;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.btn.primary {
  background: #e24b3b;
  color: #fff;
}

.btn:active {
  transform: scale(0.97);
}

.btn.server {
  width: 100%;
}

/* Rainbow and golden text */
.server.rainbow {
  background: #111;
  color: #fff;
  font-weight: 600;
  background-image: linear-gradient(90deg, red, orange, yellow, green, cyan, blue, violet);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  border: 1px solid rgba(255,255,255,0.25);
}

.server.golden {
  background: #20140a;
  background-image: linear-gradient(135deg, #e1b263, #f5d27a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  border: 1px solid rgba(248, 210, 120, 0.6);
}

/* Overlay panels */
.overlay-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: radial-gradient(circle at top, rgba(0,0,0,0.8), rgba(0,0,0,0.95));
}

.panel-inner {
  width: 100%;
  max-width: 420px;
  background: rgba(20,20,20,0.96);
  border-radius: 16px;
  padding: 12px 14px;
  border: 1px solid rgba(255,255,255,0.06);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-weight: 600;
}

.icon-btn {
  border: none;
  background: transparent;
  color: #ccc;
  font-size: 1.1rem;
  padding: 4px;
  cursor: pointer;
}

.setting-group {
  margin: 8px 0;
}

.setting-group label {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 4px;
}

.setting-sub {
  display: flex;
  gap: 8px;
  font-size: 0.8rem;
  margin-top: 4px;
}

.setting-sub label {
  margin: 0;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

input[type="range"] {
  width: 100%;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.04);
  padding: 6px 10px;
  font-size: 0.8rem;
  cursor: pointer;
}

.pill.active {
  background: #e24b3b;
  border-color: #e24b3b;
  color: #fff;
}

.small-text {
  font-size: 0.78rem;
  opacity: 0.8;
}

/* Tutorial */
.tutorial-body {
  font-size: 0.85rem;
}

.tutorial-body ul {
  margin-left: 16px;
  margin-bottom: 6px;
}

/* Server list */
.server-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 8px 0;
}

/* HUD */
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#hud-top-left,
#hud-top-right {
  position: absolute;
  top: 4px;
  font-size: 0.75rem;
  line-height: 1.3;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

#hud-top-left {
  left: 4px;
}

#hud-top-right {
  right: 4px;
  text-align: right;
}

#hud-bottom-left {
  position: absolute;
  left: 4px;
  bottom: 4px;
  width: 60%;
}

#hud-chat-log {
  max-height: 80px;
  overflow: hidden;
  font-size: 0.7rem;
}

#hud-chat-log div {
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

#hud-chat-input {
  width: 100%;
  margin-top: 4px;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.3);
  font-size: 0.78rem;
  background: rgba(0,0,0,0.7);
  color: #fff;
  pointer-events: auto;
}

/* Mobile Controls */
#mobile-controls {
  position: absolute;
  inset: auto 0 4px 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 8px;
  pointer-events: auto;
}

.mobile-left,
.mobile-right {
  display: flex;
  gap: 6px;
}

.round-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.6);
  color: #eee;
  font-size: 1rem;
  cursor: pointer;
}

.round-btn.small {
  width: 38px;
  height: 38px;
  font-size: 0.8rem;
}

.round-btn.primary {
  background: #e24b3b;
}

/* Vote panel */
#vote-panel .panel-inner {
  max-width: 320px;
}

#vote-status {
  margin-top: 6px;
}

/* Utility */
#hud-role {
  font-weight: 600;
}

#hud-role.traitor {
  color: #e24b3b;
}

#hud-role.sheriff,
#hud-role.police {
  color: #4ec1ff;
}

#hud-role.innocent {
  color: #b4f36d;
}