/* ================================================================
   phone.css — Interfaccia teleconferenza audio-only
   Design ispirato alle app di chiamata mobile (iOS/Android)
   ================================================================ */

/* ====== Token ====== */
:root {
  --bg:       #dde8f8;
  --panel:    #f0f6ff;
  --panel2:   #e4eeff;
  --border:   #bccef0;
  --text:     #0f1f3d;
  --muted:    #4e6080;
  --accent:   #2563eb;
  --ok:       #16a34a;
  --danger:   #dc2626;
  --calling-bg-top:    #ecf4ff;
  --calling-bg-bottom: #dbe8ff;
  --calling-fg:        #0f1f3d;
  --calling-fg-soft:   rgba(15,31,61,.7);
  --calling-fg-muted:  rgba(15,31,61,.5);
  --calling-card-bg:   rgba(255,255,255,.56);
  --calling-card-bd:   rgba(141,169,214,.52);
  --calling-btn-bg:    rgba(255,255,255,.72);
  --calling-btn-bd:    rgba(141,169,214,.58);
  --calling-bar-bg:    rgba(227,238,255,.8);
  --calling-bar-bd:    rgba(141,169,214,.45);
  --radius:   16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top:    env(safe-area-inset-top, 0px);
}

body[data-theme="dark"] {
  --bg:       #0b1220;
  --panel:    #0f172a;
  --panel2:   #111827;
  --border:   #1f2b43;
  --text:     #e6eef8;
  --muted:    #94a3b8;
  --accent:   #3b82f6;
  --ok:       #22c55e;
  --danger:   #ef4444;
  --calling-bg-top:    #0d1f3c;
  --calling-bg-bottom: #060e1a;
  --calling-fg:        #eaf2ff;
  --calling-fg-soft:   rgba(234,242,255,.75);
  --calling-fg-muted:  rgba(234,242,255,.5);
  --calling-card-bg:   rgba(255,255,255,.05);
  --calling-card-bd:   rgba(255,255,255,.12);
  --calling-btn-bg:    rgba(255,255,255,.1);
  --calling-btn-bd:    rgba(255,255,255,.15);
  --calling-bar-bg:    rgba(0,0,0,.3);
  --calling-bar-bd:    rgba(255,255,255,.08);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ================================================================
   SISTEMA A SCHERMATE — una sola attiva alla volta
   ================================================================ */
.screen {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  display: none;
  flex-direction: column;
  background: var(--bg);
  padding-top: var(--safe-top);
}
.screen.active { display: flex; }

/* ================================================================
   SCHERMATA PREJOIN
   ================================================================ */
.screen--prejoin {
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse 120% 80% at 50% -10%, color-mix(in srgb, var(--accent) 26%, var(--bg)), var(--bg) 60%);
}

