/* =========================================================
   CapitalSim — monochrome glassy UI
   ========================================================= */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a0a;
  --bg-2: #101010;
  --glass: rgba(255, 255, 255, 0.04);
  --glass-2: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.08);
  --border-2: rgba(255, 255, 255, 0.14);
  --text: #e8e8e8;
  --text-dim: #8a8a8a;
  --text-dim-2: #555;
  --white: #ffffff;
  --radius: 14px;
  --nav-h: 56px;
  --bottom-h: 56px;
}

html, body { height: 100%; overflow-x: hidden; }

body {
  background: var(--bg);
  background-image:
    radial-gradient(1200px 800px at 15% -10%, rgba(255,255,255,0.06), transparent 60%),
    radial-gradient(1000px 700px at 100% 100%, rgba(255,255,255,0.04), transparent 60%),
    radial-gradient(800px 600px at 50% 50%, rgba(255,255,255,0.02), transparent 70%);
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

/* =========================================================
   SVG icons
   ========================================================= */
.ico {
  width: 15px;
  height: 15px;
  display: inline-block;
  vertical-align: -2px;
  margin-right: 7px;
  color: currentColor;
  flex-shrink: 0;
}

.navbar a { display: inline-flex; align-items: center; }

.bn-icon {
  width: 20px;
  height: 20px;
  display: block;
  color: currentColor;
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

.bottom-nav a:active .bn-icon { transform: scale(0.92); }

/* =========================================================
   Navbar (desktop)
   ========================================================= */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 10, 10, 0.55);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  gap: 22px;
  align-items: center;
}

.navbar a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: color 0.2s ease;
  padding: 4px 0;
  position: relative;
}

.navbar a:hover { color: var(--white); }

.navbar .balance {
  margin-left: auto;
  color: var(--white);
  font-weight: 600;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  padding: 6px 14px;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 999px;
  backdrop-filter: blur(10px);
  display: inline-flex;
  align-items: center;
}

.bottom-nav { display: none; }

/* =========================================================
   Layout
   ========================================================= */
.container {
  padding: 40px 28px;
  max-width: 1400px;
  margin: 0 auto;
}

h1 {
  color: var(--white);
  font-size: 1.6rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  margin-bottom: 28px;
}

h2 {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 20px;
  color: var(--text-dim);
}

.grid  { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.grid2 { display: grid; grid-template-columns: 1fr 2fr; gap: 20px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }

/* =========================================================
   Cards
   ========================================================= */
.card {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.04) inset,
    0 8px 40px rgba(0,0,0,0.35);
  transition: border-color 0.25s ease, background 0.25s ease;
}

.card:hover {
  border-color: var(--border-2);
  background: var(--glass-2);
}

.pending-card {
  border-color: rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.06);
}

.pending-hint {
  color: var(--text-dim);
  font-size: 0.78rem;
  margin-top: 10px;
  letter-spacing: 0.02em;
}

/* =========================================================
   Ad unit — 4:1 aspect ratio
   ========================================================= */
.ad-unit {
  margin-top: 40px;
  padding: 12px;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  position: relative;
  aspect-ratio: 4 / 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.ad-label {
  position: absolute;
  top: 6px;
  left: 10px;
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-dim-2);
  pointer-events: none;
  z-index: 2;
}

.ad-inner {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.ad-inner > div,
.ad-inner > script + div {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ad-inner iframe,
.ad-inner img,
.ad-inner ins {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
}

/* =========================================================
   Inputs
   ========================================================= */
input, select, textarea {
  width: 100%;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 10px;
  margin: 6px 0;
  font-size: 16px;
  font-family: inherit;
  transition: border-color 0.2s ease, background 0.2s ease;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.05);
}

input::placeholder { color: var(--text-dim-2); }

select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%23888' fill='none' stroke-width='1.5' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 34px;
}

/* =========================================================
   Buttons
   ========================================================= */
button, .btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border-2);
  color: var(--white);
  padding: 12px 18px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  font-family: inherit;
  letter-spacing: 0.01em;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
  text-decoration: none;
  display: inline-block;
  min-height: 42px;
  touch-action: manipulation;
}

button:hover, .btn:hover {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.3);
}

button:active, .btn:active { background: rgba(255,255,255,0.08); }

.btn-dim {
  background: transparent;
  border-color: var(--border);
  color: var(--text-dim);
}
.btn-dim:hover {
  background: rgba(255,255,255,0.04);
  color: var(--text);
  border-color: var(--border-2);
}

