:root {
  color-scheme: dark;
  --ink: #fff4d7;
  --muted: #c5d4b1;
  --leaf: #12351f;
  --gold: #f4cf6a;
  --amber: #bd7c35;
  --panel: rgba(13, 24, 18, 0.92);
  --panel-strong: rgba(20, 32, 23, 0.97);
  --shadow: rgba(1, 8, 5, 0.72);
}

* { box-sizing: border-box; }

html, body {
  width: 100%; min-height: 100%; margin: 0;
}

body {
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 16% 12%, rgba(244, 207, 106, 0.16), transparent 18rem),
    radial-gradient(circle at 82% 20%, rgba(180, 120, 60, 0.13), transparent 22rem),
    radial-gradient(circle at 44% 90%, rgba(139, 69, 19, 0.14), transparent 23rem),
    linear-gradient(160deg, #06100b 0%, #102717 47%, #07110c 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(115deg, rgba(255, 200, 100, 0.09), transparent 26%),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.025) 0 1px, transparent 1px 5px);
  mix-blend-mode: screen;
}

.game-shell {
  position: fixed;
  width: 1120px;
  height: 780px;
  padding: 18px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  transform-origin: top left;
}

.topbar {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid rgba(244, 207, 106, 0.22);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(30, 51, 34, 0.86), rgba(10, 21, 15, 0.76)),
    radial-gradient(circle at 16% 0%, rgba(244, 207, 106, 0.18), transparent 18rem);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 14px 28px rgba(0,0,0,0.28);
  backdrop-filter: blur(10px);
}

.brand {
  color: var(--gold);
  font-size: clamp(1rem, 2.2vw, 1.28rem);
  font-weight: 900;
  text-shadow: 0 2px 14px rgba(244, 207, 106, 0.32);
  white-space: nowrap;
}

.hud-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.hud-badge {
  min-width: 80px;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 12px;
  border: 1px solid rgba(244, 207, 106, 0.38);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(39, 57, 39, 0.94), rgba(14, 25, 18, 0.94));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 8px 18px rgba(0,0,0,0.28);
  color: var(--gold);
  font-weight: 800;
  font-size: 0.92rem;
}

.score-badge { color: #e9ffd6; border-color: rgba(100, 220, 100, 0.38); }
#acornHeld { color: #ff7676; border-color: rgba(255, 110, 110, 0.44); }
.enemy-badge { color: #ff8866; border-color: rgba(220, 80, 40, 0.38); }
.biome-badge { color: #aaddff; border-color: rgba(100, 180, 255, 0.28); font-size: 0.78rem; min-width: 120px; }
.pause-button { cursor: pointer; font-family: inherit; }
.pause-button:hover { filter: brightness(1.12); }

#game {
  width: 100%; height: 100%; min-height: 320px;
  display: block;
  border: 1px solid rgba(244, 207, 106, 0.32);
  border-radius: 8px;
  background: var(--leaf);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.04),
    0 0 48px rgba(101, 186, 91, 0.16),
    0 26px 60px rgba(0,0,0,0.52);
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 200, 100, 0.08), transparent 18rem),
    rgba(4, 10, 7, 0.52);
  backdrop-filter: blur(4px);
}

.overlay.hidden { display: none; }

.panel {
  width: min(92vw, 540px);
  padding: 28px;
  border: 1px solid rgba(244, 207, 106, 0.46);
  border-radius: 10px;
  background:
    linear-gradient(180deg, var(--panel-strong), var(--panel)),
    radial-gradient(circle at 50% 0%, rgba(244, 207, 106, 0.18), transparent 18rem);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.1), 0 22px 58px rgba(0,0,0,0.55);
  text-align: center;
}