.prejoin__wrap {
  width: min(400px, 92vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

/* Icona con cerchi pulsanti */
.prejoin__hero { display: flex; flex-direction: column; align-items: center; gap: 10px; }

.ph-pulse-wrap {
  position: relative;
  width: 100px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ph-icon-bubble {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  position: relative; z-index: 2;
  box-shadow: 0 8px 32px rgba(59, 130, 246, .4);
}
.ph-pulse {
  position: absolute;
  border-radius: 50%;
  border: 2px solid var(--accent);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(1);
  opacity: 0;
  animation: none;
  opacity: .14;
}
.ph-pulse--1 { width: 80px; height: 80px; animation-delay: 0s; }
.ph-pulse--2 { width: 80px; height: 80px; animation-delay: .8s; }
.ph-pulse--3 { width: 80px; height: 80px; animation-delay: 1.6s; }
@keyframes prejoinPulse {
  0%   { transform: translate(-50%,-50%) scale(1);   opacity:.5; }
  100% { transform: translate(-50%,-50%) scale(2.4); opacity:0; }
}

.prejoin__title {
  font-size: 26px; font-weight: 700; letter-spacing: -.02em;
  text-align: center;
}
.prejoin__subtitle {
  font-size: 13px; color: var(--muted); text-align: center;
}

/* Monitor microfono */
.mic-monitor {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 12px;
  background: color-mix(in srgb, var(--panel) 90%, transparent);
  border: 1px solid var(--border);
}
.mic-track {
  flex: 1; height: 5px; background: var(--border); border-radius: 999px; overflow: hidden;
}
.mic-bar {
  height: 100%; width: 0%; background: var(--ok); border-radius: 999px;
  transition: width .07s linear;
}
.mic-label { font-size: 11px; color: var(--muted); white-space: nowrap; min-width: 58px; text-align: right; }

/* Form */
.prejoin__form { width: 100%; display: flex; flex-direction: column; gap: 10px; }

.field-group { display: flex; flex-direction: column; gap: 5px; }
.field-label { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .05em; text-transform: uppercase; }

.field-input {
  width: 100%; padding: 13px 14px;
  border-radius: 12px; border: 1px solid var(--border);
  background: var(--panel2); color: var(--text);
  font-size: 16px; font-family: inherit;
  transition: border-color .15s;
}
.field-input:focus { outline: none; border-color: var(--accent); }

.select-wrap { position: relative; }
.field-select {
  width: 100%; padding: 12px 36px 12px 14px;
  border-radius: 12px; border: 1px solid var(--border);
  background: var(--panel2); color: var(--text);
  font-size: 14px; font-family: inherit;
  appearance: none; -webkit-appearance: none;
  cursor: pointer; transition: border-color .15s;
}
.field-select:focus { outline: none; border-color: var(--accent); }
.select-arrow {
  position: absolute; right: 12px; top: 50%;
  transform: translateY(-50%); pointer-events: none; color: var(--muted);
}

.prejoin__actions { display: flex; align-items: center; gap: 10px; margin-top: 6px; }

.btn-call {
  flex: 1; padding: 15px;
  border-radius: 14px; border: none;
  background: var(--ok); color: #fff;
  font-size: 17px; font-weight: 700; font-family: inherit;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(34, 197, 94, .35);
  transition: opacity .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.btn-call:hover { opacity: .9; }
.btn-call:active { transform: scale(.97); }

.btn-admin {
  width: 46px; height: 46px; border-radius: 12px;
  border: 1px solid var(--border); background: transparent;
  color: var(--muted); cursor: pointer; display: flex;
  align-items: center; justify-content: center; flex-shrink: 0;
  opacity: .45; transition: opacity .15s;
}
.btn-admin:hover { opacity: .8; }

/* ================================================================
   SCHERMATA CHIAMATA IN ATTESA (calling)
   ================================================================ */
.screen--calling {
  align-items: stretch;
  justify-content: flex-end;
  background: var(--calling-bg-bottom);
  padding-bottom: calc(var(--safe-bottom) + 10px);
}

.calling__bg {
  position: absolute; inset: 0; z-index: 0;
  background: radial-gradient(ellipse 90% 55% at 50% 0%, var(--calling-bg-top), var(--calling-bg-bottom));
}

.calling__content {
  position: relative; z-index: 1;
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-start;
  padding: 40px 20px 16px;
  gap: 0;
  min-height: 0;
  overflow-y: auto;
}

/* Avatar sala con cerchi */
.calling__avatar-wrap {
  position: relative; width: 120px; height: 120px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 22px;
}
.calling__ring {
  position: absolute; border-radius: 50%;
  border: 2px solid rgba(59, 130, 246, .2);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(1);
  animation: none;
  opacity: .55;
}
.calling__ring--1 { width: 120px; height: 120px; }
.calling__ring--2 { width: 154px; height: 154px; }
.calling__ring--3 { width: 188px; height: 188px; }

.calling__avatar {
  width: 100px; height: 100px; border-radius: 50%;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 70%, #143784), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-size: 38px; z-index: 1;
  box-shadow: 0 10px 32px rgba(59,130,246,.32);
  color: #fff;
}
.waiting-anim .calling__ring {
  animation: callingPulse 2.4s ease-out infinite;
}
.waiting-anim .calling__ring--1 { animation-delay: 0s; }
.waiting-anim .calling__ring--2 { animation-delay: .8s; }
.waiting-anim .calling__ring--3 { animation-delay: 1.6s; }
@keyframes callingPulse {
  0%   { transform: translate(-50%,-50%) scale(1); opacity:.55; }
  100% { transform: translate(-50%,-50%) scale(1.14); opacity:.08; }
}

/* Info testuale */
.calling__info { text-align: center; display: flex; flex-direction: column; gap: 6px; margin-bottom: 24px; }
.calling__room  { font-size: 24px; font-weight: 700; color: var(--calling-fg); }
.calling__status { font-size: 15px; color: var(--calling-fg-soft); }
.calling__timer { font-size: 13px; color: var(--calling-fg-muted); font-variant-numeric: tabular-nums; }
.calling__game-cta {
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.calling__game-cta-text {
  font-size: 12px;
  color: var(--calling-fg-soft);
}
.calling__game-cta-btn {
  border: 1px solid rgba(147,197,253,.75);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(59,130,246,.45), rgba(37,99,235,.35));
  color: #eaf2ff;
  font-size: 13px;
  font-weight: 800;
  padding: 8px 14px;
  box-shadow: 0 6px 18px rgba(37,99,235,.35);
  animation: gamePulse 1.9s ease-in-out infinite;
}
@keyframes gamePulse {
  0%,100% { transform: scale(1); box-shadow: 0 6px 18px rgba(37,99,235,.35); }
  50% { transform: scale(1.04); box-shadow: 0 10px 26px rgba(37,99,235,.48); }
}

/* Chat durante attesa */
.calling__chat {
  width: 100%; max-width: 440px; flex: 1;
  display: flex; flex-direction: column; gap: 8px;
  background: var(--calling-card-bg);
  border: 1px solid var(--calling-card-bd);
  border-radius: 16px; padding: 12px;
  min-height: 0;
}
.calling__chat-log {
  flex: 1; overflow-y: auto; min-height: 60px; max-height: 160px;
  display: flex; flex-direction: column; gap: 6px;
}
.calling__msg { font-size: 13px; padding: 6px 10px; border-radius: 8px; }
.calling__msg--admin { background: color-mix(in srgb, var(--calling-btn-bg) 92%, transparent); color: var(--calling-fg); }
.calling__msg--me    { background: rgba(59,130,246,.2); color: color-mix(in srgb, var(--accent) 70%, white); align-self: flex-end; }
.calling__msg--system { color: var(--calling-fg-muted); font-size: 12px; font-style: italic; }
.calling__chat-empty { color: var(--calling-fg-muted); font-size: 13px; font-style: italic; padding: 4px 0; }

.calling__chat-input-wrap {
  display: flex; gap: 8px; align-items: flex-end;
}
.calling__textarea {
  flex: 1; resize: none; padding: 8px 10px;
  border-radius: 10px; border: 1px solid var(--calling-card-bd);
  background: color-mix(in srgb, var(--calling-btn-bg) 70%, transparent); color: var(--calling-fg);
  font-size: 13px; font-family: inherit;
}
.calling__textarea::placeholder { color: var(--calling-fg-muted); }
.calling__textarea:focus { outline: none; border-color: color-mix(in srgb, var(--calling-fg-soft) 55%, transparent); }
.calling__send-btn {
  width: 36px; height: 36px; border-radius: 10px;
  border: none; background: var(--accent); color: #fff;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* Mini-giochi sala d'attesa */
.calling__games-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 16px 12px calc(98px + env(safe-area-inset-bottom, 0px));
  background: rgba(2,6,23,.52);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.calling__games-modal.open { display: flex; }
.calling__games-sheet {
  width: min(460px, 100%);
  max-height: min(72vh, 520px);
  overflow: auto;
  background:
    repeating-linear-gradient(0deg, rgba(56,189,248,.04) 0 2px, transparent 2px 4px),
    linear-gradient(180deg, color-mix(in srgb, var(--panel2) 90%, #0a2a58), color-mix(in srgb, var(--panel) 90%, #0b1d3f));
  border: 1px solid color-mix(in srgb, var(--accent) 55%, #7dd3fc);
  border-radius: 16px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 12px 34px rgba(2,6,23,.65), inset 0 0 0 1px rgba(96,165,250,.28), inset 0 0 34px rgba(14,165,233,.14);
  animation: gamesIn .24s ease-out both;
}
@keyframes gamesIn {
  from { transform: translateY(18px) scale(.98); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
.calling__games-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.calling__games-title {
  color: color-mix(in srgb, var(--accent) 45%, white);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  text-shadow: 0 0 12px rgba(56,189,248,.45);
}
.calling__games-close {
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border));
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--text);
  font-size: 11px;
  font-weight: 800;
  padding: 5px 8px;
}
.calling__games-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.calling__game-tab {
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
  border-radius: 10px;
  background: color-mix(in srgb, var(--panel2) 90%, transparent);
  color: color-mix(in srgb, var(--accent) 35%, var(--text));
  font-size: 11px;
  font-weight: 800;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.calling__game-tab.active {
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 34%, transparent), color-mix(in srgb, var(--accent) 24%, transparent));
  border-color: color-mix(in srgb, var(--accent) 65%, white);
  color: var(--text);
  box-shadow: 0 0 16px color-mix(in srgb, var(--accent) 30%, transparent);
}
.game-tab__ico { font-size: 13px; line-height: 1; }
.calling__game-panel { display: flex; flex-direction: column; gap: 8px; position: relative; }
.game-level-hint {
  font-size: 11px;
  color: color-mix(in srgb, var(--text) 75%, var(--muted));
  border: 1px dashed color-mix(in srgb, var(--accent) 34%, var(--border));
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  padding: 5px 8px;
}
.waiting-game__status {
  font-size: 12px;
  color: var(--text);
  min-height: 18px;
}
.waiting-game__btn {
  border: 1px solid color-mix(in srgb, var(--accent) 38%, var(--border));
  border-radius: 9px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  padding: 7px 10px;
  align-self: flex-start;
}
.game-levels {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.game-level-btn {
  border: 1px solid color-mix(in srgb, var(--accent) 34%, var(--border));
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel2) 92%, transparent);
  color: var(--text);
  font-size: 11px;
  font-weight: 800;
  padding: 5px 8px;
}
.game-level-btn.active {
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  border-color: color-mix(in srgb, var(--accent) 60%, white);
  color: var(--text);
  box-shadow: 0 0 10px color-mix(in srgb, var(--accent) 28%, transparent);
}
.ttt-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.ttt-cell {
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 10px;
  background: rgba(255,255,255,.08);
  color: #fff;
  height: 44px;
  font-size: 20px;
  font-weight: 800;
}
.ttt-mark {
  display: inline-block;
  animation: markPop .18s ease-out;
}
@keyframes markPop {
  from { transform: scale(.4); opacity: .3; }
  to { transform: scale(1); opacity: 1; }
}
.memory-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.memory-card {
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 10px;
  background: rgba(255,255,255,.08);
  color: transparent;
  height: 40px;
  font-size: 20px;
  font-weight: 700;
}
.memory-card.is-open,
.memory-card.is-matched {
  color: #fff;
  background: rgba(59,130,246,.25);
}
.memory-card.is-open { animation: memFlip .2s ease-out; }
@keyframes memFlip {
  from { transform: rotateY(90deg); opacity: .5; }
  to { transform: rotateY(0deg); opacity: 1; }
}
.game-burst {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  pointer-events: none;
  opacity: .95;
  animation: burstFly .7s ease-out forwards;
}
@keyframes burstFly {
  to { transform: translate(var(--dx), var(--dy)) scale(.4); opacity: 0; }
}

.snake-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.snake-score {
  font-size: 12px;
  font-weight: 800;
  color: #ecfeff;
  background: rgba(14,165,233,.16);
  border: 1px solid rgba(125,211,252,.35);
  border-radius: 8px;
  padding: 4px 8px;
}
.snake-board {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 3px;
  background: rgba(2,6,23,.38);
  border: 1px solid rgba(125,211,252,.2);
  border-radius: 10px;
  padding: 5px;
}
.snake-cell {
  border: 1px solid rgba(125,211,252,.12);
  border-radius: 5px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15,23,42,.44);
  transition: transform .1s ease, background .1s ease;
}
.snake-cell.is-snake {
  background: linear-gradient(135deg, rgba(34,197,94,.78), rgba(16,185,129,.72));
  box-shadow: 0 0 10px rgba(34,197,94,.38);
}
.snake-cell.is-head {
  background: linear-gradient(135deg, rgba(74,222,128,.96), rgba(16,185,129,.9));
  box-shadow: 0 0 14px rgba(74,222,128,.5);
}
.snake-cell.is-food {
  background: radial-gradient(circle at 30% 30%, #fef08a, #f43f5e 75%);
  box-shadow: 0 0 10px rgba(244,63,94,.45);
  animation: foodBlink .78s ease-in-out infinite;
}
@keyframes foodBlink {
  0%,100% { transform: scale(1); }
  50% { transform: scale(.86); }
}
.snake-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  max-width: 180px;
}
.snake-start {
  border: 1px solid rgba(125,211,252,.5);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(37,99,235,.35), rgba(16,185,129,.3));
  color: #ecfeff;
  font-size: 11px;
  font-weight: 900;
}
.snake-dir {
  border: 1px solid rgba(125,211,252,.35);
  border-radius: 8px;
  background: rgba(14,165,233,.14);
  color: #f0f9ff;
  font-size: 16px;
  font-weight: 900;
  height: 34px;
}
.sudoku-board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 2px;
  background: rgba(2,6,23,.5);
  border: 1px solid rgba(125,211,252,.25);
  border-radius: 10px;
  padding: 4px;
}
.sudoku-cell {
  border: 1px solid rgba(125,211,252,.15);
  border-radius: 4px;
  height: 28px;
  background: rgba(15,23,42,.45);
  color: #e2e8f0;
  font-size: 13px;
  font-weight: 900;
}
.sudoku-cell.fixed {
  background: rgba(14,165,233,.2);
  color: #f0f9ff;
}
.sudoku-cell.sel {
  border-color: rgba(251,191,36,.82);
  box-shadow: inset 0 0 0 1px rgba(251,191,36,.82);
}
.sudoku-cell.wrong {
  background: rgba(239,68,68,.32);
}
.sudoku-pad {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}
.sudoku-num {
  border: 1px solid rgba(125,211,252,.3);
  border-radius: 8px;
  background: rgba(14,165,233,.14);
  color: #f0f9ff;
  font-size: 13px;
  font-weight: 900;
  height: 34px;
}

/* Barra azioni chiamata in attesa */
.calling__bar {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  width: 100%;
  align-self: stretch;
  flex: 0 0 auto;
  padding: 16px 24px;
  border-top: 1px solid var(--calling-bar-bd);
  background: var(--calling-bar-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.calling__bar-side {
  display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 92px;
}
.calling__bar-side--right { align-items: flex-end; }
.calling__hint {
  font-size: 11px;
  font-weight: 600;
  color: var(--calling-fg-muted);
}
.calling__bar-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.calling__action {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--calling-btn-bg); border: 1px solid var(--calling-btn-bd);
  color: var(--calling-fg); border-radius: 12px; padding: 10px 18px;
  cursor: pointer; font-family: inherit;
  transition: background .15s;
  -webkit-tap-highlight-color: transparent;
}
.calling__action:hover { background: color-mix(in srgb, var(--calling-btn-bg) 76%, #ffffff); }
.calling__action:disabled { opacity: .4; cursor: not-allowed; }
.calling__action-label { font-size: 11px; font-weight: 600; color: var(--calling-fg-soft); }
.calling__action-label--danger { color: var(--calling-fg-soft); }
.calling__bell-status {
  font-size: 11px; color: var(--calling-fg-muted);
  text-align: center; max-width: 100px;
  display: none;
}
.calling__bell-status.visible { display: block; }

.calling__end {
  width: 70px; height: 70px; border-radius: 50%;
  border: none; background: var(--danger); color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(239,68,68,.5);
  transition: opacity .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.calling__end:hover { opacity: .9; }
.calling__end:active { transform: scale(.94); }
.calling__end svg { transform: rotate(135deg); }

/* ================================================================
   SCHERMATA IN CHIAMATA
   ================================================================ */
.screen--call {
  display: none;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-columns: 1fr;
  position: relative;
  min-height: 100dvh;
}
.screen--call.active { display: grid !important; }

/* Topbar */
.call-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px;
  background: var(--panel2);
  border-bottom: 1px solid var(--border);
  z-index: 20;
}
.call-topbar__left { display: flex; align-items: center; gap: 10px; }
.call-topbar__right { display: flex; align-items: center; gap: 6px; }

.call-brand {
  font-size: 14px; font-weight: 700;
  display: flex; align-items: center; gap: 5px;
}
.call-timer-badge {
  display: flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px;
  background: rgba(34, 197, 94, .12); border: 1px solid rgba(34,197,94,.25);
  font-size: 12px; font-variant-numeric: tabular-nums; color: var(--ok);
}
.call-timer-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--ok);
  animation: timerDotBlink 2s ease infinite;
}
@keyframes timerDotBlink { 0%,100%{opacity:1} 50%{opacity:.3} }

.topbar-icon-btn {
  width: 34px; height: 34px; border-radius: 9px;
  border: 1px solid var(--border); background: transparent;
  color: var(--muted); cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  transition: background .15s, color .15s;
  -webkit-tap-highlight-color: transparent;
}
.topbar-icon-btn:hover { background: var(--panel); color: var(--text); }

.participant-count {
  display: flex; align-items: center; gap: 4px;
  font-size: 12px; color: var(--muted);
  padding: 3px 8px; border: 1px solid var(--border); border-radius: 999px;
}

.mini-badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700;
  border-radius: 999px; min-width: 16px; height: 16px;
  padding: 0 3px; display: flex; align-items: center; justify-content: center;
}

/* Sidebar */
.sidebar {
  position: absolute; top: 0; left: 0; bottom: 0;
  width: min(320px, 88vw);
  background: var(--panel2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  transform: translateX(-100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  z-index: 40;
  box-shadow: 4px 0 24px rgba(0,0,0,.4);
}
.sidebar.open { transform: translateX(0); }
.sidebar__hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar__title { font-size: 14px; font-weight: 700; }
.sidebar__close {
  width: 30px; height: 30px; border-radius: 8px;
  border: 1px solid var(--border); background: transparent;
  color: var(--muted); cursor: pointer; display: flex;
  align-items: center; justify-content: center;
}
.sidebar__body { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }

.panel-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; padding: 12px;
}
.panel-card--chat { display: flex; flex-direction: column; gap: 8px; }
.panel-card__title {
  font-size: 11px; font-weight: 700; color: var(--muted);
  letter-spacing: .05em; text-transform: uppercase; margin-bottom: 8px;
}

.user-list { list-style: none; display: flex; flex-direction: column; gap: 5px; }
.user-list li { font-size: 13px; display: flex; align-items: center; gap: 8px; }
.user-list li::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex-shrink: 0; }

.chat-log {
  min-height: 80px; max-height: 200px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px;
}
.chat-msg { font-size: 13px; line-height: 1.4; }
.chat-msg strong { color: var(--accent); }
.chat-input-row { display: flex; gap: 8px; align-items: center; }
.chat-input {
  flex: 1; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--panel2);
  color: var(--text); font-size: 13px; font-family: inherit;
}
.chat-input:focus { outline: none; border-color: var(--accent); }
.chat-send {
  width: 36px; height: 36px; border-radius: 10px;
  border: none; background: var(--accent); color: #fff;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* Allegati */
.dropzone {
  border: 1.5px dashed var(--border); border-radius: 10px;
  padding: 10px; text-align: center; font-size: 13px; color: var(--muted);
  cursor: pointer; transition: border-color .15s; margin-bottom: 8px;
}
.dropzone:hover, .dropzone.drag-over { border-color: var(--accent); color: var(--text); }
.link-btn {
  background: none; border: none; color: var(--accent);
  cursor: pointer; font-size: inherit; padding: 0; text-decoration: underline;
}
.attach-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.attach-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--border); }
.attach-item:last-child { border-bottom: none; }
.attach-meta .attach-name { font-size: 12px; font-weight: 600; }
.attach-meta .attach-size { font-size: 11px; color: var(--muted); }
.attach-actions { display: flex; gap: 5px; flex-shrink: 0; }
.attach-btn {
  padding: 4px 9px; border-radius: 7px; border: 1px solid var(--border);
  background: transparent; color: var(--muted); font-size: 11px; cursor: pointer;
}
.attach-btn.danger { color: var(--danger); }
.attach-btn:hover { background: var(--panel2); }

