/* ═══════════════════════════════════════════════════════════
   Clapp Hub · theme
   Black canvas, orange flame.
   ═══════════════════════════════════════════════════════════ */

:root {
  --bg: #000000;
  --bg-soft: #101010;
  --surface: #161616;
  --surface-2: #1d1d1d;
  --line: #2a2a2a;

  --orange: #ff8c1a;
  --orange-bright: #ffab40;
  --orange-deep: #e65c00;
  --orange-glow: rgba(255, 140, 26, 0.35);

  --text: #f4ede2;
  --muted: #9b938a;

  --radius: 14px;
  --radius-lg: 22px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg); /* exactly black */
}

body {
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

::selection { background: var(--orange); color: #111; }

/* ─── Top bar ─────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  background: rgba(10, 10, 10, 0.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.brand-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--orange-bright), var(--orange-deep));
  box-shadow: 0 0 12px var(--orange-glow);
}

.nav { display: flex; gap: 6px; }

.nav-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  transition: color 0.18s, background 0.18s, box-shadow 0.18s;
}

.nav-link:hover { color: var(--text); background: var(--surface-2); }

.nav-link.active {
  color: #1a1005;
  background: linear-gradient(135deg, var(--orange-bright), var(--orange));
  box-shadow: 0 4px 18px var(--orange-glow);
}

/* ─── Screens ─────────────────────────────────────────────── */
main { flex: 1; display: flex; }

.screen {
  display: none;
  flex: 1;
  width: 100%;
}

.screen.active { display: flex; animation: fadeIn 0.28s ease; }

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

.hidden { display: none !important; }
.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }

/* ─── Home ────────────────────────────────────────────────── */
#screen-home {
  position: relative;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow: hidden;
  padding: 9vh 20px 40px;
}

.home-content {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 1080px;
  width: 100%;
  margin-top: 40vh;
}

.logo-wrap {
  position: absolute;
  left: 50%;
  /* wordmark band (40–59% of the logo's height) anchors near the top of the screen */
  top: calc(22vh - min(312px, 28.8vw));
  transform: translateX(-50%);
  width: min(1040px, 96vw);
  z-index: 0;
  pointer-events: none;
}

.logo {
  display: block;
  width: min(1040px, 100%);
  height: auto;
  margin: 0 auto;
  /* no box, no frame, no bounce — the logo's own background blends into the page */
  background: transparent;
  border-radius: 0;
  box-shadow: none;
}

.logo-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 148px;
  height: 148px;
  margin: 0 auto;
  border-radius: 32px;
  background:
    linear-gradient(135deg, rgba(255, 140, 26, 0.16), rgba(255, 140, 26, 0.05)),
    var(--surface);
  box-shadow: 0 0 0 1px var(--line), 0 0 50px var(--orange-glow);
}

.logo-fallback .fa-hands-clapping {
  font-size: 64px;
  color: var(--orange-bright);
  filter: drop-shadow(0 0 16px var(--orange-glow));
}

.app-grid {
  display: grid;
  /* buttons side by side on the x axis */
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  text-align: left;
}

.app-card {
  position: relative;
  display: block;
  padding: 26px 24px 22px;
  background: linear-gradient(160deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--text);
  overflow: hidden;
  transition: transform 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
}

.app-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--orange), var(--orange-bright));
  opacity: 0.85;
}

.app-card:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 140, 26, 0.55);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5), 0 0 30px rgba(255, 140, 26, 0.12);
}

.card-icon {
  font-size: 1.9rem;
  margin-bottom: 12px;
  color: var(--orange-bright);
}

.card-title { font-size: 1.25rem; font-weight: 700; margin-bottom: 6px; }

.card-desc { color: var(--muted); font-size: 0.92rem; line-height: 1.5; margin-bottom: 14px; }

.card-cta {
  display: inline-block;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--orange-bright);
  transition: transform 0.2s ease, color 0.2s ease;
}

.app-card:hover .card-cta { transform: translateX(4px); color: var(--orange); }

