﻿@font-face {
  font-family: "BoutiqueSorts";
  src: url("lbds.ttf") format("opentype");
  font-display: swap;
}

:root {
  --paper: #f7ead2;
  --paper-muted: rgba(247, 234, 210, .72);
  --ink: #191412;
  --table: #191312;
  --panel: #2b211f;
  --panel-2: #3a2b27;
  --line: rgba(247, 234, 210, .18);
  --shadow: rgba(0, 0, 0, .28);
  --life: #b83b34;
  --life-dark: #81261f;
  --mana: #7650b8;
  --mana-dark: #4b327c;
  --gold: #d39a28;
  --gold-dark: #8b5b16;
  --site-bg-image: url("img/Fond.png");
  --life-bg-image: url("img/Vie.png");
  --mana-bg-image: url("img/Mana.png");
  --gold-bg-image: url("img/Or.png");
}

@supports (background-image: image-set(url("img/Fond-1600.webp") type("image/webp"))) {
  :root {
    --site-bg-image: image-set(url("img/Fond-1600.webp") type("image/webp"), url("img/Fond.png") type("image/png"));
    --life-bg-image: image-set(url("img/Vie-1600.webp") type("image/webp"), url("img/Vie.png") type("image/png"));
    --mana-bg-image: image-set(url("img/Mana-1600.webp") type("image/webp"), url("img/Mana.png") type("image/png"));
    --gold-bg-image: image-set(url("img/Or-1600.webp") type("image/webp"), url("img/Or.png") type("image/png"));
  }
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  color: var(--paper);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: var(--table);
  background-image:
    linear-gradient(rgba(25, 19, 18, .38), rgba(25, 19, 18, .62)),
    var(--site-bg-image);
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(rgba(255, 255, 255, .012), rgba(0, 0, 0, .08));
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  user-select: none;
}

.app {
  position: relative;
  width: 100%;
  height: 100svh;
  padding: max(14px, env(safe-area-inset-top)) 12px max(14px, env(safe-area-inset-bottom));
}

.screen {
  display: none;
  height: 100%;
}

.screen.active {
  display: flex;
}

.menu {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
}

.brand {
  width: min(92vw, 420px);
  padding: 0 12px;
}

.brand a {
  display: block;
  color: inherit;
  text-decoration: none;
}

.brand-logo {
  display: block;
  width: min(80vw, 340px);
  height: auto;
  max-height: 40svh;
  object-fit: contain;
  margin: 0 auto clamp(-38px, -10vw, -24px);
}

h1 {
  margin: 0;
  font-family: "BoutiqueSorts", Georgia, "Times New Roman", serif;
  font-size: clamp(1.55rem, 7vw, 2.55rem);
  font-weight: 400;
  line-height: .95;
  letter-spacing: .2px;
  text-shadow: 0 3px 0 rgba(0, 0, 0, .24);
}

.brand p {
  margin: 10px 0 0;
  color: var(--paper-muted);
  font-size: .84rem;
  font-weight: 850;
  letter-spacing: .7px;
  text-transform: uppercase;
}

.menu-actions {
  width: min(76vw, 280px);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.install-panel {
  position: relative;
  width: min(86vw, 340px);
  padding: 10px 38px 10px 12px;
  border: 1px solid rgba(247, 234, 210, .20);
  border-radius: 6px;
  background: rgba(25, 19, 18, .78);
  box-shadow: 0 10px 20px rgba(0, 0, 0, .22);
  text-align: left;
}

.install-panel[hidden],
.install-btn[hidden] {
  display: none;
}

.install-panel p {
  margin: 0 0 8px;
  color: var(--paper-muted);
  font-size: .78rem;
  font-weight: 800;
  line-height: 1.25;
}

.install-btn {
  min-height: 34px;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--panel-2);
  border: 1px solid rgba(247, 234, 210, .24);
  color: var(--paper);
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .3px;
  text-transform: uppercase;
}

.install-close {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 26px;
  height: 26px;
  padding: 0 0 2px;
  border-radius: 6px;
  background: rgba(247, 234, 210, .10);
  color: var(--paper-muted);
  font-size: 1.2rem;
  line-height: 1;
}

.big-btn,
.top-btn {
  border-radius: 6px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .35px;
  border: 2px solid rgba(247, 234, 210, .20);
  box-shadow: 0 10px 20px var(--shadow);
  text-shadow: 0 2px 0 rgba(0, 0, 0, .30);
  transition: transform .08s ease, filter .12s ease;
}