.lb-panel {
  width: min(92vw, 600px);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.eyebrow {
  margin: 0 0 8px;
  color: #a7f18a;
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

h1, h2 {
  margin: 0;
  color: var(--gold);
  line-height: 1;
  text-shadow: 0 4px 24px rgba(244, 207, 106, 0.36);
}

h1 { font-size: clamp(2.1rem, 7vw, 4rem); }
h2 { margin-bottom: 14px; font-size: 1.8rem; }

.panel p:not(.eyebrow) {
  margin: 14px auto 18px;
  max-width: 38rem;
  color: #efe8c7;
  line-height: 1.6;
  font-size: 0.95rem;
}

button {
  min-width: 160px;
  min-height: 44px;
  border: 1px solid rgba(255, 234, 167, 0.72);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffe18a, #d5973e);
  color: #251908;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.42),
    inset 0 -4px 0 rgba(61,34,10,0.2),
    0 10px 22px rgba(0,0,0,0.34);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

button:hover { filter: brightness(1.06); transform: translateY(-1px); }
button:active { transform: translateY(2px); }

.btn-secondary {
  background: linear-gradient(180deg, rgba(50,70,50,0.95), rgba(20,35,25,0.95));
  color: var(--ink);
  border-color: rgba(200, 220, 160, 0.38);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 8px 18px rgba(0,0,0,0.3);
}

.name-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  margin: 14px 0 4px;
}

input[type="text"] {
  height: 44px;
  padding: 0 14px;
  border: 1px solid rgba(244, 207, 106, 0.5);
  border-radius: 8px;
  background: rgba(10, 20, 14, 0.85);
  color: var(--gold);
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  outline: none;
  min-width: 160px;
  text-align: center;
}

input[type="text"]:focus { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(244,207,106,0.22); }
input[type="text"]::placeholder { color: rgba(200,180,120,0.45); font-weight: 400; }

.promo-box {
  margin: 8px 0 12px;
  padding: 10px 16px;
  border: 1px solid rgba(255, 215, 0, 0.6);
  border-radius: 8px;
  background: rgba(255, 200, 0, 0.1);
  color: #ffe066;
  font-size: 0.9rem;
  font-weight: 700;
}

.promo-box.hidden { display: none; }

.lb-scroll {
  overflow-y: auto;
  flex: 1;
  margin: 8px 0;
  border-radius: 6px;
  border: 1px solid rgba(244,207,106,0.18);
}

.lb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.lb-table thead th {
  position: sticky;
  top: 0;
  background: rgba(20, 38, 26, 0.97);
  color: var(--gold);
  font-weight: 900;
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid rgba(244,207,106,0.22);
}

.lb-table tbody tr:nth-child(even) { background: rgba(255,255,255,0.03); }
.lb-table tbody tr.rank-1 { background: rgba(255, 215, 0, 0.12); }
.lb-table tbody tr.rank-2 { background: rgba(192, 192, 192, 0.08); }
.lb-table tbody tr.rank-3 { background: rgba(205, 127, 50, 0.08); }

.lb-table td {
  padding: 7px 10px;
  color: #efe8c7;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.lb-table td:first-child { color: var(--gold); font-weight: 900; width: 36px; }
.lb-table td:last-child { color: #a7f18a; font-weight: 700; }

@media (max-width: 680px) {
  .game-shell { padding: 10px; gap: 8px; }
  .topbar { min-height: 36px; flex-wrap: wrap; }
  .hud-group { gap: 5px; }
  .hud-badge { min-width: 60px; font-size: 0.8rem; padding: 5px 8px; }
  .biome-badge { display: none; }
  .panel { padding: 18px; }
  button { min-width: 120px; }
}

@media (max-width: 900px) {
  /* Body : aligné en haut, pas centré */
  body { align-items: start; }

  /* Shell : prend tout l'écran moins la zone joystick */
  .game-shell {
    width: 100vw;
    height: calc(100svh - 160px);
    padding: 10px;
    gap: 8px;
    align-self: start;
  }

  /* Canvas : remplit tout l'espace dispo (plus carré) */
  #game {
    width: 100% !important;
    height: 100% !important;
    aspect-ratio: unset !important;
    align-self: stretch;
  }

  /* HUD centré, brand caché */
  .topbar { justify-content: center; }
  .brand  { display: none; }
  .hud-group { justify-content: center; flex-wrap: wrap; }
}
