:root {
  --bg: #090a0b;
  --panel: #111315;
  --panel-2: #17191c;
  --panel-3: #202328;
  --line: rgba(255,255,255,.09);
  --text: #f1eee8;
  --muted: #989b9f;
  --gold: #f0a52b;
  --gold-soft: rgba(240,165,43,.18);
  --danger: #e05252;
  --safe: #5fba78;
  --shadow: 0 22px 70px rgba(0,0,0,.55);
  --header-h: 58px;
  --radius: 20px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
  -webkit-tap-highlight-color: transparent;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); overscroll-behavior: none; }
body { min-height: 100dvh; overflow-x: hidden; }
button, input, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.app-shell {
  min-height: 100dvh;
  background:
    radial-gradient(circle at 50% -10%, rgba(240,165,43,.10), transparent 34rem),
    linear-gradient(180deg, #0c0e0f 0%, #08090a 100%);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: calc(var(--header-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 12px 0;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  background: rgba(10,11,12,.86);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.header-title { text-align: center; min-width: 0; }
.header-title strong { display: block; font-size: 15px; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-title small { color: var(--muted); font-size: 11px; letter-spacing: .08em; }

.icon-btn {
  width: 42px; height: 42px; border: 0; border-radius: 14px;
  display: inline-grid; place-items: center; cursor: pointer;
  background: rgba(255,255,255,.055); border: 1px solid var(--line);
  transition: transform .16s ease, background .16s ease, border-color .16s ease;
}
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 21px; height: 21px; }
.icon-btn.ghost { background: transparent; border-color: transparent; }
.icon-btn.danger { color: var(--danger); }
.icon-btn[disabled] { opacity: .35; pointer-events: none; }

.offline-indicator.ready { color: var(--safe); }
.offline-indicator.pending { color: var(--muted); }
.offline-indicator.offline { color: var(--gold); }

.screen { min-height: calc(100dvh - var(--header-h)); padding: 18px 14px calc(24px + env(safe-area-inset-bottom)); }

.home-screen {
  min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(28px + env(safe-area-inset-top)) 22px calc(28px + env(safe-area-inset-bottom));
  position: relative; overflow: hidden;
}
.home-screen::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle at center 38%, rgba(240,165,43,.10), transparent 25rem);
  pointer-events: none;
}
.home-emblem {
  width: min(56vw, 290px); aspect-ratio: 1; object-fit: cover; border-radius: 50%;
  filter: drop-shadow(0 26px 38px rgba(0,0,0,.65)); position: relative;
}
.home-title { margin: 18px 0 6px; font-size: clamp(36px, 11vw, 64px); letter-spacing: .08em; text-transform: uppercase; position: relative; }
.home-subtitle { margin: 0 0 34px; color: var(--muted); letter-spacing: .2em; text-transform: uppercase; font-size: 11px; position: relative; }
.home-actions { width: min(100%, 380px); display: grid; gap: 12px; position: relative; }
.version { margin-top: 24px; color: #666a6e; font-size: 11px; letter-spacing: .08em; position: relative; }

.primary-btn, .secondary-btn, .danger-btn {
  min-height: 54px; border-radius: 17px; border: 1px solid transparent; padding: 0 20px;
  font-weight: 750; letter-spacing: .025em; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  transition: transform .16s ease, filter .16s ease, background .16s ease;
}
.primary-btn { background: linear-gradient(180deg, #ffb53d, #d98512); color: #17110a; box-shadow: 0 15px 35px rgba(224,137,20,.22); }
.secondary-btn { background: rgba(255,255,255,.055); border-color: var(--line); color: var(--text); }
.danger-btn { background: rgba(224,82,82,.14); border-color: rgba(224,82,82,.3); color: #ff9d9d; }
.primary-btn:active, .secondary-btn:active, .danger-btn:active { transform: scale(.98); }
.primary-btn[disabled], .secondary-btn[disabled] { opacity: .38; pointer-events: none; filter: grayscale(.3); }
.primary-btn svg, .secondary-btn svg, .danger-btn svg { width: 20px; height: 20px; }

.setup-screen { max-width: 600px; margin: 0 auto; }
.setup-card { background: linear-gradient(180deg, rgba(25,27,30,.94), rgba(15,17,19,.97)); border: 1px solid var(--line); border-radius: 26px; padding: 18px; box-shadow: var(--shadow); }
.section-label { display: block; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; margin: 8px 2px 10px; }
.code-row { display: grid; grid-template-columns: 1fr 46px; gap: 10px; }
.code-field {
  height: 58px; width: 100%; border: 1px solid var(--line); border-radius: 17px;
  background: #0c0e0f; color: var(--text); text-align: center;
  font-size: clamp(24px, 8vw, 34px); letter-spacing: .16em; font-weight: 850; text-transform: uppercase;
}
.code-field[readonly] { cursor: default; }
.count-control { display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; gap: 10px; }
.count-value { height: 58px; border-radius: 17px; background: #0c0e0f; border: 1px solid var(--line); display: grid; place-items: center; font-size: 26px; font-weight: 800; }
.fingerprint { margin-top: 12px; padding: 12px 14px; border-radius: 14px; border: 1px solid rgba(240,165,43,.18); background: rgba(240,165,43,.065); text-align: center; color: #dcb773; font-weight: 750; letter-spacing: .075em; min-height: 44px; }

.slot-strip, .player-strip {
  display: flex; gap: 9px; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity;
  padding: 6px 3px 10px; overscroll-behavior-x: contain;
}
.slot-strip::-webkit-scrollbar, .player-strip::-webkit-scrollbar { display: none; }
.slot-pill, .player-pill {
  flex: 0 0 48px; height: 48px; border-radius: 16px; border: 1px solid var(--line);
  background: #111315; color: #a8aaad; display: grid; place-items: center;
  font-weight: 800; cursor: pointer; scroll-snap-align: center; transition: .18s ease;
}
.slot-pill svg, .player-pill svg { width: 21px; height: 21px; }
.slot-pill.selected, .player-pill.selected { background: var(--gold-soft); color: var(--gold); border-color: rgba(240,165,43,.55); transform: scale(1.08); }
.player-pill.mine { background: rgba(70,190,105,.20); border-color: rgba(90,220,125,.62); color: #7dea9c; box-shadow: inset 0 0 0 2px rgba(106,232,139,.10), 0 0 18px rgba(65,190,101,.10); }
.player-pill.mine.selected { background: rgba(70,190,105,.28); border-color: rgba(112,239,148,.82); color: #a0f6b8; transform: scale(1.08); }
.player-pill.eliminated { background: rgba(224,82,82,.18); border-color: rgba(224,82,82,.55); color: #ff7777; }
.setup-actions { display: grid; gap: 10px; margin-top: 12px; }

.game-screen { padding: 12px 10px calc(20px + env(safe-area-inset-bottom)); overflow-x: hidden; }
.player-card-wrap { max-width: 690px; margin: 0 auto; }
.player-panel { background: linear-gradient(180deg, #181a1d, #101214); border: 1px solid var(--line); border-radius: 25px; padding: 15px; box-shadow: var(--shadow); }
.player-head { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: start; margin-bottom: 12px; }
.player-title { min-width: 0; }
.player-title h2 { margin: 0; font-size: 23px; }
.player-title .status-badge { display: inline-block; margin-top: 6px; padding: 4px 9px; border-radius: 999px; font-size: 10px; font-weight: 900; letter-spacing: .12em; background: rgba(224,82,82,.18); color: #ff7c7c; }
.player-actions { display: flex; gap: 7px; }
.kick-btn { height: 40px; padding: 0 13px; border-radius: 13px; border: 1px solid rgba(224,82,82,.28); background: rgba(224,82,82,.10); color: #ff8585; font-weight: 750; cursor: pointer; }

.profession-card { display: flex; gap: 13px; align-items: center; padding: 15px; border-radius: 18px; background: linear-gradient(135deg, rgba(240,165,43,.24), rgba(240,165,43,.075)); border: 1px solid rgba(240,165,43,.34); margin-bottom: 11px; }
.profession-card .char-icon { color: var(--gold); }
.profession-card .char-label { color: #d3a95e; }
.profession-card .char-value { color: #fff1d3; }

.characteristics { display: grid; gap: 9px; overflow-anchor: none; }
.char-card {
  --accent: #8a8d91;
  position: relative; overflow: hidden; min-height: 80px; border-radius: 17px; padding: 13px 14px;
  display: grid; grid-template-columns: 42px 1fr; gap: 12px; align-items: center;
  border: 1px solid rgba(255,255,255,.08); background: linear-gradient(135deg, #272a2e, #1b1e21);
  color: #909398; touch-action: pan-y; user-select: none; -webkit-user-select: none;
  transition: background .28s ease, border-color .28s ease, color .28s ease, transform .16s ease;
  overflow-anchor: none;
}
.char-card.large { min-height: 112px; align-items: start; }
.char-card.revealed { background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 24%, #17191b), #151719 72%); border-color: color-mix(in srgb, var(--accent) 50%, transparent); color: var(--accent); }
.char-card.holding { transform: scale(.99); }
.hold-progress { position: absolute; left: 0; bottom: 0; width: 100%; height: 3px; background: var(--accent); transform: scaleX(0); transform-origin: left; opacity: 0; }
.char-card.holding .hold-progress { opacity: .95; transform: scaleX(1); transition: transform .58s linear; }
.char-icon { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; background: rgba(255,255,255,.055); color: currentColor; }
.char-icon svg { width: 23px; height: 23px; }
.char-main { min-width: 0; }
.char-label { color: currentColor; opacity: .86; font-size: 10px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.char-value { margin-top: 6px; color: var(--text); font-size: clamp(14px, 4.1vw, 17px); line-height: 1.34; overflow-wrap: anywhere; user-select: text; -webkit-user-select: text; }
.char-card.hidden .char-value { min-height: 10px; }

.notes-box { margin-top: 12px; }
.notes-box textarea { width: 100%; min-height: 108px; resize: vertical; border-radius: 17px; border: 1px solid var(--line); background: #0c0e10; color: var(--text); padding: 13px 14px; line-height: 1.45; }
.notes-box textarea::placeholder { color: #64676b; }
.game-player-strip { max-width: 690px; margin: 11px auto 0; padding: 8px 2px; }

.drawer {
  position: fixed; z-index: 80; top: calc(var(--header-h) + env(safe-area-inset-top)); bottom: 0;
  width: min(88vw, 430px); background: rgba(15,17,19,.98); border-color: var(--line); border-style: solid;
  box-shadow: var(--shadow); transition: transform .26s cubic-bezier(.2,.8,.2,1);
  display: flex; flex-direction: column; backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
.drawer.left { left: 0; border-width: 0 1px 0 0; transform: translateX(-100%); }
.drawer.right { right: 0; border-width: 0 0 0 1px; transform: translateX(100%); }
.drawer.open { transform: translateX(0); }
.drawer-head { height: 58px; display: flex; align-items: center; justify-content: space-between; padding: 0 14px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 17px; }
.drawer-body { padding: 14px; overflow-y: auto; overscroll-behavior: contain; }
.drawer-tab {
  position: fixed; z-index: 79; top: 48%; width: 36px; height: 64px; border: 1px solid var(--line); background: #191b1e;
  display: grid; place-items: center; cursor: pointer; box-shadow: 0 10px 25px rgba(0,0,0,.4);
}
.drawer-tab svg { width: 20px; }
.drawer-tab.left { left: 0; border-left: 0; border-radius: 0 14px 14px 0; }
.drawer-tab.right { right: 0; border-right: 0; border-radius: 14px 0 0 14px; }
.drawer-backdrop { position: fixed; inset: calc(var(--header-h) + env(safe-area-inset-top)) 0 0; z-index: 70; background: rgba(0,0,0,.48); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }

.info-card { border-radius: 19px; border: 1px solid var(--line); background: #121416; padding: 15px; margin-bottom: 12px; }
.info-card h3 { margin: 0 0 10px; font-size: 20px; }
.info-card p { color: #c9c7c2; line-height: 1.5; margin: 8px 0; }
.info-kicker { color: var(--gold); text-transform: uppercase; font-size: 10px; font-weight: 900; letter-spacing: .13em; margin-bottom: 7px; }
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin: 11px 0 13px; }
.metric { background: #0c0e0f; border: 1px solid var(--line); border-radius: 14px; padding: 10px 7px; text-align: center; }
.metric strong { display: block; font-size: 18px; color: #f0c171; }
.metric span { display: block; color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .08em; margin-top: 4px; }
.info-list { display: grid; gap: 7px; margin: 8px 0 14px; }
.info-list-item { border-left: 2px solid rgba(240,165,43,.55); padding: 7px 10px; background: rgba(255,255,255,.025); border-radius: 0 10px 10px 0; color: #d5d3ce; line-height: 1.35; }
.room-state { color: var(--muted); font-size: 12px; display: block; margin-top: 2px; }
.fingerprint-small { color: #d7ad65; font-size: 12px; letter-spacing: .07em; text-align: center; padding: 10px; border: 1px solid rgba(240,165,43,.17); border-radius: 12px; }
.event-locked { min-height: 260px; display: grid; place-items: center; text-align: center; color: #85888c; }
.event-lock-icon { width: 74px; height: 74px; border-radius: 25px; display: grid; place-items: center; background: #1c1f22; border: 1px solid var(--line); margin: 0 auto 20px; }
.event-lock-icon svg { width: 34px; height: 34px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 20px; background: rgba(0,0,0,.68); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.modal { width: min(100%, 390px); border-radius: 23px; border: 1px solid var(--line); background: #17191c; box-shadow: var(--shadow); padding: 20px; }
.modal h2 { margin: 0 0 8px; font-size: 21px; }
.modal p { color: var(--muted); line-height: 1.45; margin: 0 0 20px; }
.modal-spacer { height: 12px; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.toast-root { position: fixed; z-index: 300; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); transform: translateX(-50%); pointer-events: none; }
.toast { background: #26292d; color: var(--text); border: 1px solid var(--line); border-radius: 999px; padding: 10px 16px; box-shadow: var(--shadow); font-size: 13px; animation: toast-in .2s ease; white-space: nowrap; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.loading-screen { min-height: 100dvh; display: grid; place-items: center; }
.loading-emblem { width: 128px; height: 128px; border-radius: 50%; animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.04); filter: brightness(1.12); } }

.error-card { max-width: 520px; margin: 80px auto; padding: 22px; border-radius: 20px; border: 1px solid rgba(224,82,82,.35); background: rgba(224,82,82,.08); }
.error-card h2 { margin-top: 0; }

@media (min-width: 760px) {
  .screen { padding-left: 24px; padding-right: 24px; }
  .characteristics { grid-template-columns: 1fr 1fr; }
  .char-card.large { grid-column: 1 / -1; }
  .home-emblem { width: 270px; }
}

@media (min-width: 1180px) {
  .game-screen.with-left { padding-left: 450px; }
  .game-screen.with-right { padding-right: 450px; }
  .drawer-backdrop { display: none; }
  .drawer-tab { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