.big-btn {
  min-height: 46px;
  padding: 10px 14px;
  font-size: .92rem;
}

.big-btn:active,
.top-btn:active {
  transform: scale(.97);
}

.round-btn:active {
  opacity: .82;
}

.solo-btn {
  background: var(--life);
  border-color: rgba(255, 226, 212, .38);
}

.duo-btn {
  background: var(--mana);
  border-color: rgba(229, 218, 255, .36);
}

.game {
  flex-direction: column;
  gap: 10px;
}

.topbar {
  display: flex;
  gap: 10px;
  min-height: 50px;
}

.top-btn {
  flex: 1;
  padding: 11px 12px;
  font-size: .82rem;
  background: var(--panel);
}

.top-btn[data-action="reset"] {
  background: var(--gold-dark);
  border-color: rgba(255, 227, 176, .30);
}

.board {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 10px;
}

.solo-board {
  grid-template-columns: 1fr;
  grid-template-rows: 1.45fr 1fr 1fr;
}

.duo-board {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: .82fr 1.2fr 1.2fr .82fr;
}

.counter {
  position: relative;
  overflow: hidden;
  min-height: 0;
  border-radius: 8px;
  padding: 12px 62px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(247, 234, 210, .18);
  box-shadow: 0 12px 24px var(--shadow);
  isolation: isolate;
}

.counter::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  opacity: .10;
  background: linear-gradient(135deg, rgba(255, 255, 255, .16), transparent 48%);
}

.life {
  background-color: var(--life);
  background-image:
    linear-gradient(rgba(184, 59, 52, .50), rgba(129, 38, 31, .70)),
    linear-gradient(135deg, rgba(255, 230, 210, .16), transparent 42%),
    var(--life-bg-image);
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  border-color: rgba(255, 220, 210, .30);
}

.mana {
  background-color: var(--mana);
  background-image:
    linear-gradient(rgba(118, 80, 184, .50), rgba(75, 50, 124, .70)),
    linear-gradient(135deg, rgba(230, 220, 255, .18), transparent 42%),
    var(--mana-bg-image);
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  border-color: rgba(215, 228, 255, .28);
}

.gold {
  color: #241605;
  background-color: var(--gold);
  background-image:
    linear-gradient(rgba(211, 154, 40, .46), rgba(139, 91, 22, .66)),
    linear-gradient(135deg, rgba(255, 252, 226, .24), transparent 42%),
    var(--gold-bg-image);
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  border-color: rgba(255, 240, 196, .42);
}

.counter-content {
  display: grid;
  place-items: center;
  gap: 5px;
  width: 100%;
  min-width: 0;
  text-align: center;
}

.label {
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: .8px;
  line-height: 1;
  text-transform: uppercase;
  opacity: .9;
  white-space: nowrap;
}

.value {
  display: block;
  width: 2ch;
  font-size: clamp(3rem, 18vw, 7rem);
  font-weight: 950;
  font-variant-numeric: tabular-nums;
  line-height: .86;
  text-align: center;
  text-shadow: 0 3px 0 rgba(0, 0, 0, .22);
}

.gold .value {
  text-shadow: 0 2px 0 rgba(255, 255, 255, .26);
}

.round-btn {
  position: absolute;
  top: 50%;
  z-index: 2;
  width: 42px;
  height: 42px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0 4px;
  font-size: 1.85rem;
  font-weight: 900;
  line-height: 1;
  background: rgba(33, 23, 17, .20);
  border: 2px solid rgba(247, 234, 210, .36);
  box-shadow: 0 6px 12px rgba(0, 0, 0, .18);
  transform: translateY(-50%);
}

.minus {
  left: 14px;
}

.plus {
  right: 14px;
}

.life .round-btn {
  background: var(--life-dark);
}

.mana .round-btn {
  background: var(--mana-dark);
}

.gold .round-btn {
  background: var(--gold-dark);
  color: var(--paper);
  border-color: rgba(255, 246, 218, .40);
}

.duo-board .p2 .counter-content {
  transform: rotate(180deg);
}

.duo-board .p2 .round-btn {
  transform: translateY(-50%) rotate(180deg);
}

.duo-board .life {
  grid-column: 1 / 3;
}

.duo-board .life .value {
  font-size: clamp(4rem, 22vw, 7.6rem);
}

