/* Interface médiévale façon RPG 16-bit : parchemin, cadre de bois, liseré doré */
:root {
  --ink: #4A3020;
  --ink-soft: #8A6A4A;
  --paper: #F6E8C4;
  --paper-2: #E8D4A4;
  --frame: #5A3820;
  --frame-in: #D8A848;
  --accent: #A8282A;
  --gold: #E8B040;
  --blue: #8A2A1E;
  --sel: #EED8A8;
  --font: 'Pixelify Sans', monospace;
  --title: 'Jacquard 12', 'Pixelify Sans', serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.35;
  color: var(--ink);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: #6CC46A;
  background-image: var(--grass);
  background-size: 48px 48px;
  image-rendering: pixelated;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(20, 40, 60, 0) 40%, rgba(20, 40, 60, 0.45) 100%);
  pointer-events: none;
}

img, canvas { image-rendering: pixelated; image-rendering: crisp-edges; }

#app {
  position: relative;
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 440px;
}
.screen[hidden] { display: none; }

/* Fenêtre : fond clair, cadre sombre + liseré bleu clair intérieur, ombre portée */
.box {
  width: 100%;
  background: var(--paper);
  border: 4px solid var(--frame);
  border-radius: 12px;
  box-shadow: inset 0 0 0 3px var(--frame-in), inset 0 -6px 0 3px var(--paper-2), 0 5px 0 rgba(20, 30, 50, 0.35);
  padding: 14px 18px 16px;
  text-shadow: 1px 1px 0 #E0C898;
}
.center { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }

.label { margin: 0 0 8px; color: var(--ink-soft); font-size: 15px; letter-spacing: 1px; }
.center .label { margin: 0; }
p { margin: 0; }

/* Logo */
.logo {
  margin: 0 0 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: var(--title);
  font-size: 84px;
  font-weight: 400;
  line-height: 0.85;
  letter-spacing: 2px;
  color: #FFFFFF;
  color: #F6E8C4;
  text-shadow:
    3px 0 0 #5A3820, -3px 0 0 #5A3820, 0 3px 0 #5A3820, 0 -3px 0 #5A3820,
    3px 3px 0 #5A3820, -3px -3px 0 #5A3820, 3px -3px 0 #5A3820, -3px 3px 0 #5A3820,
    0 8px 0 #2A180C;
}
.logo span:last-child {
  color: #FFD860;
  text-shadow:
    3px 0 0 #A8481C, -3px 0 0 #A8481C, 0 3px 0 #A8481C, 0 -3px 0 #A8481C,
    3px 3px 0 #A8481C, -3px -3px 0 #A8481C, 3px -3px 0 #A8481C, -3px 3px 0 #A8481C,
    0 8px 0 #5C2410;
}
.logo.small { font-size: 58px; }

