/* AETHERIA — La Valle del Grano
   style.css — inchiostro, pergamena, oro. Palco fisso 960x540 scalato da main.js. */

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: #06060b;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body {
  font-family: 'Alegreya', Georgia, serif;
  color: #efe6d2;
  -webkit-font-smoothing: antialiased;
}

button, .screen, .card, .slot, .tool-btn, .tbtn, .stick {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

img, canvas { -webkit-user-drag: none; }

#stage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 960px;
  height: 540px;
  transform: translate(-50%, -50%);
  transform-origin: center center;
  overflow: hidden;
  background: #07070d;
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.85);
}

#game {
  display: block;
  width: 960px;
  height: 540px;
  touch-action: none;
}

.screen { position: absolute; inset: 0; display: none; z-index: 5; }
.screen.on { display: block; }

.kicker {
  font-family: 'Alegreya Sans', sans-serif;
  font-size: 10.5px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: #c9a45c;
  margin: 0 0 8px;
}

/* ---------------- bottoni ---------------- */

.primary, .ghost, .tab, .slot {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 13.5px;
  letter-spacing: 0.08em;
  padding: 10px 22px;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, transform 0.18s, color 0.18s;
}

.primary {
  background: linear-gradient(180deg, #4a3620, #2a1d10);
  color: #ffe9bd;
  border: 1px solid #b08a4e;
  box-shadow: inset 0 0 0 1px rgba(255, 220, 160, 0.08), 0 6px 20px rgba(0, 0, 0, 0.5);
}

.primary:hover {
  background: linear-gradient(180deg, #6a4d2c, #3a2814);
  border-color: #e3bd7c;
  transform: translateY(-1px);
}

.ghost {
  background: rgba(12, 10, 16, 0.5);
  color: #d9c9a8;
  border: 1px solid rgba(201, 164, 92, 0.35);
}

.ghost:hover { border-color: rgba(227, 189, 124, 0.7); color: #f5e6c6; }

button:disabled { opacity: 0.35; cursor: not-allowed; }

.small { font-size: 10.5px; padding: 8px 14px; letter-spacing: 0.06em; }

.row { display: flex; gap: 12px; align-items: center; }

/* ---------------- titolo ---------------- */

#scr-title .title-bg {
  position: absolute;
  inset: 0;
  background: url('../assets/img/aetheria.webp') center 42% / cover no-repeat;
  filter: saturate(0.9) brightness(0.55);
  transform: scale(1.04);
}

/* Aetheria ha due soli: il compagno sorge alto a destra, sopra la citta' */
.pad-hint {
  margin: 14px 0 0;
  font: 600 11px 'Alegreya Sans', sans-serif;
  letter-spacing: 0.05em;
  color: rgba(240, 231, 210, 0.42);
  transition: color 0.2s;
}

.pad-hint.on {
  color: rgba(240, 205, 140, 0.85);
}

body.pad-on .pad-focus {
  outline: 2px solid rgba(240, 200, 110, 0.85);
  outline-offset: 4px;
}

#scr-title .title-bg::after {
  content: '';
  position: absolute;
  left: 85%;
  top: 13%;
  width: 150px;
  height: 150px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle,
    rgba(255,250,228,0.98) 0 7px,
    rgba(255,228,170,0.6) 8px,
    rgba(255,198,124,0.2) 30px,
    rgba(255,180,100,0) 70px);
  mix-blend-mode: screen;
}

#scr-title .title-inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 30px;
  background: radial-gradient(circle at 50% 45%, rgba(10, 8, 14, 0.12), rgba(6, 5, 10, 0.84) 72%);
}

#scr-title h1 {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 56px;
  letter-spacing: 0.16em;
  margin: 0;
  color: #f6e6c0;
  text-shadow: 0 4px 34px rgba(0, 0, 0, 0.85);
}

#scr-title h2 {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 24px;
  font-weight: 500;
  letter-spacing: 0.22em;
  color: #e6cf9f;
  margin: 2px 0 8px;
}