/* Partecipanti */
.participants {
  display: flex; align-items: center; justify-content: center;
  padding: 16px; overflow-y: auto;
  position: relative;
  min-height: 0;
}

.participants-grid {
  display: flex; flex-wrap: wrap; gap: 14px;
  justify-content: center; align-content: flex-start;
  width: 100%;
}

/* Card singolo partecipante */
.p-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 18px 14px 14px;
  border-radius: 20px;
  background: var(--panel2);
  border: 1.5px solid var(--border);
  min-width: 120px; flex: 0 1 140px;
  transition: border-color .2s, box-shadow .2s;
  position: relative;
}
.p-card.speaking {
  border-color: var(--ok);
  box-shadow: 0 0 0 3px rgba(34,197,94,.18), 0 8px 28px rgba(0,0,0,.3);
}
.p-card.muted .p-avatar-wrap .mic-badge { display: flex; }

.p-avatar-wrap { position: relative; width: 72px; height: 72px; }

.p-avatar-ring {
  position: absolute; inset: -4px; border-radius: 50%;
  border: 2.5px solid transparent; transition: border-color .15s;
}
.p-card.speaking .p-avatar-ring {
  border-color: var(--ok);
  animation: avatarSpeak .9s ease-in-out infinite;
}
@keyframes avatarSpeak {
  0%,100% { box-shadow: 0 0 0 0 rgba(34,197,94,.45); }
  50%      { box-shadow: 0 0 0 7px rgba(34,197,94,0); }
}

