* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  color: #e0e0e0;
  min-height: 100vh;
  overflow-x: hidden;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 22px;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(10px);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
}

.logo {
  font-size: 1.35rem;
  font-weight: 700;
  color: #f0c040;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-badge {
  background: rgba(240, 192, 64, 0.2);
  color: #f0c040;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.9rem;
}

.user-badge.hidden {
  display: none;
}

.auth-btn, .logout-btn, .back-btn, .center-btn,
.primary-btn, #submitLogin, #submitRegister,
#sendMsg, #adminSendMsg {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  transition: transform 0.15s, background 0.2s;
}

.auth-btn {
  background: #2a3a5a;
  color: #e0e0e0;
  padding: 8px 14px;
}

.auth-btn:hover {
  background: #3a4a6b;
}

.auth-btn.hidden {
  display: none;
}

.logout-btn {
  background: #e94560;
  color: white;
  padding: 8px 16px;
}

.logout-btn:hover {
  background: #c73a52;
}

.main-page {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 80px 20px 40px;
  gap: 28px;
  overflow: hidden;
}

.images-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.images-layer img {
  position: absolute;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  max-width: 90vw;
}

.announcement {
  position: relative;
  z-index: 2;
  max-width: 560px;
  text-align: center;
  font-size: 1.1rem;
  line-height: 1.5;
  color: #f0c040;
  background: rgba(240, 192, 64, 0.12);
  border: 1px solid rgba(240, 192, 64, 0.35);
  border-radius: 12px;
  padding: 14px 22px;
  display: none;
}

.announcement.visible {
  display: block;
}

.center-btn {
  position: relative;
  z-index: 2;
  background: linear-gradient(135deg, #e94560, #c73a52);
  color: white;
  padding: 18px 48px;
  font-size: 1.2rem;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(233, 69, 96, 0.4);
}

.center-btn:hover {
  transform: scale(1.05);
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 200;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: #1f2a44;
  padding: 26px 30px;
  border-radius: 14px;
  width: 90%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.modal-content h2 {
  text-align: center;
  margin-bottom: 4px;
}

.modal-content input {
  padding: 11px 13px;
  border-radius: 8px;
  border: 1px solid #3a4a6b;
  background: #16213e;
  color: #e0e0e0;
  font-size: 1rem;
}

.modal-content input:focus {
  outline: none;
  border-color: #e94560;
}

#submitLogin, #submitRegister {
  background: #e94560;
  color: white;
  padding: 11px;
  font-weight: 600;
}

#submitLogin:hover, #submitRegister:hover {
  background: #c73a52;
}

.close-modal {
  background: transparent;
  color: #aaa;
  border: 1px solid #555;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
}

.close-modal:hover {
  color: #fff;
  border-color: #888;
}

.error {
  color: #ff6b6b;
  font-size: 0.9rem;
  text-align: center;
}

.error.hidden {
  display: none;
}

/* Chat */
.chat-view, .admin-panel {
  position: fixed;
  inset: 0;
  background: #0f1628;
  z-index: 50;
  display: flex;
  flex-direction: column;
}

.chat-view.hidden, .admin-panel.hidden {
  display: none;
}

.chat-header, .admin-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  background: rgba(0, 0, 0, 0.45);
  border-bottom: 1px solid #2a3a5a;
}

.chat-header h2, .chat-header h3, .admin-header h2 {
  flex: 1;
  font-size: 1.1rem;
}

.chat-user-name {
  font-size: 0.9rem;
  color: #f0c040;
  background: rgba(240, 192, 64, 0.15);
  padding: 4px 10px;
  border-radius: 12px;
}

.back-btn {
  background: #2a3a5a;
  color: #e0e0e0;
  padding: 7px 12px;
}

.back-btn:hover {
  background: #3a4a6b;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 12px;
  line-height: 1.4;
  word-break: break-word;
}

.message.user {
  align-self: flex-end;
  background: #e94560;
  color: white;
  border-bottom-right-radius: 4px;
}

.message.admin {
  align-self: flex-start;
  background: #2a3a5a;
  border-bottom-left-radius: 4px;
}

.message .meta {
  font-size: 0.75rem;
  opacity: 0.75;
  margin-bottom: 3px;
}

.chat-input-area {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.4);
  border-top: 1px solid #2a3a5a;
}

.chat-input-area input {
  flex: 1;
  padding: 11px 13px;
  border-radius: 8px;
  border: 1px solid #3a4a6b;
  background: #16213e;
  color: #e0e0e0;
  font-size: 1rem;
}

.chat-input-area input:focus {
  outline: none;
  border-color: #e94560;
}

#sendMsg, #adminSendMsg {
  background: #e94560;
  color: white;
  padding: 0 18px;
  font-weight: 600;
}

#sendMsg:hover, #adminSendMsg:hover {
  background: #c73a52;
}

/* Admin */
.admin-panel {
  overflow-y: auto;
  padding-top: 60px;
}

.admin-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
}

.admin-body {
  max-width: 780px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

.admin-section {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 20px;
}

.admin-section h3 {
  margin-bottom: 12px;
  color: #f0c040;
}

#announceText, #imgUrl {
  width: 100%;
  padding: 11px;
  border-radius: 8px;
  border: 1px solid #3a4a6b;
  background: #16213e;
  color: #e0e0e0;
  font-size: 1rem;
  margin-bottom: 10px;
  resize: vertical;
}

.primary-btn {
  background: #f0c040;
  color: #1a1a2e;
  padding: 9px 18px;
  font-weight: 600;
}

.primary-btn:hover {
  background: #e0b030;
}

.image-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.pos-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.pos-row label {
  font-size: 0.9rem;
  opacity: 0.85;
}

.pos-row select, .pos-row input[type="number"] {
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #3a4a6b;
  background: #16213e;
  color: #e0e0e0;
}

.custom-coords {
  display: flex;
  gap: 10px;
}

.custom-coords.hidden {
  display: none;
}

.custom-coords input {
  width: 90px;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #3a4a6b;
  background: #16213e;
  color: #e0e0e0;
}

.preview-box {
  margin: 16px 0;
}

.preview-label {
  font-size: 0.9rem;
  opacity: 0.8;
  margin-bottom: 8px;
}

.preview-main {
  position: relative;
  height: 220px;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border: 1px solid #3a4a6b;
  border-radius: 10px;
  overflow: hidden;
}

.preview-main .images-layer img {
  max-height: 80px;
}

.preview-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #e94560;
  color: white;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.85rem;
  z-index: 2;
}

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

.img-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #1f2a44;
  padding: 10px 12px;
  border-radius: 8px;
}

.img-item img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
}

.img-item .info {
  flex: 1;
  font-size: 0.85rem;
  opacity: 0.9;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.img-item .remove-btn {
  background: #e94560;
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
}

.img-item .remove-btn:hover {
  background: #c73a52;
}

.user-chats-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-item {
  background: #1f2a44;
  padding: 12px 14px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.15s;
}

.chat-item:hover {
  background: #2a3a5a;
}

.chat-item .preview {
  font-size: 0.88rem;
  opacity: 0.75;
  max-width: 55%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-item .time {
  font-size: 0.8rem;
  opacity: 0.6;
}

.empty-chats {
  text-align: center;
  opacity: 0.6;
  padding: 24px;
}

.admin-chat-view {
  position: fixed;
  inset: 0;
  background: #0f1628;
  z-index: 70;
  display: flex;
  flex-direction: column;
}

.admin-chat-view.hidden {
  display: none;
}