.rule {
  width: 128px;
  height: 1px;
  background: linear-gradient(90deg, transparent, #c9a45c, transparent);
  margin: 14px 0;
}

.lede {
  color: rgba(240, 230, 210, 0.68);
  font-size: 13px;
  letter-spacing: 0.1em;
  margin: 0 0 24px;
}

.title-buttons { display: flex; gap: 12px; align-items: center; }

.credit {
  position: absolute;
  bottom: 22px;
  left: 0;
  right: 0;
  font-family: 'Alegreya Sans', sans-serif;
  font-size: 10px;
  letter-spacing: 0.05em;
  color: rgba(240, 230, 210, 0.42);
  margin: 0;
}

/* ---------------- prologo ---------------- */

.story-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  transform: scale(1.02);
}

.story-shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(5, 4, 9, 0.94) 0%, rgba(5, 4, 9, 0.6) 46%, rgba(5, 4, 9, 0.12) 78%),
    linear-gradient(0deg, rgba(5, 4, 9, 0.92), rgba(5, 4, 9, 0) 58%);
}

.story-card {
  position: absolute;
  left: 54px;
  bottom: 46px;
  width: 560px;
  isolation: isolate;
}

/* velo morbido dietro il testo: le foto di raccordo sono piene di dettagli */
.story-card::before {
  content: '';
  position: absolute;
  inset: -30px -60px -26px -34px;
  background: radial-gradient(130% 120% at 6% 96%, rgba(6, 5, 10, 0.86) 0%, rgba(6, 5, 10, 0.5) 52%, rgba(6, 5, 10, 0) 82%);
  pointer-events: none;
  z-index: -1;
}

.story-card h2 {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 31px;
  font-weight: 700;
  margin: 0 0 12px;
  color: #f4e4bf;
  text-shadow: 0 3px 20px rgba(0, 0, 0, 0.7);
}

#story-text {
  font-size: 16px;
  line-height: 1.62;
  color: #e9dfcc;
  margin: 0 0 20px;
}

.story-nav { display: flex; align-items: center; justify-content: space-between; }

