/* =========================================================
   1. BIẾN TOÀN CỤC & RESET CƠ BẢN
   ========================================================= */
:root {
  --night: #050b1f;
  --deep: #0a1f44;
  --glow: #8fe3f0;
  --mist: #cfe6f5;
  --paper: #f3e8cf;
  --ink: #2a2018;
  --heart: #d9485f;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  max-width: 100vw;
  margin: 0;
  overscroll-behavior: none;
  overflow-x: hidden;
}

body {
  background: var(--night);
  color: var(--mist);
  font-family: "Lora", Georgia, serif;
  overflow: hidden;
  /* Ngăn cuộn toàn trang */
}

/* =========================================================
   2. BỐ CỤC CHÍNH & THANH CÔNG CỤ
   ========================================================= */
#sea {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  transform: translateZ(0);
  will-change: transform;
}

.ui {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: max(28px, env(safe-area-inset-top)) 20px max(30px, env(safe-area-inset-bottom));
  pointer-events: none;
  z-index: 10;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.ui>* {
  pointer-events: auto;
}

h1 {
  font-weight: 500;
  font-size: clamp(2rem, 5vw, 3.3rem);
  margin: 0;
  text-align: center;
  text-shadow: 0 0 30px rgba(143, 227, 240, .35);
}

.sub {
  margin: .35rem 0 0;
  font-size: 1.25rem;
  opacity: .75;
  text-align: center;
}

.actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  width: 100%;
  max-width: 480px;
  padding: 0 15px;
}

.action-item {
  flex: 1;
  display: flex;
}

.action-item .btn {
  width: 100%;
  white-space: nowrap;
  padding: 13px 10px;
  font-size: 1.1rem;
}

.btn {
  font: 600 1.2rem "Lora", Georgia, serif;
  color: var(--mist);
  cursor: pointer;
  border-radius: 999px;
  border: 1px solid rgba(143, 227, 240, .45);
  background: rgba(10, 31, 68, .55);
  backdrop-filter: blur(8px);
  transition: background .25s, box-shadow .25s, opacity .25s;
}

.btn:hover:not(:disabled) {
  background: rgba(143, 227, 240, .2);
  box-shadow: 0 0 24px rgba(143, 227, 240, .3);
}

.btn.primary {
  background: rgba(143, 227, 240, .16);
}

.btn:disabled {
  opacity: .4;
  cursor: default;
}

/* Trạng thái thiết bị bị khóa (banned device) */
.btn.banned-locked,
.icon-btn.banned-locked,
body.device-banned button:not(#supportBtn):not(#closeMyBottlesBtn),
body.device-banned .btn,
body.device-banned .icon-btn:not(#supportBtn),
body.device-banned .paper-btn,
body.device-banned [role="button"]:not(#supportBtn) {
  opacity: .45 !important;
  cursor: not-allowed !important;
  filter: grayscale(100%) !important;
  box-shadow: none !important;
  transform: none !important;
}

.btn.banned-locked:hover,
.icon-btn.banned-locked:hover,
body.device-banned button:not(#supportBtn):not(#closeMyBottlesBtn):hover,
body.device-banned .btn:hover,
body.device-banned .icon-btn:not(#supportBtn):hover,
body.device-banned .paper-btn:hover,
body.device-banned [role="button"]:not(#supportBtn):hover {
  background: rgba(10, 31, 68, .55) !important;
  box-shadow: none !important;
  transform: none !important;
}

/* Đảm bảo nút Hỗ trợ (#supportBtn) và toàn bộ nút/ô nhập trong Hỗ trợ & Ticket của tôi sáng rõ 100% */
body.device-banned #supportBtn,
body.device-banned #supportOverlay button,
body.device-banned #supportOverlay .btn,
body.device-banned #supportOverlay .icon-btn,
body.device-banned #supportOverlay [role="button"],
body.device-banned #appealOverlay button,
body.device-banned #appealOverlay .btn,
body.device-banned #appealOverlay .icon-btn,
body.device-banned #appealOverlay [role="button"],
body.device-banned #bannedFloatingNotice,
body.device-banned #bannedFloatingNotice button,
body.device-banned #myBottlesOverlay .tab-btn[data-tab="my-support"],
body.device-banned #myBottlesOverlay .user-ticket-card button,
body.device-banned #myBottlesOverlay .user-ticket-card .btn,
body.device-banned #myBottlesOverlay #closeMyBottlesBtn {
  opacity: 1 !important;
  filter: none !important;
  pointer-events: auto !important;
  cursor: pointer !important;
}

body.device-banned #supportOverlay #submitSupportTicketBtn,
body.device-banned #supportOverlay #submitSupportTicketBtn:hover {
  background: linear-gradient(135deg, #6366f1, #3b82f6) !important;
  color: #fff !important;
  opacity: 1 !important;
  filter: none !important;
  pointer-events: auto !important;
  cursor: pointer !important;
}

body.device-banned #supportOverlay #viewMySupportTicketsBtn,
body.device-banned #supportOverlay #viewMySupportTicketsBtn:hover {
  background: rgba(255, 255, 255, 0.08) !important;
  color: #cbd5e1 !important;
  opacity: 1 !important;
  filter: none !important;
  pointer-events: auto !important;
  cursor: pointer !important;
}

body.device-banned #supportOverlay #closeSupportBtn,
body.device-banned #supportOverlay #closeSupportBtn:hover,
body.device-banned #supportOverlay #confirmCloseSupportBtn,
body.device-banned #supportOverlay #confirmCloseSupportBtn:hover {
  background: rgba(255, 255, 255, 0.12) !important;
  color: #fff !important;
  opacity: 1 !important;
  filter: none !important;
  pointer-events: auto !important;
  cursor: pointer !important;
}

body.device-banned #supportOverlay input,
body.device-banned #supportOverlay select,
body.device-banned #supportOverlay textarea,
body.device-banned #appealOverlay textarea,
body.device-banned #myBottlesOverlay .user-ticket-card input {
  opacity: 1 !important;
  filter: none !important;
  pointer-events: auto !important;
}

#bannedFloatingNotice {
  position: fixed;
  top: max(70px, calc(env(safe-area-inset-top) + 60px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 45;
  display: none;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(127, 29, 29, 0.88);
  border: 1px solid rgba(248, 113, 113, 0.45);
  backdrop-filter: blur(10px);
  color: #fee2e2;
  font-size: 0.82rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  max-width: calc(100vw - 24px);
}

.banned-floating-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.banned-appeal-trigger {
  flex-shrink: 0;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid rgba(251, 191, 36, 0.55);
  background: rgba(245, 158, 11, 0.28);
  color: #fef3c7;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.banned-appeal-trigger:hover {
  background: rgba(245, 158, 11, 0.45);
}

body.device-banned #appealOverlay #submitAppealBtn,
body.device-banned #appealOverlay #submitAppealBtn:hover {
  background: linear-gradient(135deg, #f59e0b, #d97706) !important;
  color: #fff !important;
  opacity: 1 !important;
  filter: none !important;
  pointer-events: auto !important;
  cursor: pointer !important;
}

body.device-banned #supportOverlay #openAppealFromSupportBtn,
body.device-banned #supportOverlay #openAppealFromSupportBtn:hover {
  background: rgba(245, 158, 11, 0.22) !important;
  color: #fde68a !important;
  opacity: 1 !important;
  filter: none !important;
  pointer-events: auto !important;
  cursor: pointer !important;
}

:focus-visible {
  outline: 2px solid var(--glow);
  outline-offset: 3px;
}

/* Thanh công cụ (Top Nav Bar) & Dòng đếm chai */
.top-nav-bar {
  position: fixed;
  top: max(20px, env(safe-area-inset-top));
  right: 20px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  pointer-events: none;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.top-bar {
  position: static;
  display: flex;
  align-items: center;
  pointer-events: none;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.top-nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}

.top-nav-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-nav-actions .icon-btn {
  position: relative !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  overflow: visible !important;
}

.drift {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 16px;
  background: rgba(10, 31, 68, 0.65);
  border: 1px solid rgba(143, 227, 240, 0.35);
  border-radius: 999px;
  backdrop-filter: blur(6px);
  font-size: 0.95rem;
  color: var(--mist);
  opacity: 0.95;
  white-space: nowrap;
  pointer-events: auto;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 !important;
  margin: 0 !important;
  line-height: 1 !important;
  text-align: center !important;
  box-sizing: border-box !important;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(143, 227, 240, 0.3);
  background: rgba(10, 31, 68, 0.65);
  color: var(--mist);
  font-size: 1.15rem;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background 0.2s, transform 0.2s;
  overflow: hidden;
  position: fixed;
  top: max(20px, env(safe-area-inset-top));
  z-index: 10;
}

body.lucky-claimed .lucky-btn,
body.device-banned .lucky-btn,
.lucky-btn[style*="display: none"],
.lucky-btn[style*="display:none"] {
  display: none !important;
}

body.lucky-claimed .lucky-banner,
body.device-banned .lucky-banner,
.lucky-banner[style*="display: none"],
.lucky-banner[style*="display:none"] {
  display: none !important;
}

.icon-btn:hover {
  background: rgba(143, 227, 240, 0.25);
  transform: translateY(-1px);
}

.support-btn {
  right: 20px;
  font-size: 1.15rem !important;
}

.music-btn {
  right: 66px;
  font-size: 1.15rem !important;
}

.leaderboard-btn {
  right: 112px;
}

.my-bottles-btn {
  right: 158px;
  overflow: visible !important;
}

.vault-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #0284c7;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  z-index: 10;
  pointer-events: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  border: 1.5px solid #0a1f44;
}

