/* ============ Vampir Köylü — mobile-first, low-glare UI ============ */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #0d1017;
  --bg2: #151a24;
  --card: #1a2030;
  --card-hi: #232b3f;
  --text: #b8c0d0;
  --text-dim: #6b7385;
  --accent: #7d8fb3;
  --accent-soft: #3a4560;
  --danger: #8a4a4a;
  --ok: #4a7a5a;
  --border: #262e42;
  --radius: 14px;
  font-size: 16px;
}

/* Day palette: warmer but still muted — no glare that reveals your screen */
body.phase-day {
  --bg: #1a1c22;
  --bg2: #22252d;
  --card: #2a2d38;
  --card-hi: #343846;
  --text: #cfd2d8;
  --text-dim: #83879a;
  --accent: #b3a37d;
  --accent-soft: #55503a;
  --border: #3a3e4c;
}

html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  transition: background .8s ease;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 12px);
}

.hidden { display: none !important; }

/* ---------- typography / layout helpers ---------- */
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: .02em; }
h2 { font-size: 1.15rem; font-weight: 600; }
.center { text-align: center; }
.grow { flex: 1; }
.muted { color: var(--text-dim); font-size: .85rem; }
.mt { margin-top: 14px; }
.stack > * + * { margin-top: 12px; }

/* ---------- buttons ---------- */
button {
  font: inherit;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 50px;
  padding: 12px 18px;
  width: 100%;
  cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s;
  touch-action: manipulation;
}
button:active { background: var(--card-hi); }
button:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--accent-soft); border-color: var(--accent); font-weight: 600; }
.btn-danger { border-color: var(--danger); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-dim); }
.btn-small { min-height: 40px; padding: 8px 12px; width: auto; font-size: .9rem; }

/* ---------- inputs ---------- */
input[type=text], input[type=tel] {
  font: inherit;
  width: 100%;
  min-height: 50px;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text);
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}
input:focus { border-color: var(--accent); }
.code-input { text-align: center; font-size: 1.6rem; letter-spacing: .5em; font-variant-numeric: tabular-nums; }

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.topbar .timer {
  font-variant-numeric: tabular-nums;
  font-size: 1.05rem;
  font-weight: 600;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 12px;
  min-width: 62px;
  text-align: center;
}
.topbar .phase-label { flex: 1; font-weight: 600; font-size: 1rem; }
.info-btn {
  width: 42px; height: 42px; min-height: 42px;
  border-radius: 50%;
  padding: 0;
  font-style: italic;
  font-family: Georgia, serif;
  font-size: 1.1rem;
  flex: none;
  color: var(--text-dim);
}

/* ---------- player grid ---------- */
.pgrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.pcard {
  position: relative;
  min-height: 58px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding: 10px 14px;
  text-align: left;
  overflow: hidden;
}
.pcard .pname { font-weight: 600; font-size: .98rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard .psub { font-size: .72rem; color: var(--text-dim); margin-top: 2px; }
.pcard.selected { border-color: var(--accent); background: var(--card-hi); }
.pcard.dead { opacity: .35; }
.pcard .mate-dot {
  position: absolute; top: 8px; right: 10px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  opacity: .7;
}
.pcard .votes-badge {
  position: absolute; top: 8px; right: 10px;
  font-size: .78rem; color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.badge {
  display: inline-block;
  font-size: .68rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1px 7px;
  margin-left: 6px;
  color: var(--text-dim);
  vertical-align: middle;
}
.badge.ok { border-color: var(--ok); color: #7fae90; }
.badge.off { border-color: var(--danger); color: #b08080; }

/* ---------- confirm bar ---------- */
.confirm-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 10px;
  padding: 10px 0 4px;
  background: linear-gradient(transparent, var(--bg) 30%);
}

/* ---------- announcements ---------- */
.ann {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: .92rem;
  line-height: 1.45;
}
.ann + .ann { margin-top: 8px; }
.privlog { font-size: .85rem; color: var(--text-dim); background: var(--bg2); border-radius: 10px; padding: 10px 12px; line-height: 1.5; border: 1px dashed var(--border); }

/* ---------- chat ---------- */
.chat {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg2);
  overflow: hidden;
  min-height: 180px;
  max-height: 320px;
}
.chat-tabs { display: flex; border-bottom: 1px solid var(--border); }
.chat-tabs button {
  border: none; border-radius: 0; background: transparent;
  min-height: 40px; font-size: .85rem; color: var(--text-dim);
}
.chat-tabs button.active { color: var(--text); background: var(--card); }
.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  font-size: .9rem;
  line-height: 1.5;
  -webkit-user-select: text;
  user-select: text;
}
.chat-log .cmsg b { color: var(--accent); font-weight: 600; }
.chat-log .cmsg.me b { color: var(--text); }
.chat-input { display: flex; gap: 8px; padding: 8px; border-top: 1px solid var(--border); }
.chat-input input { min-height: 42px; border-radius: 10px; }
.chat-input button { width: 64px; min-height: 42px; border-radius: 10px; flex: none; }

/* ---------- role reveal ---------- */
.reveal-wrap { flex: 1; display: flex; align-items: center; justify-content: center; perspective: 900px; }
.reveal-card {
  width: min(78vw, 300px);
  aspect-ratio: 3 / 4.2;
  position: relative;
  transform-style: preserve-3d;
  animation: flip 1.4s ease forwards;
  animation-delay: .6s;
}
@keyframes flip { from { transform: rotateY(0); } to { transform: rotateY(180deg); } }
.reveal-face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 20px;
  border: 1px solid var(--border);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 20px; text-align: center;
}
.reveal-back { background: radial-gradient(circle at 50% 30%, #1c2336, #10141f); font-size: 3rem; }
.reveal-front { background: radial-gradient(circle at 50% 20%, #222a40, #131826); transform: rotateY(180deg); }
.reveal-front .rname { font-size: 1.5rem; font-weight: 700; margin: 10px 0 8px; }
.reveal-front .rdesc { font-size: .88rem; color: var(--text-dim); line-height: 1.5; }
.reveal-front .remoji { font-size: 3rem; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(5, 7, 12, .82);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  padding: 24px;
}
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  width: 100%; max-width: 380px;
  font-size: .92rem;
  line-height: 1.55;
  color: var(--text);
}
.modal h2 { margin-bottom: 8px; font-size: 1.05rem; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px);
  transform: translateX(-50%);
  background: var(--card-hi);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 18px;
  font-size: .9rem;
  z-index: 60;
  max-width: 90vw;
  text-align: center;
}

/* ---------- lobby role config ---------- */
.rolecfg { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; background: var(--bg2); }
.rolerow { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.rolerow .rn { flex: 1; font-size: .9rem; }
.rolerow button { width: 40px; min-height: 36px; padding: 0; border-radius: 10px; flex: none; }
.rolerow .cnt { width: 26px; text-align: center; font-variant-numeric: tabular-nums; }

/* ---------- language switch ---------- */
.langs { display: flex; gap: 8px; justify-content: center; }
.langs button { width: auto; min-height: 38px; padding: 6px 16px; font-size: .85rem; }
.langs button.active { border-color: var(--accent); color: var(--text); }

/* ---------- game over ---------- */
.result-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.result-table td { padding: 8px 6px; border-bottom: 1px solid var(--border); }
.winner-banner {
  text-align: center;
  padding: 22px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--accent);
  background: var(--bg2);
  font-size: 1.25rem;
  font-weight: 700;
}

.fade-in { animation: fadein .4s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
