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

html,
body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #020617; /* fond sombre comme l'app */
}

body {
  position: fixed;
  inset: 0;
}

.chat-messages,
.settings-body {
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #1f2937 0, #020617 55%, #000 100%);
  color: #f9fafb;
  display: flex;
  justify-content: center;
  align-items: stretch;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

.app-container {
  width: 100%;
  max-width: 480px;
  background: rgba(15, 23, 42, 0.95);
  border-radius: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.35);
  display: flex;
  flex-direction: column;
}

.screen {
  display: none;
  padding: 16px;
  height: 100%;
  flex-direction: column;
}

.screen.active {
  display: flex;
}

h1 {
  font-size: 1.6rem;
  margin-bottom: 8px;
}

p {
  margin-bottom: 12px;
  color: #cbd5f5;
  font-size: 1.05rem;
}

/* Splash */
.splash-logo {
  margin-top: 120px;
  text-align: center;
  font-size: 2.1rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #4ade80;
  text-shadow: 0 0 16px rgba(34, 197, 94, 0.5);
}

.splash-sub {
  margin-top: 12px;
  text-align: center;
  color: #9ca3af;
}

/* Fields & buttons */
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 14px;
}

.field span {
  font-size: 1rem;
  color: #e5e7eb;
}

.checkbox-field {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

input[type="text"],
input[type="password"],
select {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.5);
  background: rgba(15, 23, 42, 0.9);
  color: #f9fafb;
  font-size: 1.1rem;
}

input::placeholder {
  color: #6b7280;
}

.btn-row {
  display: flex;
  gap: 8px;
}

.btn {
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  padding: 10px 18px;
  background: rgba(15, 23, 42, 0.9);
  color: #e5e7eb;
  font-size: 1.05rem;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s, box-shadow 0.15s;
}

.btn.primary {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  border-color: transparent;
  color: #f9fafb;
  box-shadow: 0 10px 20px rgba(79, 70, 229, 0.4);
}

.btn.small {
  padding-inline: 10px;
}

.btn.danger {
  background: linear-gradient(135deg, #b91c1c, #dc2626);
  border-color: transparent;
  color: #fee2e2;
}

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

.icon-btn {
  border-radius: 999px;
  border: none;
  width: 32px;
  height: 32px;
  background: rgba(15, 23, 42, 0.9);
  color: #e5e7eb;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.error-msg {
  margin-top: 8px;
  font-size: 0.95rem;
  color: #f87171;
}

/* Chat */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.chat-title {
  font-weight: 600;
  font-size: 1.25rem;
}

.chat-subtitle {
  font-size: 0.95rem;
  color: #9ca3af;
}

.chat-messages {
  flex: 1;
  background: radial-gradient(circle at top, #020617 0, #020617 30%, #000 100%);
  border-radius: 20px;
  padding: 10px;
  overflow-y: auto;
  margin-bottom: 8px;
  border: 1px solid rgba(55, 65, 81, 0.7);
}

.msg-row {
  display: flex;
  margin-bottom: 6px;
}

.msg-row.me {
  justify-content: flex-end;
}

.msg-bubble {
  max-width: 78%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 1.05rem;
  line-height: 1.4;
  position: relative;
}

.msg-row.me .msg-bubble {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #f9fafb;
  border-bottom-right-radius: 4px;
}

.msg-row.other .msg-bubble {
  background: rgba(31, 41, 55, 0.95);
  color: #e5e7eb;
  border-bottom-left-radius: 4px;
}

.msg-meta {
  font-size: 0.85rem;
  color: #9ca3af;
  margin-top: 2px;
}

.msg-image {
  max-width: 100%;
  border-radius: 10px;
  margin-bottom: 6px;
}

.msg-audio {
  width: 100%;
  margin-bottom: 4px;
}

/* Actions & réactions */
.msg-actions {
  position: absolute;
  top: 2px;
  right: 4px;
  border: none;
  background: transparent;
  color: rgba(148, 163, 184, 0.8);
  font-size: 0.9rem;
  cursor: pointer;
}

.msg-reactions {
  margin-top: 4px;
  font-size: 0.9rem;
  color: #f3f4f6;
  opacity: 0.9;
}

/* Chat input */
.chat-input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 4px;
}

.chat-input-bar input[type="text"] {
  flex: 1;
  font-size: 1.05rem;
}

/* Settings */
.settings-body {
  flex: 1;
  overflow-y: auto;
  padding-top: 8px;
}

.settings-body section {
  margin-bottom: 18px;
}

.settings-body h2 {
  font-size: 1.15rem;
  margin-bottom: 6px;
}

.danger-zone {
  border-top: 1px solid rgba(148, 163, 184, 0.4);
  padding-top: 10px;
}

/* Snake fullscreen */
.screen-snake {
  padding: 0;
  background: #020617;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

#snake-canvas {
  background: #020617;
  border-radius: 12px;
  border: 2px solid #22c55e;
  box-shadow: 0 0 20px rgba(34, 197, 94, 0.5);
}

/* Big controls */
.snake-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  margin-bottom: 20px;
}

.snake-btn {
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  width: 72px;
  height: 72px;
  background: rgba(15, 23, 42, 0.95);
  color: #e5e7eb;
  font-size: 1.8rem;
  cursor: pointer;
  touch-action: manipulation;
}

/* Scrollbars */
.chat-messages::-webkit-scrollbar,
.settings-body::-webkit-scrollbar {
  width: 6px;
}
.chat-messages::-webkit-scrollbar-thumb,
.settings-body::-webkit-scrollbar-thumb {
  background: rgba(75, 85, 99, 0.8);
  border-radius: 999px;
}