.vault-badge[style*="display: none"],
.vault-badge[style*="display:none"] {
  display: none !important;
}

.vault-header-counts {
  font-size: 0.82rem;
  font-weight: normal;
  opacity: 0.85;
  margin-left: 6px;
  color: var(--glow);
  white-space: nowrap;
}

.tab-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 999px;
  background: rgba(143, 227, 240, 0.16);
  color: var(--glow);
  border: 1px solid rgba(143, 227, 240, 0.3);
  margin-left: 5px;
  line-height: 1;
  vertical-align: middle;
}

.tab-btn.active .tab-count-badge {
  background: var(--glow);
  color: #07172c;
  border-color: var(--glow);
}

.pinned-btn {
  right: 204px;
  border-color: rgba(255, 209, 102, 0.5) !important;
  background: rgba(255, 209, 102, 0.12) !important;
}

.pinned-btn:hover {
  background: rgba(255, 209, 102, 0.28) !important;
  box-shadow: 0 0 12px rgba(255, 209, 102, 0.4);
}

.lucky-btn {
  right: 250px;
  border-color: rgba(255, 215, 0, 0.6) !important;
  background: rgba(255, 215, 0, 0.15) !important;
  animation: pulse-lucky 3s ease-in-out infinite;
}

.lucky-btn:hover {
  background: rgba(255, 215, 0, 0.3) !important;
}

/* Nút Chat chung và Badge tin chưa đọc */
.chat-btn,
#chatBtn {
  right: 296px;
  border-color: rgba(56, 189, 248, 0.5) !important;
  background: rgba(56, 189, 248, 0.12) !important;
  position: fixed;
  top: 20px;
  z-index: 10;
  overflow: visible !important;
}

.chat-btn:hover,
#chatBtn:hover {
  background: rgba(56, 189, 248, 0.28) !important;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.45);
}

.chat-badge,
#chatUnreadBadge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ef4444;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  z-index: 10;
  pointer-events: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  border: 1.5px solid #0a1f44;
}

.chat-badge[style*="display: none"],
.chat-badge[style*="display:none"],
#chatUnreadBadge[style*="display: none"],
#chatUnreadBadge[style*="display:none"] {
  display: none !important;
}

/* =========================================================
   GIAO DIỆN KHUNG CHAT CHUNG BIỂN CẢ
   ========================================================= */
#chatOverlay {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 12px;
  overflow-x: hidden;
  box-sizing: border-box;
  background: rgba(3, 8, 24, .72);
  backdrop-filter: blur(6px);
}

#chatOverlay.open {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  animation: fade .3s both;
}

#chatOverlay,
#chatOverlay * {
  box-sizing: border-box;
}

.chat-dialog {
  width: 100%;
  max-width: 480px;
  min-width: 0;
  margin: 0 auto;
  height: 80vh;
  height: 80dvh;
  max-height: 640px;
  display: flex;
  flex-direction: column;
  padding: 16px 18px 14px;
  box-sizing: border-box;
  overflow-x: hidden;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  gap: 12px;
  flex-shrink: 0;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.chat-title {
  margin: 0;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--glow);
}

.chat-subtitle {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-user-pill {
  font-size: 0.78rem;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(143, 227, 240, 0.12);
  border: 1px solid rgba(143, 227, 240, 0.3);
  color: var(--glow);
  font-weight: 600;
}

.close-chat-btn {
  position: static !important;
  width: 32px !important;
  height: 32px !important;
  font-size: 0.95rem !important;
  flex-shrink: 0;
}

.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  padding: 6px 4px 6px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(143, 227, 240, 0.25) transparent;
}

.chat-messages::-webkit-scrollbar {
  width: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(143, 227, 240, 0.25);
  border-radius: 4px;
}

.chat-loading-placeholder,
.chat-empty-placeholder {
  text-align: center;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.88rem;
  padding: 40px 10px;
  font-style: italic;
}

.chat-msg {
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: background 0.2s;
  box-sizing: border-box;
}

.chat-msg:hover {
  background: rgba(255, 255, 255, 0.08);
}

.chat-msg.my-msg {
  background: rgba(56, 189, 248, 0.09);
  border-color: rgba(56, 189, 248, 0.28);
}

.chat-msg.admin-msg {
  background: linear-gradient(135deg, rgba(255, 170, 0, 0.16), rgba(255, 71, 87, 0.12));
  border: 1.5px solid rgba(255, 170, 0, 0.6);
  box-shadow: 0 0 16px rgba(255, 170, 0, 0.25);
}

.chat-msg-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  opacity: 0.85;
}

.admin-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: linear-gradient(135deg, #ffd166, #ff9f43);
  color: #3d2000;
  font-weight: 800;
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 6px rgba(255, 159, 67, 0.4);
}

.chat-sender-name {
  font-weight: 600;
  color: var(--glow);
}

.chat-msg.my-msg .chat-sender-name {
  color: #7dd3fc;
}

.chat-msg.admin-msg .chat-sender-name {
  color: #ffd166;
}

.me-tag {
  font-weight: 400;
  font-size: 0.74rem;
  opacity: 0.75;
}

.chat-msg-time {
  margin-left: auto;
  font-size: 0.7rem;
  opacity: 0.6;
}

.chat-msg-body {
  font-size: 0.92rem;
  line-height: 1.45;
  color: #f1f5f9;
  word-break: break-word;
  white-space: pre-wrap;
}

.chat-input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  width: 100%;
  flex-shrink: 0;
  box-sizing: border-box;
}

.chat-input-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
}

.chat-input-wrap input {
  width: 100%;
  min-width: 0;
  flex: 1;
  padding: 10px 48px 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(143, 227, 240, 0.3);
  background: rgba(10, 31, 68, 0.65);
  color: var(--mist);
  font-family: inherit;
  font-size: 16px !important; /* Chống auto-zoom trên iOS Safari */
  line-height: 1.35;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-input-wrap input:focus {
  border-color: var(--glow);
  box-shadow: 0 0 10px rgba(143, 227, 240, 0.3);
}

.chat-char-counter {
  position: static !important;
  align-self: flex-end;
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.55);
  pointer-events: none;
  user-select: none;
  line-height: 1;
  padding-top: 2px;
}

.chat-char-counter.warn {
  color: #ff6b6b;
  opacity: 0.95;
  font-weight: 700;
}

.chat-send-btn {
  flex-shrink: 0 !important;
  width: auto !important;
  white-space: nowrap !important;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid rgba(56, 189, 248, 0.5);
  background: linear-gradient(135deg, #0284c7, #0ea5e9);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.35);
  transition: transform 0.15s, opacity 0.15s;
}

.chat-send-btn:hover {
  background: linear-gradient(135deg, #0369a1, #0284c7);
  box-shadow: 0 4px 14px rgba(14, 165, 233, 0.5);
}

.chat-send-btn:active {
  transform: scale(0.97);
}

.chat-send-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* Làm mờ các nút công cụ nền và thanh điều khiển dưới biển khi đang mở lá thư */
body.reading-letter .top-nav-bar,
body.reading-letter .ui {
  opacity: 0.12;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

body.reading-letter .stage {
  pointer-events: auto;
  cursor: pointer;
}

body.reading-letter .stage .card {
  cursor: default;
}

/* =========================================================
   3. LÁ THƯ (CARD)
   ========================================================= */
.stage {
  position: fixed;
  inset: 0;
  height: 100vh;
  height: 100dvh;
  display: grid;
  place-items: center;
  padding: 20px;
  pointer-events: none;
  z-index: 15;
}

.card {
  display: none;
  flex-direction: column;
  position: relative;
  pointer-events: auto;
  width: min(92vw, 480px);
  padding: 24px 28px 18px;
  color: var(--ink);
  border-radius: 3px 7px 4px 8px;
  transform: rotate(-1.6deg);
  transform-origin: center center;
  background: linear-gradient(160deg, #f7edd6, var(--paper) 55%, #e9dab8);
  box-shadow: 0 30px 60px rgba(0, 0, 0, .55), inset 0 0 60px rgba(150, 110, 50, .22);
  max-height: 88vh;
  max-height: 88dvh;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  margin-bottom: 20px;
  scrollbar-width: thin;
  scrollbar-color: rgba(42, 32, 24, 0.25) transparent;
}

.card::-webkit-scrollbar {
  width: 5px;
}

.card::-webkit-scrollbar-track {
  background: transparent;
}

.card::-webkit-scrollbar-thumb {
  background: rgba(42, 32, 24, 0.25);
  border-radius: 4px;
}

.card::-webkit-scrollbar-thumb:hover {
  background: rgba(42, 32, 24, 0.45);
}

.card.show {
  display: flex !important;
  flex-direction: column !important;
  animation: reveal .8s cubic-bezier(.2, .8, .2, 1) both;
}

/* Hiệu ứng rời đi */
.card.leave {
  display: flex !important;
  flex-direction: column !important;
  pointer-events: none !important;
  animation: cardLeave .6s cubic-bezier(.35, 0, .2, 1) forwards;
  will-change: transform, opacity;
}

.card>.from,
.card>.foot {
  flex-shrink: 0;
}

/* VÙNG CUỘN NỘI DUNG THƯ */
.card>.letter {
  flex-shrink: 0;
  max-height: 40vh;
  max-height: 40dvh;
  overflow-y: auto;
  overflow-x: hidden;
  margin-bottom: 10px;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(42, 32, 24, 0.25) transparent;
}

.card>.letter::-webkit-scrollbar {
  width: 4px;
}

.card>.letter::-webkit-scrollbar-thumb {
  background: rgba(42, 32, 24, 0.2);
  border-radius: 4px;
}

.card>.foot {
  background: transparent !important;
  backdrop-filter: none !important;
  border: none !important;
  border-top: none !important;
  box-shadow: none !important;
  padding: 10px 0 0;
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  flex-shrink: 0;
}

.close-card-btn {
  padding: 2px 8px !important;
  font-size: 0.9rem !important;
  line-height: 1.2 !important;
  min-width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 6px;
  opacity: 0.8;
  transition: opacity 0.2s, background 0.2s;
}

.close-card-btn:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.08);
}

.card>.foot>div,
.card>.foot>span {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  width: 100%;
}

.from {
  font: italic 1.1rem "EB Garamond", Georgia, serif;
  opacity: .65;
  margin: 0 0 6px;
}

/* Định dạng chữ viết */
.letter {
  font: 1.3rem/32px "EB Garamond", Georgia, serif;
  overflow-wrap: anywhere;
  min-height: 96px;
  margin: 0;
  background: linear-gradient(transparent 30px, rgba(120, 90, 50, .16) 31px);
  background-size: 100% 32px;
}

/* Phần trả lời (Replies) */
.replies {
  margin: 10px 0;
  padding: 10px;
  background: rgba(255, 255, 255, .3);
  border-radius: 8px;
  border: 1px dashed rgba(42, 32, 24, .2);
}

.reply-title {
  margin: 0 0 6px;
  font-weight: 600;
  font-size: .95rem;
  opacity: .8;
}

#replyList {
  max-height: 210px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(42, 32, 24, 0.25) transparent;
}

#replyList::-webkit-scrollbar {
  width: 4px;
}

