@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@300;400;500;600;700&family=Cinzel:wght@500;600;700&display=swap');

:root {
  color-scheme: dark;
  --gold: #f7cc55;
  --gold-light: #fff0a0;
  --green: #2cfb59;
  --green-deep: #06451e;
  --ink: #fff8df;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  color: var(--ink);
  font-family: 'Kanit', sans-serif;
  background: #061b18;
}

button { font: inherit; }
button:focus-visible { outline: 2px solid var(--gold-light); outline-offset: 3px; }

.game-stage {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #061b18;
}

.game-stage::before { display: none; }

.game-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: url('../assets/images/backgrounds/scene.png') center / cover no-repeat;
  pointer-events: none;
}

.game-content {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: 26.5% minmax(0, 1fr);
  grid-template-areas: "side arena";
  overflow: hidden;
  container-type: size;
}

.game-content::after {
  content: '';
  display: block;
  position: absolute;
  z-index: 3;
  inset: 0;
  width: 100%;
  height: 100%;
  background: url('../assets/images/backgrounds/background.png') center / 100% 100% no-repeat;
  pointer-events: none;
}

.side-panel {
  position: relative;
  z-index: 4;
  grid-area: side;
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  overflow: hidden;
}

.brand {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  color: var(--gold-light);
  font: 600 clamp(12px, 1.35vw, 17px)/1.1 'Cinzel', serif;
  letter-spacing: .07em;
  text-align: center;
  text-decoration: none;
  text-shadow: 0 0 12px #80ff3b;
}
.brand b { color: #51ff64; font-size: 1.12em; }
.brand-gem { color: #54ff47; font-size: 34px; filter: drop-shadow(0 0 7px #36ff49); }

.score-card, .lives-card {
  position: absolute;
  left: 26%;
  width: 61%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.score-card { top: 10.2%; height: 12.3%; }
.best-card { top: 23.2%; }
.lives-card { top: 36.3%; height: 13%; }
.brand { display: none; }
.card-label { opacity: 0; }
.score-card strong {
  position: absolute;
  top: 51%;
  left: 3%;
  width: 94%;
  height: 45%;
  display: grid;
  place-items: center;
  color: #ffd675;
  background: transparent;
  font: 600 min(2.3cqw, 4.1cqh, 25px)/1.1 'Cinzel', serif;
  white-space: nowrap;
  text-shadow: 0 0 10px rgba(255, 127, 24, .55);
}
.best-card strong { font-size: min(2cqw, 3.6cqh, 21px); }
.hearts {
  position: absolute;
  top: 49%;
  left: 4%;
  width: 92%;
  height: 45%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6%;
  color: #ff3939;
  background: transparent;
  font-size: clamp(18px, 3vw, 34px);
  line-height: 1;
  letter-spacing: 2px;
  text-shadow: 0 0 8px #f00, 0 2px 3px #700;
}
.hearts .life-heart {
  height: 78%;
  width: auto;
  max-width: 28%;
  object-fit: contain;
  filter: drop-shadow(0 0 4px rgba(255, 120, 60, 0.7));
}

.game-controls { position: absolute; top: 51.8%; left: 26%; width: 61%; height: 34%; }
.control-button {
  position: absolute;
  left: 0;
  width: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: transparent;
  background: transparent;
  box-shadow: none;
  font-size: 0;
  cursor: pointer;
  transition: background .16s ease, box-shadow .16s ease;
}
.control-button:hover { background: rgba(122, 255, 87, .12); box-shadow: 0 0 12px rgba(255, 205, 56, .28); }
.control-button:active { background: rgba(122, 255, 87, .2); }
.control-button.primary { top: 0; height: 27%; }
.control-button:nth-child(2) { top: 30%; height: 16%; }
.control-button:nth-child(3) { top: 48%; height: 16%; }
.control-button:nth-child(4) { top: 66%; height: 16%; }
.control-button:nth-child(5) { top: 84%; height: 16%; }
.control-icon { opacity: 0; }
.side-tip { display: none; }

/* The opening in background.png is measured on the 1287 × 768 artwork.
   Extend the canvas slightly under the painted edges to avoid seams. */
.arena-frame {
  position: absolute;
  inset: 4.4% 2.02% 6.77% 26.5%;
  z-index: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.arena-topline, .arena-footer { display: none; }
.level {
  position: absolute;
  top: 8px;
  right: 14px;
  z-index: 2;
  color: #ffd975;
  font-size: clamp(10px, 1.1vw, 13px);
  letter-spacing: .03em;
  text-shadow: 0 1px 4px #000;
  pointer-events: none;
}

.control-button .slot-level {
  position: static;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: #fff4c8;
  font: 600 min(1.35cqw, 2.4cqh, 14px)/1 'Kanit', sans-serif;
  letter-spacing: .03em;
  text-shadow: 0 1px 4px #000;
}
.arena {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  margin: auto;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.arena::before,
.arena::after {
  content: none;
  display: none;
}
#game-canvas { position: relative; z-index: 2; display: block; width: 100%; height: 100%; touch-action: none; }
.game-message {
  position: absolute;
  top: 53%;
  left: 50%;
  z-index: 4;
  padding: 7px 17px;
  border: 1px solid rgba(209, 195, 106, .6);
  border-radius: 20px;
  color: #fff5c3;
  background: rgba(3, 21, 17, .74);
  box-shadow: 0 0 15px rgba(73, 255, 56, .23);
  font-size: clamp(10px, 1.2vw, 14px);
  width: max-content;
  max-width: 94%;
  text-align: center;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.game-message.is-hidden { opacity: 0; }
.arena-controls { position: absolute; z-index: 3; display: none; }
.arena-footer { justify-content: space-between; min-height: 19px; font-size: clamp(8px, .92vw, 10px); letter-spacing: 0; }
.live-dot { display: inline-block; width: 6px; height: 6px; margin-right: 5px; border-radius: 50%; background: #4fff65; box-shadow: 0 0 7px #4fff65; }

.dialog-backdrop {
  position: absolute;
  z-index: 5;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 9, 7, .78);
  backdrop-filter: blur(4px);
}
.dialog-backdrop[hidden] { display: none; }
.dialog {
  position: relative;
  width: min(390px, 100%);
  padding: 27px 25px 24px;
  border: 2px solid #a47d31;
  border-radius: 13px;
  background: linear-gradient(145deg, #143821, #061813 75%);
  box-shadow: inset 0 0 20px rgba(44, 255, 66, .12), 0 12px 40px #000;
  text-align: center;
}
.close-button { position: absolute; top: 7px; right: 11px; border: 0; color: #f8d875; background: none; font-size: 25px; cursor: pointer; }
.dialog-gem { color: #5bff4a; font-size: 28px; text-shadow: 0 0 12px #42ff45; }
.dialog h2 { margin: 4px 0 10px; color: #ffe28c; font-size: 23px; font-weight: 500; }
.dialog p { margin: 8px 0; color: #e0ead5; font-size: 14px; line-height: 1.8; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: #e0ead5; font-size: 14px; }
.setting-row input { width: 20px; height: 20px; accent-color: #37e64a; }
.level-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.level-select { padding: 8px 0; border: 1px solid rgba(212, 175, 74, .45); border-radius: 8px; color: #ffe7a5; background: rgba(22, 61, 36, .85); cursor: pointer; }
.level-select:hover { background: rgba(62, 124, 70, .9); box-shadow: 0 0 10px rgba(90, 255, 120, .25); }
.level-select.current { border-color: #7cff7d; box-shadow: inset 0 0 0 1px rgba(124,255,125,.35); }

@media (max-width: 680px) {
  .dialog { padding: 22px 18px 19px; }
}

/* Loading screen (inspired by Stone Age Checkers) */
.game-stage.is-loading .game-content { visibility: hidden; }
.loading-screen { position: absolute; z-index: 30; inset: 0; display: none; overflow: hidden; background: #061b18; }
.game-stage.is-loading .loading-screen { display: grid; }
.loading-screen-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 28%; }
.loading-start-art {
  position: absolute;
  width: 102%;
  height: 119%;
  clip-path: polygon(1% 18%, 4% 7%, 41% 6%, 96% 8%, 99% 17%, 99% 80%, 96% 88%, 4% 88%, 1% 78%);
}
.loading-start-text {
  z-index: 1;
  color: #fff7d6;
  font: 700 13px/1 'Kanit', sans-serif;
  text-shadow: 0 2px 4px #140a04;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
