/* Palette du Salon Hibiscus (rose, prune, or, sable). Aucune teinte hors
   palette : ce jeu est un ecran du salon, pas une piece rapportee. */
:root {
  color-scheme: light;
  --ink: #2A0F1B;
  --muted: #6B5A60;
  --paper: #FBF5F1;
  --cream: #F6E7DD;
  --blush: #F2C4D2;
  --plum: #7A1F3D;
  --rose: #B8355A;
  --gold: #C9A227;
  --gold-soft: #E3C766;
  --deep: #7A1F3D;
  --rose-light: #D9738F;
  --shadow: 0 14px 34px rgba(42, 15, 27, 0.18);
  --soft-shadow: 0 8px 20px rgba(42, 15, 27, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(circle at 15% 12%, rgba(227, 199, 102, 0.35), transparent 24rem),
    linear-gradient(180deg, #F6E0E8 0%, #F2E2C4 50%, #FBF5F1 100%);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
  touch-action: manipulation;
  user-select: none;
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  letter-spacing: 0;
  -webkit-tap-highlight-color: transparent;
}

.app {
  width: min(100%, 480px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 12px max(18px, env(safe-area-inset-bottom));
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.6), rgba(251, 245, 241, 0.82)),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0 8px, transparent 8px 18px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 2px 10px;
  /* L'application superpose son bouton Retour en haut a gauche de l'iframe :
     on lui reserve sa place pour que le nom du jeu reste lisible. */
  padding-left: 124px;
}

.kicker {
  margin: 0 0 2px;
  color: var(--plum);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.9rem;
  line-height: 1;
}

h2 {
  font-size: 1rem;
}

.icon-button,
.mini-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.8);
  box-shadow: var(--soft-shadow);
}

.resources {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) 1.4fr;
  gap: 7px;
  margin-bottom: 10px;
}

.resource-pill,
.level-pill {
  min-width: 0;
  min-height: 38px;
  border-radius: 8px;
  background: rgba(251, 245, 241, 0.94);
  box-shadow: var(--soft-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px;
  font-size: 0.9rem;
}

.energy {
  background: linear-gradient(135deg, #F6E7BE, #FBF5F1);
}

.level-pill {
  flex-direction: column;
  align-items: stretch;
  gap: 5px;
  font-size: 0.76rem;
  font-weight: 800;
}

.xp-track {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(42, 15, 27, 0.12);
}

.xp-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold-soft), var(--gold));
  transition: width 240ms ease;
}

.story-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 70px;
  padding: 12px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(122, 31, 61, 0.92), rgba(122, 31, 61, 0.84)),
    linear-gradient(90deg, var(--blush), var(--deep));
  color: #FBF5F1;
  box-shadow: var(--shadow);
}

.story-strip p {
  margin-bottom: 3px;
  font-size: 0.76rem;
  font-weight: 900;
  opacity: 0.86;
  text-transform: uppercase;
}

.story-strip strong {
  display: block;
  font-size: 0.95rem;
  line-height: 1.18;
}

.soft-button {
  flex: 0 0 auto;
  min-width: 74px;
  min-height: 42px;
  border-radius: 8px;
  background: #FBF5F1;
  color: var(--plum);
  font-weight: 900;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.08);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.tab {
  min-height: 42px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.64);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 900;
  box-shadow: var(--soft-shadow);
}

.tab.active {
  background: #FBF5F1;
  color: var(--ink);
  box-shadow: inset 0 -4px 0 var(--rose), var(--soft-shadow);
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.orders-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 2px 0 8px;
}

.orders {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(240px, 82%);
  gap: 9px;
  overflow-x: auto;
  padding: 2px 1px 10px;
  scroll-snap-type: x mandatory;
}

.orders::-webkit-scrollbar,
.generators::-webkit-scrollbar {
  display: none;
}

.order-card {
  min-height: 128px;
  border-radius: 8px;
  background: rgba(251, 245, 241, 0.96);
  box-shadow: var(--soft-shadow);
  padding: 10px;
  scroll-snap-align: start;
  display: grid;
  gap: 8px;
}

.order-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.portrait {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--blush), var(--rose-light));
  font-size: 1.45rem;
  box-shadow: inset 0 -4px 0 rgba(42, 15, 27, 0.1);
}

.order-copy {
  min-width: 0;
  flex: 1;
}

.order-copy strong {
  display: block;
  font-size: 0.92rem;
}