#replyList::-webkit-scrollbar-track {
  background: transparent;
}

#replyList::-webkit-scrollbar-thumb {
  background: rgba(42, 32, 24, 0.2);
  border-radius: 4px;
}

#replyList::-webkit-scrollbar-thumb:hover {
  background: rgba(42, 32, 24, 0.4);
}

#replyList > div,
.reply-item,
.reply-text {
  font-size: 1rem;
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(42, 32, 24, .1);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

#replyList > div:last-child,
.reply-item:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

/* Nút thao tác trên từng bình luận / phản hồi */
.reply-item-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  margin-left: 6px;
}

.reply-report-btn {
  background: transparent;
  border: none;
  color: rgba(42, 32, 24, 0.45);
  cursor: pointer;
  padding: 1px 4px;
  font-size: 0.8rem;
  border-radius: 4px;
  line-height: 1;
  transition: all 0.2s ease;
  opacity: 0.65;
}

.reply-report-btn:hover {
  opacity: 1;
  color: #dc2626;
  background: rgba(220, 38, 38, 0.08);
  transform: scale(1.15);
}

.reply-report-btn.is-reported {
  color: #d97706;
  opacity: 0.75;
  cursor: default;
}

.reply-form {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.reply-form input {
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(42, 32, 24, .3);
  background: rgba(255, 255, 255, .4);
  font-family: inherit;
  font-size: 16px;
  line-height: 1.35;
  box-sizing: border-box;
}

.reply-form input::placeholder {
  color: rgba(42, 32, 24, .55);
  font-size: 16px;
}

/* Định dạng Nút bấm */
.count {
  font-size: 1.15rem;
  margin-right: 5px;
}

.paper-btn {
  font: 600 1.05rem "Lora", Georgia, serif;
  color: var(--ink);
  cursor: pointer;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid rgba(42, 32, 24, .4);
  background: rgba(255, 255, 255, 0.2);
  transition: background .2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.paper-btn:hover {
  background: rgba(42, 32, 24, .1);
}

.paper-btn.like:hover {
  background: rgba(217, 72, 95, .15);
}

.paper-btn:focus-visible {
  outline-color: var(--ink);
}

.paper-btn.report {
  font-size: .95rem;
  opacity: .6;
  padding: 6px 12px;
}

.paper-btn.report:hover {
  opacity: 1;
  background: rgba(200, 60, 60, .12);
}

.paper-btn.report:disabled {
  opacity: .3;
  cursor: default;
}

.fh {
  position: absolute;
  bottom: 34px;
  left: var(--x);
  font-size: 1.4rem;
  pointer-events: none;
  animation: floatup 1.5s ease-out forwards;
}

.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin: 0 0 10px 0;
  gap: 12px;
}

.card-header-row .from {
  margin: 0;
  font-size: 1.15rem;
  font-style: italic;
  opacity: 0.85;
  color: var(--ink);
  white-space: nowrap;
}

.card-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

#countdownTimer {
  position: static !important;
  font-size: 0.82rem;
  font-family: 'Lora', Georgia, serif;
  color: var(--ink);
  background: rgba(42, 32, 24, 0.08);
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid rgba(42, 32, 24, 0.2);
  font-weight: 600;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
}

/* =========================================================
   CHAI MAY MẮN (LUCKY BOTTLE)
   ========================================================= */
.controls-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 480px;
  pointer-events: none;
}

.controls-group>* {
  pointer-events: auto;
}

.lucky-banner {
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  pointer-events: auto;
  z-index: 10;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.lucky-btn-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
  white-space: nowrap;
  gap: 8px;
  max-width: 100%;
  box-sizing: border-box;
  padding: 8px 20px;
  border-radius: 999px;
  border: 1px solid rgba(255, 215, 0, 0.6);
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.22), rgba(201, 120, 90, 0.3));
  color: #fffaf0;
  font: 600 0.95rem "Lora", Georgia, serif;
  cursor: pointer;
  backdrop-filter: blur(8px);
  box-shadow: 0 0 18px rgba(255, 215, 0, 0.3);
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s, opacity 0.2s;
  animation: pulse-lucky 3s ease-in-out infinite;
}

.lucky-btn-pill .lucky-sparkle {
  flex-shrink: 0;
  line-height: 1;
}

.lucky-btn-pill .lucky-text {
  white-space: nowrap;
}

.lucky-btn-pill:hover:not(:disabled) {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 0 28px rgba(255, 215, 0, 0.5);
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.32), rgba(201, 120, 90, 0.42));
}

.lucky-btn-pill:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
}

.lucky-btn-pill .lucky-badge {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 12px;
  background: rgba(255, 215, 0, 0.3);
  border: 1px solid rgba(255, 215, 0, 0.7);
  color: #ffd700;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

.lucky-btn-pill.claimed {
  border-color: rgba(143, 227, 240, 0.35);
  background: rgba(10, 31, 68, 0.55);
  box-shadow: none;
  animation: none;
  color: var(--mist);
  opacity: 0.8;
}

.lucky-btn-pill.claimed .lucky-badge {
  background: rgba(143, 227, 240, 0.15);
  border-color: rgba(143, 227, 240, 0.35);
  color: var(--glow);
}

@keyframes pulse-lucky {

  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.35);
  }

  50% {
    transform: scale(1.025);
    box-shadow: 0 0 18px rgba(255, 215, 0, 0.65);
  }
}

/* Giao diện Thẻ Chai May Mắn */
.card.lucky {
  border: 2.5px solid #ffd700 !important;
  box-shadow: 0 0 40px rgba(255, 215, 0, 0.45), 0 30px 60px rgba(0, 0, 0, 0.65) !important;
  background: linear-gradient(160deg, #fffcf5, #fcf3dd 55%, #f6e2b5) !important;
}

.lucky-ribbon,
.pinned-ribbon {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 12px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.lucky-ribbon span,
.pinned-ribbon span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
  white-space: nowrap;
  gap: 6px;
  max-width: 100%;
  box-sizing: border-box;
  text-align: center;
  font-weight: 700;
  border-radius: 999px;
  line-height: 1.25;
}

.lucky-ribbon span {
  background: linear-gradient(135deg, #ffd700, #ff9f43);
  color: #3d2000;
  font-size: 0.85rem;
  padding: 4px 16px;
  letter-spacing: 0.5px;
  box-shadow: 0 3px 10px rgba(255, 215, 0, 0.45);
  animation: bounce-lucky 1.2s ease-in-out infinite alternate;
}

@keyframes bounce-lucky {
  0% {
    transform: translateY(0);
  }

  100% {
    transform: translateY(-3px);
  }
}

/* Giao diện Thẻ Chai Được Ghim & Ribbon */
.card.pinned {
  border: 2px solid #ffd166 !important;
  box-shadow: 0 0 32px rgba(255, 209, 102, 0.4), 0 30px 60px rgba(0, 0, 0, 0.65) !important;
}

.pinned-ribbon span {
  background: linear-gradient(135deg, #ffd166, #ff9f43);
  color: #3d2000;
  font-size: 0.85rem;
  padding: 4px 16px;
  letter-spacing: 0.5px;
  box-shadow: 0 3px 10px rgba(255, 170, 0, 0.4);
}

.ribbon-icon {
  flex-shrink: 0;
  display: inline-block;
  line-height: 1;
}

.pinned-bottle-item {
  background: rgba(255, 255, 255, 0.08);
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid rgba(255, 209, 102, 0.3);
  cursor: pointer;
  transition: transform 0.2s, background 0.2s, border-color 0.2s;
  position: relative;
}

.pinned-bottle-item:hover {
  background: rgba(255, 209, 102, 0.12);
  border-color: rgba(255, 209, 102, 0.65);
  transform: translateY(-2px);
}

.pinned-bottle-item .pinned-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 209, 102, 0.2);
  color: #ffd166;
  border: 1px solid rgba(255, 209, 102, 0.5);
  margin-bottom: 8px;
}

.pinned-bottle-item .text {
  font-family: "EB Garamond", Georgia, serif;
  font-size: 1.15rem;
  line-height: 1.5;
  margin: 4px 0 10px;
  color: var(--mist);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.pinned-bottle-item .meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--glow);
  opacity: 0.9;
}

