/* Мафия — консоль ведущего. 100dvh, safe-area, крупные кнопки. */
html:has(body.mafia-app) {
  height: 100dvh;
  overflow: hidden;
}

body.mafia-app {
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding:
    max(6px, env(safe-area-inset-top))
    max(8px, env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom))
    max(8px, env(safe-area-inset-left));
  background-color: #0a0610;
  transition: background 1.2s steps(8);
}

body.mafia-app.night-sky {
  background:
    radial-gradient(ellipse at 72% 8%, #4a3878 0%, transparent 42%),
    radial-gradient(ellipse at 20% 0%, #1a1030 0%, #08040e 55%, #050208 100%);
}

body.mafia-app.day-sky {
  background:
    radial-gradient(ellipse at 80% -10%, #f8d878 0%, #e07030 28%, transparent 52%),
    linear-gradient(180deg, #6a3060 0%, #241028 48%, #0c0814 100%);
}

body.mafia-app input,
body.mafia-app textarea {
  user-select: text;
  -webkit-user-select: text;
}

.sky {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

.moon, .sun {
  position: absolute;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.8s steps(6), transform 1.2s steps(8);
}

.moon {
  top: 18px;
  right: 22px;
  width: 54px;
  height: 54px;
  background:
    radial-gradient(circle at 32% 32%, #fff8d0 0%, #e8d090 42%, #a08848 100%);
  box-shadow: 0 0 0 3px #3a2a10, 8px 10px 0 #050208, 0 0 24px #f8d87888;
}

.moon::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  background: #c8b068;
  top: 16px;
  left: 22px;
  box-shadow: 8px 10px 0 2px #b8a058, -6px 14px 0 1px #d0b870;
}

.sun {
  top: 14px;
  right: 20px;
  width: 58px;
  height: 58px;
  background: radial-gradient(circle at 35% 35%, #fff8d0, #f0b030 55%, #c04010);
  box-shadow: 0 0 0 3px #5a2010, 0 0 28px #f8d878aa;
}

body.night-sky .moon { opacity: 1; }
body.day-sky .sun { opacity: 1; }

.city {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 72px;
  opacity: 0.35;
  background:
    linear-gradient(180deg, transparent, #050208 90%),
    repeating-linear-gradient(90deg, transparent 0 18px, #1a1028 18px 34px, transparent 34px 50px),
    linear-gradient(90deg, #12081c 0 12%, #1c1028 12% 18%, #0e0816 18% 40%, #241428 40% 48%, #100818 48% 70%, #1a0c20 70% 78%, #0c0612 78% 100%);
  clip-path: polygon(0 100%, 0 48%, 6% 48%, 6% 28%, 12% 28%, 12% 52%, 18% 52%, 18% 22%, 24% 10%, 28% 22%, 28% 56%, 36% 56%, 36% 34%, 44% 34%, 44% 60%, 52% 60%, 52% 18%, 58% 18%, 62% 4%, 66% 18%, 66% 50%, 74% 50%, 74% 30%, 82% 30%, 82% 58%, 90% 58%, 90% 26%, 96% 26%, 96% 62%, 100% 62%, 100% 100%);
}

.m-top, .m-main { position: relative; z-index: 1; }

.m-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
  min-height: 48px;
  padding: 0 2px 6px;
}

.m-title {
  font-size: 13px;
  color: var(--gold);
  text-shadow: 3px 3px 0 #3a1008, -2px 0 0 #e83830;
  letter-spacing: 0.12em;
}

.m-tools { display: flex; gap: 6px; }

.m-main {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 2px 12px;
}

.screen[hidden], .overlay[hidden] { display: none !important; }

.lead {
  font-size: 9px;
  line-height: 1.8;
  color: var(--steel);
  margin: 0 4px 14px;
}

.preset-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 18px;
}

@media (min-width: 720px) {
  .preset-grid { grid-template-columns: 1fr 1fr; }
}

.preset-card {
  text-align: left;
  font-family: inherit;
  color: var(--cream);
  cursor: pointer;
  min-height: 140px;
  padding: 16px 14px;
  border: 4px solid var(--gold);
  background:
    linear-gradient(180deg, rgba(248,216,120,0.12), transparent 30%),
    #1a0c18;
  box-shadow: 5px 5px 0 #050208, inset 0 3px 0 rgba(248,240,216,0.12);
}

.preset-card:hover, .preset-card:focus-visible {
  transform: translate(-1px, -1px);
  border-color: var(--cream);
}

.preset-card:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 #050208; }

.preset-tag {
  display: inline-block;
  font-size: 8px;
  color: #140c10;
  background: var(--gold);
  padding: 4px 8px;
  margin-bottom: 10px;
}

.preset-tag.alt { background: #e83830; color: var(--cream); }

.preset-card strong {
  display: block;
  font-size: 13px;
  color: var(--gold);
  margin-bottom: 10px;
}

.preset-card p { font-size: 8px; line-height: 1.75; color: var(--cream); }

.role-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  padding: 8px 0 16px;
}

.count-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 8px 0 12px;
}

.icon-btn {
  font-family: inherit;
  font-size: 22px;
  width: 56px;
  height: 56px;
  border: 4px solid var(--gold);
  background: #2a1030;
  color: var(--gold);
  cursor: pointer;
  box-shadow: 3px 3px 0 #050208;
}

.count-val { text-align: center; }
.count-val b { display: block; font-size: 22px; color: var(--gold); }
.count-val span { font-size: 8px; color: var(--steel); }

.comp {
  font-size: 8px;
  line-height: 1.7;
  color: var(--gold);
  text-align: center;
  margin-bottom: 12px;
}

.names {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

@media (min-width: 640px) {
  .names { grid-template-columns: 1fr 1fr; }
}

.name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
}

.name-row span {
  width: 28px;
  font-size: 10px;
  color: var(--gold);
  text-align: right;
}

.name-row input {
  flex: 1;
  min-height: 48px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 11px;
  color: var(--cream);
  background: #140818;
  border: 3px solid #6a5070;
}

.name-row input:focus {
  outline: none;
  border-color: var(--gold);
}

.row-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin: 12px 0;
}

.sticky-btns {
  position: sticky;
  bottom: 0;
  padding: 8px 0 4px;
  background: linear-gradient(180deg, transparent, #0a0610 30%);
  z-index: 3;
}

.btn {
  min-width: 120px;
}

.phase-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.phase-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 9px;
  color: var(--cream);
}

.phase-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 8px;
  background: #2a1848;
  border: 2px solid var(--gold);
  color: var(--gold);
}

.audio-row { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  font-family: inherit;
  font-size: 7px;
  line-height: 1.3;
  min-height: 36px;
  padding: 6px 8px;
  border: 2px solid #6a5070;
  background: #1a1028;
  color: var(--steel);
  cursor: pointer;
}

.chip.on {
  border-color: var(--gold);
  color: var(--gold);
}

.phrase {
  font-size: 10px;
  line-height: 1.7;
  color: var(--gold);
  text-align: center;
  min-height: 40px;
  padding: 8px 6px;
  margin-bottom: 8px;
  border: 3px solid #3a2048;
  background: rgba(10, 6, 16, 0.55);
  text-shadow: 2px 2px 0 #000;
}

.wake-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 10px;
}

.wake-btn {
  font-family: inherit;
  font-size: 9px;
  min-height: 52px;
  min-width: 96px;
  padding: 8px 10px;
  border: 3px solid var(--cream);
  background: #4a1830;
  color: var(--cream);
  cursor: pointer;
  box-shadow: 3px 3px 0 #050208;
}

.wake-btn.sleep { background: #1a1840; }
.wake-btn.sun { background: #a05018; color: #140c10; border-color: var(--gold); }
.wake-btn.next {
  box-shadow: 3px 3px 0 #050208, 0 0 0 3px var(--gold);
}
.wake-btn.done { opacity: 0.45; }
.wake-btn:active { transform: translate(2px, 2px); }

.hint-line {
  font-size: 8px;
  line-height: 1.7;
  color: var(--steel);
  text-align: center;
  margin: 0 4px 10px;
}

.seat-grid, .deal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

@media (min-width: 640px) {
  .seat-grid, .deal-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 960px) {
  .seat-grid, .deal-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.seat {
  position: relative;
  min-height: 92px;
  padding: 8px 8px 10px;
  border: 3px solid #4a3058;
  background: #140c1c;
  cursor: pointer;
  text-align: left;
}

.seat.alive { border-color: #6a5078; }
.seat.dead { opacity: 0.42; filter: grayscale(0.6); }
.seat.pickable {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px #f8d87866;
}
.seat.picked { background: #3a1840; border-color: var(--red); }
.seat.black-team { box-shadow: inset 3px 0 0 #e83830; }
.seat.red-team { box-shadow: inset 3px 0 0 #c04040; }
.seat.grey-team { box-shadow: inset 3px 0 0 #808890; }

.seat .n {
  font-size: 8px;
  color: var(--gold);
  margin-bottom: 4px;
}

.seat .nm {
  font-size: 10px;
  line-height: 1.4;
  color: var(--cream);
  margin-bottom: 6px;
  word-break: break-word;
}

.seat .rl {
  font-size: 7px;
  color: var(--steel);
  line-height: 1.4;
}

.seat.deal-in {
  animation: dealIn 420ms steps(6) both;
}

@keyframes dealIn {
  from { transform: translateY(-40px) scale(0.4) rotate(-12deg); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* Карты — золотая фольга, общий рубашка, 3D flip */
.card {
  width: 112px;
  height: 156px;
  perspective: 900px;
  margin: 0 auto 6px;
}

.card.lg { width: 168px; height: 234px; }

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.62s cubic-bezier(.2,.7,.2,1);
}

.card.flip .card-inner { transform: rotateY(180deg); }

.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border: 4px solid #d8b048;
  box-shadow:
    inset 0 0 0 2px #3a2010,
    inset 0 0 0 5px #f8d878,
    4px 5px 0 #050208;
  overflow: hidden;
}

.card-back {
  background:
    linear-gradient(115deg, transparent 36%, rgba(255,255,240,0.5) 46%, transparent 56%),
    radial-gradient(circle at 50% 28%, #3a2a68, #120818 70%);
  background-size: 220% 100%, 100% 100%;
  animation: foilSweep 3.4s steps(10) infinite;
}

.card-front {
  transform: rotateY(180deg);
  background:
    linear-gradient(115deg, transparent 36%, rgba(255,255,240,0.45) 47%, transparent 58%),
    linear-gradient(180deg, var(--foil-hi, #4a2038), var(--foil-lo, #140810));
  background-size: 220% 100%, 100% 100%;
  animation: foilSweep 3.4s steps(10) infinite;
}

@keyframes foilSweep {
  0% { background-position: 120% 0, 0 0; }
  100% { background-position: -40% 0, 0 0; }
}

.card-face .art {
  position: absolute;
  left: 10px;
  right: 10px;
  top: 12px;
  height: 58%;
}

.card-face .lab {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 10px;
  text-align: center;
  font-size: 7px;
  line-height: 1.45;
  color: #fff8d0;
  text-shadow: 2px 2px 0 #000;
}

.card.lg .lab { font-size: 10px; bottom: 14px; }
.card.lg .art { top: 16px; }

.card-back .lab { color: var(--gold); letter-spacing: 0.14em; }

.mini-card {
  width: 36px;
  height: 50px;
  float: right;
  margin-left: 6px;
}

.mini-card .card { width: 36px; height: 50px; }
.mini-card .card-face { border-width: 2px; box-shadow: inset 0 0 0 1px #3a2010, 2px 2px 0 #050208; }
.mini-card .lab { display: none; }
.mini-card .art { left: 3px; right: 3px; top: 4px; height: 70%; }

.log {
  font-size: 8px;
  line-height: 1.75;
  color: var(--steel);
  max-height: 160px;
  overflow-y: auto;
  padding: 8px;
  border: 2px solid #2a1838;
  background: rgba(8, 4, 14, 0.6);
}

.log b { color: var(--gold); }
.log .kill { color: #ff8070; }
.log .save { color: #88e068; }

.panel.wide { width: min(520px, 100%); text-align: left; max-height: min(80dvh, 640px); overflow-y: auto; }
.panel.wide h2 { text-align: center; }

.rules-body {
  font-size: 9px;
  line-height: 1.8;
  color: var(--cream);
  margin-bottom: 16px;
}

.rules-body h3 {
  color: var(--gold);
  font-size: 10px;
  margin: 12px 0 6px;
}

.rules-body ul { padding-left: 16px; margin-bottom: 8px; }
.rules-body li { margin-bottom: 6px; }

.role-hero { display: flex; justify-content: center; margin-bottom: 10px; }

.show-wrap {
  width: min(420px, 100%);
  text-align: center;
}

.show-name {
  font-size: 12px;
  color: var(--gold);
  margin-bottom: 12px;
}

#showCard { display: flex; justify-content: center; margin-bottom: 12px; }

.home-card {
  cursor: pointer;
}

@media (max-width: 420px) {
  .m-title { font-size: 11px; }
  .wake-btn { min-width: 46%; font-size: 8px; }
  .card { width: 100px; height: 140px; }
  .btn { min-width: 100px; font-size: 11px; }
}