/* =========================================================
   Tables
   ========================================================= */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 10px;
}

.table-wrap::-webkit-scrollbar { height: 6px; }
.table-wrap::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
.table-wrap::-webkit-scrollbar-track { background: transparent; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  min-width: 100%;
}

th, td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th {
  color: var(--text-dim);
  font-weight: 500;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding-top: 0;
}

tbody tr { transition: background 0.2s ease; }
tbody tr:hover { background: rgba(255,255,255,0.03); }
tbody tr:last-child td { border-bottom: none; }
td { font-variant-numeric: tabular-nums; }

.pos, .buy { color: var(--white); font-weight: 600; }
.neg, .sell { color: var(--text-dim); font-weight: 500; }
.pos::before, .buy::before { content: "▲ "; font-size: 0.7em; opacity: 0.7; }
.neg::before, .sell::before { content: "▼ "; font-size: 0.7em; opacity: 0.7; }

/* =========================================================
   Lists
   ========================================================= */
.list { list-style: none; padding: 0; margin: 0; }
.list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  flex-wrap: wrap;
}
.list li:last-child { border-bottom: none; }
.list a { color: var(--white); text-decoration: none; }
.list a:hover { text-decoration: underline; }

.empty-row { color: var(--text-dim-2); justify-content: center !important; }

/* =========================================================
   Avatars
   ========================================================= */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.02em;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.08);
  user-select: none;
}
.avatar-sm { width: 32px; height: 32px; font-size: 0.72rem; }
.avatar-xs { width: 24px; height: 24px; font-size: 0.62rem; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.1rem; }

.friend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}
.friend-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
}
.friend-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.friend-actions button {
  padding: 8px 12px;
  font-size: 0.78rem;
  min-height: 34px;
}

.pending-tag {
  color: var(--text-dim);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* =========================================================
   Auth
   ========================================================= */
.auth { max-width: 380px; margin: 12vh auto; text-align: center; padding: 40px 32px; }
.auth h1 { font-size: 1.5rem; margin-bottom: 8px; }
.auth input { margin-bottom: 10px; }
.auth button { width: 100%; padding: 14px; margin-top: 8px; background: rgba(255,255,255,0.1); }
.auth p { color: var(--text-dim); font-size: 0.85rem; margin-top: 20px; }
.auth a { color: var(--white); text-decoration: none; border-bottom: 1px solid var(--border-2); }
.auth a:hover { border-bottom-color: var(--white); }

/* =========================================================
   Flash
   ========================================================= */
.flash {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 0.88rem;
  background: var(--glass);
  border: 1px solid var(--border-2);
  backdrop-filter: blur(10px);
}
.flash.error { color: var(--white); border-color: rgba(255,255,255,0.3); }

/* =========================================================
   Market tabs
   ========================================================= */
.market-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.sym-tab {
  padding: 8px 14px;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 999px;
  min-height: 34px;
}
.sym-tab:hover {
  background: var(--glass);
  color: var(--white);
  border-color: var(--border-2);
}
.sym-tab.active {
  background: var(--white);
  color: var(--bg);
  border-color: var(--white);
}

/* =========================================================
   Price
   ========================================================= */
.price-big {
  font-size: 2rem;
  font-weight: 300;
  letter-spacing: -0.03em;
  color: var(--white);
  margin-top: 14px;
  font-variant-numeric: tabular-nums;
}

/* =========================================================
   Chat
   ========================================================= */
.msg-layout { display: grid; grid-template-columns: 260px 1fr; gap: 20px; }

.chat-messages {
  height: 420px;
  overflow-y: auto;
  padding: 16px;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
}

.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }

