* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green: #34d399;
  --green-dark: #059669;
  --ink: #f1f5f9;
  --line: rgba(255, 255, 255, .1);
}

html, body { height: 100%; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: radial-gradient(1100px 700px at 50% -10%, #0d3b28, #04160f 70%);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.game { width: min(94vw, 440px); display: flex; flex-direction: column; gap: .85rem; }

header { text-align: center; }
h1 { font-size: 1.9rem; letter-spacing: 1px; }
.tagline { color: #86efac; font-size: .88rem; margin-top: .25rem; }

.hud { display: flex; gap: .6rem; align-items: stretch; }
.stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: rgba(0, 0, 0, .3);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: .45rem .8rem;
}
.stat .label { font-size: .68rem; text-transform: uppercase; letter-spacing: 1.5px; opacity: .6; }
.stat strong { font-size: 1.3rem; line-height: 1.2; }
.stat strong.bump { animation: pop .25s ease; }
@keyframes pop { 50% { transform: scale(1.22); } }

.hud-buttons { display: flex; gap: .5rem; }
.icon-btn {
  width: 44px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(0, 0, 0, .3);
  color: var(--ink);
  font-size: 1.05rem;
  cursor: pointer;
  transition: background .15s ease, transform .1s ease, opacity .2s ease;
}
.icon-btn:hover:not(:disabled) { background: rgba(255, 255, 255, .12); }
.icon-btn:active:not(:disabled) { transform: scale(.94); }
.icon-btn:disabled { opacity: .35; cursor: default; }

.stage { position: relative; touch-action: none; }
canvas {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #071f16;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .5), 0 0 24px rgba(52, 211, 153, .07);
}

.overlay {
  position: absolute;
  inset: 0;
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .8rem;
  padding: 1.5rem;
  text-align: center;
  background: rgba(3, 15, 10, .8);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: opacity .18s ease;
}
.overlay.hidden { opacity: 0; pointer-events: none; }
.overlay h2 { font-size: 1.5rem; }
.overlay p { color: #cbe8da; font-size: .92rem; line-height: 1.5; max-width: 32ch; }

.btn {
  padding: .7rem 1.7rem;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform .1s ease, background .2s ease;
}
.btn.primary { background: linear-gradient(180deg, #34d399, #059669); color: #04231a; }
.btn.primary:hover { background: linear-gradient(180deg, #4ade80, #10b981); }
.btn:active { transform: scale(.97); }

/* Croix directionnelle : visible seulement sur écrans tactiles */
.dpad {
  display: none;
  grid-template-columns: repeat(3, 58px);
  grid-template-rows: repeat(2, 58px);
  gap: .5rem;
  justify-content: center;
  margin: .1rem auto 0;
}
.dbtn {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(0, 0, 0, .3);
  color: var(--ink);
  font-size: 1.05rem;
  cursor: pointer;
  touch-action: manipulation;
  transition: background .12s ease, transform .1s ease;
}
.dbtn:active { background: rgba(52, 211, 153, .25); transform: scale(.95); }
.dbtn.up { grid-column: 2; grid-row: 1; }
.dbtn.left { grid-column: 1; grid-row: 2; }
.dbtn.down { grid-column: 2; grid-row: 2; }
.dbtn.right { grid-column: 3; grid-row: 2; }
@media (pointer: coarse) { .dpad { display: grid; } }

.rules {
  background: rgba(0, 0, 0, .25);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: .75rem 1rem;
  font-size: .86rem;
  line-height: 1.55;
  user-select: text;
  -webkit-user-select: text;
}
.rules summary { cursor: pointer; font-weight: 700; color: #86efac; }
.rules ul { margin: .6rem 0 0 1.1rem; }
.rules li { margin: .18rem 0; }
kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .8em;
  background: rgba(255, 255, 255, .1);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 0 .35em;
}
