@font-face {
  font-family: "Cuprum";
  src: url("/fonts/Cuprum-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Cuprum";
  src: url("/fonts/Cuprum-Italic.ttf") format("truetype");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "Cuprum";
  src: url("/fonts/Cuprum-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Cuprum";
  src: url("/fonts/Cuprum-BoldItalic.ttf") format("truetype");
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

:root {
  --font-game: "GameFont", "Trebuchet MS", "Segoe UI", sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --boot-bg: #0b3836;
}

@font-face {
  font-family: "GameFont";
  src: url("/fonts/europecondensedc.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "GameFont";
  src: url("/fonts/europecondensedc-bold.otf") format("opentype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "GameFont";
  src: url("/fonts/europecondensedc-bolditalic.otf") format("opentype");
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: var(--boot-bg);
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--boot-bg);
  color: #e8edf5;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  font-family: var(--font-game);
  overflow: hidden;
}

#app {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background-color: var(--boot-bg);
}

#appLayout {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  min-height: 100%;
  overflow: hidden;
  background-color: var(--boot-bg);
  background-image:
    radial-gradient(circle at center,
      rgba(0, 0, 0, 0) 58%,
      rgba(0, 0, 0, 0.16) 78%,
      rgba(0, 0, 0, 0.38) 100%
    ),
    radial-gradient(circle at 50% 35%, #1c5f5a 0%, #0f2f35 60%, #0a1418 100%);
  background-repeat: no-repeat;
  background-size: cover;
}

#gameWrap {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  align-self: stretch;
  position: relative;
  min-width: 0;
  min-height: 0;
  background-color: var(--boot-bg);
}

#game-canvas {
  background-color: var(--boot-bg);
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  touch-action: none;
  display: block;
}

#uiOverlayRoot {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9000;
}

.ui-overlay-layer {
  position: absolute;
  inset: 0;
  pointer-events: auto;
}

.chat-mobile-fullscreen {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  border-radius: 0 !important;
}

.chat-mobile-fullscreen .chat-panel {
  height: 100%;
  border-radius: 0;
}

.chat-toggle-btn {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: 44px;
  height: 44px;
  border: none;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  z-index: 2;
  transform: translate(15px, 35px);
}

.chat-toggle-btn:focus-visible {
  outline: 2px solid rgba(120, 200, 210, 0.7);
  outline-offset: 2px;
}

.chat-hidden {
  display: none;
}

.chat-root[hidden],
.chat-root.chat-hidden {
  display: none;
}

.chat-root {
  display: flex;
  flex-direction: column;
  font-family: "Cuprum", Arial, sans-serif;
  min-height: 0;
}

.chat-dock {
  width: clamp(300px, 24vw, 380px);
  align-self: stretch;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  position: relative;
}

.chat-panel {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, #003341 0%, #00161f 65%);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.45);
}

.chat-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  min-height: 32px;
  flex: 0 0 auto;
  background: linear-gradient(180deg, rgba(0, 38, 49, 0.95), rgba(0, 23, 31, 0.95));
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: #e3f2f4;
}

.chat-stats {
  display: flex;
  gap: 14px;
  font-size: 14px;
  font-style: italic;
  letter-spacing: 0.2px;
}

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

.chat-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
}

.chat-icon-btn img {
  width: 18px;
  height: 18px;
  opacity: 0.85;
}

.chat-icon-btn:hover img {
  opacity: 1;
}

.chat-icon-btn:active {
  transform: translateY(1px);
}

.chat-mobile-close-btn {
  display: none;
}

.chat-mobile-fullscreen .chat-mobile-close-btn {
  display: inline-flex;
}

.chat-messages {
  flex: 1 1 auto;
  padding: 12px 14px;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  min-width: 0;
  overscroll-behavior: contain;
  background: radial-gradient(120% 120% at 20% 0%, rgba(3, 64, 78, 0.35), rgba(0, 20, 27, 0.1) 60%);
  width: 100%;
  box-sizing: border-box;
}

#chatMessages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
  min-height: 0;
  min-width: 0;
  overscroll-behavior: contain;
  width: 100%;
  box-sizing: border-box;
}