.pinned-bottle-item .read-btn {
  background: rgba(255, 209, 102, 0.2);
  border: 1px solid rgba(255, 209, 102, 0.5);
  color: #ffd166;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
}

.pinned-bottle-item .read-btn:hover {
  background: rgba(255, 209, 102, 0.35);
  transform: scale(1.05);
}

/* Canvas Pháo hoa */
#fireworksCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 99;
  display: none;
}

/* =========================================================
   4. OVERLAY, DIALOG & FORM
   ========================================================= */
.overlay {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(3, 8, 24, .72);
  backdrop-filter: blur(6px);
  overflow: hidden;
  box-sizing: border-box;
}

.overlay.open {
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade .3s both;
}

.dialog {
  width: 100%;
  max-width: min(calc(100vw - 24px), 480px);
  max-height: calc(100dvh - 24px);
  padding: 22px 20px;
  border-radius: 14px;
  background: rgba(10, 31, 68, .96);
  border: 1px solid rgba(143, 227, 240, .3);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
}

.dialog h2 {
  margin: 0 0 4px;
  font-weight: 600;
  font-size: 1.7rem;
}

.dialog p {
  margin: 0 0 14px;
  opacity: .7;
  font-size: 1.15rem;
}

/* Badge hạn mức thả chai mỗi ngày */
.daily-quota-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.84rem;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(143, 227, 240, 0.08);
  border: 1px solid rgba(143, 227, 240, 0.28);
  color: var(--mist);
  margin-top: -4px;
  margin-bottom: 12px;
  width: fit-content;
  max-width: 100%;
  transition: all 0.25s ease;
}

.daily-quota-badge.limit-reached {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.38);
  color: #fca5a5;
}

.daily-quota-badge.limit-warn {
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.38);
  color: #fcd34d;
}

.daily-quota-badge.limit-unlimited {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.35);
  color: #6ee7b7;
}

textarea {
  width: 100%;
  min-height: 140px;
  resize: none;
  padding: 12px 14px;
  border-radius: 10px;
  color: var(--mist);
  font: 16px/1.5 "EB Garamond", Georgia, serif;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(143, 227, 240, .3);
  box-sizing: border-box;
}

textarea::placeholder {
  color: rgba(207, 230, 245, .45);
  font-size: 16px;
}

.nickname-input {
  width: 100%;
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  color: var(--mist);
  font: 16px/1.4 "EB Garamond", Georgia, serif;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(143, 227, 240, .3);
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.nickname-input::placeholder {
  color: rgba(207, 230, 245, .45);
  font-size: 16px;
}

.nickname-input:focus {
  border-color: var(--glow);
  background: rgba(255, 255, 255, .1);
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.counter {
  font-size: 1.1rem;
  opacity: .75;
}

.counter.warn {
  color: #ffb88a;
  opacity: 1;
}

/* Giao diện modal Hỗ trợ & Hướng dẫn */
.support-dialog {
  width: 100%;
  max-width: min(calc(100vw - 24px), 480px);
  max-height: calc(100dvh - 24px);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
}

.support-section {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(143, 227, 240, 0.16);
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

#supportTopic {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  display: block;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

#supportTopic option {
  max-width: 100%;
  box-sizing: border-box;
  background: #0f172a;
  color: #fff;
  white-space: normal;
}

.support-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  width: 100%;
  box-sizing: border-box;
}

.support-actions .btn {
  flex: 1;
  font-size: 0.95rem;
  padding: 10px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-sizing: border-box;
  white-space: nowrap;
}

.contact-chat-btn {
  text-decoration: none;
  background: rgba(56, 189, 248, 0.18) !important;
  border: 1px solid rgba(56, 189, 248, 0.6) !important;
  color: #e0f2fe !important;
  gap: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.25s, box-shadow 0.25s, transform 0.15s, border-color 0.25s !important;
}

.contact-chat-btn:hover {
  background: rgba(56, 189, 248, 0.35) !important;
  border-color: #38bdf8 !important;
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.5) !important;
  transform: translateY(-1px);
  color: #ffffff !important;
}

.contact-chat-btn:active {
  transform: translateY(0);
}

/* Bảng xếp hạng */
.rank-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 15px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(143, 227, 240, .2);
  border-radius: 8px;
}

.rank-item.top1 {
  border-color: #ffd700;
  background: rgba(255, 215, 0, 0.1);
}

.rank-item.top2 {
  border-color: #c0c0c0;
  background: rgba(192, 192, 192, 0.1);
}

.rank-item.top3 {
  border-color: #cd7f32;
  background: rgba(205, 127, 50, 0.1);
}

.rank-item.is-me {
  border-color: var(--glow) !important;
  background: rgba(143, 227, 240, 0.14) !important;
  box-shadow: 0 0 10px rgba(143, 227, 240, 0.3) !important;
}

/* Loading */
.loading {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  place-items: center;
  background: rgba(5, 11, 31, .5);
  backdrop-filter: blur(4px);
}

.loading.show {
  display: grid;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(143, 227, 240, .2);
  border-top-color: var(--glow);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* =========================================================
   5. HIỆU ỨNG (LƯỚI, TOAST, CHAI BAY)
   ========================================================= */
.net {
  position: fixed;
  left: 50%;
  top: -72vh;
  height: 70vh;
  width: min(70vw, 280px);
  margin-left: calc(min(70vw, 280px)/-2);
  z-index: 4;
  pointer-events: none;
  transform-origin: top center;
}

.net svg {
  width: 100%;
  height: 100%;
}

.net.drop {
  animation: netdrop 2s ease-in-out both;
}

.net .cargo {
  animation: cargo 2s steps(1) both;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(110px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 30;
  max-width: 90vw;
  text-align: center;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 1.15rem;
  background: rgba(5, 11, 31, .85);
  border: 1px solid rgba(143, 227, 240, .3);
  opacity: 0;
  pointer-events: none;
  transition: opacity .4s;
}

.toast.show {
  opacity: 1;
}

/* Chai trôi trang trí */
.floaters {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
  transform: translateZ(0);
  contain: layout style;
}

.fb {
  position: absolute;
  left: 0;
  top: var(--top);
  width: var(--size);
  opacity: var(--o, .8);
  animation: sail var(--dur) linear var(--delay) infinite;
  filter: drop-shadow(0 0 6px rgba(143, 227, 240, .35));
  will-change: transform;
  transform: translateZ(0);
}

.fb.rev {
  animation-direction: reverse;
}

.fb svg {
  display: block;
  width: 100%;
  height: auto;
  rotate: var(--tilt, 75deg);
  animation: bob var(--bob) ease-in-out infinite;
}

/* Tabs trong Nhật ký */
.vault-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
  border-bottom: 1px solid rgba(143, 227, 240, .2);
  padding-bottom: 10px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--mist);
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
  opacity: 0.6;
  transition: 0.2s;
}

.tab-btn.active {
  opacity: 1;
  color: var(--glow);
  font-weight: bold;
  border-bottom: 2px solid var(--glow);
  padding-bottom: 8px;
}

/* Danh sách trong hộp Nhật ký */
.vault-list {
  max-height: 50vh;
  max-height: 50dvh;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.my-bottle-item {
  background: rgba(255, 255, 255, .1);
  padding: 12px;
  border-radius: 8px;
  border: 1px solid rgba(143, 227, 240, .2);
  position: relative;
}

.my-bottle-item .nickname-tag {
  display: inline-block;
  font-size: 0.85rem;
  color: var(--glow);
  font-style: italic;
  margin-bottom: 4px;
  opacity: 0.9;
}

.my-bottle-item .text {
  font-family: "EB Garamond", Georgia, serif;
  font-size: 1.1rem;
  line-height: 1.4;
  margin-bottom: 8px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.my-bottle-item .stats {
  font-size: 0.85rem;
  color: var(--glow);
  display: flex;
  gap: 12px;
  opacity: 0.9;
}

.my-bottle-item .stats span.highlight {
  color: #ffb88a;
  font-weight: bold;
}

.delete-btn:hover {
  color: #ff4d4d;
  transform: scale(1.1);
}

/* Nút Lưu / Bỏ lưu trong item Nhật ký */
.my-bottle-item .my-bottle-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  gap: 8px;
}

.save-bottle-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(143, 227, 240, 0.3);
  color: var(--glow);
  font-family: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  padding: 3px 8px;
  border-radius: 6px;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1.3;
}

