/* ============================================================================
   STYLES UI KAWAII — MAQUETTE RÉALISTE CHATS CONTRE CHIENS TD
   Contours brun prune (#3B232E), boutons tactiles 3D, dialogues natifs <dialog>
   ============================================================================ */

:root {
  --ink: #3B232E;
  --ink-soft: #6B4E5C;
  --cream: #FFF9F2;
  --peach: #FFE5D4;
  --pink: #FF85B3;
  --pink-dark: #E85B90;
  --blue: #6EC6FF;
  --blue-dark: #3B9FE3;
  --gold: #FFD166;
  --gold-dark: #E8A825;
  --mint: #7CE0B5;
  --mint-dark: #45B889;
  --coral: #FF7575;
  --lavender: #C7B2FF;
}

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

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: #F4E8DC;
  font-family: 'Fredoka', ui-rounded, 'Nunito', system-ui, -apple-system, sans-serif;
  color: var(--ink);
}

#app {
  position: relative;
  width: 100vw;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 45%, #FBF3EA 0%, #E7D4C0 100%);
  overflow: hidden;
}

#stage-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#game-canvas {
  display: block;
  border-radius: 18px;
  box-shadow: 0 20px 48px rgba(59, 35, 46, 0.24), 0 0 0 4px var(--ink);
  background: #F5E6D3;
  touch-action: none;
  cursor: pointer;
}

/* ================= HUD SUPÉRIEUR ================= */
#hud-top {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: min(96vw, 1244px);
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
  z-index: 20;
}

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

.hud-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 5px 13px;
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 4px 0 var(--ink);
  line-height: 1;
  white-space: nowrap;
}

.hud-pill.map-pill {
  background: linear-gradient(180deg, #FFFDF8 0%, #FFF0D9 100%);
}

.hud-pill .icon-svg {
  width: 21px;
  height: 21px;
  flex-shrink: 0;
}

.hud-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: var(--cream);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 6px 11px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--ink);
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.12s ease;
}

.hud-btn:hover {
  background: #FFF0E0;
}

.hud-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--ink);
}

.hud-btn:focus-visible,
.spell-btn:focus-visible,
.big-btn:focus-visible,
.faction-pick:focus-visible,
.map-card:focus-visible,
.tab-btn:focus-visible {
  outline: 3.5px solid #FF3B9A;
  outline-offset: 2px;
}

.hud-btn.active {
  background: var(--gold);
}

.hud-btn.danger {
  background: #FFD6D6;
}

/* ================= BARRE INFÉRIEURE : SORTS + INSPECTEUR ================= */
#hud-bottom {
  position: absolute;
  bottom: max(12px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: min(96vw, 1244px);
  display: none;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
  z-index: 20;
}

.spells-bar {
  display: flex;
  gap: 10px;
  pointer-events: auto;
}

.spell-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 10px;
  background: linear-gradient(180deg, #FFFDF9 0%, #FFEBD6 100%);
  border: 3.5px solid var(--ink);
  border-radius: 20px;
  box-shadow: 0 5px 0 var(--ink);
  cursor: pointer;
  font-family: inherit;
  color: var(--ink);
  overflow: hidden;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  min-width: 174px;
}

.spell-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 7px 0 var(--ink);
}

.spell-btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--ink);
}

.spell-btn.selected {
  background: linear-gradient(180deg, #FFF4B8 0%, #FFD166 100%);
  box-shadow: 0 0 0 4px #FF85B3, 0 5px 0 var(--ink);
}

.spell-btn:disabled {
  cursor: not-allowed;
  filter: saturate(0.45);
}

.spell-icon-wrap {
  width: 40px;
  height: 40px;
  border-radius: 13px;
  border: 2.5px solid var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 21px;
  flex-shrink: 0;
  background: #FFF;
}

.spell-meta {
  text-align: left;
  line-height: 1.15;
}

.spell-name {
  font-size: 14px;
  font-weight: 700;
  display: block;
}

.spell-sub {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.78;
  display: block;
}

.keycap {
  position: absolute;
  top: 5px;
  right: 7px;
  font-size: 10px;
  font-weight: 700;
  background: #FFF;
  border: 2px solid var(--ink);
  border-radius: 6px;
  padding: 0 4px;
  line-height: 1.3;
}

.spell-cd-overlay {
  position: absolute;
  inset: 0;
  background: rgba(59, 35, 46, 0.58);
  display: none;
  align-items: center;
  justify-content: center;
  color: #FFF;
  font-size: 20px;
  font-weight: 700;
  text-shadow: 0 2px 0 var(--ink);
}

.spell-cd-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 5px;
  background: var(--pink);
  width: 0%;
  transition: width 0.1s linear;
}

