/* Always dark, whatever the Telegram theme: the arena, its effects and the pale skill names are drawn for it. */
:root {
  color-scheme: dark;
  --bg: #11141b;
  --text: #f2f2f2;
  --hint: #9aa3b2;
  --secondary-bg: #1b1f2a;
  /* Forged gold for the main action, dark iron for the rest. */
  --gold: #e2b85c;
  --gold-dim: #8a6a2e;
  --gold-text: #f6e2b0;
  --ember: #5a1f12;
  --iron: #2a2f3a;
  --iron-dark: #151820;
  --iron-edge: #5d6575;
  --serif: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Noto Serif", serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

.page {
  position: relative;
  height: 100vh;
  height: var(--app-height, 100dvh);
  overflow: hidden;
}

/* The header and the footer float over the arena; the scene keeps the fight clear of them. */
.header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: calc(10px + env(safe-area-inset-top)) 12px 18px;
  background: linear-gradient(to bottom, color-mix(in srgb, var(--bg) 85%, transparent) 55%, transparent);
  pointer-events: none;
}

.title {
  margin: 0;
  color: var(--gold-text);
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  overflow-wrap: anywhere;
}

/* A small bevelled tag, built like the buttons: the rim is the background, the face is inset by a pixel. */
.badge {
  --edge: var(--gold-dim);
  --face: var(--iron-dark);
  position: relative;
  isolation: isolate;
  padding: 3px 8px;
  clip-path: polygon(5px 0, calc(100% - 5px) 0, 100% 5px, 100% calc(100% - 5px), calc(100% - 5px) 100%, 5px 100%, 0 calc(100% - 5px), 0 5px);
  background: var(--edge);
  color: var(--gold-text);
  font-family: var(--serif);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge::before {
  content: "";
  position: absolute;
  inset: 1px;
  z-index: -1;
  clip-path: inherit;
  background: var(--face);
}

.stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--secondary-bg);
}

/* Out of the flow, so the canvas never props the stage open and resizes feed back on themselves. */
.stage canvas {
  position: absolute;
  inset: 0;
  display: block;
}

.badge--live {
  --edge: #e2584a;
  --face: #6e1410;
  color: #ffe9e4;
}

/* The dot of "fight in progress" breathes like an ember. */
.badge--live::first-letter {
  color: #ff6b57;
}

@media (prefers-reduced-motion: no-preference) {
  .badge--live {
    animation: ember 1.6s ease-in-out infinite;
  }
}

@keyframes ember {
  50% {
    filter: brightness(1.35);
  }
}

/* Keeps its height while the buttons are hidden, so the fight does not jump when they appear. */
.footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  min-height: calc(80px + env(safe-area-inset-bottom));
  padding: 24px 12px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, color-mix(in srgb, var(--bg) 85%, transparent) 55%, transparent);
}

.controls {
  display: flex;
  gap: 8px;
  max-width: 560px;
  margin: 0 auto;
}

/* Bevelled plates instead of rounded app buttons: the clipped corners read as forged metal. */
.button {
  --edge: var(--gold);
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 14px;
  border: none;
  clip-path: polygon(10px 0, calc(100% - 10px) 0, 100% 10px, 100% calc(100% - 10px), calc(100% - 10px) 100%, 10px 100%, 0 calc(100% - 10px), 0 10px);
  background: var(--edge);
  color: var(--gold-text);
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.7);
  cursor: pointer;
  position: relative;
  isolation: isolate;
  transition: transform 80ms ease, filter 120ms ease;
}

/* The face of the plate, inset by a pixel so the clipped edge shows as a rim. */
.button::before {
  content: "";
  position: absolute;
  inset: 1.5px;
  z-index: -1;
  clip-path: inherit;
  background:
    linear-gradient(to bottom, rgba(255, 220, 150, 0.22), transparent 45%),
    radial-gradient(120% 140% at 50% 120%, #8c3a1c 0%, var(--ember) 55%, #2a0d07 100%);
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.6);
}

.button--secondary {
  --edge: var(--iron-edge);
  color: var(--text);
}

.button--secondary::before {
  background:
    linear-gradient(to bottom, rgba(255, 255, 255, 0.08), transparent 45%),
    linear-gradient(to bottom, var(--iron), var(--iron-dark));
}

.button__icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.7));
}

.button:not(:disabled):active {
  transform: translateY(1px);
  filter: brightness(1.15);
}

@media (hover: hover) {
  .button:not(:disabled):hover {
    filter: brightness(1.12);
  }
}

.button:disabled {
  opacity: 0.4;
  cursor: default;
  filter: grayscale(0.6);
}

.status {
  max-width: 560px;
  margin: 0 auto;
  color: var(--hint);
  font-size: 14px;
  text-align: center;
}

.status:empty {
  display: none;
}

.status--error {
  color: var(--text);
  padding: 12px;
  border-radius: 10px;
  background: var(--secondary-bg);
}