.save-bottle-btn:hover {
  background: rgba(143, 227, 240, 0.16);
  border-color: var(--glow);
  transform: translateY(-1px);
}

.save-bottle-btn.is-saved {
  background: rgba(245, 158, 11, 0.18);
  border-color: rgba(245, 158, 11, 0.55);
  color: #fbbf24;
  font-weight: 600;
}

.save-bottle-btn.is-saved:hover {
  background: rgba(239, 68, 68, 0.16);
  border-color: rgba(239, 68, 68, 0.5);
  color: #f87171;
}

/* Nút Bookmark trên lá thư */
.bookmark-card-btn {
  font-size: 0.84rem;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(42, 32, 24, 0.25);
  background: rgba(42, 32, 24, 0.05);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  flex-shrink: 0;
}

.bookmark-card-btn:hover {
  background: rgba(42, 32, 24, 0.12);
  transform: translateY(-1px);
}

.bookmark-card-btn.is-saved,
.paper-btn.save-card-btn.is-saved {
  background: rgba(217, 119, 6, 0.18) !important;
  color: #b45309 !important;
  border-color: #d97706 !important;
  font-weight: 700 !important;
}

.bookmark-card-btn.is-saved:hover,
.paper-btn.save-card-btn.is-saved:hover {
  background: rgba(239, 68, 68, 0.15) !important;
  border-color: #ef4444 !important;
  color: #dc2626 !important;
}

/* =========================================================
   6. CSS CHO TÍNH NĂNG UPLOAD ẢNH
   ========================================================= */
.image-upload-box {
  margin-top: 15px;
  padding: 10px;
  border: 1px dashed rgba(143, 227, 240, .3);
  border-radius: 10px;
  background: rgba(255, 255, 255, .02);
}

.image-upload-box label {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 8px;
  color: var(--glow);
}

.image-upload-box input[type="file"] {
  font-size: 0.9rem;
  width: 100%;
}

#imagePreview {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}

#imagePreview img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid rgba(143, 227, 240, .3);
}

/* ĐÃ FIX KHOẢNG TRẮNG ẢNH VÀ CHỮ */
.letter-images-container {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 0px;
  margin-top: 5px;
  justify-content: center;
  width: 100%;
}

.letter-images-container img {
  border-radius: 8px;
  object-fit: cover;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  border: 4px solid #fff;
  background-color: #fff;
  display: block;
  margin: 5px auto;
  max-height: 220px;
}

.letter-images-container.single img {
  max-width: 100%;
  width: auto;
}

.letter-images-container.multiple img {
  width: calc(33.33% - 10px);
  height: 120px;
}

/* Hộp tick chọn yêu cầu ghim thư */
.pin-request-box {
  margin-top: 10px;
  padding: 8px 12px;
  background: rgba(255, 209, 102, 0.08);
  border: 1px solid rgba(255, 209, 102, 0.25);
  border-radius: 8px;
  display: flex;
  align-items: center;
  transition: background 0.2s, border-color 0.2s;
  box-sizing: border-box;
}

.pin-request-box:hover {
  background: rgba(255, 209, 102, 0.14);
  border-color: rgba(255, 209, 102, 0.45);
}

.pin-request-box.disabled {
  opacity: 0.6;
  cursor: not-allowed;
  border-color: rgba(255, 209, 102, 0.15);
  background: rgba(255, 209, 102, 0.04);
}

.pin-request-box.disabled:hover {
  background: rgba(255, 209, 102, 0.04);
  border-color: rgba(255, 209, 102, 0.15);
}

.pin-request-box.disabled .pin-request-label {
  cursor: not-allowed;
}

.pin-request-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  color: #ffd166;
  cursor: pointer;
  user-select: none;
  font-family: inherit;
  width: 100%;
}

.pin-request-label input[type="checkbox"] {
  accent-color: #ffd166;
  width: 16px;
  height: 16px;
  cursor: pointer;
  margin: 0;
  flex-shrink: 0;
}

.pin-request-label input[type="checkbox"]:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

#pickImageBtn:hover,
#captureImageBtn:hover {
  background: rgba(143, 227, 240, .25);
  border-color: var(--glow);
}

/* =========================================================
   7. THUYỀN VÀ CÁ TRÊN BIỂN (SEA LIFE)
   ========================================================= */
.sea-life {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
  transform: translateZ(0);
  contain: layout style;
}

.boat,
.fish {
  position: absolute;
  left: 0;
  top: var(--top);
  width: var(--size);
  opacity: var(--o, .8);
  animation: cruise var(--dur) linear var(--delay) infinite;
  will-change: transform;
  transform: translateZ(0);
}

.boat.rev,
.fish.rev {
  animation-direction: reverse;
}

.boat .flip,
.fish .flip {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
}

.boat.rev .flip,
.fish.rev .flip {
  transform: scaleX(-1);
}

.boat svg,
.fish svg {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
}

.boat svg {
  animation: rock 4s ease-in-out infinite alternate;
  transform-origin: 50% 90%;
}

.boat::after {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: -2px;
  height: 3px;
  border-radius: 50%;
  background: rgba(143, 227, 240, .4);
  filter: blur(2px);
}

.lamp {
  animation: flicker 2.4s ease-in-out infinite;
  filter: drop-shadow(0 0 5px #ffd98a);
}

.fish svg {
  color: var(--c, #8fe3f0);
  animation: wiggle var(--wig, 1.5s) ease-in-out infinite;
  filter: drop-shadow(0 0 6px rgba(143, 227, 240, .25));
  transform-origin: center;
}

/* =========================================================
   8. KEYFRAMES (ANIMATIONS)
   ========================================================= */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(40px) scale(.8) rotate(-7deg);
  }

  to {
    opacity: 1;
    transform: rotate(-1.6deg);
  }
}

@keyframes fade {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes floatup {
  from {
    opacity: 1;
    transform: translateY(0) scale(.6);
  }

  to {
    opacity: 0;
    transform: translate(var(--dx), -140px) scale(1.3);
  }
}

@keyframes netdrop {
  0% {
    transform: translateY(0);
  }

  38% {
    transform: translateY(58vh);
  }

  55% {
    transform: translateY(56vh) rotate(1.5deg);
  }

  100% {
    transform: translateY(0);
  }
}

@keyframes cargo {

  0%,
  54% {
    opacity: 0;
  }

  55%,
  100% {
    opacity: 1;
  }
}

@keyframes sail {
  from {
    transform: translateX(-10vw);
  }

  to {
    transform: translateX(110vw);
  }
}

@keyframes bob {

  0%,
  100% {
    transform: translateY(-3px) rotate(-5deg);
  }

  50% {
    transform: translateY(4px) rotate(6deg);
  }
}

@keyframes cruise {
  from {
    transform: translateX(-15vw);
  }

  to {
    transform: translateX(115vw);
  }
}

@keyframes rock {
  0% {
    transform: translateY(0) rotate(-2deg);
  }

  100% {
    transform: translateY(4px) rotate(2deg);
  }
}

@keyframes wiggle {

  0%,
  100% {
    transform: translateY(-3px) rotate(-4deg);
  }

  50% {
    transform: translateY(4px) rotate(4deg);
  }
}

@keyframes flicker {

  0%,
  100% {
    opacity: 1;
  }

  45% {
    opacity: .55;
  }

  60% {
    opacity: .9;
  }
}

/* Keyframes rời đi cho lá thư */
@keyframes cardLeave {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(-1.6deg);
  }

  100% {
    opacity: 0;
    transform: translateY(70px) scale(0.9) rotate(-3deg);
  }
}

/* Hiệu ứng thả chai lại biển (trôi đi) */
.throwback-wrapper {
  position: fixed;
  left: 50%;
  top: 55%;
  width: 38px;
  z-index: 5;
  pointer-events: none;
  animation: drift-away 2.6s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

.throwback-wrapper svg {
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 0 8px rgba(143, 227, 240, .45));
}

@keyframes drift-away {
  0% {
    transform: translate(-50%, -15px) scale(0.9) rotate(-12deg);
    opacity: 0;
  }

  20% {
    transform: translate(-50%, 15px) scale(1) rotate(6deg);
    opacity: 1;
  }

  45% {
    transform: translate(calc(-50% + 15px), 25px) scale(0.92) rotate(-6deg);
    opacity: 0.9;
  }

  75% {
    transform: translate(calc(-50% + 45px), 10px) scale(0.78) rotate(10deg);
    opacity: 0.6;
  }

  100% {
    transform: translate(calc(-50% + 80px), -15px) scale(0.55) rotate(18deg);
    opacity: 0;
    filter: blur(2px);
  }
}

/* =========================================================
   HIỆU ỨNG THẢ CHAI MỚI (MƯỢT MÀ)
   ========================================================= */
.flying-wrapper {
  position: fixed;
  left: 50%;
  bottom: 90px;
  width: 36px;
  z-index: 4;
  pointer-events: none;
  animation: fly-smooth 2.8s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

.flying-wrapper svg {
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 0 6px rgba(143, 227, 240, .35));
}

