/* Age of War — remake. Couche UI logique 700×500 mise à l'échelle par main.js. */
:root {
  --ink: #1b1410;
  --gold: #ffd84a;
  --cream: #fff4d6;
  --msg: #ffec3d;
  --title: "Lilita One", "Arial Black", "Segoe UI Black", Impact, sans-serif;
  --body: "Nunito", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #120c07;
  background-image: radial-gradient(ellipse at 50% 40%, #2a1d12 0%, #120c07 70%);
  color: var(--cream);
  font-family: var(--body);
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  overscroll-behavior: none;
}
#stage {
  position: absolute; overflow: hidden;
  box-shadow: 0 0 0 2px #000, 0 10px 50px rgba(0, 0, 0, 0.7);
  background: #7ec0ee;
}
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#ui {
  position: absolute; left: 0; top: 0; width: 700px; height: 500px;
  transform-origin: 0 0; pointer-events: none;
}
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus { outline: none; }
button:focus-visible { outline: 2px solid #fff57a; outline-offset: 2px; }

/* ------------------------------------------------------------------ HUD */
.hud { position: absolute; inset: 0 0 auto 0; height: 110px; opacity: 0; visibility: hidden; transition: opacity .3s; }
.hud.on { opacity: 1; visibility: visible; }
.hud .outlined, .gold, .xp, .caption, .slabel, .trainlabel {
  text-shadow: -1.5px -1.5px 0 var(--ink), 1.5px -1.5px 0 var(--ink), -1.5px 1.5px 0 var(--ink), 1.5px 1.5px 0 var(--ink), 0 2px 0 var(--ink);
}
.hud-left { position: absolute; left: 8px; top: 5px; width: 165px; }
.gold { display: flex; align-items: center; gap: 5px; font: 23px/1 var(--title); color: #fff; letter-spacing: .5px; }
.gold canvas { width: 20px; height: 20px; }
.xp { margin-top: 4px; font: 14px/1 var(--title); color: #e8f6ff; letter-spacing: .3px; }
.xpbar {
  position: relative; margin-top: 4px; width: 150px; height: 12px; border: 1.5px solid var(--ink); border-radius: 5px;
  background: rgba(255, 255, 255, .22); overflow: hidden;
}
.xpbar i { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(#a8e6ff, #3aa0e8); }
.xp-next { position: absolute; left: 4px; top: 0; font: 800 8px/9.5px var(--body); color: #0d2233; white-space: nowrap; text-shadow: 0 0 2px rgba(255,255,255,.8); }
.msg {
  position: absolute; left: 10px; top: 72px; width: 410px; font: 800 12.5px/1.25 var(--body); color: var(--msg);
  text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000, 0 2px 2px #000;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.msg.err { color: #ff8a6a; animation: shake .3s; }
.msg.info { color: #b6ff8a; }
@keyframes shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
.hud-center { position: absolute; left: 182px; top: 9px; width: 240px; }
.trainrow { display: flex; align-items: center; gap: 7px; }
.trainbar {
  position: relative; width: 150px; height: 13px; border: 2px solid var(--ink); border-radius: 4px;
  background: rgba(255, 255, 255, .2); overflow: hidden; box-shadow: 0 2px 0 rgba(0,0,0,.4);
}
.trainbar i { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(#ff6a5a, #d21d12 60%, #a10e08); }
.queue { display: flex; gap: 4px; }
.queue b { width: 12px; height: 12px; border: 1.5px solid rgba(255, 255, 255, .6); border-radius: 2px; background: rgba(255,255,255,.08); }
.queue b.on { background: rgba(255, 255, 255, .85); border-color: #fff; box-shadow: 0 0 4px rgba(255,255,255,.6); }
.trainlabel { margin-top: 4px; font: 12px/1 var(--title); color: #fff; letter-spacing: .3px; white-space: nowrap; }

.hud-right { position: absolute; right: 8px; top: 2px; width: 270px; text-align: right; }
.caption { font: 12px/14px var(--title); color: #fff; letter-spacing: .5px; padding-right: 2px; }
.row { display: flex; justify-content: flex-end; gap: 6px; margin-top: 2px; pointer-events: auto; }

.ib {
  position: relative; width: 48px; height: 48px; padding: 0; border: 2px solid var(--ink); border-radius: 9px;
  background: linear-gradient(#fbecc0, #e2b45c 52%, #c28934);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .7), inset 0 -3px 0 rgba(0, 0, 0, .22), 0 3px 0 var(--ink);
  transition: transform .08s, filter .15s, box-shadow .08s;
  display: grid; place-items: center;
}
.ib canvas { width: 40px; height: 40px; pointer-events: none; }
.ib:active { transform: translateY(2px); box-shadow: inset 0 2px 4px rgba(0,0,0,.35), 0 1px 0 var(--ink); }
.ib.back { background: linear-gradient(#e7dccb, #b9a88f 52%, #8d7b62); }
.ib.poor { filter: grayscale(.85) brightness(.72); }
.ib.locked { filter: grayscale(1) brightness(.5); }
.ib.locked canvas { opacity: .55; }
.ib.selected { background: linear-gradient(#fffbd0, #ffe066 52%, #f2b51c); box-shadow: 0 0 0 2px #fff57a, 0 0 12px 3px rgba(255, 240, 120, .8), 0 3px 0 var(--ink); }
.ib.ready { animation: glow 1.2s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: inset 0 2px 0 rgba(255,255,255,.7), 0 0 10px 3px rgba(255, 230, 90, .9), 0 3px 0 var(--ink); } }
.ib .key, .special .key {
  position: absolute; left: -3px; top: -4px; min-width: 13px; height: 13px; padding: 0 2px; border-radius: 4px;
  background: var(--ink); color: #ffe9a8; font: 9px/13px var(--title); text-align: center;
}
.ib .cost {
  position: absolute; left: 1px; right: 1px; bottom: 1px; font: 8.5px/10px var(--title); color: #fff;
  background: rgba(27, 20, 16, .72); border-radius: 0 0 6px 6px; text-align: center; letter-spacing: .2px;
}
.ib .cost:empty { display: none; }

.hud-special { position: absolute; right: 8px; top: 70px; display: flex; align-items: center; gap: 6px; pointer-events: none; }
.hud-special > * { pointer-events: auto; }
.slabel { font: 12px/1 var(--title); color: #fff; margin-left: 4px; pointer-events: none; }
.special {
  position: relative; width: 92px; height: 36px; padding: 0; border: 2px solid var(--ink); border-radius: 9px; overflow: visible;
  background: linear-gradient(#bfe6ff, #5aa9e6 55%, #2f74b8);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .7), inset 0 -3px 0 rgba(0, 0, 0, .25), 0 3px 0 var(--ink);
  display: grid; place-items: center; transition: transform .08s, filter .15s;
}
.special canvas { width: 30px; height: 30px; pointer-events: none; }
.special .cool { position: absolute; left: 0; right: 0; top: 0; height: 100%; background: rgba(10, 8, 20, .62); border-radius: 7px 7px 0 0; pointer-events: none; }
.special .coolbar { position: absolute; left: 4px; right: 4px; bottom: 3px; height: 4px; background: rgba(0,0,0,.5); border-radius: 2px; overflow: hidden; pointer-events: none; }
.special .coolbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #7ff3ff, #ffe866); }
.special.ready { animation: sglow 1s ease-in-out infinite; }
.special.ready .coolbar { display: none; }
.special:active { transform: translateY(2px); }
@keyframes sglow { 50% { box-shadow: inset 0 2px 0 rgba(255,255,255,.7), 0 0 12px 4px rgba(127, 243, 255, .9), 0 3px 0 var(--ink); } }

.sbtn {
  width: 28px; height: 28px; padding: 0; border: 2px solid var(--ink); border-radius: 8px;
  background: linear-gradient(#6a5a48, #3c3026); box-shadow: inset 0 1px 0 rgba(255,255,255,.3), 0 2px 0 var(--ink);
  display: grid; place-items: center; transition: transform .08s, filter .15s;
}
.sbtn canvas { width: 22px; height: 22px; pointer-events: none; }
.sbtn:active { transform: translateY(2px); box-shadow: 0 0 0 var(--ink); }

/* survol réservé aux pointeurs fins (sinon l'état reste « collé » après un tap) */
@media (hover: hover) {
  .ib:hover { filter: brightness(1.12); transform: translateY(-1px); box-shadow: inset 0 2px 0 rgba(255,255,255,.8), inset 0 -3px 0 rgba(0,0,0,.22), 0 4px 0 var(--ink); }
  .ib.poor:hover { filter: grayscale(.7) brightness(.82); }
  .ib.locked:hover { filter: grayscale(1) brightness(.5); }
  .ib.selected:hover { box-shadow: 0 0 0 2px #fff57a, 0 0 12px 3px rgba(255, 240, 120, .8), 0 4px 0 var(--ink); }
  .special:hover { filter: brightness(1.1); transform: translateY(-1px); }
  .sbtn:hover { filter: brightness(1.25); }
  .btn:hover { filter: brightness(1.1) saturate(1.1); transform: translateY(-2px); box-shadow: inset 0 3px 0 rgba(255,255,255,.55), inset 0 -4px 0 rgba(0,0,0,.22), 0 6px 0 var(--ink), 0 12px 18px rgba(0,0,0,.35); }
  .link:hover { color: #c2470f; }
  /* l'appui doit rester prioritaire sur le survol */
  .ib:active { transform: translateY(2px); box-shadow: inset 0 2px 4px rgba(0,0,0,.35), 0 1px 0 var(--ink); }
  .special:active, .sbtn:active { transform: translateY(2px); }
}

/* -------------------------------------------------------------- écrans */
.screen {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden; pointer-events: none; transform: scale(.97);
  transition: opacity .35s ease, transform .35s ease, visibility 0s linear .35s;
  background: radial-gradient(ellipse at 50% 45%, rgba(10, 6, 2, .25), rgba(10, 6, 2, .72));
}
.screen.on { opacity: 1; visibility: visible; pointer-events: auto; transform: none; transition: opacity .35s ease, transform .35s ease; }
.screen-title { justify-content: flex-start; padding-top: 18px; background: radial-gradient(ellipse at 50% 40%, rgba(10,6,2,0) 30%, rgba(10,6,2,.55)); }
.screen-title .logo { width: 520px; height: 200px; filter: drop-shadow(0 6px 8px rgba(0,0,0,.45)); animation: bob 3s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-4px) rotate(-.4deg); } }
.screen-title .menu-col { margin-top: 10px; }
.screen-title .mute-toggle { position: absolute; right: 12px; top: 12px; width: 34px; height: 34px; }
.screen-title .mute-toggle canvas { width: 26px; height: 26px; }
.footnote { position: absolute; bottom: 8px; font: 800 10px var(--body); color: rgba(255,244,214,.85); text-shadow: 0 1px 2px #000; letter-spacing: .3px; }
.menu-col { display: flex; flex-direction: column; align-items: center; gap: 10px; }

.btn {
  min-width: 190px; padding: 7px 26px 9px; border: 3px solid var(--ink); border-radius: 12px;
  font: 20px/1.1 var(--title); letter-spacing: .6px; color: #fff8e6;
  background: linear-gradient(#ffc36b, #f07a22 50%, #c2470f);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, .5), inset 0 -4px 0 rgba(0, 0, 0, .22), 0 4px 0 var(--ink), 0 8px 14px rgba(0,0,0,.35);
  text-shadow: -1.5px -1.5px 0 var(--ink), 1.5px -1.5px 0 var(--ink), -1.5px 1.5px 0 var(--ink), 1.5px 1.5px 0 var(--ink), 0 2.5px 0 var(--ink);
  transition: transform .09s, filter .15s, box-shadow .09s;
}
.btn:active { transform: translateY(3px); box-shadow: inset 0 3px 6px rgba(0,0,0,.3), 0 1px 0 var(--ink); }
.btn.big { min-width: 230px; font-size: 27px; padding: 9px 30px 11px; background: linear-gradient(#ffe27a, #f5a31c 50%, #c96a07); }
.btn.red { background: linear-gradient(#ff8a7a, #d8352a 50%, #8f1810); }

.panel {
  position: relative; min-width: 360px; max-width: 520px; padding: 16px 26px 18px; text-align: center;
  background: linear-gradient(#f8ebc8, #e6cf98); color: #3a2614;
  border: 3px solid var(--ink); border-radius: 16px;
  box-shadow: inset 0 0 0 3px rgba(255,255,255,.45), inset 0 -6px 0 rgba(120, 80, 30, .2), 0 6px 0 var(--ink), 0 18px 40px rgba(0, 0, 0, .55);
}
.panel.wide { width: 620px; max-width: 620px; padding: 14px 22px 14px; }
.panel.wide p { font-size: 11.5px; line-height: 1.35; margin: 4px 0; }
.panel.wide .keys { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; font-size: 10.5px; }
.panel.wide .btn { margin-top: 6px; padding: 5px 24px 7px; }
.panel h2 {
  margin: -40px 0 6px; font: 38px/1 var(--title); color: var(--gold); letter-spacing: 1px;
  text-shadow: -3px -3px 0 var(--ink), 3px -3px 0 var(--ink), -3px 3px 0 var(--ink), 3px 3px 0 var(--ink), 0 -3px 0 var(--ink), 0 3px 0 var(--ink), -3px 0 0 var(--ink), 3px 0 0 var(--ink), 0 6px 0 var(--ink);
}
.panel h3 { margin: 10px 0 4px; font: 17px var(--title); color: #8a3a12; letter-spacing: .4px; }
.panel p { margin: 6px 0; font: 700 13px/1.4 var(--body); }
.panel .sub { font: 800 14px/1.35 var(--body); color: #5a3a1c; margin-bottom: 12px; }
.panel .small { font-size: 11.5px; font-weight: 700; color: #6b4a2a; }
.panel .credits { font: 800 15px/1.5 var(--body); color: #3a2614; }
.panel .btn { margin-top: 8px; }
.scroll { max-height: 350px; overflow-y: auto; text-align: left; padding: 0 6px 4px 0; pointer-events: auto; }
.scroll::-webkit-scrollbar { width: 6px; }
.scroll::-webkit-scrollbar-thumb { background: rgba(90, 58, 28, .5); border-radius: 3px; }
.keys { margin: 4px 0 0; padding: 0; list-style: none; font: 700 12px/1.35 var(--body); }
.keys li { margin: 4px 0; padding-left: 4px; }
kbd {
  display: inline-block; min-width: 18px; padding: 1px 5px; margin: 0 1px; border: 1.5px solid var(--ink); border-radius: 5px;
  background: linear-gradient(#fffaf0, #e4d6b8); box-shadow: 0 2px 0 var(--ink); font: 11px/14px var(--title); color: var(--ink); text-align: center;
}
.diff { display: flex; flex-direction: column; gap: 10px; align-items: center; margin-bottom: 8px; }
.diffbtn { display: flex; flex-direction: column; align-items: center; min-width: 260px; padding: 6px 20px 8px; }
.diffbtn b { font: 22px/1.1 var(--title); }
.diffbtn small { font: 800 11px/1.2 var(--body); color: #fff1d6; text-shadow: 0 1px 1px rgba(0,0,0,.6); letter-spacing: 0; }
.link { margin-top: 8px; border: 0; background: none; font: 800 13px var(--body); color: #7a3a10; text-decoration: underline; }

.screen-pause .panel h2 { font-size: 44px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin: 4px 0 10px; text-align: left; }
.stats div { display: flex; justify-content: space-between; gap: 8px; padding: 4px 9px; border-radius: 7px; background: rgba(120, 80, 30, .14); font: 800 12.5px var(--body); }
.stats b { font: 14px var(--title); color: #7a2a0c; letter-spacing: .3px; }
.stats div:last-child:nth-child(odd) { grid-column: 1 / -1; }
.screen-over .panel h2 { color: #ff6a50; }
.screen-over.win .panel h2 { color: var(--gold); }
.screen-over.on .panel { animation: pop .5s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }

/* ----------------------------------------------------- orientation mobile */
#rotate {
  position: fixed; inset: 0; z-index: 10; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: #120c07; color: var(--cream); text-align: center; font: 22px/1.3 var(--title); letter-spacing: .5px;
}
#rotate small { font: 800 14px var(--body); opacity: .8; }
#rotate .phone {
  width: 54px; height: 92px; border: 5px solid var(--gold); border-radius: 12px; position: relative;
  animation: rot 2.2s ease-in-out infinite;
}
#rotate .phone::after { content: ''; position: absolute; left: 50%; bottom: 5px; width: 10px; height: 4px; margin-left: -5px; border-radius: 2px; background: var(--gold); }
@keyframes rot { 0%, 20% { transform: rotate(0); } 50%, 80% { transform: rotate(-90deg); } 100% { transform: rotate(0); } }
@media (orientation: portrait) and (pointer: coarse) {
  #rotate { display: flex; }
}
body.portrait #rotate { display: flex; }
.noscript { position: fixed; inset: 40% 0 auto; text-align: center; }
