/* ============================================================================
   style.css — Interface du Labyrinthe 3D.
   Direction : "soirée jeux" — fond nuit indigo, couleurs bonbon très franches,
   typographie ronde (Baloo 2 / Nunito), gros boutons pour mains d'enfants.
   ============================================================================ */

:root {
  --ink: #2b2e5a;
  --night: #23264d;
  --night-2: #31356b;
  --cream: #fff8ec;
  --pink: #ff5d8f;
  --yellow: #ffb400;
  --sky: #38c8f5;
  --lime: #7be04b;
  --violet: #9d6bff;
  --radius: 22px;
  --shadow: 0 8px 0 rgba(0, 0, 0, 0.18);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: 'Nunito', 'Segoe UI', system-ui, sans-serif;
  color: var(--ink);
  background: var(--night);
}

h1, h2, h3, .preset-name, .big-btn, .title {
  font-family: 'Baloo 2', 'Nunito', sans-serif;
}

.hidden { display: none !important; }

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ============================= HUD ============================= */

#hud {
  position: fixed;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  z-index: 20;
  pointer-events: none;
}

.hud-pill {
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 5px 14px;
  font-weight: 800;
  font-size: 16px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

#hudKey.found { background: #d8ffd0; }

#pelletSwatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid var(--ink);
  background: var(--sky);
  display: inline-block;
}
#pelletSwatch.clickable { cursor: pointer; }

.hud-spacer { flex: 1; }

.hud-btn {
  pointer-events: auto;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 3px solid var(--ink);
  background: var(--yellow);
  font-family: 'Baloo 2', sans-serif;
  font-size: 20px;
  font-weight: 800;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);
}
.hud-btn:active { transform: translateY(2px); box-shadow: none; }

#compass {
  pointer-events: auto;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 3px solid var(--ink);
  background: var(--cream);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);
  position: relative;
  display: grid;
  place-items: center;
}
#needle {
  font-size: 20px;
  color: var(--pink);
  transition: transform 0.08s linear;
  line-height: 1;
}
#compass b {
  position: absolute;
  top: 0px;
  font-size: 9px;
}

/* Aide */
#helpPanel {
  position: fixed;
  top: 66px;
  right: 10px;
  z-index: 25;
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 18px;
  max-width: 340px;
  font-size: 14px;
  cursor: pointer;
}
#helpPanel h3 { margin: 0 0 6px; }
#helpPanel p { margin: 5px 0; }
.help-goal { font-weight: 800; }

/* ======================= Contrôles tactiles ======================= */

#touchControls {
  position: fixed;
  inset: 0;
  z-index: 30;
  pointer-events: none;
}

.tc-left {
  position: absolute;
  left: 14px;
  bottom: 16px;
  display: grid;
  grid-template-columns: repeat(3, 64px);
  gap: 10px;
  pointer-events: auto;
}

.tc-right {
  position: absolute;
  right: 14px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: auto;
}

.tc {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  border: 3px solid var(--ink);
  background: rgba(255, 248, 236, 0.9);
  font-size: 26px;
  color: var(--ink);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3);
  touch-action: none;
  user-select: none;
}
.tc.pressed { transform: translateY(3px); box-shadow: none; background: var(--yellow); }
.tc-big { width: 68px; height: 68px; border-radius: 50%; }
.tc-dot {
  display: inline-block;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid var(--ink);
  background: var(--pellet, var(--sky));
  vertical-align: middle;
}

/* ============================ Toast ============================ */

#toast {
  position: fixed;
  left: 50%;
  bottom: 110px;
  transform: translateX(-50%);
  z-index: 70;
  background: var(--ink);
  color: var(--cream);
  border-radius: 999px;
  padding: 10px 22px;
  font-weight: 800;
  font-size: 16px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3);
  max-width: 92vw;
  text-align: center;
  animation: pop 0.25s ease-out;
}
@keyframes pop {
  from { transform: translateX(-50%) scale(0.7); opacity: 0; }
  to { transform: translateX(-50%) scale(1); opacity: 1; }
}

/* ============================ Carte ============================ */

#mapOverlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(24, 26, 52, 0.6);
  display: grid;
  place-items: center;
  padding: 12px;
}

.map-card {
  background: var(--cream);
  border: 4px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  width: min(92vw, 560px);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.map-head {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Baloo 2', sans-serif;
  font-weight: 800;
  font-size: 18px;
}
.map-head span { flex: 1; text-align: center; }

.map-btn {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: 3px solid var(--ink);
  background: var(--sky);
  font-size: 22px;
  font-weight: 800;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.2);
}
.map-btn:disabled { opacity: 0.35; cursor: default; }
.map-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: none; }
.map-close { background: var(--pink); }