.p-avatar {
  width: 72px; height: 72px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 700; color: #fff;
  position: relative; z-index: 1; letter-spacing: -.02em;
}

.mic-badge {
  position: absolute; bottom: -2px; right: -2px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--danger); border: 2px solid var(--panel2);
  display: none; align-items: center; justify-content: center; z-index: 2;
}
.mic-badge svg { width: 12px; height: 12px; color: #fff; }

.p-name {
  font-size: 13px; font-weight: 600; text-align: center;
  max-width: 110px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text);
}
.p-sub {
  font-size: 11px; color: var(--muted); text-align: center; min-height: 14px;
}

/* Empty state */
.empty-state {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  color: var(--muted); text-align: center; padding: 32px 20px;
}
.empty-state__icon { font-size: 52px; opacity: .3; }
.empty-state__text { font-size: 15px; line-height: 1.5; }
.empty-state__hint { font-size: 13px; opacity: .6; }

/* Barra controlli in chiamata */
.call-bar {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%;
  margin-top: auto;
  padding: 14px 20px calc(14px + var(--safe-bottom));
  background: var(--panel2); border-top: 1px solid var(--border);
  gap: 10px;
}
.call-bar__group { display: flex; gap: 10px; }

.call-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; padding: 10px 16px;
  border-radius: 14px; border: 1.5px solid var(--border);
  background: var(--panel); color: var(--muted);
  cursor: pointer; font-family: inherit;
  transition: background .15s, color .15s, border-color .15s;
  -webkit-tap-highlight-color: transparent;
  min-width: 64px;
}
.call-btn.active { background: rgba(59,130,246,.12); border-color: var(--accent); color: var(--accent); }
.call-btn.danger { background: rgba(239,68,68,.12); border-color: var(--danger); color: var(--danger); }
.call-btn:hover { background: var(--panel2); color: var(--text); }
.call-btn:disabled { opacity: .35; cursor: not-allowed; }

