/* Minecraft-like chat style, matches index page visuals */
:root{
  --bg-dark: #0b1220;
  --panel: rgba(10,12,15,0.86);
  --muted: #dbe9ff;
  --accent: #8b5cf6; /* slightly brighter purple */
  --me-bg: #2b6e24; /* keep green-ish for 'me' */
  --other-bg: rgba(255,255,255,0.04);
  --bubble-text: #f8fafc;
  --max-width: 920px;
}

.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}

/* Make background locked to viewport and prevent body scroll; chat container handles internal scrolling */
html,body{height:100%;min-height:100vh;overflow:auto}
body{
  margin:0;padding:0;font-family:'Open Sans', Arial, sans-serif;
  background-image: url('/img/minecraft.jpg'), url('https://bybilly.uk/portal/img/minecraft.jpg');
  background-size: cover; background-position:center; background-repeat:no-repeat; background-attachment: fixed;
  color:var(--muted);
}

/* full-screen overlay to darken the wallpaper (covers entire viewport) */
body::before{
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 0;
  pointer-events: none;
}

/* container layering */
*{box-sizing:border-box}
.chat-wrapper{width:100%;max-width:var(--max-width);display:block;padding:24px 12px;margin:48px auto;box-sizing:border-box;position:relative;z-index:10}
.chat-container{
  display:flex;flex-direction:column;
  width:min(920px,96vw);height:calc(100vh - 96px);max-height:calc(100vh - 96px);background:linear-gradient(180deg, rgba(0,0,0,0.45), rgba(10,10,10,0.65));border-radius:10px;overflow:hidden;border:3px solid rgba(0,0,0,0.55);
  margin:0 auto;
  /* allow flex children (.messages) to shrink and scroll correctly */
  min-height:0;
}

.header{display:flex;align-items:center;justify-content:space-between;padding:14px 18px;border-bottom:2px solid rgba(255,255,255,0.04);background:linear-gradient(90deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));}
.header{min-height:64px}
.brand{display:flex;align-items:center;gap:12px}
.brand img{height:44px}
.brand h2{margin:0;font-size:1.05rem;color:#fff;text-transform:uppercase;letter-spacing:1px}

.name-area{display:flex;align-items:center;gap:8px}
.name-area input{padding:8px 10px;border-radius:6px;border:1px solid rgba(255,255,255,0.06);min-width:160px;background:rgba(255,255,255,0.02);color:var(--muted)}
.name-area button{padding:8px 10px;border-radius:6px;border:1px solid rgba(255,255,255,0.04);background:var(--accent);color:white;cursor:pointer;font-weight:700}
.name-area button:focus{outline:3px solid rgba(79,70,229,0.18)}

.messages{flex:1 1 auto;overflow:auto;padding:18px;display:flex;flex-direction:column;gap:12px;background:transparent;min-height:0; -webkit-overflow-scrolling: touch;scroll-behavior: auto}

/* visible scrollbar styles for modern browsers */
.messages::-webkit-scrollbar{width:10px}
.messages::-webkit-scrollbar-thumb{background:rgba(255,255,255,0.07);border-radius:6px}
.messages{scrollbar-width:thin;scrollbar-color: rgba(255,255,255,0.07) transparent}

.message{display:flex;gap:12px;align-items:flex-end;max-width:78%;}
.message .avatar{width:36px;height:36px;border-radius:6px;background:#111;color:#fff;display:flex;align-items:center;justify-content:center;font-weight:700;font-size:0.9rem;border:2px solid rgba(255,255,255,0.04)}
.message .bubble{padding:10px 12px;border-radius:8px;box-shadow:inset 0 -1px 0 rgba(255,255,255,0.03);font-size:0.95rem;color:var(--bubble-text);max-width:100%;word-break:break-word}
.message .meta{display:block;font-size:0.78rem;color:rgba(255,255,255,0.5);margin-bottom:6px}

/* other/left */
.message.other{align-self:flex-start}
.message.other .bubble{background:rgba(255,255,255,0.03);border-left:4px solid rgba(255,255,255,0.03)}

/* me/right */
.message.me{align-self:flex-end;flex-direction:row-reverse}
.message.me .bubble{background:linear-gradient(180deg, rgba(43,110,36,0.98), rgba(34,99,31,0.98));color: #f8fff8;border-right:4px solid rgba(255,255,255,0.04)}

.message .time{display:block;font-size:0.72rem;color:rgba(255,255,255,0.45);margin-top:6px}

.composer{display:grid;grid-template-columns:1fr auto;padding:12px 12px;border-top:2px solid rgba(255,255,255,0.03);gap:8px;align-items:center;background:linear-gradient(180deg, rgba(0,0,0,0.35), rgba(0,0,0,0.45));position:sticky;bottom:0}
.composer{min-height:64px}
.composer input{flex:1 1 auto;min-width:0;padding:12px 14px;border-radius:8px;border:1px solid rgba(255,255,255,0.04);font-size:1rem;background:rgba(255,255,255,0.02);color:var(--muted);width:100%}
.composer button{padding:10px 14px;border-radius:8px;border:1px solid rgba(255,255,255,0.03);background:var(--accent);color:white;cursor:pointer;font-weight:700;flex:0 0 auto;min-width:84px}

/* Responsive tweaks */
@media (max-width:700px){
  .chat-wrapper{padding:6px;margin:6px}
  .message .avatar{width:30px;height:30px}
  .brand h2{font-size:0.95rem}
  .chat-container{width:100%;border-width:2px}
  .composer{grid-template-columns:1fr;flex-direction:column;gap:6px;padding:10px}
  .composer button{width:100%;min-width:0}
}

/* focus states */
button:focus,input:focus{outline:3px solid rgba(79,70,229,0.14);outline-offset:2px}

/* small helpers */

.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