.order-copy span {
  color: var(--muted);
  display: block;
  font-size: 0.78rem;
  line-height: 1.2;
  margin-top: 2px;
}

.requirement-row,
.reward-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.req-chip,
.reward-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 28px;
  padding: 4px 7px;
  border-radius: 8px;
  background: rgba(217, 115, 143, 0.22);
  font-size: 0.75rem;
  font-weight: 800;
}

.req-chip {
  min-width: 74px;
  justify-content: space-between;
  background: linear-gradient(135deg, var(--req-a), var(--req-b));
  border: 1px solid rgba(42, 15, 27, 0.12);
  box-shadow: inset 0 0 0 999px rgba(255, 255, 255, 0.36);
  color: var(--ink);
}

.req-chip b {
  font-size: 1rem;
  line-height: 1;
}

.req-chip em {
  font-style: normal;
  font-size: 0.66rem;
  font-weight: 900;
}

.req-chip small {
  min-width: 24px;
  border-radius: 999px;
  background: rgba(251, 245, 241, 0.78);
  padding: 2px 4px;
  text-align: center;
  font-size: 0.62rem;
}

.req-chip.done {
  background: linear-gradient(135deg, rgba(201, 162, 39, 0.36), rgba(201, 162, 39, 0.24));
  color: #7A1F3D;
}

.complete-order {
  min-height: 34px;
  border-radius: 8px;
  background: var(--rose);
  color: #fff;
  font-weight: 900;
  box-shadow: inset 0 -4px 0 rgba(42, 15, 27, 0.12);
}

.complete-order:disabled {
  background: rgba(107, 90, 96, 0.25);
  color: var(--muted);
}

.bonus-track {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 8px;
  margin: 0 0 10px;
}

.bonus-card {
  min-height: 70px;
  border-radius: 8px;
  background: rgba(251, 245, 241, 0.92);
  box-shadow: var(--soft-shadow);
  padding: 9px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 6px;
}

.bonus-card strong,
.bonus-card span {
  display: block;
}

.bonus-card strong {
  font-size: 0.84rem;
}

.bonus-card span {
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.15;
  margin-top: 2px;
}

.bonus-card small {
  color: var(--plum);
  font-size: 0.72rem;
  font-weight: 900;
}

.bonus-card .progress-track {
  grid-column: 1 / -1;
  align-self: end;
}

.resident-alert.ready {
  background: linear-gradient(135deg, #FBF5F1, #F7DCE4);
  box-shadow:
    0 0 0 2px rgba(184, 53, 90, 0.28),
    var(--soft-shadow);
}

.generators {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  overflow: visible;
  padding: 1px 1px 10px;
}

.generator-button {
  position: relative;
  min-height: 86px;
  border-radius: 8px;
  background: #FBF5F1;
  box-shadow: var(--soft-shadow);
  overflow: hidden;
  padding: 8px;
  text-align: left;
}

.generator-button.locked {
  filter: grayscale(0.5);
  opacity: 0.7;
}

.generator-button .gen-icon {
  display: block;
  font-size: 1.6rem;
}

.generator-button strong {
  display: block;
  margin-top: 3px;
  font-size: 0.78rem;
  line-height: 1.05;
}

.generator-button small {
  color: var(--muted);
  display: block;
  font-size: 0.68rem;
  font-weight: 800;
  margin-top: 4px;
}

.charge-bar {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 7px;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(42, 15, 27, 0.12);
}

.charge-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), var(--gold-soft));
}

.board-wrap {
  border-radius: 8px;
  padding: 8px;
  background:
    linear-gradient(180deg, rgba(251, 245, 241, 0.88), rgba(246, 231, 221, 0.9)),
    linear-gradient(135deg, rgba(122, 31, 61, 0.1), rgba(184, 53, 90, 0.12));
  box-shadow: var(--shadow);
}

.board {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
}

.cell {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(42, 15, 27, 0.08);
  box-shadow: inset 0 -4px 0 rgba(42, 15, 27, 0.05);
  overflow: hidden;
}

.cell.selected {
  outline: 3px solid var(--gold);
  outline-offset: -3px;
}

.cell.hint {
  animation: hintPulse 700ms ease-in-out 3;
}

.cell.blocked {
  display: grid;
  place-items: center;
  background:
    linear-gradient(135deg, rgba(201, 162, 39, 0.32), rgba(240, 220, 180, 0.5)),
    #EAD7AE;
  color: #7A1F3D;
  font-size: 1.3rem;
  font-weight: 900;
}

