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

html, body {
  height: 100%;
  overflow: hidden;
  overflow-x: hidden;
  /* Stop iOS from inflating text when the device is rotated to landscape. */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: #E4DCB7;
  background-image:
    radial-gradient(ellipse at 20% 30%, rgba(255, 255, 255, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 70%, rgba(255, 255, 255, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 15% 85%, rgba(255, 255, 255, 0.1) 0%, transparent 40%),
    radial-gradient(circle at 85% 15%, rgba(255, 255, 255, 0.1) 0%, transparent 40%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200' viewBox='0 0 200 200'%3E%3Cg fill='none' stroke='%23ffffff' stroke-width='0.5' opacity='0.35'%3E%3Cellipse cx='100' cy='80' rx='20' ry='8' transform='rotate(-30 100 80)'/%3E%3Cellipse cx='100' cy='80' rx='20' ry='8' transform='rotate(30 100 80)'/%3E%3Cellipse cx='100' cy='80' rx='20' ry='8' transform='rotate(90 100 80)'/%3E%3Cellipse cx='100' cy='80' rx='20' ry='8' transform='rotate(150 100 80)'/%3E%3Cellipse cx='100' cy='80' rx='20' ry='8' transform='rotate(-150 100 80)'/%3E%3Ccircle cx='100' cy='80' r='4'/%3E%3Cellipse cx='40' cy='160' rx='15' ry='6' transform='rotate(-45 40 160)'/%3E%3Cellipse cx='40' cy='160' rx='15' ry='6' transform='rotate(15 40 160)'/%3E%3Cellipse cx='40' cy='160' rx='15' ry='6' transform='rotate(75 40 160)'/%3E%3Cellipse cx='40' cy='160' rx='15' ry='6' transform='rotate(135 40 160)'/%3E%3Cellipse cx='40' cy='160' rx='15' ry='6' transform='rotate(-105 40 160)'/%3E%3Ccircle cx='40' cy='160' r='3'/%3E%3Cellipse cx='170' cy='140' rx='12' ry='5' transform='rotate(20 170 140)'/%3E%3Cellipse cx='170' cy='140' rx='12' ry='5' transform='rotate(92 170 140)'/%3E%3Cellipse cx='170' cy='140' rx='12' ry='5' transform='rotate(164 170 140)'/%3E%3Ccircle cx='170' cy='140' r='3'/%3E%3C/g%3E%3C/svg%3E");
  min-height: 100vh;
  min-height: 100dvh;
}

.container {
  background-color: #E4DCB7;
  background-image:
    radial-gradient(ellipse at 20% 30%, rgba(255, 255, 255, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 70%, rgba(255, 255, 255, 0.15) 0%, transparent 50%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200' viewBox='0 0 200 200'%3E%3Cg fill='none' stroke='%23ffffff' stroke-width='0.5' opacity='0.35'%3E%3Cellipse cx='100' cy='80' rx='20' ry='8' transform='rotate(-30 100 80)'/%3E%3Cellipse cx='100' cy='80' rx='20' ry='8' transform='rotate(30 100 80)'/%3E%3Cellipse cx='100' cy='80' rx='20' ry='8' transform='rotate(90 100 80)'/%3E%3Cellipse cx='100' cy='80' rx='20' ry='8' transform='rotate(150 100 80)'/%3E%3Cellipse cx='100' cy='80' rx='20' ry='8' transform='rotate(-150 100 80)'/%3E%3Ccircle cx='100' cy='80' r='4'/%3E%3Cellipse cx='40' cy='160' rx='15' ry='6' transform='rotate(-45 40 160)'/%3E%3Cellipse cx='40' cy='160' rx='15' ry='6' transform='rotate(15 40 160)'/%3E%3Cellipse cx='40' cy='160' rx='15' ry='6' transform='rotate(75 40 160)'/%3E%3Cellipse cx='40' cy='160' rx='15' ry='6' transform='rotate(135 40 160)'/%3E%3Cellipse cx='40' cy='160' rx='15' ry='6' transform='rotate(-105 40 160)'/%3E%3Ccircle cx='40' cy='160' r='3'/%3E%3Cellipse cx='170' cy='140' rx='12' ry='5' transform='rotate(20 170 140)'/%3E%3Cellipse cx='170' cy='140' rx='12' ry='5' transform='rotate(92 170 140)'/%3E%3Cellipse cx='170' cy='140' rx='12' ry='5' transform='rotate(164 170 140)'/%3E%3Ccircle cx='170' cy='140' r='3'/%3E%3C/g%3E%3C/svg%3E");
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 3px solid #b0b0b0;
}

.header {
  padding: 18px 24px;
  background-color: #E4DCB7;
  background-image:
    radial-gradient(ellipse at 20% 30%, rgba(255, 255, 255, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 70%, rgba(255, 255, 255, 0.15) 0%, transparent 50%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200' viewBox='0 0 200 200'%3E%3Cg fill='none' stroke='%23ffffff' stroke-width='0.5' opacity='0.35'%3E%3Cellipse cx='100' cy='80' rx='20' ry='8' transform='rotate(-30 100 80)'/%3E%3Cellipse cx='100' cy='80' rx='20' ry='8' transform='rotate(30 100 80)'/%3E%3Cellipse cx='100' cy='80' rx='20' ry='8' transform='rotate(90 100 80)'/%3E%3Cellipse cx='100' cy='80' rx='20' ry='8' transform='rotate(150 100 80)'/%3E%3Cellipse cx='100' cy='80' rx='20' ry='8' transform='rotate(-150 100 80)'/%3E%3Ccircle cx='100' cy='80' r='4'/%3E%3Cellipse cx='40' cy='160' rx='15' ry='6' transform='rotate(-45 40 160)'/%3E%3Cellipse cx='40' cy='160' rx='15' ry='6' transform='rotate(15 40 160)'/%3E%3Cellipse cx='40' cy='160' rx='15' ry='6' transform='rotate(75 40 160)'/%3E%3Cellipse cx='40' cy='160' rx='15' ry='6' transform='rotate(135 40 160)'/%3E%3Cellipse cx='40' cy='160' rx='15' ry='6' transform='rotate(-105 40 160)'/%3E%3Ccircle cx='40' cy='160' r='3'/%3E%3Cellipse cx='170' cy='140' rx='12' ry='5' transform='rotate(20 170 140)'/%3E%3Cellipse cx='170' cy='140' rx='12' ry='5' transform='rotate(92 170 140)'/%3E%3Cellipse cx='170' cy='140' rx='12' ry='5' transform='rotate(164 170 140)'/%3E%3Ccircle cx='170' cy='140' r='3'/%3E%3C/g%3E%3C/svg%3E");
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  padding-top: calc(18px + env(safe-area-inset-top));
  padding-left: calc(24px + env(safe-area-inset-left));
  padding-right: calc(24px + env(safe-area-inset-right));
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  z-index: 10;
  min-width: 0;
}

.logo-icon {
  font-size: 2rem;
}

.logo-img-wrap {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid black;
}

.logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(2.0);
  filter: grayscale(1) brightness(1.2) contrast(3.5) saturate(1.2);
}

.logo-text {
  font-family: 'Abril Fatface', cursive;
  color: #a3575c;
  -webkit-text-stroke: 2px #a3575c;
  font-size: 1.4rem;
  font-weight: 400;
  letter-spacing: 1px;
  text-transform: uppercase;
  white-space: nowrap;
  filter: none;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-link {
  color: white;
  text-decoration: none;
  font-size: 0.85rem;
  padding: 8px 16px;
  border: 2px solid rgba(255,255,255,0.5);
  border-radius: 20px;
  transition: all 0.3s;
}

.admin-link:hover {
  background: rgba(255,255,255,0.2);
  border-color: white;
}

.status {
  text-align: center;
  padding: 14px;
  color: #666666;
  font-size: 0.85rem;
  background: #f9f0f0;
  border-bottom: 2px solid #e0d0d0;
  flex-shrink: 0;
}

.hidden {
  display: none !important;
}

#connectSection {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background-color: #E4DCB7;
  background-image:
    radial-gradient(ellipse at 20% 30%, rgba(255, 255, 255, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 70%, rgba(255, 255, 255, 0.15) 0%, transparent 50%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200' viewBox='0 0 200 200'%3E%3Cg fill='none' stroke='%23ffffff' stroke-width='0.5' opacity='0.35'%3E%3Cellipse cx='100' cy='80' rx='20' ry='8' transform='rotate(-30 100 80)'/%3E%3Cellipse cx='100' cy='80' rx='20' ry='8' transform='rotate(30 100 80)'/%3E%3Cellipse cx='100' cy='80' rx='20' ry='8' transform='rotate(90 100 80)'/%3E%3Cellipse cx='100' cy='80' rx='20' ry='8' transform='rotate(150 100 80)'/%3E%3Cellipse cx='100' cy='80' rx='20' ry='8' transform='rotate(-150 100 80)'/%3E%3Ccircle cx='100' cy='80' r='4'/%3E%3Cellipse cx='40' cy='160' rx='15' ry='6' transform='rotate(-45 40 160)'/%3E%3Cellipse cx='40' cy='160' rx='15' ry='6' transform='rotate(15 40 160)'/%3E%3Cellipse cx='40' cy='160' rx='15' ry='6' transform='rotate(75 40 160)'/%3E%3Cellipse cx='40' cy='160' rx='15' ry='6' transform='rotate(135 40 160)'/%3E%3Cellipse cx='40' cy='160' rx='15' ry='6' transform='rotate(-105 40 160)'/%3E%3Ccircle cx='40' cy='160' r='3'/%3E%3Cellipse cx='170' cy='140' rx='12' ry='5' transform='rotate(20 170 140)'/%3E%3Cellipse cx='170' cy='140' rx='12' ry='5' transform='rotate(92 170 140)'/%3E%3Cellipse cx='170' cy='140' rx='12' ry='5' transform='rotate(164 170 140)'/%3E%3Ccircle cx='170' cy='140' r='3'/%3E%3C/g%3E%3C/svg%3E");
}

.btn {
  padding: 14px 32px;
  border: none;
  border-radius: 30px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Only lift on devices with a real pointer — on touch, :hover sticks after a tap. */
@media (hover: hover) and (pointer: fine) {
  .btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(255, 154, 158, 0.4);
  }
}

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

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-primary {
  background: linear-gradient(135deg, #8f5943 0%, #a66a52 100%);
  color: white;
  text-shadow: none;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #a66a52 0%, #bc7b61 100%);
}

.btn-danger {
  background: linear-gradient(135deg, #8f5943 0%, #a66a52 100%);
  color: white;
  font-size: 0.75rem;
  padding: 10px 18px;
}

.btn-danger:hover {
  background: linear-gradient(135deg, #a66a52 0%, #bc7b61 100%);
}

#chatSection {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: #E4DCB7;
  background-image:
    radial-gradient(ellipse at 20% 30%, rgba(255, 255, 255, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 70%, rgba(255, 255, 255, 0.15) 0%, transparent 50%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200' viewBox='0 0 200 200'%3E%3Cg fill='none' stroke='%23ffffff' stroke-width='0.5' opacity='0.35'%3E%3Cellipse cx='100' cy='80' rx='20' ry='8' transform='rotate(-30 100 80)'/%3E%3Cellipse cx='100' cy='80' rx='20' ry='8' transform='rotate(30 100 80)'/%3E%3Cellipse cx='100' cy='80' rx='20' ry='8' transform='rotate(90 100 80)'/%3E%3Cellipse cx='100' cy='80' rx='20' ry='8' transform='rotate(150 100 80)'/%3E%3Cellipse cx='100' cy='80' rx='20' ry='8' transform='rotate(-150 100 80)'/%3E%3Ccircle cx='100' cy='80' r='4'/%3E%3Cellipse cx='40' cy='160' rx='15' ry='6' transform='rotate(-45 40 160)'/%3E%3Cellipse cx='40' cy='160' rx='15' ry='6' transform='rotate(15 40 160)'/%3E%3Cellipse cx='40' cy='160' rx='15' ry='6' transform='rotate(75 40 160)'/%3E%3Cellipse cx='40' cy='160' rx='15' ry='6' transform='rotate(135 40 160)'/%3E%3Cellipse cx='40' cy='160' rx='15' ry='6' transform='rotate(-105 40 160)'/%3E%3Ccircle cx='40' cy='160' r='3'/%3E%3Cellipse cx='170' cy='140' rx='12' ry='5' transform='rotate(20 170 140)'/%3E%3Cellipse cx='170' cy='140' rx='12' ry='5' transform='rotate(92 170 140)'/%3E%3Cellipse cx='170' cy='140' rx='12' ry='5' transform='rotate(164 170 140)'/%3E%3Ccircle cx='170' cy='140' r='3'/%3E%3C/g%3E%3C/svg%3E");
  min-height: 0;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  padding-left: calc(18px + env(safe-area-inset-left));
  padding-right: calc(18px + env(safe-area-inset-right));
  background: #d0d0d0;
  border-bottom: 2px solid #b0b0b0;
  flex-shrink: 0;
}

.chat-header-title {
  color: #333333;
  font-weight: 600;
  font-size: 0.9rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#endBtn {
  flex-shrink: 0;
}

/* The end-chat button carries a long label on desktop and a terse one on
   phones; only one is ever rendered. */
.label-short {
  display: none;
}

@media (max-width: 700px) {
  .label-full {
    display: none;
  }

  .label-short {
    display: inline;
  }
}

.messages {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background-color: #E4DCB7;
  background-image:
    radial-gradient(ellipse at 20% 30%, rgba(255, 255, 255, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 70%, rgba(255, 255, 255, 0.15) 0%, transparent 50%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200' viewBox='0 0 200 200'%3E%3Cg fill='none' stroke='%23ffffff' stroke-width='0.5' opacity='0.35'%3E%3Cellipse cx='100' cy='80' rx='20' ry='8' transform='rotate(-30 100 80)'/%3E%3Cellipse cx='100' cy='80' rx='20' ry='8' transform='rotate(30 100 80)'/%3E%3Cellipse cx='100' cy='80' rx='20' ry='8' transform='rotate(90 100 80)'/%3E%3Cellipse cx='100' cy='80' rx='20' ry='8' transform='rotate(150 100 80)'/%3E%3Cellipse cx='100' cy='80' rx='20' ry='8' transform='rotate(-150 100 80)'/%3E%3Ccircle cx='100' cy='80' r='4'/%3E%3Cellipse cx='40' cy='160' rx='15' ry='6' transform='rotate(-45 40 160)'/%3E%3Cellipse cx='40' cy='160' rx='15' ry='6' transform='rotate(15 40 160)'/%3E%3Cellipse cx='40' cy='160' rx='15' ry='6' transform='rotate(75 40 160)'/%3E%3Cellipse cx='40' cy='160' rx='15' ry='6' transform='rotate(135 40 160)'/%3E%3Cellipse cx='40' cy='160' rx='15' ry='6' transform='rotate(-105 40 160)'/%3E%3Ccircle cx='40' cy='160' r='3'/%3E%3Cellipse cx='170' cy='140' rx='12' ry='5' transform='rotate(20 170 140)'/%3E%3Cellipse cx='170' cy='140' rx='12' ry='5' transform='rotate(92 170 140)'/%3E%3Cellipse cx='170' cy='140' rx='12' ry='5' transform='rotate(164 170 140)'/%3E%3Ccircle cx='170' cy='140' r='3'/%3E%3C/g%3E%3C/svg%3E");
  min-height: 0;
}

.messages::-webkit-scrollbar {
  width: 6px;
}

.messages::-webkit-scrollbar-track {
  background: #d0d0d0;
}

.messages::-webkit-scrollbar-thumb {
  background: #999999;
  border-radius: 3px;
}

.message {
  max-width: 75%;
  padding: 12px 18px;
  border-radius: 20px;
  word-wrap: break-word;
  font-size: 0.95rem;
  line-height: 1.4;
  animation: fadeIn 0.3s ease;
}

.bottom-left-img {
  position: fixed;
  bottom: -100px;
  left: 30px;
  width: min(600px, 55vw);
  max-width: 600px;
  height: auto;
  border-radius: 20px;
  opacity: 0.35;
  z-index: 5;
  pointer-events: none;
  -webkit-mask-image: radial-gradient(ellipse at center, black 40%, transparent 75%);
  mask-image: radial-gradient(ellipse at center, black 40%, transparent 75%);
}

.bottom-right-img {
  position: fixed;
  bottom: 0px;
  right: 0px;
  width: min(550px, 50vw);
  max-width: 550px;
  height: auto;
  border-radius: 20px;
  opacity: 0.25;
  z-index: 5;
  pointer-events: none;
  -webkit-mask-image: radial-gradient(ellipse at center, black 40%, transparent 75%);
  mask-image: radial-gradient(ellipse at center, black 40%, transparent 75%);
  filter: sepia(0.6) saturate(0.5) hue-rotate(10deg) brightness(1.2) contrast(1.1);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.message.own {
  align-self: flex-end;
  background: linear-gradient(135deg, #053e65 0%, #0a5a8a 100%);
  color: white;
  border-bottom-right-radius: 6px;
  text-shadow: none;
}

.message.other {
  align-self: flex-start;
  background: #c0c0c0;
  color: #333333;
  border-bottom-left-radius: 6px;
}

.message.system {
  align-self: center;
  background: transparent;
  color: #000000;
  font-size: 0.8rem;
  font-style: italic;
  padding: 8px 16px;
  border: none;
  border-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'%3E%3Ctext x='5' y='15' font-size='12' fill='%23c4a882'%3E%E2%99%A5%3C/text%3E%3C/svg%3E") 10 round;
  border-width: 4px;
  border-style: solid;
  border-radius: 12px;
}

.input-area {
  display: flex;
  align-items: center;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  padding-left: calc(16px + env(safe-area-inset-left));
  padding-right: calc(16px + env(safe-area-inset-right));
  gap: 12px;
  background: #d0d0d0;
  border-top: 2px solid #b0b0b0;
  flex-shrink: 0;
}

.typing-indicator {
  padding: 6px 20px;
  font-size: 0.8rem;
  color: #666666;
  font-style: italic;
  background: #d0d0d0;
  flex-shrink: 0;
}

#messageInput {
  flex: 1;
  min-width: 0;
  padding: 14px 22px;
  border: none;
  border-radius: 25px;
  /* Must stay >= 16px: iOS Safari auto-zooms the page on focus below that. */
  font-size: 16px;
  outline: none;
  background: #ffffff;
  color: #333333;
  transition: box-shadow 0.3s;
  border: 2px solid #999999;
}

#messageInput::placeholder {
  color: #999999;
}

#messageInput:focus {
  box-shadow: 0 0 0 3px rgba(47, 79, 79, 0.3);
  border-color: #2f4f4f;
}

#sendBtn {
  padding: 14px 24px;
  border-radius: 25px;
}

.connect-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
  max-width: 480px;
  padding: 20px;
  position: relative;
  z-index: 10;
}

.welcome-text {
  background: linear-gradient(135deg, #000000 0%, #000000 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 16px;
  letter-spacing: 0.5px;
}

.nickname-row {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
  width: 100%;
  max-width: 320px;
}

.nickname-input {
  padding: 12px 20px;
  border: 2px solid #8f5943;
  border-radius: 25px;
  /* Must stay >= 16px: iOS Safari auto-zooms the page on focus below that. */
  font-size: 16px;
  outline: none;
  background: #ffffff;
  color: #333333;
  flex: 1;
  min-width: 0;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.nickname-input::placeholder {
  color: #999999;
}

.nickname-input:focus {
  border-color: #8f5943;
  box-shadow: 0 0 0 3px rgba(143, 89, 67, 0.3);
}

.btn-nickname {
  padding: 12px 24px;
  border-radius: 25px;
  flex-shrink: 0;
  background: linear-gradient(135deg, #8f5943 0%, #a66a52 100%);
  color: white;
  font-weight: 600;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  border: none;
  transition: all 0.3s ease;
}

@media (hover: hover) and (pointer: fine) {
  .btn-nickname:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(143, 89, 67, 0.4);
  }
}

.connect-icon {
  font-size: 4rem;
  margin-bottom: 20px;
}

.connect-title {
  background: linear-gradient(135deg, #ffffff 0%, #ffffff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-size: 1.2rem;
  margin-bottom: 8px;
  font-weight: 600;
  filter: drop-shadow(2px 2px 3px rgba(0,0,0,0.5)) drop-shadow(4px 4px 6px rgba(0,0,0,0.3));
}

.connect-subtitle {
  background: linear-gradient(135deg, #ffffff 0%, #ffffff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-size: 1rem;
  font-weight: 400;
  margin-bottom: 30px;
  filter: drop-shadow(2px 2px 3px rgba(0,0,0,0.5)) drop-shadow(4px 4px 6px rgba(0,0,0,0.3));
}

.left-notice {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px;
  padding-bottom: calc(30px + env(safe-area-inset-bottom));
  background: #d0d0d0;
  border-top: 2px solid #b0b0b0;
  flex-shrink: 0;
}

.left-icon {
  font-size: 3rem;
  margin-bottom: 15px;
}

.left-text {
  color: #333333;
  font-size: 1rem;
  margin-bottom: 20px;
  font-weight: 500;
}

.suggestion-btn {
  background: #915853;
  color: white;
  border: 2px solid #915853;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
  flex-shrink: 0;
  white-space: nowrap;
  position: relative;
  z-index: 10;
}

@media (hover: hover) and (pointer: fine) {
  .suggestion-btn:hover {
    background: #7a4a46;
    border-color: #7a4a46;
  }
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  background: rgba(0,0,0,0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
  overflow-y: auto;
}

.modal-content {
  background: #333333;
  border-radius: 20px;
  padding: 30px;
  width: 100%;
  max-width: 400px;
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.modal-header {
  text-align: center;
  margin-bottom: 20px;
}

.modal-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 10px;
}

.modal-header h2 {
  color: #e0e0e0;
  font-size: 1.3rem;
}

.suggestion-textarea {
  width: 100%;
  padding: 14px;
  border: 2px solid #555555;
  border-radius: 12px;
  font-size: 1rem;
  font-family: inherit;
  resize: none;
  outline: none;
  transition: border-color 0.3s;
  background: #1a1a1a;
  color: #e0e0e0;
}

.suggestion-textarea:focus {
  border-color: #ff9a9e;
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.btn-secondary {
  background: #555555;
  color: #e0e0e0;
  flex: 1;
}

.btn-secondary:hover {
  background: #666666;
}

.modal-actions .btn-primary {
  flex: 1;
}

.btn-attach {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid #555555;
  background: #1a1a1a;
  color: #cccccc;
  font-size: 1.4rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
  flex-shrink: 0;
}

.btn-attach:hover {
  background: #333333;
  border-color: #cccccc;
}

.message-image {
  width: 260px;
  max-width: 100%;
  max-height: 300px;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
  cursor: pointer;
  display: block;
}

.message-video {
  width: 280px;
  max-width: 100%;
  max-height: 300px;
  height: auto;
  border-radius: 12px;
  display: block;
}

.message-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(255,255,255,0.1);
  text-decoration: none;
  color: #e0e0e0;
  transition: background 0.2s;
}

.message-file:hover {
  background: rgba(255,255,255,0.2);
}

.message-file-icon {
  font-size: 1.8rem;
}

.message-file-name {
  font-size: 0.85rem;
  word-break: break-all;
}

.message.own .message-file {
  background: rgba(255,255,255,0.3);
}

.message.own .message-file:hover {
  background: rgba(255,255,255,0.5);
}

/* ---------- Tablets and below ---------- */
@media (max-width: 768px) {
  .container {
    border-width: 2px;
  }

  .header {
    padding: 14px 16px;
    padding-top: calc(14px + env(safe-area-inset-top));
    padding-left: calc(16px + env(safe-area-inset-left));
    padding-right: calc(16px + env(safe-area-inset-right));
  }

  .connect-icon {
    font-size: 3.2rem;
    margin-bottom: 16px;
  }

  .welcome-text {
    font-size: 1.4rem;
  }

  /* Pull the decorative art back so it never sits under the chat controls. */
  .bottom-left-img {
    left: -10px;
    bottom: -40px;
    opacity: 0.18;
  }

  .bottom-right-img {
    opacity: 0.14;
  }
}

/* ---------- Phones ---------- */
@media (max-width: 500px) {
  .logo-img-wrap {
    width: 40px;
    height: 40px;
  }

  .logo-text {
    font-size: 1.05rem;
    -webkit-text-stroke-width: 1px;
    letter-spacing: 0.5px;
  }

  .logo-icon {
    font-size: 1.6rem;
  }

  .status {
    padding: 10px 14px;
    font-size: 0.8rem;
  }

  .btn {
    padding: 13px 24px;
    font-size: 0.9rem;
  }

  .btn-danger {
    padding: 10px 14px;
    font-size: 0.7rem;
  }

  .messages {
    padding: 16px 14px;
  }

  .message {
    max-width: 85%;
    font-size: 0.9rem;
  }

  .chat-header {
    padding: 12px 14px;
    padding-left: calc(14px + env(safe-area-inset-left));
    padding-right: calc(14px + env(safe-area-inset-right));
  }

  .chat-header-title {
    font-size: 0.82rem;
  }

  .input-area {
    padding: 12px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    padding-left: calc(12px + env(safe-area-inset-left));
    padding-right: calc(12px + env(safe-area-inset-right));
    gap: 8px;
  }

  #messageInput {
    padding: 12px 18px;
  }

  #sendBtn {
    padding: 12px 18px;
    font-size: 0.85rem;
  }

  .connect-title {
    font-size: 1.1rem;
  }

  .connect-subtitle {
    font-size: 0.95rem;
    margin-bottom: 24px;
  }

  .left-notice {
    padding: 24px 20px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
  }

  .modal-content {
    padding: 24px 20px;
  }

  .modal-icon {
    font-size: 2.4rem;
  }
}

/* ---------- Small phones (iPhone SE and narrower) ---------- */
@media (max-width: 400px) {
  /* Collapse the header action to just its icon so the logo keeps its room. */
  .suggestion-btn-text {
    display: none;
  }

  .suggestion-btn {
    padding: 0;
    width: 40px;
    height: 40px;
    font-size: 1.1rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .logo-text {
    font-size: 0.95rem;
  }

  .message {
    max-width: 90%;
  }

  .btn {
    padding: 12px 20px;
    font-size: 0.85rem;
  }

  .nickname-row {
    max-width: 100%;
  }
}

/* ---------- Short viewports (landscape phones, on-screen keyboard) ---------- */
@media (max-height: 600px) {
  .header {
    padding: 10px 16px;
    padding-top: calc(10px + env(safe-area-inset-top));
  }

  .logo-img-wrap {
    width: 36px;
    height: 36px;
  }

  .logo-icon {
    font-size: 1.4rem;
  }

  .logo-text {
    font-size: 1rem;
  }

  .status {
    padding: 8px;
    font-size: 0.78rem;
  }

  .messages {
    padding: 12px;
    gap: 8px;
  }

  .message {
    padding: 10px 14px;
    font-size: 0.85rem;
  }

  .input-area {
    padding: 10px 12px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }

  .connect-icon {
    font-size: 2.4rem;
    margin-bottom: 10px;
  }

  .welcome-text {
    font-size: 1.2rem;
    margin-bottom: 10px;
  }

  .nickname-row {
    margin-bottom: 14px;
  }

  .connect-subtitle {
    margin-bottom: 16px;
  }

  .left-notice {
    padding: 16px;
  }

  .left-icon {
    font-size: 2rem;
    margin-bottom: 8px;
  }

  /* The art has no room to breathe here and only crowds the controls. */
  .bottom-left-img,
  .bottom-right-img {
    display: none;
  }
}