@keyframes fly-smooth {
  0% {
    transform: translate(-50%, 0) scale(1);
    opacity: 1;
    filter: blur(0);
  }

  25% {
    transform: translate(-50%, 15vh) scale(0.98);
    opacity: 0.9;
  }

  35% {
    transform: translate(-50%, 12vh) scale(0.97);
  }

  100% {
    transform: translate(-50%, -15vh) scale(0.8) rotate(-5deg);
    opacity: 0;
    filter: blur(3px);
  }
}

/* =========================================================
   9. TỐI ƯU GIAO DIỆN ĐIỆN THOẠI (MOBILE)
   ========================================================= */
@media (max-width: 768px) {

  /* Chống triệt để hiện tượng tự động phóng to (auto-zoom) trên iOS Safari & Android */
  input,
  textarea,
  select,
  .nickname-input,
  .reply-form input {
    font-size: 16px !important;
    -webkit-text-size-adjust: 100%;
  }

  input::placeholder,
  textarea::placeholder,
  .nickname-input::placeholder,
  .reply-form input::placeholder {
    font-size: 16px !important;
  }

  /* Tối ưu kích thước dialog và các ô nhập trên mobile để vừa vặn, không tràn màn hình */
  .dialog {
    width: 100%;
    max-width: min(calc(100vw - 24px), 440px);
    max-height: calc(100dvh - 24px);
    padding: 16px 14px;
    box-sizing: border-box;
    overflow-x: hidden;
  }

  .support-dialog {
    padding: 14px 12px;
  }

  .dialog h2 {
    font-size: 1.35rem;
    margin: 0 0 2px;
  }

  .dialog p {
    font-size: 0.88rem;
    margin: 0 0 8px;
  }

  textarea#msg {
    min-height: 95px;
    height: 105px;
    max-height: 130px;
    resize: none;
    padding: 10px 12px;
    font-size: 16px !important;
    line-height: 1.4;
    border-radius: 8px;
    box-sizing: border-box;
  }

  .nickname-input {
    margin-top: 8px;
    padding: 8px 12px;
    font-size: 16px !important;
    line-height: 1.35;
    border-radius: 8px;
    box-sizing: border-box;
  }

  .image-upload-box {
    margin-top: 10px;
    padding: 8px 10px;
    border-radius: 8px;
  }

  .image-upload-box label {
    font-size: 0.78rem;
    margin-bottom: 6px;
    line-height: 1.35;
  }

  .pin-request-box {
    margin-top: 8px;
    padding: 6px 10px;
    border-radius: 8px;
  }

  .pin-request-label {
    font-size: 0.8rem;
    gap: 6px;
  }

  .ui {
    padding-top: 80px;
  }

  h1 {
    font-size: 1.8rem;
    margin-top: 0;
  }

  .sub {
    font-size: 0.95rem;
    margin-top: 5px;
  }

  /* Mobile: Chia 2 cụm nút góc trên trái và góc trên phải */
  .top-nav-bar,
  .top-nav-actions {
    display: contents !important;
  }

  .top-nav-left {
    position: fixed !important;
    top: max(14px, env(safe-area-inset-top)) !important;
    left: 14px !important;
    right: auto !important;
    z-index: 10 !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    pointer-events: auto !important;
  }

  .top-nav-right {
    position: fixed !important;
    top: max(14px, env(safe-area-inset-top)) !important;
    right: 14px !important;
    left: auto !important;
    z-index: 10 !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    pointer-events: auto !important;
  }

  .top-nav-left .icon-btn,
  .top-nav-right .icon-btn,
  .icon-btn {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    width: 34px !important;
    height: 34px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    margin: 0 !important;
    line-height: 1 !important;
    text-align: center !important;
    box-sizing: border-box !important;
    backdrop-filter: none !important;
    font-size: 0.95rem !important;
    overflow: visible !important;
  }

  /* Tối ưu hiệu năng mobile: tắt backdrop-filter trên các nút để không giật lag */
  .drift,
  .btn,
  .paper-btn {
    backdrop-filter: none !important;
  }

  /* Ẩn UI khi đang đọc thư */
  body.reading-letter .ui,
  body.reading-letter .top-nav-bar,
  body.reading-letter .top-nav-left,
  body.reading-letter .top-nav-right,
  body.reading-letter .top-bar,
  body.reading-letter .icon-btn {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }

  #chatOverlay {
    padding: 10px !important;
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }

  .chat-dialog {
    width: 100% !important;
    max-width: 440px !important;
    min-width: 0 !important;
    margin: 0 auto !important;
    height: 80vh !important;
    height: 80dvh !important;
    max-height: 620px !important;
    padding: 14px 14px 12px !important;
    border-radius: 14px !important;
    display: flex !important;
    flex-direction: column !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
  }

  .chat-title {
    font-size: 1.15rem !important;
  }

  .chat-messages {
    flex: 1 !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow-y: auto !important;
  }

  .chat-input-bar {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    width: 100% !important;
    margin-top: 8px !important;
    padding-top: 6px !important;
  }

  .chat-input-wrap {
    flex: 1 !important;
    min-width: 0 !important;
    display: flex !important;
    align-items: center !important;
  }

  .chat-input-wrap input {
    width: 100% !important;
    min-width: 0 !important;
    padding: 9px 40px 9px 10px !important;
    font-size: 16px !important;
    box-sizing: border-box !important;
  }

  .chat-char-counter {
    position: static !important;
    font-size: 0.66rem !important;
  }

  .chat-send-btn {
    flex-shrink: 0 !important;
    width: auto !important;
    white-space: nowrap !important;
    padding: 10px 16px !important;
    font-size: 0.88rem !important;
    display: inline-flex !important;
  }

  .stage {
    height: 100vh;
    height: 100dvh;
    padding: 10px;
    align-items: center;
  }

  /* Mobile: Đưa dòng đếm chai xuống giữa màn hình */
  .top-bar {
    position: fixed !important;
    top: 155px !important;
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    justify-content: center !important;
  }

  .drift {
    font-size: 0.85rem;
    padding: 6px 14px;
  }

  /* Sửa lỗi thẻ bị kẹt nút trên mobile */
  .card {
    width: 92vw;
    max-height: 80vh;
    max-height: 80dvh;
    margin-top: 0;
    margin-bottom: 0;
    padding: 16px;
    transform: rotate(0deg);
    display: none;
    flex-direction: column;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
  }

  .card.show {
    display: flex !important;
    flex-direction: column !important;
  }

  .card.leave {
    display: flex !important;
    flex-direction: column !important;
    pointer-events: none !important;
    animation: cardLeaveMobile .6s cubic-bezier(.35, 0, .2, 1) forwards;
    will-change: transform, opacity;
  }

  @keyframes cardLeaveMobile {
    0% {
      opacity: 1;
      transform: translateY(0) scale(1) rotate(0deg);
    }

    100% {
      opacity: 0;
      transform: translateY(60px) scale(0.92) rotate(0deg);
    }
  }

  .card>.letter {
    flex: none;
    overflow-y: visible;
    padding-right: 0;
    min-height: auto;
    margin-bottom: 10px;
  }

  .card>.replies {
    max-height: none;
  }

  .letter {
    font-size: 1.1rem;
    line-height: 26px;
    background-size: 100% 26px;
    background-position: 0 26px;
  }

  .letter-images-container.single img {
    max-height: 200px;
    width: auto;
    object-fit: contain;
  }

  .letter-images-container.multiple img {
    height: 80px;
  }

  .foot {
    background: transparent !important;
    backdrop-filter: none !important;
    border: none !important;
    border-top: none !important;
    box-shadow: none !important;
    flex-direction: column;
    gap: 8px;
    padding-top: 6px;
    padding-bottom: 0;
    margin-top: 8px;
  }

  /* Ẩn nút lưu ở footer trên mobile vì đã có nút lưu trên thanh tiêu đề */
  #saveCardBtn {
    display: none !important;
  }

  .foot>span:last-child {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    width: 100%;
  }

  .foot>span:last-child #reportBtn {
    grid-column: span 1;
  }

  .paper-btn {
    font-size: 0.85rem;
    padding: 8px 4px;
    width: 100%;
    text-align: center;
    justify-content: center;
  }

  .reply-form {
    margin-bottom: 8px;
    gap: 6px;
  }

  .reply-form input {
    padding: 7px 10px;
    font-size: 16px !important;
    line-height: 1.35;
    border-radius: 8px;
    box-sizing: border-box;
  }

  .card-header-row {
    margin-bottom: 8px;
    gap: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
  }

  .card-header-row .from {
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex: 1;
    margin: 0;
  }

  .card-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
  }

  /* Nút Bookmark trên thanh tiêu đề lá thư */
  #saveCardHeaderBtn,
  .bookmark-card-btn {
    width: auto !important;
    min-width: unset !important;
    min-height: unset !important;
    height: 26px !important;
    padding: 0 8px !important;
    font-size: 0.75rem !important;
    line-height: 1 !important;
    white-space: nowrap !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 3px !important;
    flex-shrink: 0 !important;
    box-sizing: border-box !important;
    border-radius: 999px !important;
    margin: 0 !important;
    font-family: inherit;
    font-weight: 600;
  }

  #countdownTimer {
    position: static !important;
    font-size: 0.75rem !important;
    height: 26px;
    padding: 0 8px;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    line-height: 1;
    white-space: nowrap;
    flex-shrink: 0;
    margin: 0;
    border-radius: 999px;
  }

  .close-card-btn {
    height: 26px !important;
    width: 26px !important;
    min-width: 26px !important;
    padding: 0 !important;
    font-size: 0.88rem !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    box-sizing: border-box !important;
    line-height: 1 !important;
    margin: 0 !important;
    border-radius: 6px !important;
  }

  /* Banner Chai May Mắn trên mobile */
  .lucky-banner {
    width: 100%;
    max-width: 100%;
    padding: 0 10px;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
  }

  .lucky-btn-pill {
    font-size: 0.82rem !important;
    padding: 6px 14px !important;
    gap: 6px !important;
    max-width: 100% !important;
    white-space: nowrap !important;
    flex-wrap: nowrap !important;
  }

  .lucky-btn-pill .lucky-text {
    font-size: 0.82rem !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  .lucky-btn-pill .lucky-badge {
    font-size: 0.7rem !important;
    padding: 2px 6px !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
  }

  .lucky-btn-pill .lucky-sparkle {
    font-size: 0.85rem !important;
    flex-shrink: 0 !important;
  }

  /* Ribbons (Chai May Mắn & Thư Được Ghim) trên mobile:
     Đảm bảo nằm gọn trên 1 dòng duy nhất, không bao giờ rớt icon xuống dòng */
  .lucky-ribbon,
  .pinned-ribbon {
    margin-bottom: 10px;
    width: 100%;
    max-width: 100%;
    display: flex;
    justify-content: center;
  }

  .lucky-ribbon span,
  .pinned-ribbon span {
    font-size: 0.72rem !important;
    padding: 4px 10px !important;
    letter-spacing: 0.2px !important;
    gap: 4px !important;
    max-width: 100% !important;
    white-space: nowrap !important;
    flex-wrap: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    box-sizing: border-box !important;
    line-height: 1.2 !important;
  }

  .ribbon-icon {
    font-size: 0.82rem !important;
    flex-shrink: 0 !important;
  }

  /* Badge ghim trong danh sách thư */
  .pinned-bottle-item .pinned-badge {
    font-size: 0.72rem !important;
    padding: 2px 6px !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
  }

  /* Cuộn ngang tab nhật ký trên màn hình nhỏ */
  .vault-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 6px;
  }

  .tab-btn {
    white-space: nowrap;
    flex-shrink: 0;
    font-size: 0.85rem;
    padding: 6px 10px;
  }

  #pickImageBtn,
  #captureImageBtn {
    font-size: 0.8rem;
    padding: 6px 4px;
    white-space: nowrap;
  }

  .support-actions {
    gap: 8px;
  }

  .support-actions .btn {
    font-size: 0.84rem !important;
    padding: 8px 10px !important;
  }

  /* Ép hiển thị chai, thuyền, cá trên mobile */
  .floaters,
  .sea-life {
    display: block;
    visibility: visible;
    opacity: 1;
    z-index: 1;
  }

  .fb,
  .boat,
  .fish {
    display: block;
    visibility: visible;
    opacity: var(--o, 0.8);
    animation-play-state: running;
  }
}