.cell.blocked small {
  position: absolute;
  bottom: 3px;
  font-size: 0.58rem;
  color: #7A1F3D;
}

.cell.locked {
  display: grid;
  place-items: center;
  background: rgba(74, 29, 51, 0.15);
  color: rgba(42, 15, 27, 0.64);
}

.item {
  position: absolute;
  inset: 4px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background:
    radial-gradient(circle at 30% 18%, rgba(255, 255, 255, 0.92), transparent 34%),
    linear-gradient(145deg, var(--item-a), var(--item-b));
  box-shadow:
    inset 0 -5px 0 rgba(42, 15, 27, 0.12),
    0 7px 12px rgba(42, 15, 27, 0.14);
  cursor: grab;
  touch-action: none;
  transition:
    transform 150ms ease,
    filter 150ms ease;
}

.item:active {
  cursor: grabbing;
  transform: scale(0.96);
}

.item.dragging-source {
  opacity: 0;
}

.item .icon {
  font-size: 1.35rem;
  line-height: 1;
}

.item .level {
  position: absolute;
  right: 4px;
  bottom: 3px;
  min-width: 17px;
  height: 17px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(251, 245, 241, 0.92);
  color: var(--ink);
  font-size: 0.58rem;
  font-weight: 900;
}

.item.new {
  animation: popIn 220ms ease-out;
}

.item.maxed {
  box-shadow:
    inset 0 -5px 0 rgba(42, 15, 27, 0.12),
    0 0 0 2px rgba(201, 162, 39, 0.86),
    0 7px 12px rgba(42, 15, 27, 0.14);
}

.merge-ghost {
  pointer-events: none;
  position: fixed;
  z-index: 30;
  width: 58px;
  height: 58px;
  transform: translate(-50%, -50%);
  border-radius: 8px;
  background: rgba(251, 245, 241, 0.88);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  font-size: 1.5rem;
}

.merge-ghost[hidden] {
  display: none;
}

.action-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.action-button {
  min-height: 42px;
  border-radius: 8px;
  background: #FBF5F1;
  font-size: 0.86rem;
  font-weight: 900;
  box-shadow: var(--soft-shadow);
}

.action-button.danger {
  color: #7A1F3D;
}

.inventory-band {
  margin-top: 12px;
  border-radius: 8px;
  background: rgba(251, 245, 241, 0.76);
  box-shadow: var(--soft-shadow);
  padding: 10px;
}

.inventory-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-weight: 900;
}

.inventory-title small {
  color: var(--muted);
}

.inventory {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.inventory-slot {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px dashed rgba(42, 15, 27, 0.25);
}

.inventory-slot .item {
  inset: 5px;
}

.restoration-scene {
  min-height: 210px;
  border-radius: 8px;
  padding: 14px;
  color: #FBF5F1;
  background:
    linear-gradient(180deg, rgba(74, 29, 51, 0.18), rgba(42, 15, 27, 0.32)),
    linear-gradient(135deg, #7A1F3D, #B8355A 48%, #C9A227);
  box-shadow: var(--shadow);
  display: grid;
  align-content: end;
  overflow: hidden;
  position: relative;
}

.restoration-scene::before {
  content: "";
  position: absolute;
  left: 6%;
  right: 6%;
  bottom: 52px;
  height: 74px;
  border-radius: 8px 8px 4px 4px;
  background:
    linear-gradient(90deg, rgba(251, 245, 241, 0.9) 0 23%, transparent 23% 30%, rgba(251, 245, 241, 0.9) 30% 65%, transparent 65% 72%, rgba(251, 245, 241, 0.9) 72%),
    linear-gradient(180deg, #F0DCB4, #C09A62);
  box-shadow: 0 -30px 0 -8px rgba(74, 29, 51, 0.9);
  opacity: var(--scene-clarity, 0.45);
}

.restoration-scene::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 54px;
  background:
    repeating-linear-gradient(90deg, rgba(251, 245, 241, 0.22) 0 16px, transparent 16px 32px),
    linear-gradient(180deg, rgba(255, 255, 255, 0), rgba(122, 31, 61, 0.74));
}

.scene-copy {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 4px;
  text-shadow: 0 2px 8px rgba(42, 15, 27, 0.25);
}

.scene-copy strong {
  font-size: 1.18rem;
}

.scene-copy span {
  font-size: 0.88rem;
  line-height: 1.24;
}

.restoration-list,
.resident-list,
.collection-list,
.shop-grid {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.restore-card,
.resident-card,
.collection-card,
.shop-offer {
  border-radius: 8px;
  background: rgba(251, 245, 241, 0.92);
  box-shadow: var(--soft-shadow);
  padding: 12px;
}

.restore-card {
  display: grid;
  gap: 8px;
}

.restore-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.restore-top strong {
  font-size: 0.96rem;
}

.restore-top span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.restore-button {
  min-height: 38px;
  border-radius: 8px;
  background: var(--gold-soft);
  color: #fff;
  font-weight: 900;
}

.restore-button:disabled {
  background: rgba(107, 90, 96, 0.24);
  color: var(--muted);
}

.progress-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(42, 15, 27, 0.1);
}

.progress-track span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--rose), var(--gold));
}