#mapCanvas {
  width: 100%;
  height: min(60vh, 480px);
  background: #efe4cf;
  border: 3px solid var(--ink);
  border-radius: 14px;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  font-size: 13px;
  font-weight: 700;
  justify-content: center;
}
.lg { display: inline-block; width: 12px; height: 12px; vertical-align: -1px; }
.lg-player { background: #ff4d4d; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.lg-up { background: #ff8c42; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.lg-down { background: #8f5dff; clip-path: polygon(0 0, 100% 0, 50% 100%); }
.lg-pellet { background: var(--sky); border-radius: 50%; border: 2px solid var(--ink); }
.lg-flip { color: #7a4dff; }

/* --- Mode "petite carte" : dans un coin, le jeu continue derrière --- */
#mapOverlay.mini {
  inset: auto;
  top: 64px;
  right: 10px;
  background: transparent;
  display: block;
  padding: 0;
  pointer-events: none;
}
#mapOverlay.mini .map-card {
  pointer-events: auto;
  width: min(62vw, 290px);
  padding: 8px;
  border-width: 3px;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.25);
  opacity: 0.94;
}
#mapOverlay.mini #mapCanvas {
  height: min(52vw, 250px);
}
#mapOverlay.mini .map-head { font-size: 14px; gap: 6px; }
#mapOverlay.mini .map-btn { width: 32px; height: 32px; font-size: 17px; border-radius: 10px; }
#mapOverlay.mini .map-legend { display: none; }

@media (max-width: 560px) {
  #mapOverlay.mini { top: 104px; } /* sous le HUD qui passe sur deux lignes */
}

/* ====================== Écran de configuration ====================== */

#configScreen {
  position: fixed;
  inset: 0;
  z-index: 100;
  overflow-y: auto;
  background:
    radial-gradient(circle at 15% 20%, rgba(157, 107, 255, 0.35), transparent 42%),
    radial-gradient(circle at 85% 15%, rgba(56, 200, 245, 0.3), transparent 40%),
    radial-gradient(circle at 70% 90%, rgba(255, 93, 143, 0.28), transparent 45%),
    var(--night);
}

.config-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 34px 18px 60px;
  text-align: center;
}

.title {
  color: var(--cream);
  font-size: clamp(42px, 9vw, 74px);
  font-weight: 800;
  margin: 0;
  letter-spacing: 1px;
  text-shadow: 0 6px 0 rgba(0, 0, 0, 0.35);
}
.title-3d {
  color: var(--yellow);
  display: inline-block;
  transform: rotate(-6deg);
  text-shadow: 4px 4px 0 var(--pink), 0 6px 0 rgba(0, 0, 0, 0.35);
}

.subtitle {
  color: #cdd4ff;
  font-size: 18px;
  font-weight: 700;
  margin: 8px 0 26px;
}

.presets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.preset {
  background: var(--cream);
  border: 4px solid var(--ink);
  border-radius: var(--radius);
  padding: 14px 8px 12px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.12s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.preset:nth-child(odd) { transform: rotate(-1.4deg); }
.preset:nth-child(even) { transform: rotate(1.2deg); }
.preset:hover { transform: rotate(0deg) translateY(-3px); }
.preset.selected {
  background: var(--yellow);
  transform: rotate(0deg) scale(1.05);
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.28), 0 0 0 5px rgba(255, 180, 0, 0.4);
}
.preset-emoji { font-size: 38px; }
.preset-name { font-size: 21px; font-weight: 800; }
.preset-desc { font-size: 12px; font-weight: 700; opacity: 0.75; line-height: 1.25; }

/* Panneau expert */
#expertPanel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease;
}
#expertPanel.open { max-height: 1200px; }

#expertPanel .grid {
  background: var(--cream);
  border: 4px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px 22px;
  text-align: left;
}

#expertPanel label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-weight: 800;
  font-size: 14px;
}
#expertPanel label.check { flex-direction: row; align-items: center; gap: 8px; }
#expertPanel output { color: var(--pink); }
#expertPanel .dual { display: flex; gap: 8px; }
#expertPanel .dual input { flex: 1; }

input[type='range'] { accent-color: var(--pink); height: 26px; }
input[type='checkbox'] { width: 20px; height: 20px; accent-color: var(--pink); }

select, #inSeed {
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 15px;
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 12px;
  padding: 8px 10px;
  background: #fff;
}

/* Graine */
.seed-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--cream);
  font-weight: 800;
}
#inSeed {
  width: 150px;
  text-align: center;
  letter-spacing: 2px;
  text-transform: uppercase;
}
#btnRandomSeed {
  width: 46px;
  height: 46px;
  font-size: 22px;
  border-radius: 14px;
  border: 3px solid var(--ink);
  background: var(--lime);
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);
}
#btnRandomSeed:active { transform: translateY(2px); box-shadow: none; }
.seed-hint { color: #aab2e8; font-size: 13px; font-weight: 700; margin: 8px 0 22px; }

/* Gros boutons */
.big-btn {
  border: 4px solid var(--ink);
  border-radius: 999px;
  padding: 14px 34px;
  font-size: 22px;
  font-weight: 800;
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.1s ease;
}
.big-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2); }

