/* ============================================================
   Mafia Game — Main Stylesheet
   Theme: dark, cinematic, noir
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=Crimson+Pro:ital,wght@0,300;0,400;1,300&display=swap');

/* ── Variables ──────────────────────────────────────────────── */
:root {
  --bg-void:    #0a0a0f;
  --bg-deep:    #0f0e17;
  --bg-surface: #1a1826;
  --bg-card:    #201e2e;
  --bg-hover:   #2a2740;

  --red:        #c0392b;
  --red-bright: #e74c3c;
  --red-glow:   rgba(192,57,43,.25);
  --gold:       #c9972b;
  --gold-light: #e8b84b;

  --text-primary:   #e8e4d4;
  --text-secondary: #9e9882;
  --text-muted:     #5c5a4e;

  --border:     rgba(201,151,43,.15);
  --border-red: rgba(192,57,43,.3);

  --font-display: 'Cinzel', serif;
  --font-body:    'Crimson Pro', serif;
  --radius:       8px;
  --radius-lg:    16px;
}

/* ── Reset ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background: var(--bg-void);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 1.1rem;
  line-height: 1.65;
  min-height: 100vh;
}

/* Subtle noise texture overlay */
body::before {
  content: '';
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
}

/* ── Typography ──────────────────────────────────────────────── */
h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--gold-light);
}
h1 { font-size: 2.2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }

a { color: var(--gold); text-decoration: none; transition: color .2s; }
a:hover { color: var(--gold-light); }

/* ── Layout ──────────────────────────────────────────────────── */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.page-wrap {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Navbar ──────────────────────────────────────────────────── */
.navbar {
  border-bottom: 1px solid var(--border);
  padding: .9rem 0;
  backdrop-filter: blur(8px);
  background: rgba(10,10,15,.7);
  position: sticky; top: 0; z-index: 100;
}
.navbar .inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1.5rem;
}
.navbar .logo {
  font-family: var(--font-display);
  font-size: 1.25rem;
  letter-spacing: .1em;
  color: var(--gold-light);
}
.navbar .logo span { color: var(--red-bright); }
.navbar-links { display: flex; gap: 1.5rem; align-items: center; }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  position: relative;
  overflow: hidden;
  transition: border-color .25s, transform .2s;
}
.card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: .4;
}
.card:hover { border-color: var(--border-red); transform: translateY(-2px); }

/* ── Role Card ───────────────────────────────────────────────── */
.role-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2rem 1.5rem;
  text-align: center;
  min-height: 320px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  position: relative;
  overflow: hidden;
  cursor: default;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1);
}
.role-card.revealed { animation: cardFlip .6s cubic-bezier(.34,1.56,.64,1); }
@keyframes cardFlip {
  0%   { transform: rotateY(90deg) scale(.8); opacity: 0; }
  100% { transform: rotateY(0)     scale(1);  opacity: 1; }
}
.role-card .role-icon {
  width: 100px; height: 100px;
  border-radius: 50%;
  background: var(--bg-hover);
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.5rem;
}
.role-card .role-name {
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--gold-light);
}
.role-card .role-desc {
  font-size: 1rem;
  color: var(--text-secondary);
  font-style: italic;
  max-width: 280px;
  line-height: 1.5;
}
.role-card .special-info {
  font-size: .9rem;
  background: var(--red-glow);
  border: 1px solid var(--border-red);
  border-radius: var(--radius);
  padding: .6rem 1rem;
  color: var(--red-bright);
  width: 100%;
}

/* Mafia team glow */
.role-card.mafia { border-color: var(--border-red); }
.role-card.mafia::after {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 0%, var(--red-glow) 0%, transparent 65%);
  pointer-events: none;
}

/* Town glow */
.role-card.town::after {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(201,151,43,.12) 0%, transparent 65%);
  pointer-events: none;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center; justify-content: center;
  gap: .5rem;
  font-family: var(--font-display);
  font-size: .85rem;
  letter-spacing: .08em;
  font-weight: 600;
  padding: .65rem 1.4rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: all .2s;
}
.btn-primary {
  background: var(--red);
  color: #fff;
}
.btn-primary:hover { background: var(--red-bright); box-shadow: 0 0 18px var(--red-glow); }

.btn-gold {
  background: transparent;
  color: var(--gold-light);
  border: 1px solid var(--gold);
}
.btn-gold:hover { background: rgba(201,151,43,.12); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { border-color: var(--text-secondary); color: var(--text-primary); }

.btn-sm { padding: .4rem .9rem; font-size: .78rem; }
.btn-lg { padding: .9rem 2rem; font-size: .95rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ── Forms ───────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1.2rem; }

label {
  font-family: var(--font-display);
  font-size: .78rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

input[type="text"],
input[type="password"],
input[type="email"] {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 1rem;
  padding: .65rem 1rem;
  border-radius: var(--radius);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  width: 100%;
}
input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201,151,43,.12);
}