.chat-message {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  align-self: stretch;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(145deg, #647780, #2e3b41);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  flex: 0 0 32px;
  min-width: 32px;
  max-width: 32px;
  position: relative;
  overflow: visible;
}

.chat-avatar.chat-avatar-wreath::before {
  content: "";
  position: absolute;
  display: block;
  left: 50%;
  top: 50%;
  width: 42px;
  height: 42px;
  transform: translate(-50%, -50%);
  background: url("/img/venok250.png") no-repeat center / contain;
  pointer-events: none;
  z-index: 1;
}

.chat-avatar.chat-avatar-vip::after {
  content: "";
  position: absolute;
  display: block;
  left: 50%;
  top: -12px;
  width: 18px;
  height: 18px;
  transform: translateX(-50%);
  background: url("/img/crown.png") no-repeat center / contain;
  pointer-events: none;
  z-index: 2;
}

.chat-bubble {
  max-width: calc(100% - 54px);
  width: auto;
  min-width: 0;
  padding: 8px 10px;
  line-height: 1.25;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(8, 35, 44, 0.78);
  color: #e6f1f4;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
  box-sizing: border-box;
}

.chat-name {
  display: inline;
  font-size: 13px;
  font-weight: 700;
  color: #9ee7e5;
  margin: 0;
  padding: 0;
}

.chat-sep {
  display: inline;
  opacity: 0.9;
}

.chat-name-clickable {
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.chat-name-clickable:hover {
  opacity: 0.85;
}

.chat-text {
  display: inline;
  font-size: 14px;
  line-height: 1.25;
  color: #e6f1f4;
  margin: 0;
  padding: 0;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.chat-inputbar {
  display: flex;
  position: relative;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  min-height: 52px;
  flex: 0 0 auto;
  background: rgba(0, 30, 38, 0.95);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-emoji-panel {
  position: absolute;
  right: 10px;
  bottom: 56px;
  width: 260px;
  max-width: calc(100% - 20px);
  padding: 10px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(180deg, rgba(0, 38, 49, 0.98), rgba(0, 20, 28, 0.98));
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  z-index: 5;
}

.chat-emoji-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}

.chat-emoji-btn {
  height: 34px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  font-size: 18px;
  line-height: 34px;
}

.chat-emoji-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.chat-emoji-btn:active {
  transform: translateY(1px);
}

.chat-input {
  flex: 1;
  height: 36px;
  padding: 0 14px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
  color: #eef7f8;
  font-family: inherit;
  font-size: 14px;
  outline: none;
}

.chat-input::placeholder {
  color: rgba(230, 241, 244, 0.55);
}

.chat-input:focus {
  border-color: rgba(133, 214, 219, 0.6);
  box-shadow: 0 0 0 2px rgba(133, 214, 219, 0.15);
}

.chat-inputbar .chat-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 12px;
}

@media (min-width: 901px) {
  body {
    align-items: stretch;
    justify-content: stretch;
  }

  #app {
    align-items: stretch;
    justify-content: stretch;
  }

  #appLayout {
    padding: 0;
    height: 100%;
    min-height: 100%;
    overflow: hidden;
  }

  #gameWrap {
    height: 100%;
    flex: 0 0 auto;
  }

  #chatDock::before {
    content: "";
    position: absolute;
    left: -6px;
    top: 0;
    width: 6px;
    height: 100%;
    background: linear-gradient(180deg, rgba(160, 220, 230, 0.2), rgba(160, 220, 230, 0.05));
    pointer-events: none;
  }
}

@media (max-width: 900px) {
  #appLayout {
    display: block;
    padding: 0;
    height: 100%;
    min-height: 100%;
  }

  #chatDock.chat-mobile-fullscreen {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-width: 100vw;
    max-height: 100dvh;
    margin: 0;
    padding: env(safe-area-inset-top) env(safe-area-inset-right)
      env(safe-area-inset-bottom) env(safe-area-inset-left);
  }

  #gameWrap {
    width: 100%;
    height: 100%;
  }

  #game-canvas {
    border-radius: 0;
    box-shadow: none;
  }

  #chatDock {
    display: none;
  }

  #chatDock.chat-mobile-fullscreen {
    display: flex;
  }

  .chat-toggle-btn {
    display: none;
    transform: translate(-15px, -15px);
  }
}