.btn-play {
  background: repeating-linear-gradient(-45deg, var(--yellow) 0 18px, #ffc93c 18px 36px);
  font-size: 28px;
  padding: 16px 64px;
}
.btn-blue { background: var(--sky); }
.btn-pink { background: var(--pink); color: #fff; }
.btn-ghost { background: var(--cream); }

.controls-help {
  margin-top: 26px;
  color: #aab2e8;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.7;
}
.controls-help b { color: var(--cream); }

/* ======================== Écran de victoire ======================== */

#victoryOverlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(24, 26, 52, 0.65);
  display: grid;
  place-items: center;
  padding: 16px;
}

.victory-card {
  background: var(--cream);
  border: 5px solid var(--ink);
  border-radius: 28px;
  box-shadow: 0 12px 0 rgba(0, 0, 0, 0.3);
  padding: 26px 30px;
  text-align: center;
  max-width: 460px;
  width: 100%;
  animation: bounceIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes bounceIn {
  from { transform: scale(0.5); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.victory-card h1 {
  margin: 0;
  font-size: 46px;
  color: var(--pink);
  text-shadow: 3px 3px 0 var(--yellow);
}
.victory-sub { font-weight: 800; margin: 4px 0 16px; }

.stats { display: grid; gap: 8px; margin-bottom: 14px; }
.stat {
  display: flex;
  justify-content: space-between;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 8px 16px;
  font-weight: 800;
}
.stat-value { color: var(--pink); }

.seed-line { font-size: 13px; font-weight: 700; opacity: 0.7; margin: 0 0 16px; }

.victory-buttons { display: flex; flex-direction: column; gap: 10px; }
.victory-buttons .big-btn { font-size: 19px; padding: 12px 20px; }

/* ============================ Confettis ============================ */

#confetti {
  position: fixed;
  inset: 0;
  z-index: 95;
  pointer-events: none;
}

/* ============================ Divers ============================ */

@media (max-width: 560px) {
  .hud-pill { font-size: 13px; padding: 4px 10px; }
  .tc { width: 56px; height: 56px; font-size: 22px; }
  .tc-left { grid-template-columns: repeat(3, 56px); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ============================= Hall of fame ============================= */

.hof-menu-btn { margin-top: 10px; }

.btn-gold {
  background: linear-gradient(180deg, #ffd95e, #ffb300);
  color: #4a3200;
}

.hof-submit {
  margin: 14px auto 4px;
  padding: 12px 14px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: #fff8e6;
  max-width: 420px;
}
.hof-submit-title { font-weight: 800; margin: 0 0 8px; }
.hof-submit-row { display: flex; gap: 8px; justify-content: center; }
.hof-submit-row input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-weight: 700;
  padding: 10px 12px;
  border: 3px solid var(--ink);
  border-radius: 12px;
}
.hof-submit-result { font-weight: 800; margin: 8px 0 0; min-height: 1.2em; }

#hofOverlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(30, 26, 60, 0.55);
}
.hof-card {
  width: min(94vw, 520px);
  max-height: 88vh;
  overflow: auto;
  background: var(--paper, #fffdf6);
  border: 4px solid var(--ink);
  border-radius: 22px;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.25);
  padding: 14px 16px 12px;
}
.hof-head { display: flex; align-items: center; justify-content: space-between; }
.hof-head h2 { margin: 0; }
.hof-tabs { display: flex; gap: 8px; margin: 10px 0; }
.hof-tab {
  flex: 1;
  font: inherit;
  font-weight: 800;
  padding: 8px 4px;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
}
.hof-tab.active { background: #ffd95e; }
.hof-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.hof-table th, .hof-table td { padding: 6px 8px; text-align: left; }
.hof-table th { border-bottom: 3px solid var(--ink); }
.hof-table tbody tr:nth-child(odd) { background: rgba(0, 0, 0, 0.045); }
.hof-table td.num, .hof-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.hof-table tbody tr:nth-child(1) td:first-child::before { content: '🥇 '; }
.hof-table tbody tr:nth-child(2) td:first-child::before { content: '🥈 '; }
.hof-table tbody tr:nth-child(3) td:first-child::before { content: '🥉 '; }
.hof-msg { text-align: center; font-weight: 700; padding: 18px 6px; }
.hof-note { font-size: 12.5px; opacity: 0.75; margin: 10px 2px 0; }