.form-error {
  background: var(--red-glow);
  border: 1px solid var(--border-red);
  border-radius: var(--radius);
  color: var(--red-bright);
  padding: .65rem 1rem;
  font-size: .95rem;
  margin-bottom: 1rem;
}
.form-success {
  background: rgba(39,174,96,.15);
  border: 1px solid rgba(39,174,96,.3);
  border-radius: var(--radius);
  color: #2ecc71;
  padding: .65rem 1rem;
  margin-bottom: 1rem;
}

/* ── Room list ───────────────────────────────────────────────── */
.room-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.4rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: .75rem;
  transition: border-color .2s;
}
.room-item:hover { border-color: var(--border-red); }
.room-name { font-family: var(--font-display); font-size: 1rem; }
.room-meta { font-size: .85rem; color: var(--text-secondary); margin-top: .2rem; }
.room-actions { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; }

.badge {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 4px;
  font-size: .75rem;
  font-family: var(--font-display);
  letter-spacing: .06em;
}
.badge-waiting  { background: rgba(201,151,43,.15); color: var(--gold);     border: 1px solid rgba(201,151,43,.3); }
.badge-started  { background: var(--red-glow);      color: var(--red-bright); border: 1px solid var(--border-red); }
.badge-finished { background: rgba(92,90,78,.2);    color: var(--text-muted); border: 1px solid var(--border); }

/* ── Players list ────────────────────────────────────────────── */
.player-list { list-style: none; display: flex; flex-wrap: wrap; gap: .5rem; }
.player-pill {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: .3rem .85rem;
  font-size: .9rem;
  color: var(--text-secondary);
}

/* ── Timer ───────────────────────────────────────────────────── */
.game-timer {
  font-family: var(--font-display);
  font-size: 3rem;
  letter-spacing: .12em;
  color: var(--gold-light);
  text-align: center;
  padding: 1rem;
  text-shadow: 0 0 24px rgba(201,151,43,.4);
}
.game-timer.urgent { color: var(--red-bright); animation: pulse .7s ease-in-out infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.6} }

/* ── Phase banner ────────────────────────────────────────────── */
.phase-banner {
  text-align: center;
  padding: .6rem 1rem;
  font-family: var(--font-display);
  letter-spacing: .1em;
  font-size: .85rem;
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
}
.phase-day   { background: rgba(201,151,43,.1); color: var(--gold); border: 1px solid rgba(201,151,43,.25); }
.phase-night { background: rgba(10,10,15,.8);   color: #aab4d4;     border: 1px solid rgba(100,120,200,.2); }

/* ── Auth page centering ─────────────────────────────────────── */
.auth-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}
.auth-box {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
}
.auth-title {
  text-align: center;
  margin-bottom: 2rem;
}
.auth-title h1 { font-size: 1.8rem; }
.auth-title p  { color: var(--text-secondary); margin-top: .4rem; font-style: italic; }

/* ── Divider ─────────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

/* ── Spinner ─────────────────────────────────────────────────── */
.spinner {
  width: 22px; height: 22px;
  border: 2px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toasts ──────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  display: flex; flex-direction: column; gap: .6rem;
  z-index: 10000;
}
.toast {
  padding: .8rem 1.2rem;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: .95rem;
  min-width: 220px;
  border: 1px solid;
  animation: toastIn .3s ease forwards;
  box-shadow: 0 4px 24px rgba(0,0,0,.4);
}
.toast-success { background: rgba(39,174,96,.15); border-color: rgba(39,174,96,.3); color: #2ecc71; }
.toast-error   { background: var(--red-glow); border-color: var(--border-red); color: var(--red-bright); }
.toast-info    { background: rgba(201,151,43,.12); border-color: rgba(201,151,43,.25); color: var(--gold-light); }
@keyframes toastIn {
  from { transform: translateX(120%); opacity:0; }
  to   { transform: translateX(0);    opacity:1; }
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 600px) {
  h1 { font-size: 1.6rem; }
  .room-item { grid-template-columns: 1fr; }
  .room-actions { justify-content: flex-start; }
  .game-timer { font-size: 2.2rem; }
}

/* ── Rol ikonu ───────────────────────────────────────────────── */
.role-icon-img {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--border);
  background: var(--bg-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1);
}
.role-icon-img img {
  width: 110px;
  height: 110px;
  object-fit: cover;
  border-radius: 50%;
}
.role-card.revealed .role-icon-img {
  animation: iconPop .5s cubic-bezier(.34,1.56,.64,1) .3s both;
}
@keyframes iconPop {
  0%   { transform: scale(0) rotate(-15deg); opacity: 0; }
  100% { transform: scale(1) rotate(0deg);   opacity: 1; }
}
.role-card.mafia .role-icon-img { border-color: var(--border-red); }
.role-card.town  .role-icon-img { border-color: rgba(201,151,43,.4); }