.chat-msg {
  padding: 8px 14px;
  border-radius: 14px;
  max-width: 72%;
  word-wrap: break-word;
  font-size: 0.88rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.chat-msg.mine {
  background: var(--white);
  color: var(--bg);
  margin-left: auto;
  border-bottom-right-radius: 4px;
}

.chat-msg.theirs {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.chat-msg b { font-weight: 600; opacity: 0.7; margin-right: 4px; font-size: 0.82rem; }
.chat-msg .avatar-xs { margin-right: 6px; }
.chat-body { display: flex; flex-direction: column; }
.chat-body b { font-size: 0.72rem; opacity: 0.6; margin-bottom: 2px; }

.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.chat-header h2 { margin: 0; }

.chat-status {
  font-size: 0.72rem;
  color: var(--text-dim-2);
  margin-top: 8px;
  letter-spacing: 0.04em;
}
.chat-status.live { color: #c8c8c8; }

#chat-form, #lobby-form { display: flex; gap: 8px; }
#chat-form input, #lobby-form input { flex: 1; margin: 0; }

/* =========================================================
   Message tabs
   ========================================================= */
.chat-list { padding: 0; }
.chat-tab {
  border-bottom: 1px solid var(--border);
  padding: 0 !important;
  display: block !important;
}
.chat-tab a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 6px;
  text-decoration: none;
  border-radius: 8px;
  transition: background 0.15s ease;
}
.chat-tab a:hover { background: rgba(255,255,255,0.04); }
.chat-tab.active a {
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border-2);
}
.chat-tab-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.badge {
  background: var(--white);
  color: var(--bg);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
}

/* =========================================================
   Tags
   ========================================================= */
.tag {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 999px;
  vertical-align: middle;
  background: var(--white);
  color: var(--bg);
  margin-left: 10px;
}
.tag.priv {
  background: transparent;
  border: 1px solid var(--border-2);
  color: var(--text-dim);
}

/* =========================================================
   Lobby cards & rows
   ========================================================= */
.lobby-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px -6px;
  border-radius: 12px;
  transition: background 0.15s ease;
}
.lobby-row:hover { background: rgba(255,255,255,0.03); }
.lobby-row .lobby-card { margin: 0; }

.lobby-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 18px;
  margin: 8px -6px;
  border-radius: 12px;
  border: 1px solid transparent;
  text-decoration: none;
  color: inherit;
  transition: all 0.2s ease;
  min-height: 60px;
}
.lobby-card:hover {
  background: rgba(255,255,255,0.05);
  border-color: var(--border-2);
}
.lobby-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.lobby-name {
  font-size: 0.98rem;
  font-weight: 500;
  color: var(--white);
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lobby-meta {
  font-size: 0.75rem;
  color: var(--text-dim);
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.lobby-arrow { color: var(--text-dim-2); font-size: 1.1rem; transition: all 0.2s ease; flex-shrink: 0; }
.lobby-card:hover .lobby-arrow { color: var(--white); transform: translateX(4px); }

.btn-delete {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 0;
  width: 34px;
  height: 34px;
  min-height: 34px;
  border-radius: 8px;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-right: 4px;
}
.btn-delete:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.35);
  color: var(--white);
}

.lobby-code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  color: var(--white);
  background: rgba(255,255,255,0.06);
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.lobby-code-inline {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  color: var(--text-dim);
  margin-left: 12px;
  vertical-align: middle;
  font-weight: 400;
  text-transform: uppercase;
}