/* Panneau Inspecteur / Statut tactique en bas à droite */
#inspector-bar {
  pointer-events: auto;
  background: rgba(255, 249, 242, 0.96);
  border: 3px solid var(--ink);
  border-radius: 18px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 5px 0 var(--ink);
  max-width: 470px;
  min-width: 260px;
  line-height: 1.28;
}

.inspector-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 3px;
}

.inspector-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

.inspector-tag {
  font-size: 11px;
  font-weight: 700;
  background: var(--gold);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 1px 8px;
}

.inspector-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-soft);
}

.inspector-stat-pill {
  background: #FFF;
  border: 2px solid rgba(59, 35, 46, 0.2);
  border-radius: 9px;
  padding: 2px 7px;
  font-weight: 700;
  color: var(--ink);
}

/* ================= DIALOGUES NATIFS (<dialog>) ================= */
dialog {
  border: none;
  padding: 0;
  background: transparent;
  color: var(--ink);
  width: min(94vw, 900px);
  max-width: min(94vw, 900px);
  max-height: 92dvh;
  overflow: visible;
}

dialog[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}

dialog:modal {
  overscroll-behavior: contain;
}

dialog::backdrop {
  background: rgba(59, 35, 46, 0.52);
  backdrop-filter: blur(5px);
  overflow: hidden;
  overscroll-behavior: contain;
}

.modal-card {
  background: var(--cream);
  border: 4px solid var(--ink);
  border-radius: 30px;
  box-shadow: 0 12px 0 var(--ink), 0 24px 52px rgba(59, 35, 46, 0.34);
  padding: 22px 26px;
  width: 100%;
  max-height: 90dvh;
  overflow-y: auto;
  text-align: center;
}

.modal-card.narrow {
  max-width: 520px;
}

.title-badge {
  display: inline-block;
  background: var(--gold);
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 4px 15px;
  font-size: 12.5px;
  font-weight: 700;
  margin-bottom: 6px;
  box-shadow: 0 3px 0 var(--ink);
}

.game-title {
  margin: 2px 0 4px;
  font-size: clamp(26px, 4vw, 40px);
  line-height: 1.05;
  letter-spacing: -0.5px;
}

.game-title .cat-txt {
  color: #E85B90;
}

.game-title .dog-txt {
  color: #3B9FE3;
}

.subtitle {
  margin: 0 0 16px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink-soft);
}

.section-label {
  text-align: left;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--ink-soft);
  margin: 10px 0 8px;
}