/* Đảm bảo các lớp nền không chặn thao tác chạm */
.sea-life,
.floaters,
#sea {
  pointer-events: none;
}

/* Giao diện Thẻ Ticket Hỗ trợ người dùng trong Nhật ký */
.user-ticket-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(143, 227, 240, 0.2);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 12px;
  box-sizing: border-box;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.user-ticket-card:hover {
  border-color: rgba(143, 227, 240, 0.38);
  background: rgba(255, 255, 255, 0.06);
}

.user-ticket-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}

.user-ticket-title {
  font-weight: 600;
  font-size: 0.98rem;
  color: var(--glow);
}

.user-ticket-time {
  font-size: 0.76rem;
  opacity: 0.6;
  margin-bottom: 8px;
}

.user-ticket-body {
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--mist);
  margin-bottom: 10px;
  white-space: pre-wrap;
  word-break: break-word;
}

.user-ticket-toggle-btn {
  background: transparent;
  border: 1px solid rgba(143, 227, 240, 0.25);
  border-radius: 6px;
  color: var(--glow);
  font-size: 0.8rem;
  padding: 5px 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.user-ticket-toggle-btn:hover {
  background: rgba(143, 227, 240, 0.12);
  border-color: var(--glow);
}

.user-ticket-thread {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(143, 227, 240, 0.15);
}

.user-ticket-msg-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
  overflow-x: hidden;
  margin-bottom: 10px;
  padding-right: 4px;
}

.user-msg-bubble {
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.85rem;
  line-height: 1.5;
  box-sizing: border-box;
}

.user-msg-bubble.from-admin {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.32);
  margin-right: 12px;
}

.user-msg-bubble.from-user {
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.3);
  margin-left: 12px;
}

.user-msg-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.74rem;
  opacity: 0.8;
  margin-bottom: 4px;
}

.user-ticket-reply-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.user-ticket-reply-input {
  flex: 1;
  min-width: 0;
  box-sizing: border-box;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(143, 227, 240, 0.25);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 0.85rem;
  color: #fff;
}

.user-ticket-reply-input:focus {
  outline: none;
  border-color: var(--glow);
}

.user-ticket-reply-btn {
  white-space: nowrap;
  flex-shrink: 0;
  padding: 7px 14px;
  font-size: 0.82rem;
  background: linear-gradient(135deg, #6366f1, #3b82f6);
  border: none;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  font-weight: 500;
  transition: opacity 0.2s ease;
}

.user-ticket-reply-btn:hover {
  opacity: 0.9;
}

/* =========================================================
   BẢN TIN BIỂN ĐÊM 21:00 (NIGHT SEA BULLETIN)
   ========================================================= */
.night-bulletin-banner {
  position: fixed;
  top: max(78px, calc(env(safe-area-inset-top) + 68px));
  left: 50%;
  transform: translate(-50%, -18px);
  width: min(calc(100vw - 32px), 540px);
  z-index: 15;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 18px 14px;
  box-sizing: border-box;
  background: rgba(10, 25, 47, 0.82);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  border: 1px solid rgba(100, 255, 218, 0.4);
  border-radius: 16px;
  box-shadow: 0 10px 32px rgba(2, 12, 27, 0.65), 
              0 0 20px rgba(100, 255, 218, 0.2), 
              inset 0 1px 0 rgba(255, 255, 255, 0.15);
  color: #e2e8f0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s cubic-bezier(0.16, 1, 0.3, 1), 
              transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform, opacity;
}

.night-bulletin-banner.show {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.night-bulletin-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #64ffda;
  text-shadow: 0 0 10px rgba(100, 255, 218, 0.5);
}

.night-bulletin-body {
  font-size: 0.9rem;
  line-height: 1.48;
  color: #f1f5f9;
  word-break: break-word;
  padding-right: 24px;
}

.night-bulletin-body strong.winner-name {
  color: #ffd978;
  font-weight: 700;
  text-shadow: 0 0 8px rgba(255, 217, 120, 0.45);
}

.night-bulletin-body strong.pick-count {
  color: #64ffda;
  font-weight: 700;
  text-shadow: 0 0 6px rgba(100, 255, 218, 0.4);
}

.night-bulletin-close {
  position: absolute;
  top: 9px;
  right: 10px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
  transition: all 0.2s ease;
  padding: 0;
}

.night-bulletin-close:hover,
.night-bulletin-close:focus-visible {
  color: #fff;
  background: rgba(255, 255, 255, 0.18);
  transform: scale(1.08);
  outline: none;
}

/* Ẩn banner khi đang mở xem lá thư */
body.reading-letter .night-bulletin-banner {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* Responsive trên mobile */
@media (max-width: 640px) {
  .night-bulletin-banner {
    top: max(72px, calc(env(safe-area-inset-top) + 62px));
    width: min(calc(100vw - 24px), 430px);
    padding: 10px 14px 11px;
    border-radius: 14px;
    gap: 4px;
  }

  .night-bulletin-badge {
    font-size: 0.68rem;
  }

  .night-bulletin-body {
    font-size: 0.82rem;
    line-height: 1.42;
    padding-right: 22px;
  }

  .night-bulletin-close {
    top: 7px;
    right: 8px;
    width: 24px;
    height: 24px;
    font-size: 1rem;
  }
}

/* =========================================================
   THÔNG BÁO & BÌNH CHỌN TOÀN BIỂN (SEA ANNOUNCEMENTS & POLLS)
   ========================================================= */
.sea-announcement-banner {
  position: fixed;
  top: max(78px, calc(env(safe-area-inset-top) + 68px));
  left: 50%;
  transform: translate(-50%, -18px);
  width: min(calc(100vw - 32px), 540px);
  z-index: 14;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 13px 18px 15px;
  box-sizing: border-box;
  background: rgba(11, 27, 54, 0.85);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 16px;
  box-shadow: 0 10px 32px rgba(2, 12, 27, 0.7), 
              0 0 22px rgba(56, 189, 248, 0.22), 
              inset 0 1px 0 rgba(255, 255, 255, 0.15);
  color: #e2e8f0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s cubic-bezier(0.16, 1, 0.3, 1), 
              transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform, opacity;
}

.sea-announcement-banner.show {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.sea-ann-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.sea-ann-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #38bdf8;
  text-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
}

.sea-ann-badge.poll-badge {
  color: #c084fc;
  text-shadow: 0 0 10px rgba(192, 132, 252, 0.5);
}

.sea-ann-close {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: rgba(255, 255, 255, 0.75);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
  transition: all 0.2s ease;
  padding: 0;
}

.sea-ann-close:hover,
.sea-ann-close:focus-visible {
  color: #fff;
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.08);
  outline: none;
}

.sea-ann-title {
  font-size: 0.96rem;
  font-weight: 700;
  color: #ffd978;
  text-shadow: 0 0 8px rgba(255, 217, 120, 0.35);
  line-height: 1.35;
}

.sea-ann-content {
  font-size: 0.88rem;
  line-height: 1.48;
  color: #f1f5f9;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Khu vực cảm xúc (notice) */
.sea-ann-reactions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.sea-react-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 20px;
  padding: 4px 11px;
  color: #e2e8f0;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sea-react-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(56, 189, 248, 0.5);
  transform: scale(1.04);
}

.sea-react-btn.reacted {
  background: rgba(56, 189, 248, 0.22);
  border-color: #38bdf8;
  color: #38bdf8;
  font-weight: 600;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
  cursor: default;
}

/* Khu vực bình chọn (poll) */
.sea-ann-poll-options {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 4px;
}

.sea-poll-vote-btn {
  width: 100%;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  padding: 8px 14px;
  color: #f8fafc;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sea-poll-vote-btn:hover {
  background: rgba(192, 132, 252, 0.2);
  border-color: #c084fc;
  transform: translateX(2px);
}

.sea-poll-results {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 4px;
}

.sea-poll-result-bar-wrap {
  position: relative;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  overflow: hidden;
  padding: 7px 12px;
}

.sea-poll-result-bar-wrap.my-choice {
  border-color: #c084fc;
  box-shadow: 0 0 10px rgba(192, 132, 252, 0.25);
}

.sea-poll-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.3), rgba(192, 132, 252, 0.4));
  border-radius: 9px;
  transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 1;
}

