:root {
  --game-ink: #f4f4f5;
  --game-muted: #a1a1aa;
  --game-panel: rgba(13, 13, 16, .94);
  --game-panel-2: #202027;
  --game-line: rgba(255, 255, 255, .12);
  --game-accent: #ff2424;
  --game-accent-soft: rgba(255, 36, 36, .16);
  --game-shadow: #08080a;
}

.game-page {
  min-height: 100vh;
  color: var(--game-ink);
  font-family: "SF Pro Text", Arial, sans-serif;
  background: var(--bg-dark);
}

.game-page-main {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 116px 0 44px;
}

.game-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 18px;
}

.game-heading h2 {
  margin: 2px 0 0;
  color: #f4f4f5;
  font: 700 clamp(2rem, 4vw, 3.5rem)/.95 "SF Pro Display", "SF Pro Text", Arial, sans-serif;
  letter-spacing: -.055em;
}

.game-heading > p {
  max-width: 540px;
  margin: 0;
  color: var(--game-muted);
  line-height: 1.55;
}

.game-layout { display: block; }

.game-shell,
.game-panel {
  border: 1px solid var(--game-line);
  border-radius: 20px;
  background: var(--game-panel);
  box-shadow: 0 18px 44px rgba(0, 0, 0, .28);
}

.game-shell {
  min-width: 0;
  padding: 8px;
}

.game-hud {
  position: absolute;
  z-index: 4;
  top: 10px;
  left: 10px;
  right: 10px;
  display: grid;
  grid-template-columns: auto 1fr auto auto 38px;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 2px;
  border: 0;
  color: #f4f4f5;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.game-hud-block {
  display: grid;
  gap: 2px;
}

.game-hud-inventory {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.game-hud-inventory .game-inventory-item {
  grid-template-columns: 16px auto;
  min-height: 22px;
  padding: 0;
  gap: 6px;
  border: 0;
  background: transparent;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .9);
}

.game-hud-inventory .game-item-pixel {
  width: 13px;
  height: 13px;
  border-width: 1px;
}

.game-hud-inventory .game-inventory-item span:nth-child(2) { display: none; }
.game-hud-inventory .game-inventory-item strong { font-size: .92rem; }

.game-hud-counter {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: max-content;
  color: #f4f4f5;
  font-size: .86rem;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .9);
}

.game-hud-counter > i { color: #d4d4d8; font-size: .74rem; }
.game-fire-counter > i { color: #ff7043; }

.game-hud-label,
.game-panel-label,
.game-screen-kicker {
  color: #a1a1aa;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.game-hud strong {
  font-variant-numeric: tabular-nums;
}

.game-fire-line,
.game-panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.game-icon-button {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 50%;
  color: #f4f4f5;
  background: rgba(32, 32, 39, .92);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .23);
  cursor: pointer;
}

.game-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 13px;
  background: #1b2716;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .55);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  outline: none;
  background: #416131;
}

#playerCanvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.game-screen {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: none;
  place-items: center;
  padding: clamp(16px, 5vw, 52px);
  background: rgba(10, 11, 9, .76);
  backdrop-filter: blur(2px);
}

.game-screen.is-visible {
  display: grid;
}

.game-screen-card {
  width: min(470px, 100%);
  padding: clamp(18px, 4vw, 34px);
  border: 1px solid rgba(255, 255, 255, .15);
  border-radius: 24px;
  color: #f4f4f5;
  background: #18181d;
  box-shadow: 0 22px 56px rgba(0, 0, 0, .52);
}

.game-screen-card h3 {
  margin: 8px 0 12px;
  color: #f4f4f5;
  font: 700 clamp(1.35rem, 3vw, 2rem)/1.1 "SF Pro Display", "SF Pro Text", Arial, sans-serif;
}

.game-screen-card p:not(.game-screen-kicker) {
  margin: 0 0 20px;
  color: #a1a1aa;
  line-height: 1.55;
}

.game-character-choice {
  display: flex;
  gap: 10px;
  margin: 0 0 18px;
}

.game-character-choice-button {
  display: grid;
  grid-template-columns: 38px auto;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 4px 10px 4px 4px;
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 999px;
  color: #a1a1aa;
  background: #202027;
  cursor: pointer;
}

.game-character-choice-button img {
  width: 38px;
  height: 38px;
  object-fit: contain;
  image-rendering: pixelated;
}

.game-character-choice-button.is-selected {
  border-color: var(--game-accent);
  color: #fff;
  background: var(--game-accent-soft);
  box-shadow: 0 0 0 1px rgba(255, 36, 36, .2), 0 5px 18px rgba(255, 36, 36, .16);
}

.game-primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--game-accent);
  border-radius: 999px;
  color: #fff;
  background: var(--game-accent);
  box-shadow: 0 7px 20px rgba(255, 36, 36, .28);
  font-weight: 800;
  cursor: pointer;
}

.game-screen-tip {
  display: block;
  margin-top: 13px;
  color: #71717a;
  font-size: .77rem;
}

.game-prompt,
.game-toast {
  position: absolute;
  z-index: 5;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
}

.game-prompt {
  bottom: 12px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 9px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 999px;
  color: #f4f4f5;
  background: rgba(24, 24, 29, .94);
  opacity: 0;
  transition: opacity .1s linear;
}

.game-prompt.is-visible {
  opacity: 1;
}

