:root {
  --gold: #f5c542;
  --red: #e3342f;
  --green: #38c172;
  --blue: #3490dc;
  --ink: #101418;
  --paper: #f4f1e8;
  --stage-w: 1080px;
  --stage-h: 1920px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: #0b0d10; color: var(--paper); font-family: Nunito, system-ui, sans-serif; }
body { display: flex; align-items: center; justify-content: center; gap: 24px; overflow: hidden; }

/* ---- Scène 9:16 (format short) : en-tête / écran de jeu / roue / bas ---- */
.stage {
  position: relative; flex: none;
  width: var(--stage-w); height: var(--stage-h);
  margin: calc((var(--stage-h) * (var(--stage-scale, .5) - 1)) / 2) calc((var(--stage-w) * (var(--stage-scale, .5) - 1)) / 2);
  transform: scale(var(--stage-scale, 0.5));
  overflow: hidden;
  background: linear-gradient(180deg, #1b2a38 0%, #101820 45%, #0b1014 100%);
  box-shadow: 0 0 0 2px #222, 0 30px 80px rgba(0,0,0,.6);
  display: grid;
  grid-template-rows: 150px 720px 1fr 300px;
}

/* En-tête : panneau de lieu + compteur Pokédex */
.top { padding: 22px 36px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.banner {
  background: var(--paper); color: var(--ink);
  border: 6px solid var(--ink); border-radius: 14px;
  box-shadow: 6px 6px 0 rgba(0,0,0,.45);
  padding: 12px 24px; display: flex; flex-direction: column; gap: 6px; min-width: 0;
  animation: slideIn .5s cubic-bezier(.2,.9,.2,1.2);
}
.banner-kind { font-family: 'Press Start 2P', monospace; font-size: 15px; letter-spacing: 2px; color: #666; }
.banner-name { font-family: 'Press Start 2P', monospace; font-size: 28px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.banner-name.long { font-size: 20px; }
@keyframes slideIn { from { transform: translateX(-120%); } to { transform: none; } }

.dex-chip {
  flex: none; display: flex; align-items: center; gap: 12px; cursor: pointer;
  background: var(--red); color: #fff; border: 6px solid var(--ink); border-radius: 60px;
  padding: 12px 24px 12px 14px; box-shadow: 6px 6px 0 rgba(0,0,0,.45);
  font-family: 'Press Start 2P', monospace;
}
.dex-chip .ball { width: 46px; height: 46px; border-radius: 50%; border: 5px solid var(--ink);
  background: linear-gradient(180deg, #fff 0 44%, var(--ink) 44% 56%, #fff 56%); }
.dex-count { font-size: 34px; }
.dex-total { font-size: 18px; opacity: .85; align-self: flex-end; padding-bottom: 4px; }
.dex-chip.bump { animation: bump .5s; }
@keyframes bump { 40% { transform: scale(1.18); } }

/* Écran de jeu : l'extrait, en entier (3:2), jamais recouvert */
.screen { position: relative; background: #000; border-top: 6px solid var(--ink); border-bottom: 6px solid var(--ink); overflow: hidden; }
.screen video { width: 100%; height: 100%; object-fit: cover; display: block; }
.screen-fallback { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 40px;
  background: repeating-linear-gradient(45deg, #1f3b2a 0 40px, #1a3324 40px 80px);
  font-family: 'Press Start 2P', monospace; font-size: 30px; line-height: 1.6; color: var(--gold); text-shadow: 4px 4px 0 #000; }

/* Roue */
.middle { display: grid; place-items: center; position: relative; }
#wheel { width: 620px; height: 620px; filter: drop-shadow(0 14px 26px rgba(0,0,0,.6)); }
.wheel-pointer {
  position: absolute; top: calc(50% - 310px - 26px); left: 50%; transform: translateX(-50%);
  width: 0; height: 0; border-left: 30px solid transparent; border-right: 30px solid transparent;
  border-top: 62px solid var(--gold); filter: drop-shadow(0 5px 0 #000);
}
.result {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 30px; padding: 0 40px;
  background: rgba(8,12,16,.88);
  animation: pop .45s cubic-bezier(.2,.9,.2,1.3);
}
.result img { width: 360px; height: 360px; image-rendering: pixelated; filter: drop-shadow(0 10px 20px #000); flex: none; }
.result img[src=""] { display: none; }
.result-text { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.result-name { font-family: 'Press Start 2P', monospace; font-size: 40px; line-height: 1.3; color: var(--gold); text-shadow: 4px 4px 0 #000; }
.result-sub { font-size: 30px; font-weight: 800; text-shadow: 2px 2px 0 #000; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }

/* Bas : méthode + Pokémon de la zone */
.bottom { padding: 0 36px 34px; display: flex; flex-direction: column; justify-content: flex-end; gap: 18px; }
.method {
  background: var(--ink); color: var(--paper); border: 6px solid var(--paper); border-radius: 18px;
  padding: 16px 26px; display: flex; align-items: center; justify-content: space-between; gap: 20px;
}
.method-label { font-family: 'Press Start 2P', monospace; font-size: 18px; color: #aaa; }
.method-value { font-family: 'Press Start 2P', monospace; font-size: 26px; color: var(--gold); text-align: right; }
.method.flash { animation: flash .6s steps(2) 3; }
@keyframes flash { 50% { background: var(--gold); color: var(--ink); } }

.pool { display: flex; flex-wrap: wrap; gap: 8px; min-height: 92px; }
.pool .mon { position: relative; width: 92px; height: 92px; background: rgba(255,255,255,.1); border-radius: 12px; border: 4px solid transparent; }
.pool .mon img { width: 100%; height: 100%; image-rendering: pixelated; }
.pool .mon.todo img { filter: brightness(0); opacity: .55; }
.pool .mon.caught { background: rgba(56,193,114,.25); border-color: var(--green); }
.pool .mon.picked { border-color: var(--gold); }
.pool.many .mon { width: 76px; height: 76px; }

/* Pokédex plein écran */
.dex { position: absolute; inset: 0; z-index: 10; background: #c8102e; display: flex; flex-direction: column; padding: 26px 30px 30px; animation: pop .3s; }
.dex-head { display: flex; justify-content: space-between; align-items: center; font-family: 'Press Start 2P', monospace; font-size: 38px; color: #fff; text-shadow: 4px 4px 0 #000; padding: 6px 6px 22px; }
.dex-grid { flex: 1; display: grid; grid-template-columns: repeat(10, 1fr); grid-auto-rows: 1fr; gap: 6px; background: var(--ink); border: 6px solid var(--ink); border-radius: 16px; padding: 8px; }
.dex-cell { position: relative; background: #2a333d; border-radius: 8px; display: grid; place-items: center; cursor: pointer; overflow: hidden; }
.dex-cell img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; filter: brightness(0); opacity: .45; }
.dex-cell span { position: absolute; left: 4px; top: 3px; font-family: 'Press Start 2P', monospace; font-size: 10px; color: #8a96a3; }
.dex-cell.caught { background: var(--paper); }
.dex-cell.caught img { filter: none; opacity: 1; }
.dex-cell.caught span { color: #555; }
.dex-cell.here { outline: 4px solid var(--gold); outline-offset: -4px; }

.toast {
  position: absolute; left: 50%; bottom: 320px; transform: translateX(-50%); z-index: 5;
  background: var(--paper); color: var(--ink); border: 5px solid var(--ink); border-radius: 12px;
  padding: 16px 26px; font-family: 'Press Start 2P', monospace; font-size: 20px; max-width: 90%; text-align: center; line-height: 1.5;
}

/* ---- Panneau de contrôle (hors cadre, pas enregistré) ---- */
.panel {
  width: 380px; flex: none; max-height: 96vh; overflow: auto; padding: 18px; border-radius: 14px;
  background: #15191f; border: 1px solid #2a3140; font-size: 14px;
}
.panel h1 { font-size: 20px; margin: 0 0 4px; }
.panel h1 small { font-weight: 600; color: #8a93a3; font-size: 12px; }
.panel h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: #8a93a3; margin: 18px 0 8px; border-top: 1px solid #2a3140; padding-top: 14px; }
.row { margin-bottom: 8px; }
.row select, .panel select { width: 100%; padding: 7px; background: #0b0d10; color: var(--paper); border: 1px solid #2a3140; border-radius: 6px; }
.row.inline label { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.buttons button, .zone-list button { flex: 1; padding: 9px 8px; border: 0; border-radius: 8px; background: #2a3140; color: var(--paper); font-weight: 800; cursor: pointer; font-family: inherit; }
.buttons button:hover, .zone-list button:hover { background: #3b4559; }
.buttons button.primary { background: #b8861b; }
.buttons button.primary:hover { background: #d19c25; }
.buttons button.danger { background: #5a1f1f; }
.check { display: flex; gap: 8px; align-items: center; margin: 8px 0; color: #c6ccd6; }
.help { color: #8a93a3; line-height: 1.5; margin: 8px 0 0; font-size: 12.5px; }
.zone-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.zone-list li { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 6px; background: #0b0d10; }
.zone-list li.link { cursor: pointer; }
.zone-list img { width: 32px; height: 32px; image-rendering: pixelated; }
.zone-list .name { flex: 1; cursor: pointer; min-width: 0; }
.zone-list .name small { display: block; color: #8a93a3; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.zone-list li.caught .name { color: var(--green); }
.zone-list li.caught .name::after { content: " ✔"; }
.zone-list button { flex: none; padding: 5px 9px; }
.zone-list .tag { margin-left: auto; font-size: 11px; color: #8a93a3; }
.zone-list kbd { background: #2a3140; border-radius: 4px; padding: 1px 6px; font-size: 11px; }
