* {
  box-sizing: border-box;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, sans-serif;
}

:root {
  --card-bg: rgba(24, 26, 34, 0.9);
  --panel-bg: rgba(34, 37, 48, 0.82);
  --border-soft: rgba(190, 166, 186, 0.34);
  --text-main: #f1f1f5;
  --text-soft: #cfc5d0;
  --input-bg: rgba(255, 255, 255, 0.06);
  --button-a: #f05a67;
  --button-b: #a9445a;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  background: radial-gradient(circle at top, #283e51, #0a2342);
  color: var(--text-main);
}

body.device-mobile .app {
  max-width: 560px;
  padding: 10px 8px 18px;
}

body.device-mobile .screen {
  padding: 12px 10px;
}

body.device-mobile .party-actions button,
body.device-mobile .guess-input button,
body.device-mobile .chat-input-row button {
  width: 100%;
}

body.device-mobile .auth-actions button,
body.device-mobile .admin-tools-actions button {
  width: 100%;
}

body.device-mobile .guess-input,
body.device-mobile .chat-input-row {
  flex-direction: column;
  align-items: stretch;
}

body.device-mobile #letter-input {
  width: 100%;
}

body.device-mobile h1 {
  font-size: clamp(1.25rem, 5vw, 1.6rem);
  margin: 10px 0 12px;
  text-align: left;
}

body.device-mobile h2 {
  margin-top: 4px;
  font-size: 1.12rem;
}

body.device-mobile .party-actions {
  gap: 8px;
}

body.device-mobile .game-top-row {
  align-items: center;
}

body.device-mobile #leave-party-btn {
  margin-left: 0;
  padding: 4px 10px;
}

body.device-mobile .panel {
  padding: 10px;
}

body.device-mobile .status-bar,
body.device-mobile .message,
body.device-mobile .scoreboard {
  font-size: 0.86rem;
}

body.device-mobile .hangman-box {
  padding: 6px;
}

body.device-mobile #hangman-svg {
  width: min(66vw, 190px);
  height: min(66vw, 190px);
}

body.device-mobile .word-display {
  min-height: 58px;
  gap: 6px;
  padding: 8px;
}

body.device-mobile .letter-slot {
  min-width: 22px;
  height: 34px;
  font-size: 1.25rem;
}

body.device-mobile .letter-slot.space {
  width: 14px;
}

body.device-mobile .keyboard {
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
  padding: 6px;
}

body.device-mobile .key-btn {
  min-height: 34px;
  font-size: 0.8rem;
}

body.device-mobile .site-footer {
  margin: 10px 0 8px;
  padding: 0 10px;
}

.app {
  max-width: 960px;
  width: 100%;
  padding: 24px 16px 32px;
}

.top-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 8px;
}

.top-nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

h1 {
  text-align: center;
  margin-bottom: 16px;
  letter-spacing: 0.05em;
}

.screen {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 20px 18px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.4);
  display: none;
}

.screen.active {
  display: block;
}

.game-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.game-top-row h2 {
  margin: 0;
}

#leave-party-btn {
  margin-left: 0;
}

.lang-switch {
  display: flex;
  gap: 6px;
}

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

.icon-btn {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  padding: 0;
  font-size: 1.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#chat-toggle-btn {
  display: inline-flex;
}

#auth-open-btn.auth-user-name {
  width: auto;
  min-width: 42px;
  max-width: min(42vw, 220px);
  padding: 0 12px;
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#auth-open-btn.auth-user-name.user-glow {
  color: #ffd9dd;
  text-shadow: 0 0 6px rgba(236, 103, 120, 0.58), 0 0 12px rgba(236, 103, 120, 0.32);
}

#auth-open-btn.auth-user-name.admin-glow {
  background-image: linear-gradient(90deg, #ffffff 0 50%, #b9cfff 50% 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 6px rgba(255, 255, 255, 0.62), 0 0 13px rgba(153, 198, 255, 0.46);
}

.chat-unread-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 22px;
  height: 18px;
  border-radius: 999px;
  padding: 0 6px;
  background: #de2f40;
  color: #fff;
  font-size: 0.7rem;
  line-height: 18px;
  font-weight: 700;
  box-shadow: 0 0 0 2px rgba(24, 26, 34, 0.95);
}

.lang-btn {
  border-radius: 10px;
  padding: 6px 8px;
  border: 1px solid var(--border-soft);
  background: rgba(34, 37, 48, 0.9);
}

.lang-btn.active {
  box-shadow: 0 0 0 2px rgba(147, 201, 255, 0.45);
}

.name-input {
  margin-bottom: 12px;
}

.party-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

#online-search-status {
  margin-bottom: 10px;
}

#online-players-live {
  margin-top: -4px;
  color: var(--text-soft);
}