.resident-card {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) minmax(82px, auto);
  align-items: center;
  gap: 9px;
}

.resident-avatar {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--blush), var(--rose-light));
  font-size: 1.5rem;
  box-shadow: inset 0 -4px 0 rgba(42, 15, 27, 0.1);
}

.resident-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.resident-copy strong {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
}

.resident-copy strong span {
  border-radius: 999px;
  background: rgba(217, 115, 143, 0.24);
  padding: 2px 6px;
  color: var(--plum);
  font-size: 0.63rem;
}

.resident-copy small,
.resident-copy p {
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.15;
}

.resident-copy p {
  margin: 0;
}

.bond-track {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(42, 15, 27, 0.1);
}

.bond-track span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #CE5C7D, var(--rose));
}

.upgrade-resident {
  min-height: 38px;
  border-radius: 8px;
  background: var(--deep);
  color: #FBF5F1;
  padding: 6px 8px;
  font-size: 0.72rem;
  font-weight: 900;
}

.upgrade-resident:disabled {
  background: rgba(107, 90, 96, 0.22);
  color: var(--muted);
}

.collection-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.collection-card strong {
  display: block;
  font-size: 0.9rem;
}

.collection-card span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.collection-icons {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
  max-width: 46%;
}

.collection-icons i {
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  border-radius: 7px;
  background: rgba(217, 115, 143, 0.22);
  font-style: normal;
  font-size: 0.82rem;
}

.collection-icons i.locked-icon {
  filter: grayscale(1);
  opacity: 0.36;
}

.shop-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.shop-offer {
  min-height: 120px;
  text-align: left;
  display: grid;
  align-content: space-between;
  gap: 6px;
}

.shop-offer span {
  font-size: 1.7rem;
}

.shop-offer strong {
  display: block;
  font-size: 0.95rem;
}

.shop-offer small {
  color: var(--muted);
  font-weight: 800;
}

.shop-offer.pass {
  grid-column: 1 / -1;
  min-height: 96px;
  background: linear-gradient(135deg, #FBF5F1, #F7DCE4);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 50;
  width: min(92vw, 420px);
  min-height: 42px;
  transform: translate(-50%, 120%);
  opacity: 0;
  border-radius: 8px;
  background: rgba(42, 15, 27, 0.94);
  color: #FBF5F1;
  display: grid;
  place-items: center;
  padding: 10px 14px;
  font-size: 0.86rem;
  font-weight: 800;
  text-align: center;
  transition:
    transform 180ms ease,
    opacity 180ms ease;
}

.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

@keyframes popIn {
  0% {
    transform: scale(0.75) rotate(-6deg);
  }
  70% {
    transform: scale(1.08) rotate(2deg);
  }
  100% {
    transform: scale(1) rotate(0);
  }
}

@keyframes hintPulse {
  0%,
  100% {
    box-shadow: inset 0 -4px 0 rgba(42, 15, 27, 0.05);
  }
  50% {
    box-shadow:
      inset 0 -4px 0 rgba(42, 15, 27, 0.05),
      0 0 0 4px rgba(201, 162, 39, 0.58);
  }
}

@media (max-width: 360px) {
  .app {
    padding-left: 8px;
    padding-right: 8px;
  }

  .board {
    gap: 4px;
  }

  .item .icon {
    font-size: 1.1rem;
  }

  .resources {
    gap: 5px;
  }

  .bonus-track,
  .generators {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .resource-pill,
  .level-pill {
    font-size: 0.78rem;
    padding: 5px;
  }
}
