* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background-color: #C0C0C0;
  font-family: Tahoma, Verdana, sans-serif;
  font-size: 12px;
  color: #000;
  padding: 10px;
  -webkit-text-size-adjust: 100%; /* Prevent iOS zoom */
}

.app-container {
  max-width: 920px;
  margin: 0 auto;
  background: #D4D0C8;
  border: 2px outset #FFFFFF;
  box-shadow: 4px 4px 0 #808080;
}

.yahoo-header {
  background: linear-gradient(to right, #000080, #0033CC);
  color: #FFF;
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: bold;
  letter-spacing: 0.5px;
}
.logo { font-size: 16px; }
.nav span { cursor: pointer; text-decoration: underline; }
.nav span:hover { color: #FFCC00; }

.main-layout {
  display: flex;
  height: 480px;
  border-top: 2px groove #FFFFFF;
}

.sidebar-left, .sidebar-right {
  width: 150px;
  background: #E0E0E0;
  padding: 4px;
  overflow-y: auto;
}
.sidebar-left { border-right: 2px inset #808080; }
.sidebar-right { border-left: 2px inset #808080; }

.panel-title {
  background: #000080;
  color: #FFF;
  padding: 4px 6px;
  font-weight: bold;
  font-size: 11px;
  margin-bottom: 6px;
  border: 1px outset #4040A0;
}

#room-list, #user-list { list-style: none; }
#room-list li {
  padding: 5px 8px;
  cursor: pointer;
  margin-bottom: 2px;
  border: 1px solid transparent;
  font-size: 11px;
}
#room-list li:hover { background: #D0D0D0; }
#room-list li.active {
  background: #000080;
  color: #FFF;
  font-weight: bold;
}

#user-list li {
  padding: 3px 6px;
  font-size: 11px;
  border-bottom: 1px dotted #A0A0A0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #FFF;
}

.chat-header {
  background: #C0C0C0;
  padding: 4px 8px;
  border-bottom: 1px solid #808080;
  font-size: 11px;
  font-weight: bold;
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.45;
  background: #FAFAFA;
}

.msg { margin-bottom: 3px; word-wrap: break-word; }
.msg.system { color: #666; font-style: italic; font-size: 11px; }
.msg .time { color: #555; font-size: 10px; margin-right: 4px; }
.msg .user { color: #0000CC; font-weight: bold; cursor: pointer; }
.msg .user:hover { text-decoration: underline; }
.msg .text { color: #000; }

.input-area {
  background: #D4D0C8;
  padding: 6px;
  border-top: 2px groove #FFFFFF;
  display: flex;
  gap: 4px;
}
.input-area input {
  flex: 1;
  padding: 4px 6px;
  border: 2px inset #A0A0A0;
  font-family: inherit;
  font-size: 12px;
  background: #FFF;
}
.input-area button {
  padding: 4px 12px;
  background: #D4D0C8;
  border: 2px outset #FFFFFF;
  font-family: inherit;
  font-size: 11px;
  font-weight: bold;
  cursor: pointer;
}
.input-area button:active { border-style: inset; }
.input-area button:disabled { background: #A8A8A8; color: #666; cursor: default; }

.status-bar {
  background: #C0C0C0;
  padding: 4px 8px;
  font-size: 10px;
  display: flex;
  justify-content: space-between;
  border-top: 1px solid #808080;
}

/* 90s scrollbar styling */
::-webkit-scrollbar { width: 14px; }
::-webkit-scrollbar-track { background: #E0E0E0; border: 1px inset #A0A0A0; }
::-webkit-scrollbar-thumb { background: #A8A8A8; border: 1px outset #FFFFFF; }

/* Auth Modal */
.modal-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal-box {
  background: #C0C0C0;
  border: 2px outset #FFFFFF;
  box-shadow: 6px 6px 0 #808080;
  width: 280px;
}
.modal-title {
  background: linear-gradient(to right, #000080, #0033CC);
  color: #FFF;
  padding: 6px 10px;
  font-weight: bold;
  font-size: 12px;
}
.modal-content { padding: 15px; }
.modal-content input {
  width: 100%; padding: 6px; margin-bottom: 8px;
  border: 2px inset #A0A0A0; font-family: inherit; font-size: 12px;
  box-sizing: border-box;
}
.modal-actions { display: flex; gap: 8px; margin-top: 4px; }
.modal-actions button {
  flex: 1; padding: 6px; background: #D4D0C8;
  border: 2px outset #FFFFFF; font-family: inherit; font-size: 11px;
  font-weight: bold; cursor: pointer;
}
.modal-actions button:active { border-style: inset; }
.error-msg {
  color: #CC0000; font-size: 11px; margin-top: 8px; min-height: 14px;
  text-align: center;
}

/* 📱 MOBILE RESPONSIVE STYLES */
@media (max-width: 768px) {
  body { padding: 5px; }
  
  .app-container {
    border-width: 1px;
    box-shadow: 2px 2px 0 #808080;
  }
  
  .yahoo-header {
    padding: 6px 8px;
    flex-wrap: wrap;
    gap: 4px;
  }
  .logo { font-size: 14px; }
  .nav { font-size: 10px; }
  
  .main-layout {
    flex-direction: column; /* Stack vertically */
    height: auto;
    min-height: 500px;
  }
  
  /* Sidebars become top/bottom panels */
  .sidebar-left, .sidebar-right {
    width: 100%;
    max-height: 120px; /* Scrollable but compact */
    border: none;
    border-bottom: 2px inset #808080;
  }
  .sidebar-right {
    border-top: 2px inset #808080;
    border-bottom: none;
  }
  
  .panel-title {
    font-size: 10px;
    padding: 3px 5px;
    margin-bottom: 4px;
  }
  
  #room-list li, #user-list li {
    font-size: 10px;
    padding: 4px 6px;
  }
  
  .chat-header {
    font-size: 10px;
    padding: 3px 6px;
  }
  
  .messages-container {
    font-size: 11px;
    padding: 6px;
  }
  
  .msg .time { font-size: 9px; }
  .msg .user { font-size: 11px; }
  
  /* Input area: stack on very small screens */
  .input-area {
    flex-wrap: wrap;
    padding: 4px;
  }
  .input-area input {
    font-size: 13px; /* iOS won't zoom if >=16px, but 13px is readable */
    padding: 6px 8px;
    min-height: 36px; /* Better touch target */
  }
  .input-area button {
    padding: 6px 16px;
    font-size: 12px;
    min-height: 36px;
    width: 100%; /* Full-width button on mobile */
    margin-top: 4px;
  }
  
  .status-bar {
    font-size: 9px;
    padding: 3px 6px;
    flex-wrap: wrap;
    gap: 4px;
  }
  
  /* Modal: full-width on mobile */
  .modal-box {
    width: 90%;
    max-width: 320px;
  }
  .modal-content input {
    font-size: 14px; /* Prevent iOS zoom */
    padding: 8px;
    min-height: 40px;
  }
  .modal-actions button {
    padding: 8px;
    font-size: 12px;
    min-height: 40px;
  }
}

/* 📱 EXTRA SMALL PHONES (<480px) */
@media (max-width: 480px) {
  body { font-size: 13px; padding: 3px; }
  
  .main-layout { min-height: 450px; }
  
  .sidebar-left, .sidebar-right {
    max-height: 100px;
  }
  
  #room-list, #user-list {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
  }
  #room-list li, #user-list li {
    padding: 3px 5px;
    font-size: 9px;
    border: 1px outset #808080;
    border-radius: 2px;
  }
  
  .messages-container {
    font-size: 10px;
    line-height: 1.4;
  }
  
  .input-area input {
    font-size: 14px; /* iOS zoom prevention */
  }
  
  .status-bar {
    font-size: 8px;
  }
}

/* 🎨 Touch-friendly tweaks (no hover on mobile) */
@media (hover: none) and (pointer: coarse) {
  #room-list li:hover, #room-list li.active {
    background: #000080;
    color: #FFF;
  }
  .msg .user:hover {
    text-decoration: none;
    cursor: default;
  }
  .input-area button {
    min-height: 44px; /* Apple HIG minimum touch target */
  }
}

#logout-link:hover {
  color: #FFF !important;
  text-decoration: underline !important;
}