.game-toast {
  top: 12px;
  max-width: calc(100% - 24px);
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 999px;
  color: #f4f4f5;
  background: rgba(24, 24, 29, .96);
  box-shadow: 0 9px 24px rgba(0, 0, 0, .3);
  opacity: 0;
  transition: opacity .15s linear;
  white-space: nowrap;
}

.game-toast.is-visible {
  opacity: 1;
}

kbd {
  display: inline-grid;
  min-width: 22px;
  min-height: 20px;
  place-items: center;
  padding: 1px 5px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 999px;
  color: #fff;
  background: #30303a;
  font: 700 .72rem/1 monospace;
}

.game-sidebar {
  display: grid;
  gap: 12px;
}

.game-panel {
  padding: 17px;
}

.game-panel h3 {
  margin: 7px 0 8px;
  color: #ded8b9;
  font: 700 1.1rem/1.2 Georgia, serif;
}

.game-panel p {
  margin: 0;
  color: var(--game-muted);
  font-size: .88rem;
  line-height: 1.5;
}

.game-progress-dots {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12px, 1fr));
  gap: 6px;
  margin-top: 14px;
}

.game-progress-dots span {
  height: 7px;
  border: 1px solid #595d46;
  background: #292c22;
}

.game-progress-dots span.is-done {
  border-color: #9ca064;
  background: #8d954d;
}

.game-panel-heading {
  margin-bottom: 12px;
}

.game-panel-heading > span {
  color: #777a65;
  font-size: .76rem;
}

.game-inventory {
  display: grid;
  gap: 6px;
}

.game-inventory-item {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  gap: 9px;
  min-height: 34px;
  padding: 5px 8px;
  border: 1px solid #3b3f31;
  background: var(--game-panel-2);
}

.game-inventory-item span:nth-child(2) {
  color: #a8a98e;
  font-size: .86rem;
}

.game-inventory-item strong {
  color: #e1dab9;
  font-variant-numeric: tabular-nums;
}

.game-item-pixel {
  width: 12px;
  height: 12px;
  border: 2px solid #27261d;
  image-rendering: pixelated;
}

.game-item-pixel.wood { background: #79522f; box-shadow: inset 3px 0 #ad7a3d; }
.game-item-pixel.matches { background: #b8a569; box-shadow: inset 0 4px #914b2d; }
.game-item-pixel.oil { background: #505f62; box-shadow: inset 3px 0 #8f9a8c; }

.game-help-panel dl {
  display: grid;
  gap: 10px;
  margin: 12px 0 0;
}

.game-help-panel dl > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.game-help-panel dt,
.game-help-panel dd {
  margin: 0;
}

.game-help-panel dd {
  color: #90927b;
  font-size: .78rem;
  text-align: right;
}

.game-twitch-note {
  margin-top: 15px !important;
  padding-top: 12px;
  border-top: 1px solid #3c4031;
}

.game-touch-controls {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 5px 3px;
}

.game-direction-pad {
  display: grid;
  grid-template: repeat(3, 44px) / repeat(3, 44px);
}

.game-touch-button {
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 50%;
  color: #f4f4f5;
  background: #202027;
  box-shadow: 0 7px 18px rgba(0, 0, 0, .22);
  touch-action: manipulation;
}

.game-touch-button:active {
  transform: translateY(1px);
  background: #30303a;
}

.move-up { grid-area: 1 / 2; }
.move-left { grid-area: 2 / 1; }
.game-direction-center { grid-area: 2 / 2; }
.move-right { grid-area: 2 / 3; }
.move-down { grid-area: 3 / 2; }

.game-touch-action {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border-color: var(--game-accent);
  background: var(--game-accent);
  box-shadow: 0 9px 24px rgba(255, 36, 36, .27);
  font-weight: 800;
}

.game-touch-action small {
  display: block;
  color: rgba(255, 255, 255, .7);
}

.game-credit {
  margin: 18px 0 0;
  color: #71717a;
  font-size: .78rem;
  text-align: center;
}

@media (max-width: 720px), (pointer: coarse) {
  .game-page-main { width: min(100% - 18px, 680px); padding-top: 10px; padding-bottom: 28px; }
  .game-heading { display: none; }
  .game-touch-controls { display: flex; }
  .game-shell { padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
  .game-stage { border-radius: 18px; }
  .game-touch-controls { padding: 16px 10px 2px; }
  .game-screen { padding: 18px; }
  .game-toast { font-size: .78rem; }
  .game-credit { margin-top: 14px; font-size: .72rem; }
}

/* Sur téléphone, le cadre reste carré tandis que la carte agrandie dépasse
   volontairement de 10 % sur chaque bord : overflow:hidden la recadre. */
@media (max-width: 720px) {
  #gameCanvas,
  #playerCanvas {
    transform: scale(1.2);
    transform-origin: center;
  }
}

@media (max-width: 440px) {
  .game-hud { grid-template-columns: minmax(0, 1fr) auto auto 32px; }
  .game-hud { top: 6px; left: 6px; right: 6px; gap: 5px; }
  .game-hud-inventory { gap: 4px; }
  .game-hud-inventory .game-inventory-item { gap: 4px; }
  .game-hud-inventory .game-item-pixel { width: 11px; height: 11px; }
  .game-hud-counter { gap: 3px; font-size: .77rem; }
  .game-hud strong { font-size: .82rem; }
  .game-icon-button { width: 32px; height: 32px; }
  .game-screen-card { padding: 17px; }
  .game-direction-pad { grid-template: repeat(3, 40px) / repeat(3, 40px); }
}

@media (prefers-reduced-motion: reduce) {
  .game-prompt,
  .game-toast { transition: none; }
}