.duo-board .mana .value,
.duo-board .gold .value {
  font-size: clamp(2.4rem, 14vw, 4.8rem);
}

.duo-board .mana,
.duo-board .gold {
  border-radius: 8px;
  padding-inline: 52px;
}

.duo-board .mana .round-btn,
.duo-board .gold .round-btn {
  width: 38px;
  height: 38px;
  font-size: 1.6rem;
}

.duo-board .mana .minus,
.duo-board .gold .minus {
  left: 10px;
}

.duo-board .mana .plus,
.duo-board .gold .plus {
  right: 10px;
}

.duo-board .p2.mana {
  grid-row: 1;
  grid-column: 1;
}

.duo-board .p2.gold {
  grid-row: 1;
  grid-column: 2;
}

.duo-board .p2.life {
  grid-row: 2;
}

.duo-board .p1.life {
  grid-row: 3;
}

.duo-board .p1.mana {
  grid-row: 4;
  grid-column: 1;
}

.duo-board .p1.gold {
  grid-row: 4;
  grid-column: 2;
}

.solo-board .life .value {
  font-size: clamp(4.2rem, 24vw, 8rem);
}

@media (max-width: 370px) {
  .counter {
    padding-inline: 54px;
  }

  .round-btn {
    width: 38px;
    height: 38px;
    font-size: 1.6rem;
  }

  .minus {
    left: 10px;
  }

  .plus {
    right: 10px;
  }

  .duo-board .mana,
  .duo-board .gold {
    padding-inline: 46px;
  }

  .duo-board .mana .round-btn,
  .duo-board .gold .round-btn {
    width: 34px;
    height: 34px;
  }

  .duo-board .mana .minus,
  .duo-board .gold .minus {
    left: 8px;
  }

  .duo-board .mana .plus,
  .duo-board .gold .plus {
    right: 8px;
  }
}

@media (orientation: landscape) {
  .solo-board {
    grid-template-columns: 1.3fr 1fr 1fr;
    grid-template-rows: 1fr;
  }

  .duo-board {
    grid-template-columns: 1.25fr .8fr .8fr .8fr .8fr 1.25fr;
    grid-template-rows: 1fr;
  }

  .duo-board .life {
    grid-column: auto;
  }

  .duo-board .p2.life {
    grid-column: 1;
    grid-row: 1;
  }

  .duo-board .p2.mana {
    grid-column: 2;
    grid-row: 1;
  }

  .duo-board .p2.gold {
    grid-column: 3;
    grid-row: 1;
  }

  .duo-board .p1.mana {
    grid-column: 4;
    grid-row: 1;
  }

  .duo-board .p1.gold {
    grid-column: 5;
    grid-row: 1;
  }

  .duo-board .p1.life {
    grid-column: 6;
    grid-row: 1;
  }

  .duo-board .life .value,
  .solo-board .life .value {
    font-size: clamp(3.3rem, 11vw, 6.8rem);
  }

  .duo-board .life {
    padding-inline: 72px;
  }

  .duo-board .life .value {
    font-size: clamp(3.4rem, 8vw, 6rem);
  }

  .duo-board .mana .value,
  .duo-board .gold .value {
    font-size: clamp(2.4rem, 5vw, 4.2rem);
  }

  .duo-board .mana,
  .duo-board .gold {
    padding-inline: 44px;
  }

  .duo-board .counter-content {
    position: absolute;
    inset: 0;
    display: block;
    width: auto;
  }

  .duo-board .mana .counter-content,
  .duo-board .gold .counter-content {
    width: auto;
    margin-inline: 0;
  }

  .duo-board .label {
    position: absolute;
    left: 50%;
    top: calc(50% - 3.2em);
    transform: translateX(-50%);
    max-width: 7ch;
    overflow: hidden;
    text-align: center;
    text-overflow: ellipsis;
  }

  .duo-board .mana .label,
  .duo-board .gold .label {
    font-size: clamp(.68rem, 1.45vw, .78rem);
  }

  .duo-board .value {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
  }

  .duo-board .mana .round-btn,
  .duo-board .gold .round-btn {
    width: 36px;
    height: 36px;
  }

  .duo-board .mana .minus,
  .duo-board .gold .minus {
    left: 8px;
  }

  .duo-board .mana .plus,
  .duo-board .gold .plus {
    right: 8px;
  }
}
