:root {
  --bg: #16120e;
  --card-bg: #221b14;
  --cream: #f0e5d0;
  --red: #b3372e;
  --red-dark: #7e241e;
  --gold: #c9a35c;
  --liberal: #2f6f8f;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { background: var(--bg); }

body {
  background: radial-gradient(ellipse at top, #2a2118 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--cream);
  font-family: 'Georgia', 'Times New Roman', serif;
  min-height: 100vh;
}

/* ---- screens ---- */
.screen {
  display: none;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}
.screen.active { display: flex; }

.card {
  background: var(--card-bg);
  border: 1px solid #3d3122;
  border-radius: 14px;
  padding: 2.5rem 2rem;
  width: min(400px, 100%);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .55);
  text-align: center;
}
.card.wide { width: min(460px, 100%); }

.title {
  font-size: 2.2rem;
  letter-spacing: .18em;
  margin-bottom: .2rem;
}
.title.small { font-size: 1.6rem; }
.title .red { color: var(--red); }

.subtitle {
  color: var(--gold);
  font-style: italic;
  font-size: .95rem;
  margin-bottom: 1.6rem;
}

input {
  background: #171310;
  border: 1px solid #4a3d2b;
  border-radius: 8px;
  color: var(--cream);
  font-family: inherit;
  font-size: 1rem;
  padding: .7rem .9rem;
  text-align: center;
  width: 100%;
}
input:focus { outline: none; border-color: var(--gold); }
#code-input { text-transform: uppercase; letter-spacing: .35em; font-weight: bold; }

.btn-row { display: flex; gap: .7rem; margin-top: 1rem; }
.btn-row.center { justify-content: center; }

.btn {
  background: var(--cream);
  border: none;
  border-radius: 8px;
  color: #221b14;
  cursor: pointer;
  flex: 1;
  font-family: inherit;
  font-size: 1rem;
  font-weight: bold;
  letter-spacing: .05em;
  padding: .75rem 1rem;
  transition: transform .08s ease, filter .15s ease;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(.97); }
.btn:disabled { cursor: not-allowed; filter: grayscale(.6) brightness(.7); }

.btn.primary { background: var(--red); color: var(--cream); }
.btn.ghost { background: transparent; border: 1px solid #4a3d2b; color: var(--cream); flex: 0; }
.btn.hidden { display: none; }

/* ---- lobby setting ---- */
.setting-row {
  align-items: center;
  border: 1px solid #33291c;
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  margin: 0 auto .4rem;
  padding: .55rem .9rem;
  width: min(320px, 100%);
}
.setting-label { font-size: .92rem; }
.auto-tag { color: var(--gold); font-size: .78rem; font-style: italic; }
.setting-controls { align-items: center; display: flex; gap: .45rem; }
.setting-value {
  font-weight: bold;
  min-width: 1.4em;
  text-align: center;
}
.btn.mini {
  background: #191510;
  border: 1px solid #4a3d2b;
  color: var(--cream);
  flex: none;
  font-size: 1rem;
  line-height: 1;
  padding: .35rem .6rem;
}
.btn.mini:disabled { opacity: .35; }
.btn.mini.ghost { border-color: #4a3d2b; }

.divider {
  color: #8a7a5e;
  font-size: .85rem;
  margin: 1.2rem 0;
  display: flex;
  align-items: center;
  gap: .8rem;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #3d3122;
}

.error { color: var(--red); margin-top: .9rem; min-height: 1.2em; font-size: .9rem; }
.hint { color: #8a7a5e; font-size: .9rem; }

/* ---- lobby ---- */
.code-hint { color: var(--gold); font-size: .85rem; text-transform: uppercase; letter-spacing: .2em; }
.room-code {
  font-size: 3rem;
  font-weight: bold;
  letter-spacing: .3em;
  margin: .6rem 0 1.2rem;
  padding-left: .3em; /* balance letter-spacing */
  text-shadow: 0 0 24px rgba(201, 163, 92, .35);
  white-space: nowrap;
}

.player-list {
  list-style: none;
  margin: .4rem 0 1rem;
  max-height: 40vh;
  overflow-y: auto;
}
.player-list li {
  background: #191510;
  border: 1px solid #33291c;
  border-radius: 8px;
  margin: .35rem auto;
  padding: .6rem .9rem;
  text-align: left;
  width: min(320px, 100%);
}
.player-list li.self { border-color: var(--gold); }
.player-list li.host::after { content: ' ♛'; color: var(--gold); }
.player-list li.you-tag::before { content: 'you'; float: right; color: #8a7a5e; font-size: .75rem; font-style: italic; }

/* ---- role reveal ---- */
.role-scene { text-align: center; }

.role-card {
  cursor: pointer;
  height: 330px;
  margin: 1.4rem auto 0;
  perspective: 1200px;
  width: min(250px, 74vw);
}
.role-card-inner {
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform .65s cubic-bezier(.2, .7, .3, 1);
  width: 100%;
}
.role-card.face-down .role-card-inner { transform: rotateY(0deg); }
.role-card.face-up .role-card-inner { transform: rotateY(180deg); }

.role-back, .role-front {
  backface-visibility: hidden;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  left: 0;
  position: absolute;
  top: 0;
  width: 100%;
}

.role-back {
  background: linear-gradient(160deg, #2b2119, #171310);
  border: 2px solid var(--gold);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .6);
  font-size: 5rem;
  color: var(--gold);
}
.role-back span { text-shadow: 0 0 30px rgba(201, 163, 92, .5); }

.role-front {
  border: 3px solid var(--gold);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .6);
  padding: 1.2rem;
  transform: rotateY(180deg);
}
.role-front.liberal-theme { background: linear-gradient(165deg, #35566b, #1d3342); }
.role-front.fascist-theme { background: linear-gradient(165deg, #6e2721, #3a1210); }

.role-party {
  font-size: .8rem;
  letter-spacing: .3em;
  opacity: .85;
  text-transform: uppercase;
}
.role-membership { font-size: .75rem; font-style: italic; opacity: .8; margin-top: .2rem; }

.role-title {
  font-size: 2.3rem;
  letter-spacing: .12em;
  margin: .6rem 0 .4rem;
}
.role-team { font-size: .95rem; opacity: .9; }

.hidden { display: none !important; }

@media (max-height: 640px) {
  .role-card { height: 270px; }
}