.member-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.member-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
}
.member-tag {
  color: var(--text-dim-2);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* =========================================================
   Chart
   ========================================================= */
#chart { border-radius: 10px; overflow: hidden; }

/* =========================================================
   TABLET  (≤ 1024px)
   ========================================================= */
@media (max-width: 1024px) {
  .container { padding: 28px 20px; }
  .grid { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .grid3 { grid-template-columns: 1fr 1fr; }
  .msg-layout { grid-template-columns: 240px 1fr; }
}

/* =========================================================
   MOBILE  (≤ 768px)
   ========================================================= */
@media (max-width: 768px) {
  body {
    padding-bottom: calc(var(--bottom-h) + env(safe-area-inset-bottom) + 8px);
    font-size: 15px;
  }

  .navbar { display: none; }

  .bottom-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 200;
    height: calc(var(--bottom-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: rgba(10, 10, 10, 0.9);
    backdrop-filter: blur(24px) saturate(160%);
    -webkit-backdrop-filter: blur(24px) saturate(160%);
    border-top: 1px solid var(--border);
    overflow: hidden;
  }

  .bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.62rem;
    font-weight: 500;
    letter-spacing: 0.03em;
    padding: 6px 2px;
    transition: color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    overflow: hidden;
    min-width: 0;
  }

  .bottom-nav a:active {
    color: var(--white);
    background: rgba(255,255,255,0.05);
  }

  .bn-label {
    font-size: 0.62rem;
    letter-spacing: 0.03em;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }

  .container { padding: 20px 14px; }
  h1 { font-size: 1.35rem; margin-bottom: 18px; }
  h2 { font-size: 0.72rem; margin-bottom: 14px; }

  .card { padding: 16px; border-radius: 12px; margin-bottom: 14px; }

  .grid, .grid2, .grid3 { grid-template-columns: 1fr; gap: 14px; }

  /* Chat / messages */
  .msg-layout { grid-template-columns: 1fr; gap: 12px; }

  .chats-col { padding: 12px; }
  .chats-col h2 { margin-bottom: 10px; }
  .chat-list {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin: 0 -4px;
    padding: 0 4px;
  }
  .chat-list::-webkit-scrollbar { display: none; }
  .chat-tab {
    flex: 0 0 auto;
    border: none;
    padding: 0 !important;
  }
  .chat-tab a {
    flex-direction: column;
    gap: 4px;
    padding: 8px 10px;
    min-width: 68px;
    background: rgba(255,255,255,0.04);
    border-radius: 12px;
  }
  .chat-tab.active a { background: rgba(255,255,255,0.12); }
  .chat-tab-name { font-size: 0.68rem; max-width: 66px; }
  .avatar-sm { width: 36px; height: 36px; font-size: 0.78rem; }

  .chat-col { padding: 14px; }
  .chat-messages {
    height: calc(100vh - 380px);
    max-height: 420px;
    min-height: 220px;
    padding: 12px;
  }
  .chat-header h2 {
    font-size: 1rem;
    text-transform: none;
    letter-spacing: -0.01em;
    color: var(--white);
  }
  .chat-msg { max-width: 85%; font-size: 0.85rem; padding: 8px 12px; }

  /* Tables */
  table { font-size: 0.82rem; }
  th, td { padding: 10px 8px; }
  th { font-size: 0.65rem; }

  /* Chart */
  #chart { height: 240px !important; }
  .price-big { font-size: 1.6rem; margin-top: 10px; }

  /* Lobby cards */
  .lobby-card { padding: 14px; margin: 6px -4px; }
  .member-tag { display: none; }
  .lobby-code { font-size: 0.72rem; padding: 2px 6px; }
  .btn-delete {
    width: 40px;
    height: 40px;
    min-height: 40px;
  }
  .lobby-row { gap: 6px; }

  /* Buttons */
  button, .btn { padding: 11px 16px; font-size: 0.85rem; min-height: 44px; }
  .friend-actions button { padding: 8px 10px; font-size: 0.75rem; min-height: 34px; }

  /* Auth */
  .auth { margin: 6vh auto; padding: 32px 22px; max-width: 100%; }
  .auth h1 { font-size: 1.3rem; }

  /* Lists */
  .list li { padding: 10px 4px; font-size: 0.88rem; }

  /* Market tabs */
  .sym-tab { padding: 7px 12px; font-size: 0.75rem; min-height: 32px; }

  /* Ad unit */
  .ad-unit {
    aspect-ratio: 4 / 1;
    margin-top: 24px;
    padding: 8px;
  }
  .ad-label { font-size: 0.55rem; top: 4px; left: 8px; }
}

/* =========================================================
   SMALL PHONE  (≤ 380px) — icon-only nav
   ========================================================= */
@media (max-width: 380px) {
  .container { padding: 16px 10px; }
  h1 { font-size: 1.2rem; }
  .card { padding: 14px; }

  #chart { height: 200px !important; }
  .price-big { font-size: 1.35rem; }

  .bn-label { display: none; }
  .bn-icon { width: 22px; height: 22px; }
  .bottom-nav a { gap: 0; padding: 8px 2px; }

  .chat-messages { height: calc(100vh - 360px); min-height: 180px; }
  .chat-tab a { min-width: 60px; padding: 6px 8px; }
  .avatar-sm { width: 32px; height: 32px; font-size: 0.72rem; }

  .friend-actions { flex-direction: column; gap: 4px; width: 100%; }
  .friend-actions button { width: 100%; }

  .ad-unit { aspect-ratio: 4 / 1; padding: 6px; }
}

/* =========================================================
   TOUCH polish
   ========================================================= */
@media (hover: none) {
  button, .btn, .navbar a, .lobby-card, .bottom-nav a, .chat-tab a {
    -webkit-tap-highlight-color: transparent;
  }
  button:hover, .btn:hover { background: rgba(255,255,255,0.06); }
}

/* =========================================================
   Landscape phones
   ========================================================= */
@media (max-height: 500px) and (orientation: landscape) {
  .chat-messages { height: 55vh; max-height: 260px; }
  #chart { height: 200px !important; }
  .ad-unit { aspect-ratio: auto; height: 90px; }
}