.call-btn__ico { width: 22px; height: 22px; }
.call-btn__ico--end { transform: rotate(135deg); }
.call-btn__label { font-size: 10px; font-weight: 600; letter-spacing: .03em; }

.call-btn--end {
  width: 66px; height: 66px;
  border-radius: 50%; padding: 0;
  background: var(--danger); border-color: var(--danger); color: #fff;
  box-shadow: 0 6px 20px rgba(239,68,68,.4);
  flex-shrink: 0; min-width: unset;
}
.call-btn--end:hover { opacity: .9; }
.call-btn--end .call-btn__ico--end { width: 26px; height: 26px; }

.call-btn--mute { }
.call-btn--mute.muted { background: rgba(239,68,68,.12); border-color: var(--danger); color: var(--danger); }

/* ================================================================
   WAITING PROMPT (host, durante la chiamata)
   ================================================================ */
.waiting-prompt {
  position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
  z-index: 60;
  background: var(--panel);
  border: 1px solid var(--ok);
  border-radius: 16px;
  padding: 12px 16px;
  min-width: 260px; max-width: min(400px, 90vw);
  box-shadow: 0 8px 32px rgba(0,0,0,.5), 0 0 0 1px rgba(34,197,94,.2);
  display: flex; flex-direction: column; gap: 10px;
}
.waiting-prompt__hd {
  display: flex; align-items: center; gap: 8px;
}
.waiting-prompt__text { flex: 1; font-size: 13px; font-weight: 600; color: var(--text); }
.waiting-prompt__min {
  background: none; border: none; cursor: pointer; color: var(--muted);
  display: flex; align-items: center; padding: 2px;
}
.waiting-prompt__actions { display: flex; gap: 8px; }
.wp-btn {
  padding: 7px 14px; border-radius: 9px; border: 1px solid var(--border);
  font-size: 13px; font-weight: 600; font-family: inherit; cursor: pointer;
  transition: background .15s;
}
.wp-btn--admit { background: var(--ok); border-color: var(--ok); color: #fff; }
.wp-btn--reject { background: transparent; color: var(--muted); }
.wp-btn--reject:hover { background: var(--panel2); }
.wp-btn--open {
  background: transparent; color: var(--muted);
  padding: 7px 10px; margin-left: auto;
}

/* Sala d'attesa sidebar */
.waiting-item { padding: 8px 0; border-bottom: 1px solid var(--border); }
.waiting-item:last-child { border-bottom: none; }
.waiting-item__name { font-size: 13px; font-weight: 600; }
.waiting-item__sub  { font-size: 11px; color: var(--muted); }
.waiting-item__msg  { font-size: 11px; color: var(--muted); font-style: italic; margin-top: 2px; }
.waiting-item__actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.hint { font-size: 12px; color: var(--muted); font-style: italic; }

/* ================================================================
   OVERLAY MODALE (allegati preview)
   ================================================================ */
.overlay-modal {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.75); backdrop-filter: blur(5px);
  z-index: 90; align-items: center; justify-content: center;
}
.overlay-modal.open { display: flex; }
.overlay-panel {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 20px; padding: 20px;
  width: min(720px, 95vw); max-height: 85vh;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 80px rgba(0,0,0,.6);
}
.overlay-panel__hd { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.overlay-panel__title { font-size: 16px; font-weight: 700; }
.overlay-close {
  width: 32px; height: 32px; border-radius: 9px;
  border: 1px solid var(--border); background: transparent;
  color: var(--muted); cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.overlay-panel__body { overflow-y: auto; }

/* ================================================================
   RINGTONE OVERLAY (avviso in foreground con suoneria)
   ================================================================ */
.ringtone-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.82); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
}
.ringtone-box {
  background: var(--panel); border: 1px solid rgba(255,255,255,.1);
  border-radius: 24px; padding: 32px 28px;
  text-align: center; display: flex; flex-direction: column;
  align-items: center; gap: 12px; width: min(320px, 90vw);
  animation: ringBoxPop .3s cubic-bezier(.34,1.56,.64,1);
}
@keyframes ringBoxPop { from { transform: scale(.85); opacity: 0; } }
.ringtone-icon { font-size: 48px; animation: ringIconShake .5s ease infinite; }
@keyframes ringIconShake {
  0%,100% { transform: rotate(-12deg); }
  50%      { transform: rotate(12deg); }
}
.ringtone-text { font-size: 18px; font-weight: 700; color: var(--text); }
.ringtone-dismiss {
  padding: 12px 32px; border-radius: 12px; border: none;
  background: var(--accent); color: #fff;
  font-size: 15px; font-weight: 700; font-family: inherit;
  cursor: pointer; margin-top: 6px;
}