.panel {
  margin-top: 12px;
  padding: 14px;
  border-radius: 10px;
  background: var(--panel-bg);
  border: 1px solid var(--border-soft);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
}

.auth-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
}

.admin-secret-wrap {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--text-soft);
}

.admin-check-wrap {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-soft);
  font-size: 0.92rem;
}

.admin-check-wrap input {
  width: 16px;
  height: 16px;
}

.profile-settings {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--text-soft);
  font-size: 0.92rem;
}

.profile-scale-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.profile-scale-controls .small-btn {
  margin-left: 0;
  min-width: 34px;
}

.profile-scale-value {
  min-width: 52px;
  text-align: center;
  font-weight: 700;
  color: var(--text-main);
}

.auth-actions,
.admin-tools-actions {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.auth-panel .message {
  margin-top: 8px;
}

.admin-tools {
  position: fixed;
  right: 58px;
  top: 102px;
  z-index: 119;
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

.admin-tools .admin-tools-actions {
  margin-top: 0;
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
}

.admin-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  padding: 0;
  font-size: 1.05rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.admin-icon-btn.secondary {
  background: rgba(34, 37, 48, 0.92);
}

.hidden {
  display: none;
}

.center-banner.hidden,
.screen-notification.hidden {
  display: none !important;
}

.party-code-box {
  display: flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  margin: 6px 0 10px;
}

#party-code-display {
  font-weight: 700;
  letter-spacing: 0.15em;
}

.host-controls {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#secret-label {
  display: inline-block;
  font-size: 1.02rem;
  font-weight: 700;
  margin-bottom: 6px;
}

ul {
  margin: 6px 0;
  padding-left: 18px;
}

.admin-player-name-btn {
  padding: 0;
  border: none;
  background: none;
  box-shadow: none;
  color: #ff8a8a;
  font-weight: 700;
  text-align: left;
  border-radius: 0;
  text-shadow: 0 0 6px rgba(235, 97, 97, 0.45);
}

.admin-player-name-btn:hover {
  transform: none;
  box-shadow: none;
  color: #ffb3b3;
  text-decoration: underline;
}

.admin-player-name-btn:active {
  transform: none;
  box-shadow: none;
  opacity: 1;
}

input {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  background: var(--input-bg);
  color: var(--text-main);
}

button {
  cursor: pointer;
  border: none;
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  background: linear-gradient(135deg, var(--button-a), var(--button-b));
  color: #fff5f6;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease,
    background 0.2s ease, opacity 0.12s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.4);
}

button:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  opacity: 0.9;
}

button.secondary {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-soft);
  box-shadow: none;
}

button.small-btn {
  padding: 4px 10px;
  font-size: 0.8rem;
  margin-left: 8px;
}

.message {
  min-height: 22px;
  font-size: 0.9rem;
  margin-top: 10px;
}

.scoreboard {
  margin: 8px 0 10px;
  font-weight: 700;
  color: var(--text-soft);
}

.message.win {
  color: #55ffb5;
}

.message.lose {
  color: #ff9b9b;
}

.status-bar {
  margin-bottom: 10px;
  font-size: 0.9rem;
}

.hangman-box {
  margin: 8px 0 10px;
  padding: 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  justify-content: center;
}

#hangman-svg {
  width: 220px;
  height: 220px;
}

.gallow {
  stroke: #cdbfc8;
  stroke-width: 5;
  stroke-linecap: round;
}

.hang-part {
  stroke: #ffcf8c;
  stroke-width: 5;
  fill: none;
  stroke-linecap: round;
  opacity: 0.15;
  transition: opacity 0.2s ease;
}

.hang-part.visible {
  opacity: 1;
}

.word-display {
  min-height: 72px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
}

.letter-slot {
  min-width: 26px;
  height: 42px;
  border-bottom: 3px solid rgba(192, 169, 187, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  text-transform: uppercase;
}

.letter-slot.space {
  border-bottom: none;
  width: 18px;
}

.letter-slot.dash {
  border-bottom: none;
  min-width: 26px;
  font-size: 1.4rem;
}

.controls {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-panel {
  margin-top: 12px;
  padding: 12px;
  border-radius: 14px;
  backdrop-filter: blur(6px);
}

#chat-window {
  position: fixed;
  right: 14px;
  bottom: 14px;
  width: min(92vw, 340px);
  z-index: 122;
  border: 1px solid rgba(210, 188, 208, 0.36);
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.42);
}

.chat-header-row,
.auth-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.chat-header-row p,
.auth-header-row p {
  margin: 0;
}

.chat-close-btn {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  padding: 0;
  margin-left: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  line-height: 1;
}

.chat-body {
  position: relative;
  min-height: 190px;
}