/* ─── Shared UI bits ──────────────────────────────────────── */
.btn {
  font: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  border: none;
  border-radius: 999px;
  padding: 11px 22px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

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

.btn-primary {
  color: #1a1005;
  background: linear-gradient(135deg, var(--orange-bright), var(--orange));
  box-shadow: 0 6px 22px rgba(255, 140, 26, 0.35);
}

.btn-primary:hover { box-shadow: 0 8px 28px rgba(255, 140, 26, 0.5); }

.btn-ghost {
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
}

.btn-ghost:hover { color: var(--text); border-color: var(--orange); }

.input {
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}

.input:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(255, 140, 26, 0.18);
}

.input::placeholder { color: #6b645c; }

.screen-title { margin: 0; font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em; }

/* ─── Chat ────────────────────────────────────────────────── */
#screen-chat { justify-content: center; padding: 26px 18px 40px; }

.chat-shell {
  width: 100%;
  max-width: 760px;
  height: min(680px, calc(100vh - 150px));
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
}

.chat-subtitle { margin: 4px 0 0; color: var(--muted); font-size: 0.85rem; }

.mode-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(255, 140, 26, 0.12);
  color: var(--orange-bright);
  border: 1px solid rgba(255, 140, 26, 0.35);
}

.name-gate {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px;
}

.name-gate-inner { text-align: center; max-width: 380px; width: 100%; }

.name-gate-inner h3 { margin: 0 0 18px; font-size: 1.2rem; }

.name-options {
  display: flex;
  gap: 14px;
  justify-content: center;
}

.name-option {
  font-size: 1.35rem;
  font-weight: 800;
  min-width: 130px;
  padding: 18px 20px;
}

.password-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.password-title { margin: 0; color: var(--muted); font-size: 0.9rem; }

.pw-form {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 320px;
}

.pw-form .input { flex: 1; text-align: center; }

.pw-error {
  margin: 0;
  color: #ff7b72;
  font-size: 0.82rem;
  font-weight: 600;
}

.chat-main { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.message-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message-list::-webkit-scrollbar { width: 8px; }
.message-list::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; }
.message-list::-webkit-scrollbar-thumb:hover { background: var(--orange); }

.message {
  align-self: flex-start;
  max-width: 78%;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 14px 14px 14px 4px;
  animation: popIn 0.18s ease;
}

@keyframes popIn {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.message.mine {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(255, 140, 26, 0.22), rgba(255, 140, 26, 0.08));
  border-color: rgba(255, 140, 26, 0.45);
  border-radius: 14px 14px 4px 14px;
}

.message-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 3px;
}

.message-name { font-size: 0.78rem; font-weight: 800; color: var(--orange-bright); }

.message.mine .message-name { color: var(--orange); }

.message-time { font-size: 0.68rem; color: var(--muted); }

.message-text { margin: 0; font-size: 0.95rem; line-height: 1.45; word-wrap: break-word; }

.message-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.message-edited {
  font: inherit;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline dotted;
}

.message-edited:hover { color: var(--orange-bright); }

.message-original {
  margin: 6px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  font-style: italic;
  word-wrap: break-word;
}

.message-edit {
  margin-left: auto;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 3px 8px;
  border-radius: 6px;
}

.message-edit:hover {
  color: var(--orange-bright);
  background: rgba(255, 140, 26, 0.12);
}

.message-editbox {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.message-editbox .input { flex: 1; padding: 8px 12px; font-size: 0.9rem; }

.message-editbox .btn { padding: 8px 14px; font-size: 0.85rem; white-space: nowrap; }

.message-delete {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
}

.message-delete:hover { color: #ff6b5e; background: rgba(255, 80, 60, 0.12); }

.message-delete.armed { color: #fff; background: #e5484d; }

.message.deleted {
  border-style: dashed;
  opacity: 0.9;
}

.message-deleted-note {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  font-style: italic;
}

.message-deleted-note .fa-ban { color: var(--orange); }

.message-deleted-view {
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--orange-bright);
  background: transparent;
  border: 1px solid rgba(255, 140, 26, 0.4);
  border-radius: 999px;
  padding: 3px 12px;
  margin-top: 8px;
  cursor: pointer;
}

.message-deleted-view:hover { background: rgba(255, 140, 26, 0.12); }

.message-deleted-content { margin-top: 8px; }

.chat-status {
  align-self: center;
  font-size: 0.72rem;
  color: var(--muted);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  padding: 4px 12px;
  border-radius: 999px;
}

.message-form {
  display: flex;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  background: var(--bg-soft);
}

.message-form .input { flex: 1; }

/* ─── Snake (EXAMPLES game embedded) ─────────────────────── */
#screen-snake { padding: 14px 18px 24px; }

#snakeFrame {
  flex: 1;
  width: 100%;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #000;
  box-shadow: var(--shadow);
}

/* (legacy built-in snake styles kept for reference) */
.snake-shell { width: 100%; max-width: 520px; }

.snake-frame {
  border: 1px solid #c9bd97;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: #e9e1c8;
}

.snake-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  height: 58px;
  padding: 0 14px;
  background: #644d1f;
  user-select: none;
}