.dots { display: flex; gap: 7px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: rgba(230, 210, 170, 0.22); }
.dots i.on { background: #d8b46a; }

.story-card.swap { animation: fadeUp 0.45s ease-out; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ---------------- selezione ---------------- */

#scr-select { background: radial-gradient(circle at 50% 0%, #1c1526, #08070d 72%); }

.wrap {
  position: absolute;
  inset: 0;
  padding: 18px 46px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.select-head { display: flex; justify-content: space-between; align-items: flex-end; }

.select-head h2 {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 25px;
  margin: 2px 0 0;
  color: #f2e2bd;
}

.mode { display: flex; gap: 6px; }

.tab {
  background: rgba(14, 11, 18, 0.7);
  border: 1px solid rgba(201, 164, 92, 0.25);
  color: #bfae8e;
  font-size: 10.5px;
  padding: 7px 14px;
}

.tab.on { background: rgba(90, 64, 30, 0.7); border-color: #c9a45c; color: #ffe9bd; }

.slots { display: flex; align-items: center; gap: 10px; }

.slot {
  font-size: 11px;
  padding: 7px 16px;
  background: rgba(14, 11, 18, 0.6);
  border: 1px solid rgba(201, 164, 92, 0.25);
  color: #e6d4ae;
}

.slot.active { border-color: #e3bd7c; box-shadow: 0 0 0 1px rgba(227, 189, 124, 0.4) inset; }

.slot-hint {
  font-family: 'Alegreya Sans', sans-serif;
  font-size: 10.5px;
  color: rgba(230, 215, 190, 0.55);
  margin-left: 6px;
}

.slot-hint.warn { color: #e8a27a; }

.cards {
  display: grid;
  grid-template-columns: repeat(3, 280px);
  gap: 16px;
  justify-content: center;
  flex: 1;
  align-content: start;
}

.card {
  position: relative;
  overflow: hidden;
  background: rgba(14, 11, 20, 0.82);
  border: 1px solid rgba(201, 164, 92, 0.22);
  border-radius: 4px;
  cursor: pointer;
  text-align: left;
  padding: 0;
  transition: border-color 0.18s, transform 0.18s, box-shadow 0.18s;
  outline: none;
}

.card:hover, .card:focus-visible { border-color: rgba(227, 189, 124, 0.7); transform: translateY(-2px); }
.card.sel-p1 { border-color: #e3bd7c; box-shadow: 0 0 0 1px #e3bd7c, 0 10px 34px rgba(180, 130, 60, 0.28); }
.card.sel-p2 { border-color: #8fc0d8; box-shadow: 0 0 0 1px #8fc0d8, 0 10px 34px rgba(90, 150, 190, 0.28); }

.card .portrait {
  height: 108px;
  background-size: cover;
  background-position: center 28%;
  position: relative;
}

.card .portrait img,
.card .portrait canvas.portrait-fb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 26%;
  display: block;
}

.card .portrait .badge {
  z-index: 3;
}

.card .portrait::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, rgba(14, 11, 20, 0.98), rgba(14, 11, 20, 0) 72%);
}

.badge {
  position: absolute;
  top: 8px;
  right: 8px;
  font-family: 'Alegreya Sans', sans-serif;
  font-size: 9px;
  letter-spacing: 0.14em;
  padding: 3px 8px;
  background: rgba(8, 7, 12, 0.82);
  border: 1px solid rgba(201, 164, 92, 0.3);
  color: rgba(230, 215, 190, 0.55);
  z-index: 2;
}

.badge.on { background: #e3bd7c; color: #241a0e; border-color: #e3bd7c; }
.card.sel-p2 .badge.on { background: #8fc0d8; border-color: #8fc0d8; }

.card-body { padding: 9px 13px 12px; }

.card-kicker {
  font-family: 'Alegreya Sans', sans-serif;
  font-size: 8.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #b99a63;
}

.card-title {
  display: block;
  font-family: 'Cinzel', Georgia, serif;
  font-size: 19px;
  color: #f6e6c0;
  margin: 2px 0 6px;
}

.blurb {
  font-size: 11px;
  line-height: 1.42;
  color: rgba(235, 225, 205, 0.8);
  margin: 0 0 8px;
  min-height: 62px;
}

.ability {
  border-top: 1px solid rgba(201, 164, 92, 0.18);
  padding-top: 6px;
  font-family: 'Alegreya Sans', sans-serif;
  font-size: 9.5px;
  color: #cdb98f;
}

.ability b { display: block; color: #e8cf9e; font-size: 9.5px; letter-spacing: 0.08em; margin-bottom: 2px; }
.ability span { color: rgba(230, 215, 190, 0.55); }

.select-foot { display: flex; justify-content: space-between; align-items: center; }

.party-line {
  font-family: 'Alegreya Sans', sans-serif;
  font-size: 10.5px;
  letter-spacing: 0.05em;
  color: rgba(230, 215, 190, 0.7);
  margin: 0;
  white-space: pre;
}

/* ---------------- briefing ---------------- */

#scr-brief { background: radial-gradient(circle at 50% 38%, #2c2219, #07060a 72%); }

.brief-wrap { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }

.brief-paper {
  width: 680px;
  padding: 24px 30px;
  background: linear-gradient(180deg, rgba(30, 24, 18, 0.97), rgba(16, 13, 11, 0.98));
  border: 1px solid rgba(201, 164, 92, 0.35);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.7);
}

.brief-paper h2 {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 25px;
  margin: 0 0 10px;
  color: #f6e6c0;
}

#brief-text { font-size: 13.5px; line-height: 1.55; color: #e6dccb; margin: 0 0 12px; }

.brief-goal { border-left: 2px solid #c9a45c; padding: 4px 0 4px 12px; margin: 0 0 10px; font-size: 12.5px; line-height: 1.45; }

.brief-goal b {
  display: block;
  font-family: 'Alegreya Sans', sans-serif;
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #c9a45c;
  margin-bottom: 3px;
}

.brief-tip { font-size: 11px; line-height: 1.45; color: rgba(230, 215, 190, 0.62); font-style: italic; margin: 0 0 12px; }

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px 18px;
  font-family: 'Alegreya Sans', sans-serif;
  font-size: 10px;
  color: rgba(230, 215, 190, 0.6);
  margin-bottom: 14px;
}

.controls b { color: #e0c795; }
.brief-paper .row { justify-content: flex-end; }

/* ---------------- pausa e sconfitta ---------------- */

#scr-pause, #scr-over { background: rgba(6, 5, 10, 0.76); }

.panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 580px;
  padding: 24px 30px;
  background: linear-gradient(180deg, rgba(22, 18, 26, 0.98), rgba(12, 10, 15, 0.99));
  border: 1px solid rgba(201, 164, 92, 0.35);
  text-align: center;
}

.panel h2 {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 27px;
  margin: 0 0 10px;
  color: #f4e4bf;
}

.panel p { font-size: 13px; color: rgba(235, 225, 205, 0.78); margin: 0 0 6px; }

.check {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: 'Alegreya Sans', sans-serif;
  font-size: 11px;
  color: rgba(230, 215, 190, 0.75);
  margin: 14px 0 0;
  cursor: pointer;
}

.panel .row { justify-content: center; margin-top: 18px; }
.panel .controls { text-align: left; margin-top: 12px; }

/* ---------------- vittoria ---------------- */

.win-bg {
  position: absolute;
  inset: 0;
  background: url('../assets/img/foresta.webp') center / cover no-repeat;
  filter: brightness(0.36) saturate(0.85);
}

.win-shade {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 40%, rgba(10, 8, 14, 0.35), rgba(6, 5, 10, 0.94));
}

.win-wrap { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }

.win-panel {
  width: 700px;
  padding: 20px 28px;
  background: rgba(10, 8, 14, 0.86);
  border: 1px solid rgba(201, 164, 92, 0.35);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.7);
}

.win-panel h2 {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 24px;
  margin: 0 0 12px;
  color: #f4e4bf;
}

.dialog p { margin: 0 0 7px; font-size: 12px; line-height: 1.45; color: #e6dccb; }

.dialog .who {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 10.5px;
  letter-spacing: 0.1em;
  margin-right: 8px;
  color: #e0c795;
}

.dialog .who.aura { color: #a8d8b8; }
.dialog .who.kael { color: #c9a6d8; }
.dialog .who.sylara { color: #9fc4d8; }
.dialog .who.marco { color: #f0c86a; }

.teaser { border-top: 1px solid rgba(201, 164, 92, 0.25); margin-top: 10px; padding-top: 10px; }

.teaser h3 {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 16px;
  margin: 2px 0 4px;
  color: #e8cf9e;
}

.teaser p { font-size: 11px; color: rgba(230, 215, 190, 0.65); margin: 0; line-height: 1.45; }

.stats {
  font-family: 'Alegreya Sans', sans-serif;
  font-size: 10px;
  color: rgba(230, 215, 190, 0.6);
  margin: 10px 0 0;
}

.win-panel .row { justify-content: flex-end; margin-top: 12px; }

/* ============================================================
   COMANDI A SCHERMO, SCHERMO INTERO, ORIENTAMENTO
   ============================================================ */

.touch-only { display: none !important; }
body.touch-on .touch-only { display: grid !important; }
body.touch-on .keyboard-only { display: none !important; }

/* strumenti sempre disponibili, fuori dal palco scalato */
.game-tools {
  position: fixed;
  z-index: 40;
  top: max(56px, calc(env(safe-area-inset-top) + 18vh));
  right: max(12px, env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tool-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(201, 164, 92, 0.38);
  background: rgba(8, 7, 12, 0.62);
  color: #e8d6b0;
  font: 600 14px/1 'Alegreya Sans', sans-serif;
  cursor: pointer;
  touch-action: none;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  transition: border-color 0.18s, background 0.18s, color 0.18s;
}

.tool-btn:hover,
.tool-btn[aria-pressed="true"] {
  border-color: #e3bd7c;
  background: rgba(58, 42, 26, 0.82);
  color: #fff2cf;
}

#btn-pause-touch { display: none; }
body.in-game #btn-pause-touch { display: grid; }

/* levetta + azioni, sopra il palco ma dentro lo schermo */
.touch {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: none;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 max(14px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  pointer-events: none;
}

body.touch-on.in-game .touch { display: flex; }

.touch .side { pointer-events: auto; }
.stick-wrap { display: flex; align-items: flex-end; }

.stick {
  position: relative;
  width: 118px;
  height: 118px;
  border-radius: 50%;
  border: 1px solid rgba(201, 164, 92, 0.32);
  background: radial-gradient(circle at 50% 45%, rgba(30, 24, 18, 0.52), rgba(8, 7, 12, 0.74));
  box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.45), 0 8px 24px rgba(0, 0, 0, 0.35);
  touch-action: none;
  pointer-events: auto;
}

.stick-ring {
  position: absolute;
  inset: 18%;
  border-radius: 50%;
  border: 1px dashed rgba(201, 164, 92, 0.25);
}

.stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  border-radius: 50%;
  border: 1px solid rgba(227, 189, 124, 0.6);
  background: radial-gradient(circle at 40% 35%, rgba(120, 90, 50, 0.9), rgba(38, 28, 18, 0.92));
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  transition: transform 0.05s linear;
}

.stick.active .stick-knob {
  border-color: #ffe0a0;
  box-shadow: 0 0 18px rgba(240, 200, 110, 0.35);
}

.actions { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }

.spell-row { display: none; gap: 6px; justify-content: flex-end; }
body.p1-marco .spell-row { display: flex; }

.action-row { display: flex; align-items: flex-end; gap: 8px; }

.tbtn {
  width: 52px;
  height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 50%;
  border: 1px solid rgba(201, 164, 92, 0.4);
  background: rgba(10, 8, 13, 0.62);
  color: #f2e2bd;
  font: 700 14px/1 'Cinzel', Georgia, serif;
  cursor: pointer;
  touch-action: none;
  box-shadow: inset 0 0 0 1px rgba(255, 230, 180, 0.04), 0 6px 18px rgba(0, 0, 0, 0.35);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

.tbtn span {
  font: 600 7px/1 'Alegreya Sans', sans-serif;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(240, 231, 210, 0.62);
}

.tbtn.mid { width: 54px; height: 54px; }

.tbtn.big {
  width: 66px;
  height: 66px;
  font-size: 18px;
  border-color: rgba(200, 80, 70, 0.65);
  background: rgba(80, 24, 24, 0.55);
}

.tbtn.tiny {
  width: 34px;
  height: 34px;
  font-family: 'Alegreya Sans', sans-serif;
  font-size: 12px;
  color: #e6d4ae;
}

.tbtn.on,
.tbtn:active {
  background: rgba(120, 82, 38, 0.8);
  border-color: #ffe0a0;
  color: #fff;
  transform: scale(0.96);
}

.tbtn.big.on,
.tbtn.big:active {
  background: rgba(160, 50, 44, 0.8);
  border-color: #ffb0a0;
}

/* invito a ruotare: solo su dispositivi touch in verticale */
.rotate {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #07060b;
  text-align: center;
}

body.touch-on.portrait .rotate { display: flex; }
body.touch-on.portrait .touch,
body.touch-on.portrait .game-tools { display: none !important; }

.rotate-card { max-width: 340px; }

.rotate-icon {
  margin: 8px auto 2px;
  font-size: 58px;
  line-height: 1;
  color: #c9a45c;
  transform: rotate(90deg);
}

.rotate-card h2 {
  margin: 10px 0 8px;
  font-family: 'Cinzel', Georgia, serif;
  font-size: 27px;
  color: #f6e6c0;
}

.rotate-card p {
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 1.6;
  color: rgba(240, 231, 210, 0.72);
}

@media (max-height: 430px) {
  .stick { width: 96px; height: 96px; }
  .stick-knob { width: 44px; height: 44px; margin: -22px 0 0 -22px; }
  .tbtn { width: 46px; height: 46px; }
  .tbtn.mid { width: 48px; height: 48px; }
  .tbtn.big { width: 58px; height: 58px; font-size: 16px; }
  .tbtn.tiny { width: 30px; height: 30px; }
  .action-row { gap: 6px; }
  .spell-row { gap: 4px; }
  .game-tools { top: max(48px, calc(env(safe-area-inset-top) + 15vh)); }
}
