:root {
  color-scheme: dark;
  --ink: #07111e;
  --panel: #0b2036;
  --panel-2: #0e2d4c;
  --line: rgba(196, 222, 255, .18);
  --text: #f8fbff;
  --muted: #b7c7da;
  --gold: #ffc329;
  --orange: #f26522;
  --blue: #176fc7;
  --green: #22a946;
  --red: #d94035;
  --shadow: 0 18px 42px rgba(0, 0, 0, .42);
  font-family: Inter, "Arial Rounded MT Bold", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: #f7f2ea;
  color: var(--text);
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.game-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
  background:
    radial-gradient(circle at 50% 0, rgba(255, 198, 72, .28), transparent 28rem),
    linear-gradient(180deg, #fffaf0, #f2eee7);
}

.screen {
  position: relative;
  overflow: hidden;
  display: none;
  width: min(1180px, calc(100vw - 24px));
  aspect-ratio: 16 / 9;
  min-height: 540px;
  border: 6px solid #05070b;
  border-radius: 18px;
  background: #071321;
  box-shadow: var(--shadow);
}

.screen.active { display: block; }
.hidden { display: none !important; }

.browser-bar {
  position: absolute;
  z-index: 10;
  top: 0;
  left: 0;
  right: 0;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  background: rgba(14, 18, 24, .86);
  backdrop-filter: blur(10px);
}

.dot { width: 12px; height: 12px; border-radius: 999px; display: inline-block; }
.dot.red { background: #ff5f57; }
.dot.yellow { background: #ffbd2e; }
.dot.green { background: #28c840; }
.address {
  margin-left: 14px;
  padding: 8px 120px 8px 14px;
  border-radius: 999px;
  color: #ecf3ff;
  background: rgba(255, 255, 255, .12);
  font-weight: 800;
}

.menu-screen {
  background: linear-gradient(180deg, #ffc36f 0%, #86b7d7 32%, #345f38 100%);
}

.menu-art, .menu-art > * {
  position: absolute;
  inset: 0;
}

.sunset {
  background:
    radial-gradient(circle at 72% 24%, rgba(255, 188, 98, .76), transparent 14rem),
    linear-gradient(180deg, #8ec9ff 0%, #ffd09a 45%, #5a8c55 100%);
}

.trees.left, .trees.right {
  top: 38px;
  width: 44%;
  bottom: auto;
  height: 64%;
  filter: drop-shadow(0 12px 10px rgba(0,0,0,.45));
}

.trees.left {
  left: -4%;
  background:
    radial-gradient(circle at 18% 28%, #365f24 0 40px, transparent 42px),
    radial-gradient(circle at 30% 18%, #477a2c 0 58px, transparent 60px),
    radial-gradient(circle at 46% 36%, #2e5722 0 50px, transparent 52px),
    radial-gradient(circle at 12% 54%, #24451d 0 64px, transparent 66px);
}

.trees.right {
  left: auto;
  right: -7%;
  background:
    radial-gradient(circle at 78% 28%, #365f24 0 54px, transparent 56px),
    radial-gradient(circle at 58% 20%, #477a2c 0 64px, transparent 66px),
    radial-gradient(circle at 46% 42%, #2e5722 0 58px, transparent 60px);
}

.house {
  inset: auto auto 28px 42px;
  width: 270px;
  height: 155px;
  background: linear-gradient(180deg, #8b5a2b, #5d351d);
  border: 4px solid rgba(33, 17, 7, .55);
  border-radius: 14px;
  box-shadow: 0 16px 24px rgba(0,0,0,.34);
}

.house::before {
  content: "";
  position: absolute;
  left: -18px;
  right: -18px;
  top: -54px;
  height: 70px;
  background: linear-gradient(135deg, #5a2c19, #a34e23);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.house.h2 {
  left: auto;
  right: 74px;
  width: 300px;
  height: 172px;
  transform: scale(.92);
}

.road {
  top: auto;
  height: 210px;
  background: radial-gradient(ellipse at 50% 100%, #b17a48 0 18%, #765030 55%, transparent 56%);
  opacity: .82;
}

.menu-content {
  position: absolute;
  inset: 50px 0 0;
  z-index: 3;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 16px;
}

.logo-burst {
  position: relative;
  width: min(600px, 86vw);
  min-height: 205px;
  display: grid;
  place-items: center;
}

.burst {
  position: absolute;
  width: min(420px, 70vw);
  height: 170px;
  background: linear-gradient(135deg, #ff5b21, #ffce2d 52%, #1288df);
  clip-path: polygon(50% 0, 60% 24%, 90% 8%, 75% 37%, 100% 50%, 74% 60%, 88% 92%, 58% 75%, 50% 100%, 39% 75%, 8% 92%, 24% 61%, 0 50%, 25% 38%, 10% 8%, 40% 24%);
  filter: drop-shadow(0 10px 0 rgba(0,0,0,.72));
}

.logo-burst h1 {
  position: relative;
  z-index: 2;
  margin: 0;
  transform: rotate(-8deg);
  font-size: clamp(56px, 11vw, 118px);
  line-height: .8;
  letter-spacing: -.06em;
  text-transform: uppercase;
  color: #ffdb39;
  -webkit-text-stroke: 6px #17120a;
  text-shadow: 0 7px 0 #f26722, 0 13px 0 #0a65bd, 0 18px 15px rgba(0,0,0,.55);
}

.logo-burst p {
  position: absolute;
  z-index: 3;
  bottom: 18px;
  margin: 0;
  font-size: clamp(22px, 4vw, 42px);
  color: white;
  font-weight: 1000;
  text-transform: uppercase;
  -webkit-text-stroke: 3px #11151e;
  text-shadow: 0 4px 0 #126bd1;
}

.menu-buttons {
  width: min(360px, 80vw);
  display: grid;
  gap: 10px;
}

.menu-button, .start-button {
  min-height: 60px;
  border: 3px solid rgba(9, 12, 18, .82);
  border-radius: 10px;
  font-weight: 1000;
  text-transform: uppercase;
  box-shadow: inset 0 3px 0 rgba(255,255,255,.32), 0 7px 0 rgba(0,0,0,.45);
}

.menu-button:active, .start-button:active { transform: translateY(4px); box-shadow: inset 0 2px 0 rgba(255,255,255,.2), 0 3px 0 rgba(0,0,0,.55); }
.menu-button.orange { background: linear-gradient(#ff8b2c, #ec4c17); }
.menu-button.blue { background: linear-gradient(#1c86df, #12589c); }
.menu-button.green { background: linear-gradient(#35c858, #178c34); }
.menu-button.gray { background: linear-gradient(#6b747c, #3c4248); }

.player-chip, .version-chip {
  position: absolute;
  z-index: 5;
  bottom: 20px;
  border-radius: 12px;
  background: rgba(0,0,0,.76);
  border: 2px solid rgba(255,255,255,.18);
  color: white;
}

.player-chip {
  left: 22px;
  min-width: 190px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
}

.player-chip span:last-child, .player-chip div span {
  display: block;
  color: #ffdd69;
  font-weight: 900;
}

.version-chip {
  right: 18px;
  padding: 8px 10px;
  text-align: right;
  font-weight: 800;
  font-size: 13px;
}

.online-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #50e66d;
  margin-right: 4px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  border-radius: 14px;
  background: #f0b384;
  border: 3px solid rgba(255,255,255,.72);
  box-shadow: inset 0 -8px 0 rgba(0,0,0,.12);
  font-size: 32px;
}

.avatar.small { width: 44px; height: 44px; border-radius: 10px; font-size: 25px; }
.avatar.tiny { width: 42px; height: 42px; border-radius: 10px; font-size: 24px; }

.lobby-screen, .leaderboard-screen {
  background:
    radial-gradient(circle at 70% 20%, rgba(36, 110, 172, .28), transparent 24rem),
    linear-gradient(135deg, #061322, #0b2d4f);
  padding: 34px;
}

.lobby-top {
  display: grid;
  grid-template-columns: 150px 1fr 180px;
  align-items: center;
  gap: 14px;
}

.lobby-top h2 {
  margin: 0;
  text-align: center;
  font-size: 32px;
  text-transform: uppercase;
}

.back-button, .mini-button {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: linear-gradient(#1b4369, #102b47);
  font-weight: 1000;
}

.lobby-layout {
  display: grid;
  grid-template-columns: 1fr 330px;
  gap: 22px;
  margin-top: 28px;
  height: calc(100% - 156px);
}

.players-list {
  display: grid;
  align-content: start;
  gap: 18px;
  padding: 20px;
  border-radius: 16px;
  background: rgba(1, 12, 23, .36);
}

.player-row {
  display: grid;
  grid-template-columns: 64px 1fr 110px 80px;
  align-items: center;
  gap: 14px;
  color: white;
  font-size: 20px;
  font-weight: 900;
}

.role-tag {
  color: #ffdc42;
  text-align: right;
  text-transform: uppercase;
  font-size: 16px;
}

.ready { color: #50ee65; text-align: right; font-size: 16px; }

.room-card {
  padding: 18px;
  border-radius: 16px;
  background: rgba(0, 0, 0, .28);
}

.section-title {
  margin: 0 0 10px;
  color: white;
  font-weight: 1000;
  text-transform: uppercase;
  letter-spacing: .04em;
}

#mini-map {
  width: 100%;
  border-radius: 10px;
  border: 2px solid rgba(255,255,255,.14);
  background: #20405b;
}

.map-name {
  display: block;
  text-align: center;
  margin: 8px 0 18px;
  text-transform: uppercase;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  min-height: 54px;
  padding: 0 12px;
  border-radius: 8px;
  margin-top: 10px;
  background: rgba(0,0,0,.28);
  font-weight: 950;
  text-transform: uppercase;
}

.stat-row span { color: #d4e2f2; font-size: 14px; }

.start-button {
  position: absolute;
  left: 50%;
  bottom: 44px;
  transform: translateX(-50%);
  width: min(420px, 72%);
  background: linear-gradient(#ffdb55, #ffae1f);
  color: #0b0f15;
  font-size: 25px;
}

.room-footer {
  position: absolute;
  left: 34px;
  right: 34px;
  bottom: 16px;
  display: flex;
  justify-content: space-between;
  color: #bed2e8;
  font-weight: 800;
}

.play-screen {
  background: #070b10;
}

#arena {
  display: block;
  width: 100%;
  height: 100%;
  background: #2f3028;
}

.game-hud {
  position: absolute;
  inset: 12px 12px auto;
  display: grid;
  grid-template-columns: 158px 1fr 124px;
  align-items: start;
  pointer-events: none;
}

.role-badge, .timer, .hiders-left {
  background: rgba(0,0,0,.76);
  border: 2px solid rgba(255,255,255,.12);
  border-radius: 9px;
  box-shadow: 0 8px 18px rgba(0,0,0,.46);
  backdrop-filter: blur(4px);
}

.role-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
}

.role-badge small, .hiders-left small {
  display: block;
  font-size: 12px;
  color: white;
  font-weight: 950;
}

.role-badge strong {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--green);
  text-transform: uppercase;
  font-weight: 1000;
  letter-spacing: .02em;
}

.role-badge.taya strong { background: var(--red); }

.timer {
  justify-self: center;
  padding: 7px 24px;
  font-size: 32px;
  font-weight: 1000;
  line-height: 1;
}

.hiders-left {
  justify-self: end;
  min-width: 116px;
  padding: 7px 10px;
  text-align: center;
}

.hiders-left strong {
  display: block;
  font-size: 28px;
  line-height: 1.05;
}

.chat-button {
  position: absolute;
  top: 45%;
  right: 14px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: rgba(0,0,0,.6);
  font-size: 20px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.14), 0 6px 14px rgba(0,0,0,.35);
}

.joystick {
  position: absolute;
  left: 42px;
  bottom: 50px;
  width: 152px;
  height: 152px;
  border-radius: 50%;
  background: rgba(0,0,0,.24);
  border: 3px solid rgba(255,255,255,.22);
  box-shadow: inset 0 0 38px rgba(255,255,255,.08), 0 12px 28px rgba(0,0,0,.28);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  place-items: center;
}

.joystick span {
  grid-column: 2;
  grid-row: 2;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, rgba(255,255,255,.96), rgba(214,218,219,.78));
  box-shadow: 0 8px 18px rgba(0,0,0,.28);
}

.joystick button {
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  color: rgba(255,255,255,.5);
  font-weight: 1000;
}

.joystick [data-dir="up"] { grid-column: 2; grid-row: 1; }
.joystick [data-dir="left"] { grid-column: 1; grid-row: 2; }
.joystick [data-dir="right"] { grid-column: 3; grid-row: 2; }
.joystick [data-dir="down"] { grid-column: 2; grid-row: 3; }

.primary-action {
  position: absolute;
  right: 66px;
  bottom: 62px;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: 4px solid rgba(0,0,0,.45);
  color: white;
  font-size: 26px;
  font-weight: 1000;
  text-transform: uppercase;
  box-shadow: inset 0 5px 0 rgba(255,255,255,.26), 0 12px 26px rgba(0,0,0,.38);
  text-shadow: 0 3px 0 rgba(0,0,0,.35);
}

.primary-action.bang { background: radial-gradient(circle at 34% 24%, #ff7c70, #bd1f2e 70%); }
.primary-action.sak { background: radial-gradient(circle at 34% 24%, #67e777, #198c38 70%); }

.primary-action.bang::before,
.primary-action.sak::before {
  display: block;
  margin-bottom: 2px;
  font-size: 36px;
  line-height: .85;
}

.primary-action.bang::before { content: "💥"; }
.primary-action.sak::before { content: "🏠"; }

.game-toast {
  position: absolute;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%);
  max-width: 70%;
  padding: 12px 18px;
  border-radius: 999px;
  background: rgba(0,0,0,.78);
  border: 1px solid rgba(255,255,255,.22);
  font-weight: 1000;
  text-align: center;
}

.result-screen {
  display: none;
  place-items: center;
  text-align: center;
  background:
    radial-gradient(circle at 50% 25%, rgba(45, 96, 167, .4), transparent 18rem),
    linear-gradient(135deg, #0a1027, #16122c);
  padding: 34px;
}

.result-screen.active { display: grid; }

.confetti {
  position: absolute;
  inset: 0;
  opacity: .75;
  background-image:
    radial-gradient(circle, #ffc329 0 3px, transparent 4px),
    radial-gradient(circle, #ff5e57 0 3px, transparent 4px),
    radial-gradient(circle, #2ed573 0 3px, transparent 4px),
    radial-gradient(circle, #1e90ff 0 3px, transparent 4px);
  background-size: 130px 120px, 170px 140px, 190px 160px, 150px 130px;
  animation: confetti 10s linear infinite;
}

@keyframes confetti { from { background-position: 0 0; } to { background-position: 160px 260px; } }

.result-screen h2 {
  position: relative;
  margin: 0;
  color: #ff4438;
  font-size: clamp(48px, 9vw, 86px);
  text-transform: uppercase;
  -webkit-text-stroke: 4px #130b0b;
  text-shadow: 0 6px 0 #ffb01f;
}

.result-card, .reward-card {
  position: relative;
  width: min(440px, 84%);
  margin: 10px auto;
  padding: 14px;
  border-radius: 12px;
  background: rgba(14, 43, 72, .72);
  border: 1px solid rgba(255,255,255,.12);
}

.winner-row, .caught-list {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
}

.caught-list .caught-person {
  display: grid;
  justify-items: center;
  gap: 4px;
  font-weight: 900;
}

.reward-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  font-size: 24px;
}

.leaderboard-screen {
  display: none;
  grid-template-columns: 260px 1fr;
  padding: 0 0 72px;
}

.leaderboard-screen.active { display: grid; }

.leader-tabs {
  padding: 52px 26px;
  background: rgba(1, 12, 23, .28);
  border-right: 1px solid var(--line);
}

.leader-tabs button {
  display: block;
  width: 100%;
  min-height: 70px;
  margin-bottom: 16px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(#193d65, #0e2b49);
  font-weight: 1000;
  text-transform: uppercase;
}

.leader-tabs .active { background: linear-gradient(#ffdc55, #ffb51f); color: #0c1118; }

.leader-panel {
  padding: 42px;
}

.leader-panel h2 {
  margin: 0 0 22px;
  text-align: center;
  text-transform: uppercase;
}

.leader-list {
  display: grid;
  gap: 10px;
}

.leader-row, .your-rank {
  display: grid;
  grid-template-columns: 58px 58px 1fr 120px;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 8px 14px;
  border: 1px solid rgba(105, 164, 220, .24);
  border-radius: 8px;
  background: rgba(3, 25, 45, .62);
  font-size: 20px;
  font-weight: 950;
}

.rank-medal {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  justify-self: center;
  color: #121314;
  background: #cbd5e1;
  font-weight: 1000;
}

.rank-medal.gold { background: #ffcf33; }
.rank-medal.silver { background: #e5e7eb; }
.rank-medal.bronze { background: #d28b4f; }

.your-rank {
  margin-top: 24px;
  grid-template-columns: 100px 58px 1fr 120px;
  background: rgba(13, 54, 91, .86);
}

.bottom-nav {
  position: absolute;
  left: 260px;
  right: 0;
  bottom: 0;
  height: 72px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: rgba(1, 12, 23, .68);
}

.bottom-nav button {
  border: 0;
  background: transparent;
  color: #a8b5c4;
  font-size: 22px;
  font-weight: 900;
}

.bottom-nav button span {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
}

.bottom-nav .active {
  color: #ffcf33;
  background: rgba(22, 111, 199, .22);
}

.modal {
  width: min(620px, calc(100vw - 26px));
  border: 3px solid #05070b;
  border-radius: 18px;
  color: white;
  background: #10243a;
  padding: 24px;
  box-shadow: var(--shadow);
}

.modal::backdrop { background: rgba(0,0,0,.62); backdrop-filter: blur(5px); }
.modal h2 { margin-top: 0; text-transform: uppercase; }
.modal li, .modal p { color: #d5e2ef; line-height: 1.7; font-weight: 750; }
.close { float: right; width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: rgba(255,255,255,.08); font-size: 24px; }

@media (max-width: 860px) {
  .game-shell { padding: 0; background: #05070b; }
  .screen {
    width: 100vw;
    min-height: 100svh;
    aspect-ratio: auto;
    border: 0;
    border-radius: 0;
  }

  .browser-bar { display: none; }
  .menu-content { inset: 0; padding: 18px; }
  .logo-burst { min-height: 180px; }
  .player-chip { left: 12px; bottom: 12px; }
  .version-chip { right: 12px; bottom: 12px; }

  .lobby-screen, .leaderboard-screen { padding: 14px; }
  .lobby-top { grid-template-columns: 100px 1fr 112px; }
  .lobby-top h2 { font-size: 22px; }
  .mini-button, .back-button { min-height: 42px; font-size: 12px; }
  .lobby-layout { grid-template-columns: 1fr; height: auto; }
  .room-card { display: none; }
  .player-row { grid-template-columns: 54px 1fr 72px 54px; font-size: 16px; }
  .start-button { bottom: 26px; width: calc(100% - 48px); }
  .room-footer { bottom: 8px; left: 14px; right: 14px; }

  .game-hud {
    inset: calc(env(safe-area-inset-top) + 8px) 8px auto;
    grid-template-columns: 120px 1fr 92px;
  }
  .role-badge { padding: 5px; }
  .role-badge small { font-size: 10px; }
  .role-badge strong { font-size: 12px; padding: 4px 6px; }
  .timer { font-size: 20px; padding: 7px 14px; }
  .hiders-left { min-width: 88px; padding: 6px; }
  .hiders-left small { font-size: 9px; }
  .hiders-left strong { font-size: 18px; }
  .joystick { left: 24px; bottom: 28px; width: 112px; height: 112px; }
  .joystick span { width: 56px; height: 56px; }
  .joystick button { width: 34px; height: 34px; }
  .primary-action { right: 32px; bottom: 36px; width: 98px; height: 98px; font-size: 22px; }
  .chat-button { right: 10px; top: 44%; }

  .leaderboard-screen { grid-template-columns: 1fr; padding-bottom: 68px; }
  .leader-tabs { display: flex; gap: 8px; padding: 12px; border-right: 0; }
  .leader-tabs button { min-height: 46px; margin: 0; }
  .leader-panel { padding: 12px; }
  .leader-row { grid-template-columns: 42px 46px 1fr 78px; font-size: 15px; }
  .your-rank { grid-template-columns: 72px 46px 1fr 78px; font-size: 15px; }
  .bottom-nav { left: 0; }
}
