:root {
  --glass: rgba(9, 15, 25, 0.46);
  --glass-strong: rgba(7, 12, 20, 0.82);
  --border: rgba(255, 255, 255, 0.16);
  --text: #f5fbff;
  --muted: rgba(245, 251, 255, 0.7);
  --danger: #ff8f8f;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  user-select: none;
  background: transparent;
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
  border: 0;
  color: var(--text);
}

#gameCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: transparent;
}

.overlay {
  position: fixed;
  z-index: 10;
  pointer-events: none;
}

.top-left {
  top: 20px;
  left: 20px;
}

.top-right {
  top: 20px;
  right: 20px;
}

.bottom-center {
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  max-width: min(92vw, 900px);
}

.top-center {
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
}

.orb-overlay {
  left: 20px;
  top: 20px;
}

.glass {
  background: var(--glass);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.block-lg {
  min-width: min(420px, 86vw);
  padding: 18px 20px;
  border-radius: 24px;
}

.movable-panel {
  position: fixed;
  left: 20px;
  top: 20px;
  pointer-events: auto;
}

.eyebrow {
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

#phaseDisplay {
  margin: 6px 0 0;
  font-size: clamp(34px, 5vw, 64px);
  line-height: 1;
}

.subline,
.note,
.hint {
  color: var(--muted);
}

.subline {
  margin-top: 6px;
}

.metric-row {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 12px;
  font-size: 16px;
}

.panel-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-mini-actions {
  display: flex;
  gap: 8px;
}

.tiny-btn,
.ghost-btn,
.primary-btn,
.inline-field button,
.orb-menu button {
  padding: 9px 13px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.tiny-btn {
  padding: 6px 10px;
  font-size: 12px;
}

.danger-btn {
  color: #ffd4d4;
  border-color: rgba(255, 143, 143, 0.28);
  background: rgba(255, 143, 143, 0.12);
}

.tiny-btn:hover,
.ghost-btn:hover,
.primary-btn:hover,
.inline-field button:hover,
.orb-menu button:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.2);
}

.primary-btn {
  background: linear-gradient(135deg, rgba(142, 245, 204, 0.28), rgba(127, 183, 255, 0.28));
  border-color: rgba(142, 245, 204, 0.32);
}

.panel {
  pointer-events: auto;
  width: 220px;
  padding: 12px;
  border-radius: 22px;
}

.panel-title,
.section-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 10px;
}

.emote-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.emote-grid button {
  min-height: 48px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 24px;
  pointer-events: auto;
  transition: transform 160ms ease, background 160ms ease;
}

.emote-grid button:hover {
  transform: scale(1.05);
  background: rgba(255, 255, 255, 0.14);
}

.emote-icon-image {
  width: 28px;
  height: 28px;
  object-fit: contain;
  pointer-events: none;
}

.hint {
  padding: 10px 16px;
  border-radius: 999px;
  text-align: center;
  pointer-events: auto;
}

.orb-stack {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  pointer-events: auto;
}

.ui-orb {
  width: 64px;
  height: 64px;
  min-width: 64px;
  min-height: 64px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,0.28), rgba(127,183,255,0.2) 42%, rgba(7,12,20,0.9));
  box-shadow: 0 18px 40px rgba(0,0,0,0.28);
  backdrop-filter: blur(16px);
  font-size: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.orb-menu {
  position: absolute;
  left: 76px;
  top: 0;
  display: grid;
  gap: 10px;
  min-width: 160px;
  padding: 14px;
  border-radius: 24px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(4, 6, 10, 0.48);
  padding: 20px;
}

.modal.active {
  display: flex;
}

.dialog {
  width: min(720px, 96vw);
  max-height: 92vh;
  overflow: auto;
  border-radius: 28px;
  padding: 22px;
  background: var(--glass-strong);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.dialog.large {
  width: min(860px, 96vw);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.dialog-header h2 {
  margin: 0;
}

.settings-section + .settings-section {
  margin-top: 18px;
}

.settings-grid,
.dialog-grid {
  display: grid;
  gap: 12px;
}

.settings-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.dialog-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

label,
.stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

input[type="text"],
input:not([type]),
input[type="file"],
input[readonly],
textarea {
  width: 100%;
}

input {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 16px;
  padding: 12px 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  outline: none;
}

input:focus {
  border-color: rgba(142, 245, 204, 0.46);
  box-shadow: 0 0 0 4px rgba(142, 245, 204, 0.08);
}

.inline-actions,
.network-actions,
.network-status,
.inline-field {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.network-actions,
.network-status {
  margin-top: 18px;
}

.qr-output-wrap,
.qr-input-wrap {
  min-height: 220px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
}

.qr-image {
  width: min(100%, 260px);
  aspect-ratio: 1 / 1;
  object-fit: contain;
  border-radius: 18px;
  background: white;
  padding: 10px;
}

.qr-empty {
  color: var(--muted);
  text-align: center;
}

.peer-list-wrap {
  margin-top: 18px;
}

.peer-list {
  display: grid;
  gap: 10px;
}

.peer-list.empty {
  color: var(--muted);
}

.peer-chip {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.peer-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.peer-meta small {
  color: var(--muted);
}

.peer-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.peer-actions button {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.invite-banner {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 18px;
  border-radius: 22px;
  pointer-events: auto;
  min-width: min(88vw, 520px);
}

.quiet-zone-chip {
  position: fixed;
  z-index: 12;
  border: 0;
  border-radius: 18px;
  background: transparent;
  box-shadow: none;
  pointer-events: none;
}

.quiet-zone-chip.selecting {
  border: 2px dashed rgba(142, 245, 204, 0.72);
  background: rgba(142, 245, 204, 0.1);
}

.hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .block-lg {
    min-width: auto;
    width: min(88vw, 420px);
  }

  .invite-banner {
    min-width: min(92vw, 520px);
    flex-direction: column;
    align-items: stretch;
  }

  .orb-stack {
    flex-direction: column-reverse;
    align-items: flex-end;
  }
}