.chat-messages {
  min-height: 190px;
  max-height: min(42vh, 330px);
  overflow-y: auto;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.chat-line {
  max-width: 88%;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 9px;
  border-radius: 12px;
  background: rgba(61, 65, 84, 0.86);
  border: 1px solid rgba(198, 174, 196, 0.28);
  font-size: 0.86rem;
  line-height: 1.3;
  word-break: break-word;
}

.chat-line .sender {
  color: #ffc2c8;
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

.chat-line .meta {
  color: var(--text-soft);
  opacity: 0.84;
  font-size: 0.74rem;
}

.chat-line.mine {
  align-self: flex-end;
  background: rgba(171, 73, 93, 0.36);
  border-color: rgba(243, 184, 194, 0.44);
}

.chat-line.other {
  align-self: flex-start;
}

.chat-line.system {
  align-self: center;
  max-width: 96%;
  background: rgba(130, 142, 173, 0.2);
  border-style: dashed;
}

.chat-empty {
  position: absolute;
  inset: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-soft);
  text-align: center;
  font-size: 0.86rem;
  pointer-events: none;
}

.chat-input-row {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.chat-input-row input {
  flex: 1;
  min-width: 0;
}

.guess-input {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

#letter-input {
  width: 48px;
  text-align: center;
  text-transform: uppercase;
}

.keyboard {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(30px, 1fr));
  gap: 4px;
  padding: 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
}

.key-btn {
  padding: 6px 0;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  background: rgba(56, 60, 78, 0.82);
  color: #f3eef1;
  border: 1px solid rgba(197, 173, 190, 0.56);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.key-btn.correct {
  background: linear-gradient(135deg, #1fd75f, #0ba345);
  border-color: #96f7c8;
  color: #02160a;
}

.key-btn.wrong {
  background: linear-gradient(135deg, #e24c4c, #a22222);
  border-color: #f6b1b1;
  color: #ffecec;
}

.key-btn:disabled {
  opacity: 0.6;
  cursor: default;
  transform: none;
  box-shadow: none;
}

.center-banner {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  max-width: min(90vw, 900px);
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(56, 60, 78, 0.9);
  border: 1px solid var(--border-soft);
  color: #f4edf2;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.center-banner.animate-pop {
  animation: notifyPop 3.5s ease forwards;
}

.screen-notification {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  background: rgba(2, 8, 18, 0.38);
}

.screen-notification.animate-pop {
  animation: notifyOverlay 3.5s ease forwards;
}

.screen-notification span {
  padding: 16px 22px;
  border-radius: 14px;
  border: 1px solid rgba(180, 225, 255, 0.65);
  background: rgba(58, 47, 62, 0.94);
  color: #fff1f3;
  font-size: clamp(1.3rem, 3.4vw, 2.3rem);
  font-weight: 800;
  letter-spacing: 0.04em;
  text-align: center;
  text-transform: uppercase;
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.5);
}

.screen-notification.animate-pop span {
  animation: notifyPop 3.5s ease forwards;
}

.screen-notification.win span {
  border-color: rgba(138, 255, 191, 0.8);
  color: #d9ffe8;
}

.screen-notification.lose span {
  border-color: rgba(255, 163, 163, 0.8);
  color: #ffe6e6;
}

.site-footer {
  margin: 12px 0 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #e0d2d9;
}

.site-footer p {
  margin: 0;
  text-align: center;
  opacity: 0.9;
}

.device-modal {
  position: fixed;
  inset: 0;
  z-index: 130;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(1, 10, 20, 0.66);
}

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 131;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(1, 10, 20, 0.72);
}

.auth-modal.hidden {
  display: none !important;
}

.auth-card {
  width: min(92vw, 480px);
  background: rgba(34, 37, 48, 0.97);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.5);
}

.device-modal.hidden {
  display: none !important;
}

.device-card {
  width: min(92vw, 460px);
  background: rgba(34, 37, 48, 0.95);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.5);
}

.device-card h3 {
  margin: 0 0 6px;
}

.device-card p {
  margin: 0 0 12px;
}

.device-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

body.device-mobile #chat-window {
  right: 8px;
  left: 8px;
  width: auto;
  bottom: 8px;
  max-width: none;
}

body.device-mobile .chat-body {
  min-height: 170px;
}

body.device-mobile .chat-messages {
  min-height: 170px;
  max-height: 38vh;
}

body.device-mobile .top-nav-row {
  align-items: flex-start;
}

body.device-mobile .admin-tools {
  right: 56px;
  top: 96px;
}

body.device-mobile .admin-tools-actions button {
  width: auto;
}

.fireworks-canvas {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
}

@keyframes notifyPop {
  0% {
    opacity: 0;
    transform: translateY(-8px) scale(0.96);
  }
  15% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  80% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
  }
}

@keyframes notifyOverlay {
  0% {
    opacity: 0;
  }
  15% {
    opacity: 1;
  }
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}