:root {
  --primary:    #f39200;
  --danger:     #e30613;
  --anthracite: #2b2a29;
  --slate:      #667690;
  --violet:     #8f8fe3;
  --pearl:      #e6e6e6;

  --bg:         #1a1918;
  --surface:    #252321;
  --surface-2:  #2f2d2b;
  --border:     #3a3835;
  --text:       #e6e6e6;
  --text-muted: #8a8886;
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  display: flex;
  justify-content: center;
}

.screen {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hidden { display: none !important; }

/* --- Splash --- */
#screen-splash {
  align-items: center;
  justify-content: center;
  gap: 20px;
}

#screen-splash .logo {
  width: 220px;
  margin-bottom: 8px;
}

.badge-icon {
  width: 72px;
  height: 72px;
  align-self: center;
  margin-bottom: 4px;
}

/* rende visibile il testo antracite del logo su sfondo scuro */
.logo {
  filter: drop-shadow(0 0 1px rgba(230,230,230,0.6));
}

#screen-splash .tagline {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 0;
  letter-spacing: 0.04em;
}

/* --- QR / Video --- */
#qr-display, #team-qr-display {
  background: white;
  padding: 12px;
  border-radius: 8px;
  align-self: center;
}
#qr-display svg, #team-qr-display svg { display: block; width: 200px; height: 200px; }
#qr-scan-video { width: 100%; border-radius: 8px; background: black; }

/* --- Channel type selector --- */
#channel-type-selector { display: flex; gap: 8px; }
.type-btn { background: var(--surface-2); flex: 1; }
.type-btn.active { background: var(--primary); color: #000; font-weight: 600; }

/* --- Typography --- */
h1 { text-align: center; margin: 0; font-size: 2rem; }
h2 { margin-bottom: 8px; }

/* --- Buttons --- */
button {
  background: var(--primary);
  color: #000;
  border: none;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

button:active { opacity: 0.85; }

button.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 400;
}

button.danger {
  background: var(--danger);
  color: white;
}

button.icon-btn {
  background: transparent;
  color: var(--text);
  width: 36px;
  padding: 0;
  font-size: 1.2rem;
  font-weight: 400;
  align-self: flex-start;
}

/* --- Inputs --- */
input, select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 12px;
  font-size: 1rem;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
}

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* --- Error --- */
.error {
  color: var(--danger);
  font-size: 0.9rem;
}

/* --- Home header --- */
.home-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.home-header-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.home-header h2 { margin: 0; }

.current-user-label {
  font-size: 0.78rem;
  color: var(--primary);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-icon-small {
  width: 36px;
  height: 36px;
}

.empty-state {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 24px 0;
  line-height: 1.6;
}

/* --- Channel list --- */
#channel-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.channel-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: border-color 0.15s;
}

.channel-item:hover { border-color: var(--primary); }

.channel-item-main {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.channel-name {
  font-weight: 600;
  font-size: 1rem;
}

.channel-status.pending {
  font-size: 0.75rem;
  color: var(--primary);
}

.channel-item-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.channel-last-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.unread-badge {
  background: var(--primary);
  color: #000;
  font-size: 0.72rem;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

/* --- Chat header --- */
#chat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

#chat-title { font-weight: bold; flex: 1; }

#security-badge.verde       { color: #4ade80; }
#security-badge.giallo-verde { color: #fbbf24; }
#security-badge.giallo       { color: var(--primary); }

/* --- Message list --- */
#message-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  min-height: 300px;
}

.message-bubble {
  max-width: 75%;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--surface-2);
}

.message-bubble.mine {
  align-self: flex-end;
  background: var(--primary);
  color: #000;
}

.msg-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}

.msg-sender {
  font-size: 0.72rem;
  font-weight: 700;
  opacity: 0.75;
}

.msg-time {
  font-size: 0.68rem;
  opacity: 0.6;
  white-space: nowrap;
}

.message-bubble.mine .msg-sender,
.message-bubble.mine .msg-time {
  color: #000;
}

.message-bubble .cipher {
  font-family: monospace;
  font-size: 0.8rem;
  opacity: 0.7;
  display: none;
}

.message-bubble.show-cipher .text { display: none; }
.message-bubble.show-cipher .cipher { display: block; }

/* --- Chat input --- */
#chat-input { display: flex; gap: 8px; }
#chat-input input { flex: 1; }

/* --- Channel code display --- */
#channel-code-display {
  font-family: monospace;
  font-size: 1.4rem;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  letter-spacing: 0.1em;
}

/* --- Throw buttons (dice screen) --- */
#throw-buttons { display: flex; gap: 8px; }
.throw-btn {
  flex: 1;
  font-size: 1.4rem;
  padding: 16px 0;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.throw-btn:active { background: var(--primary); color: #000; border-color: var(--primary); }

#throw-progress {
  font-size: 1.1rem;
  text-align: center;
  color: var(--text-muted);
}

/* --- Divider --- */
hr { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

/* --- Flow steps --- */
.flow-steps {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.flow-step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.step-num {
  background: var(--primary);
  color: #000;
  font-weight: 700;
  font-size: 0.75rem;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.section-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 4px 0 0;
}

/* --- Throws screen --- */
.throws-instruction {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.throw-progress-display {
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
  color: var(--primary);
  padding: 8px 0;
}

.throws-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 4px;
}