.sea-poll-result-bar-wrap.my-choice .sea-poll-fill {
  background: linear-gradient(90deg, rgba(168, 85, 247, 0.38), rgba(216, 180, 254, 0.48));
}

.sea-poll-result-text {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.84rem;
  font-weight: 500;
  color: #f8fafc;
}

/* Ẩn khi đang đọc thư */
body.reading-letter .sea-announcement-banner {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* Responsive mobile */
@media (max-width: 640px) {
  .sea-announcement-banner {
    top: max(72px, calc(env(safe-area-inset-top) + 62px));
    width: min(calc(100vw - 24px), 430px);
    padding: 11px 14px 13px;
    border-radius: 14px;
    gap: 6px;
  }

  .sea-ann-title {
    font-size: 0.9rem;
  }

  .sea-ann-content {
    font-size: 0.82rem;
    line-height: 1.42;
  }

  .sea-react-btn {
    font-size: 0.78rem;
    padding: 3px 9px;
  }

  .sea-poll-vote-btn {
    font-size: 0.8rem;
    padding: 7px 11px;
  }
}

/* ====================================================================
   KHUNG CHAT TỔNG (TRÒ CHUYỆN TRÊN BIỂN)
   ==================================================================== */
.chat-btn {
  font-size: 1.15rem;
  line-height: 1;
}

.global-chat-dialog {
  width: 100%;
  max-width: min(calc(100vw - 24px), 480px);
  height: min(620px, calc(100dvh - 32px));
  max-height: calc(100dvh - 32px);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
  background: rgba(10, 25, 47, 0.94);
  border: 1px solid rgba(138, 180, 248, 0.32);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7), 0 0 25px rgba(56, 189, 248, 0.15);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 18px;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  flex-shrink: 0;
}

.chat-title-group {
  flex: 1;
  min-width: 0;
}

.chat-main-title {
  margin: 0 0 3px;
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.01em;
}

.chat-subtitle {
  margin: 0;
  font-size: 0.78rem;
  color: #7dd3fc;
  opacity: 0.92;
  font-style: italic;
  line-height: 1.35;
}

.close-chat-btn {
  position: static !important;
  width: 32px;
  height: 32px;
  min-width: 32px;
  font-size: 0.95rem;
  flex-shrink: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Danh sách tin nhắn */
.chat-messages-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 6px 4px 6px 0;
  box-sizing: border-box;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.chat-messages-container::-webkit-scrollbar {
  width: 5px;
}

.chat-messages-container::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 4px;
}

.chat-messages-container::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.35);
  border-radius: 4px;
}

.chat-messages-container::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.55);
}

.chat-empty-state, .chat-loading-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin: auto;
  padding: 30px 16px;
  color: #94a3b8;
  font-size: 0.88rem;
  line-height: 1.5;
}

/* Từng bubble tin nhắn */
.chat-msg-item {
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 11px;
  padding: 6px 11px;
  position: relative;
  transition: background 0.2s, border-color 0.2s;
  box-sizing: border-box;
  width: 100%;
}

.chat-msg-item.is-mine {
  background: rgba(14, 116, 144, 0.22);
  border-color: rgba(56, 189, 248, 0.38);
  box-shadow: 0 2px 10px rgba(56, 189, 248, 0.08);
}

.chat-msg-item.is-admin {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.42);
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.1);
}

.chat-msg-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 2px;
  font-size: 0.76rem;
}

.chat-msg-author {
  font-weight: 600;
  color: #38bdf8;
  display: flex;
  align-items: center;
  gap: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-crown-badge {
  font-size: 0.75rem;
  font-weight: 700;
  color: #fde047;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.28), rgba(217, 119, 6, 0.35));
  border: 1px solid rgba(253, 224, 71, 0.55);
  border-radius: 5px;
  padding: 1px 7px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  text-shadow: 0 0 6px rgba(253, 224, 71, 0.35);
}

.chat-msg-author .mine-badge {
  font-size: 0.66rem;
  font-weight: 700;
  background: rgba(56, 189, 248, 0.25);
  color: #bae6fd;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid rgba(56, 189, 248, 0.4);
}

.chat-msg-time-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.chat-msg-time {
  font-size: 0.7rem;
  color: #94a3b8;
  white-space: nowrap;
}

.chat-msg-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 0.74rem;
  opacity: 0.7;
  transition: opacity 0.2s, background 0.2s;
  color: #cbd5e1;
}

.chat-msg-action-btn:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.15);
}

.chat-msg-content {
  font-size: 0.86rem;
  line-height: 1.42;
  color: #f8fafc;
  word-break: break-word;
  white-space: pre-wrap;
}

/* Khu vực nhập liệu (1 dòng duy nhất) */
.chat-input-form {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  flex-shrink: 0;
}

.chat-send-row {
  display: flex;
  gap: 6px;
  align-items: flex-end;
  width: 100%;
}

.chat-input-box {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: unset !important;
  height: auto !important;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  padding: 6px 10px !important;
  box-sizing: border-box;
  transition: border-color 0.2s;
}

.chat-input-box:focus-within {
  border-color: #38bdf8;
}

#chatMessageInput,
.chat-text-input {
  width: 100%;
  resize: none;
  border: none;
  background: transparent;
  outline: none;
  min-height: 22px !important;
  height: 22px;
  max-height: 76px;
  padding: 0 !important;
  margin: 0 !important;
  flex: none !important;
  font-family: inherit;
  font-size: 0.92rem;
  color: #fff;
  overflow-y: auto;
  line-height: 1.35;
  box-sizing: border-box;
}

#chatMessageInput:focus,
.chat-text-input:focus {
  border-color: transparent;
}

.chat-counter-bar {
  display: flex;
  justify-content: flex-end;
  width: 100%;
}

.chat-char-counter {
  position: static !important;
  align-self: flex-end;
  font-size: 0.68rem;
  line-height: 1;
  padding-top: 2px;
  color: rgba(148, 163, 184, 0.78);
  pointer-events: none;
  font-variant-numeric: tabular-nums;
  user-select: none;
}

.chat-unread-badge {
  background: #ea580c !important;
  border-color: #07152b !important;
  box-shadow: 0 0 8px rgba(234, 88, 12, 0.65);
}

.chat-send-btn {
  white-space: nowrap;
  padding: 6px 11px;
  font-size: 0.82rem;
  border-radius: 9px;
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  transition: transform 0.15s, opacity 0.2s;
  height: 35px;
  box-sizing: border-box;
}

.chat-send-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

@media (max-width: 640px) {
  .global-chat-dialog {
    padding: 12px 10px;
    height: min(580px, calc(100dvh - 16px));
    max-height: calc(100dvh - 16px);
  }

  .chat-main-title {
    font-size: 1.15rem;
  }

  .chat-subtitle {
    font-size: 0.74rem;
  }

  .chat-input-box {
    padding: 6px 9px !important;
  }

  #chatMessageInput,
  .chat-text-input {
    font-size: 0.9rem;
    padding: 0 !important;
  }

  .chat-char-counter {
    font-size: 0.66rem;
  }

  .chat-send-btn {
    padding: 5px 9px;
    font-size: 0.78rem;
    height: 33px;
    border-radius: 8px;
  }
}