.snake-bar-scores {
  display: flex;
  align-items: center;
  gap: 10px;
}

.snake-bar-icon { font-size: 1.1rem; color: #fff; }

.snake-bar-value {
  font-family: "Nunito", "Inter", sans-serif;
  font-weight: 800;
  font-size: 1.3rem;
  color: #fff;
  min-width: 22px;
  margin-right: 4px;
}

.snake-bar-actions { display: flex; gap: 4px; }

.snake-bar-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.85);
  font-size: 1.05rem;
  cursor: pointer;
  padding: 8px 9px;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}

.snake-bar-btn:hover { background: rgba(0, 0, 0, 0.28); color: #fff; }

.canvas-wrap {
  position: relative;
  background: #e9e1c8;
}

#snakeCanvas { display: block; width: 100%; height: auto; background: #e9e1c8; }

.snake-keys {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.55);
  text-align: center;
}

.snake-keys .fa-arrows {
  font-size: 2.4rem;
  color: #fff;
  padding: 20px 26px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 16px;
}

.snake-keys span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.snake-countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Nunito", "Inter", sans-serif;
  font-size: 7rem;
  font-weight: 900;
  color: #2e7d32;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.12);
  pointer-events: none;
  z-index: 5;
}

.snake-overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.72);
  transition: opacity 0.3s;
  padding: 20px;
}

.snake-panel {
  width: min(300px, 86%);
  background: #644d1f;
  border-radius: 10px;
  padding: 26px 30px 24px;
  text-align: center;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.6);
}

.overlay-title {
  margin: 0 0 4px;
  font-family: "Nunito", "Inter", sans-serif;
  font-size: 1.9rem;
  font-weight: 900;
  color: #fff;
}

.overlay-hint {
  margin: 0 0 16px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.84rem;
}

.snake-panel-scores {
  display: flex;
  justify-content: center;
  gap: 28px;
  margin-bottom: 18px;
}

.snake-panel-score {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: "Nunito", "Inter", sans-serif;
  font-weight: 800;
  font-size: 1.55rem;
  color: #fff;
}

.snake-panel-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.btn-snake {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: 800 1.05rem/1 "Nunito", "Inter", sans-serif;
  color: #fff;
  background: #56ad1e;
  border: none;
  border-radius: 10px;
  padding: 13px 26px;
  cursor: pointer;
  transition: transform 0.12s, filter 0.12s;
}

.btn-snake:hover { filter: brightness(1.12); }

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

.btn-snake-shuffle {
  width: 50px;
  padding: 0;
  font-size: 1.05rem;
}

/* ─── Footer ──────────────────────────────────────────────── */
.footer {
  padding: 14px 22px;
  text-align: center;
  color: #55504a;
  font-size: 0.78rem;
  border-top: 1px solid var(--line);
  background: rgba(10, 10, 10, 0.6);
}

@media (max-width: 520px) {
  .chat-shell { height: calc(100vh - 120px); }
  .message { max-width: 90%; }
  .nav { gap: 2px; }
  .nav-link { padding: 7px 10px; font-size: 0.85rem; }
  .brand { gap: 7px; }
  .app-card { padding: 18px 14px 16px; }
  .card-title { font-size: 1.08rem; }
  .card-desc { font-size: 0.8rem; }
  .card-icon { font-size: 1.5rem; margin-bottom: 8px; }
}

@media (max-width: 380px) {
  .brand-name { display: none; } /* keep just the orange dot on tiny screens */
  .topbar { padding: 12px 14px; }
}