.title-party { display: flex; gap: 10px; align-items: flex-end; }
.title-party img { width: 48px; height: 72px; filter: drop-shadow(0 3px 0 rgba(20, 40, 30, 0.35)); }
.footer { color: #FFFFFF; text-shadow: 2px 2px 0 var(--frame); font-size: 15px; }

/* Boutons de menu : curseur ▶ qui clignote au survol */
.btn {
  font-family: var(--font);
  font-size: 20px;
  color: var(--ink);
  background: none;
  border: none;
  padding: 6px 6px 6px 26px;
  cursor: pointer;
  position: relative;
  text-align: left;
  text-shadow: 1px 1px 0 #E0C898;
}
.btn::before {
  content: '▶';
  position: absolute;
  left: 4px;
  font-size: 15px;
  top: 9px;
  visibility: hidden;
  color: var(--ink);
}
.btn:hover::before, .btn:focus-visible::before { visibility: visible; animation: nudge 0.5s steps(2) infinite; }
.btn:focus { outline: none; }
.btn:disabled { color: var(--ink-soft); cursor: wait; }
.btn.ghost { color: var(--ink-soft); }
.btn.small { font-size: 16px; }
.btn.small::before { top: 7px; font-size: 13px; }
.center .btn { padding-right: 26px; }
@keyframes nudge { 50% { transform: translateX(3px); } }

.menu { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.join { display: flex; align-items: center; gap: 8px; padding-left: 26px; }
input {
  font-family: var(--font);
  font-size: 22px;
  width: 104px;
  padding: 4px 10px;
  background: #FFF6DC;
  color: var(--blue);
  border: 3px solid var(--frame);
  border-radius: 6px;
  letter-spacing: 5px;
  text-transform: uppercase;
}
input::placeholder { color: #C4A880; }
input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--frame-in); }

/* Profil */
.profile { display: flex; align-items: center; gap: 18px; }
.profile img { width: 64px; height: 96px; }
.stats { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.stat { display: flex; justify-content: space-between; }
.pname { color: var(--ink); font-weight: 700; }

/* Jauge d'EXP, comme les barres de PV des RPG */
.bar { height: 8px; background: #485060; border: 2px solid var(--ink); border-radius: 4px; overflow: hidden; margin-top: 2px; }
.bar i { display: block; height: 100%; background: linear-gradient(#90E8A0 0 40%, #48C060 40%); }

.code { font-size: 48px; letter-spacing: 12px; color: var(--blue); padding-left: 12px; font-weight: 700; }
.small-text { font-size: 15px; color: var(--blue); }

/* Équipe */
.party { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.party li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 10px;
  border-radius: 8px;
}
.party li.me { background: var(--sel); box-shadow: inset 0 0 0 2px var(--frame-in); }
.party img { width: 32px; height: 48px; flex: none; }
.party .plevel { font-size: 15px; color: var(--ink-soft); }
.party .host { color: var(--accent); }
.party .empty { color: #A8ACBC; font-size: 15px; }
.party .slot { width: 32px; height: 48px; border: 2px dashed #C4C8D4; border-radius: 6px; }
.party.compact li { gap: 8px; padding: 2px 6px; }
.party.compact img { width: 24px; height: 36px; }
.party.compact .pname { font-size: 16px; }
.party.compact .plevel { font-size: 13px; }

.blink { animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ───────── Écran de jeu ───────── */
.screen.game {
  max-width: none;
  height: calc(100vh - 32px);
  height: calc(100dvh - 32px);
  flex-direction: row;
  align-items: stretch;
  gap: 14px;
}
.game-view {
  flex: 1;
  min-width: 0;
  position: relative;
  overflow: hidden;
  background: #2A1A10;
  border: 4px solid var(--frame);
  border-radius: 12px;
  box-shadow: 0 0 0 3px var(--frame-in), 0 5px 0 3px rgba(20, 30, 50, 0.35);
}
#game-canvas { display: block; position: absolute; left: 0; top: 0; }

.game-panel {
  width: 220px;
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.game-panel .box { padding: 10px 12px 12px; }
#minimap { width: 128px; height: 128px; border: 3px solid var(--frame); border-radius: 6px; }
.keys { font-size: 15px; color: var(--ink-soft); }
.keys .btn { margin-top: 4px; }

/* Croix directionnelle tactile */
.dpad { display: none; }
body.touch .dpad {
  display: grid;
  grid-template-columns: repeat(3, 54px);
  grid-template-rows: repeat(3, 54px);
  position: absolute;
  left: 12px;
  bottom: 12px;
  opacity: 0.85;
  touch-action: none;
}
.dpad button {
  font-size: 18px;
  color: var(--ink);
  background: var(--paper);
  border: 3px solid var(--frame);
  border-radius: 10px;
  touch-action: none;
}
.dpad button:active { background: var(--frame-in); }
.dpad .up { grid-column: 2; grid-row: 1; }
.dpad .left { grid-column: 1; grid-row: 2; }
.dpad .right { grid-column: 3; grid-row: 2; }
.dpad .down { grid-column: 2; grid-row: 3; }

@media (max-width: 760px) {
  .screen.game { flex-direction: column; height: auto; min-height: calc(100dvh - 32px); }
  .game-view { flex: none; height: 60dvh; }
  .game-panel { width: 100%; flex-direction: row; flex-wrap: wrap; }
  .game-panel .box { flex: 1 1 150px; }
  .logo { font-size: 48px; }
}

/* Bandeau mode démo et notifications */
#demo-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10;
  padding: 4px;
  text-align: center;
  font-size: 15px;
  background: var(--gold);
  color: var(--ink);
}
#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 20;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  font-size: 17px;
  background: var(--paper);
  border: 4px solid var(--frame);
  border-radius: 10px;
  box-shadow: inset 0 0 0 3px var(--frame-in);
}