/* Sélecteur de camp (étape 1) */
.faction-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.faction-pick {
  position: relative;
  border: 4px solid var(--ink);
  border-radius: 22px;
  padding: 13px 15px;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: inherit;
  color: var(--ink);
  box-shadow: 0 6px 0 var(--ink);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.faction-pick.cats {
  background: linear-gradient(180deg, #FFF5F9 0%, #FFE4EF 100%);
}

.faction-pick.dogs {
  background: linear-gradient(180deg, #F3FAFF 0%, #DCF0FF 100%);
}

.faction-pick:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 0 var(--ink);
}

.faction-pick[aria-pressed='true'] {
  box-shadow: 0 0 0 4px var(--gold), 0 6px 0 var(--ink);
}

.faction-pick .check-pill {
  position: absolute;
  top: 9px;
  right: 10px;
  font-size: 11px;
  font-weight: 700;
  background: var(--gold);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 1px 8px;
  display: none;
}

.faction-pick[aria-pressed='true'] .check-pill {
  display: inline-block;
}

.faction-avatar {
  width: 60px;
  height: 60px;
  border-radius: 16px;
  border: 3px solid var(--ink);
  background: #FFF;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.faction-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.faction-sub {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
}

/* Sélecteur des 3 cartes (étape 2) */
.maps-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.map-card {
  position: relative;
  background: #FFF;
  border: 3.5px solid var(--ink);
  border-radius: 20px;
  padding: 12px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  color: var(--ink);
  box-shadow: 0 5px 0 var(--ink);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.map-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 7px 0 var(--ink);
}

.map-card[aria-pressed='true'] {
  background: #FFFDF2;
  box-shadow: 0 0 0 4px #FF85B3, 0 5px 0 var(--ink);
}

.map-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.map-diff {
  font-size: 11px;
  font-weight: 700;
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 1px 8px;
}

.map-stars {
  font-size: 15px;
  letter-spacing: 1px;
}

.map-name {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.map-sub {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-soft);
}

.map-desc {
  margin: 0;
  font-size: 12px;
  line-height: 1.3;
  color: var(--ink-soft);
}

/* Boutons d'action principaux */
.modal-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.big-btn {
  padding: 11px 22px;
  border-radius: 16px;
  border: 3.5px solid var(--ink);
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 5px 0 var(--ink);
  color: var(--ink);
  background: var(--gold);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.big-btn.primary-cats {
  background: #FF6B9E;
  color: #FFF;
}

.big-btn.primary-dogs {
  background: #4BA8F0;
  color: #FFF;
}

.big-btn.secondary {
  background: #FFF;
}

.big-btn:hover {
  transform: translateY(-1px);
}

.big-btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--ink);
}

/* ================= BESTIAIRE & GUIDE ILLUSTRÉ ================= */
.help-tabs {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 10px 0 14px;
  flex-wrap: wrap;
}

.tab-btn {
  background: #FFF;
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 6px 14px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 3px 0 var(--ink);
}

.tab-btn[aria-selected='true'] {
  background: var(--gold);
}

.bestiary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
  text-align: left;
  margin-bottom: 14px;
}

.bestiary-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #FFF;
  border: 3px solid var(--ink);
  border-radius: 18px;
  padding: 9px 11px;
}

.portrait-canvas {
  width: 58px;
  height: 58px;
  border-radius: 14px;
  border: 2.5px solid var(--ink);
  background: #FFF7EB;
  flex-shrink: 0;
}

.bestiary-info h3 {
  margin: 0 0 2px;
  font-size: 14.5px;
}

.bestiary-meta {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-soft);
  margin-bottom: 3px;
}

.bestiary-desc {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.28;
  color: var(--ink-soft);
}

/* ================= ÉCRAN FIN DE PARTIE ================= */
.stars-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 10px 0 12px;
  font-size: 46px;
}

.star-slot {
  filter: drop-shadow(0 4px 0 var(--ink));
}

.star-slot.dim {
  opacity: 0.22;
  filter: grayscale(1);
}

.stats-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 12px 0;
  text-align: left;
}

.summary-box {
  background: #FFF;
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  padding: 8px 11px;
  font-size: 12.5px;
  font-weight: 600;
}

.summary-box strong {
  display: block;
  font-size: 16px;
  color: var(--ink);
}

@media (max-width: 820px) {
  .maps-grid {
    grid-template-columns: 1fr;
  }

  .hud-pill {
    font-size: 13px;
    padding: 4px 9px;
    gap: 5px;
  }

  .hud-btn {
    font-size: 12px;
    padding: 5px 8px;
    border-radius: 10px;
  }

  .spell-btn {
    min-width: 134px;
    padding: 6px 10px 6px 8px;
  }

  .spell-icon-wrap {
    width: 32px;
    height: 32px;
    font-size: 18px;
  }

  .spell-name {
    font-size: 12px;
  }

  .spell-sub,
  .keycap {
    display: none;
  }

  #inspector-bar {
    display: none;
  }

  .modal-card {
    padding: 16px;
    border-radius: 22px;
  }
}
