:root {
  --wood: #6b3f22;
  --wood-dark: #3f2412;
  --cream: #fbf3dc;
  --leaf: #5c9a2f;
  --leaf-dark: #2f5a17;
  --p1: #7fd04b;
  --p2: #58a8ff;
  --gold: #f4c542;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #1c2a14;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--cream);
  overflow: hidden;
}

#wrap {
  position: relative;
  width: min(100vw, calc(100vh * 1.5));
  height: min(100vh, calc(100vw / 1.5));
  margin: 0 auto;
  top: 50%;
  transform: translateY(-50%);
}

canvas#game {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: auto;
  background: #4d7d2c;
  border-radius: 6px;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 6px;
}
.screen.visible { display: flex; }

.title-bg, .shop-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
}
.title-bg { background-image: url("../img/entree.jpg"); filter: brightness(0.75); }
.shop-bg  { background-image: url("../img/jardin-drone.jpg"); filter: brightness(0.45) blur(1px); }
#over { background: rgba(20, 10, 5, 0.75); }

.panel {
  position: relative;
  background: linear-gradient(180deg, rgba(107,63,34,0.95), rgba(63,36,18,0.96));
  border: 4px solid #2a170a;
  border-radius: 18px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.6), inset 0 0 0 2px rgba(255,220,160,0.25);
  padding: 2.2% 3%;
  text-align: center;
  max-height: 96%;
  overflow: auto;
}

.title-panel { width: 68%; margin-left: 22%; }
.title-troll {
  position: absolute;
  z-index: 1;
  height: 80%;
  left: 2%;
  bottom: 3%;
  filter: drop-shadow(4px 6px 6px rgba(0,0,0,0.6));
  pointer-events: none;
}

h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(22px, 4.2vw, 52px);
  margin: 0.2em 0 0.1em;
  letter-spacing: 2px;
  color: #fff4d2;
  text-shadow: 0 3px 0 #2a170a, 0 0 18px rgba(255,210,120,0.4);
}
h2 {
  font-family: Georgia, serif;
  font-size: clamp(18px, 2.6vw, 34px);
  margin: 0.2em 0 0.4em;
  text-shadow: 0 2px 0 #2a170a;
}
h3 { margin: 0.2em 0; font-size: clamp(12px, 1.4vw, 18px); }
.tagline { font-size: clamp(11px, 1.4vw, 18px); margin: 0 0 1em; opacity: 0.9; }

.menu { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 0.6em 0 1em; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  color: #2a170a;
  font-weight: bold;
  border-radius: 10px;
  background: linear-gradient(180deg, #ffe29a, #e0a93a);
  box-shadow: 0 3px 0 #7a4a12;
  transition: transform 0.08s, filter 0.1s;
}
button:hover, button:focus-visible { filter: brightness(1.1); transform: translateY(-1px); outline: 3px solid #fff4d2; outline-offset: 2px; }
button:active { transform: translateY(2px); box-shadow: 0 1px 0 #7a4a12; }
button:disabled { filter: grayscale(0.9) brightness(0.7); cursor: not-allowed; transform: none; }
button.big { font-size: clamp(12px, 1.6vw, 20px); padding: 0.55em 1.2em; }
.hidden { display: none !important; }

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 0.35em;
  margin: 0 1px;
  border-radius: 5px;
  background: #fbf3dc;
  color: #2a170a;
  font-family: Consolas, monospace;
  font-size: 0.85em;
  box-shadow: 0 2px 0 #9b8a66;
}

.controls { display: flex; gap: 16px; justify-content: center; font-size: clamp(10px, 1.2vw, 15px); }
.ctrl { background: rgba(0,0,0,0.25); border-radius: 12px; padding: 6px 14px; }
.ctrl p { margin: 0.35em 0; }
.ctrl.p1 h3 { color: var(--p1); }
.ctrl.p2 h3 { color: var(--p2); }
.hint { font-size: clamp(10px, 1.2vw, 15px); margin: 0.8em 0 0; opacity: 0.9; }

/* Boutique */
.shop-panel { width: 92%; }
.harvest {
  font-size: clamp(10px, 1.2vw, 15px);
  background: rgba(0,0,0,0.25);
  border-radius: 10px;
  padding: 6px 10px;
  margin-bottom: 6px;
  line-height: 1.5;
}
.money-line { font-size: clamp(13px, 1.8vw, 22px); margin: 4px 0 8px; color: var(--gold); font-weight: bold; }
.shop-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 10px;
  text-align: left;
}
.shop-cat {
  grid-column: 1 / -1;
  font-family: Georgia, serif;
  font-size: clamp(12px, 1.4vw, 17px);
  color: #ffe29a;
  border-bottom: 1px solid rgba(255,226,154,0.35);
  margin-top: 4px;
}
.item {
  background: rgba(251,243,220,0.1);
  border: 1px solid rgba(251,243,220,0.2);
  border-radius: 10px;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: clamp(9px, 1vw, 13px);
}
.item .name { font-weight: bold; font-size: 1.12em; }
.item .desc { opacity: 0.85; flex: 1; }
.item .owned { color: var(--p1); font-size: 0.95em; }
.item button { padding: 4px 6px; font-size: 1em; }

.over-panel { width: 60%; }
#overText { font-size: clamp(12px, 1.5vw, 18px); }

/* Crédit discret sur l'écran titre */
.credit { margin: .6em 0 0; font-size: .75rem; opacity: .6; }
.credit a { color: inherit; }