/* ================================================================
   UTILITY
   ================================================================ */
.sr-only {
  position: absolute!important; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 100px;
  transform: translateX(-50%);
  background: rgba(30,40,60,.96); color: #fff;
  padding: 10px 18px; border-radius: 12px;
  font-size: 13px; z-index: 999;
  box-shadow: 0 4px 20px rgba(0,0,0,.5);
  animation: toastIn .2s ease, toastOut .3s ease 2.3s forwards;
  pointer-events: none;
}
.toast.error { background: rgba(180,30,30,.96); }
.toast.ok    { background: rgba(22,100,50,.96); }
@keyframes toastIn  { from{opacity:0;transform:translate(-50%,8px)} to{opacity:1;transform:translate(-50%,0)} }
@keyframes toastOut { to{opacity:0;transform:translate(-50%,8px)} }

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 480px) {
  .calling__bar { padding: 12px 14px; }
  .calling__bar-side { min-width: 84px; }
  .calling__action { padding: 9px 12px; }
  .calling__end { width: 60px; height: 60px; }
  .call-bar { padding: 10px 12px calc(10px + var(--safe-bottom)); gap: 6px; }
  .call-btn { min-width: 52px; padding: 9px 10px; }
  .call-btn__label { display: none; }
  .p-card { min-width: 100px; flex: 0 1 120px; padding: 14px 10px 10px; }
  .p-avatar, .p-avatar-wrap { width: 60px; height: 60px; }
  .p-avatar { font-size: 21px; }
}

@media (prefers-reduced-motion: reduce) {
  .ph-pulse, .calling__ring,
  .p-card.speaking .p-avatar-ring,
  .call-timer-dot, .ringtone-icon { animation: none; }
}
