@font-face {
  font-family: 'Trackim';
  src: url('font/trackim_font.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

*, *::before, *::after {
  margin: 0; padding: 0; box-sizing: border-box;
  outline: none !important;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

:root {
  --bg:      #0a0a0f;
  --accent:  #c0392b;
  --accent2: #e67e22;
  --glow:    rgba(192,57,43,0.6);
  --glow2:   rgba(230,126,34,0.45);
  --text:    #e8dcc8;
  --muted:   #6b6052;
  --gold:    #f1c40f;
  --bottom-h: 72px;
}

html, body {
  height: 100%; overflow: hidden;
  user-select: none; -webkit-user-select: none;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Trackim', sans-serif;
  display: flex; flex-direction: column;
  cursor: default;
}

/* ── HEADER ── */
#header {
  flex-shrink: 0; height: 54px;
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: linear-gradient(180deg,#0e0e16 0%,rgba(10,10,15,0.85) 100%);
  border-bottom: 1px solid rgba(192,57,43,0.25);
  position: relative; z-index: 100; gap: 16px;
}

#title {
  font-family: 'Trackim', cursive;
  font-size: clamp(20px,3vw,34px);
  letter-spacing: 0.1em; color: var(--accent);
  text-shadow: 0 0 14px var(--glow);
  white-space: nowrap; flex-shrink: 0;
}

/* Right side of header — mute + hamburger */
#header-right {
  display: flex; align-items: center; gap: 4px; flex-shrink: 0;
}

.stat-row { display: flex; align-items: center; gap: 18px; }
.stat     { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.stat-label {
  font-size: 8px; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--muted);
}
.stat-value {
  font-family: 'Trackim', cursive;
  font-size: clamp(16px,2.2vw,24px);
  color: var(--accent2); text-shadow: 0 0 8px var(--glow2);
  line-height: 1; min-width: 3ch; text-align: center;
}
.stat-divider { width: 1px; height: 32px; background: rgba(192,57,43,0.2); }

/* ── MUTE BUTTON ── */
#mute-btn {
  background: none; border: none; cursor: pointer;
  padding: 6px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.2s, background 0.2s;
  flex-shrink: 0;
}
#mute-btn:hover { opacity: 0.75; background: rgba(255,255,255,0.06); }
#mute-btn img {
  width: 22px; height: 22px;
  display: block; pointer-events: none;
  /* Tint the SVG to match the text colour */
  filter: invert(92%) sepia(8%) saturate(300%) hue-rotate(10deg) brightness(0.9);
  transition: filter 0.2s, opacity 0.2s;
}
/* Muted state: desaturate / dim the icon */
#mute-btn.muted img {
  filter: invert(40%) sepia(0%) saturate(0%) brightness(0.6);
  opacity: 0.55;
}

/* ── HAMBURGER ── */
#hamburger-btn {
  background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; justify-content: center;
  gap: 5px; padding: 6px; flex-shrink: 0;
  transition: opacity 0.2s;
}
#hamburger-btn:hover { opacity: 0.75; }
#hamburger-btn span {
  display: block; width: 24px; height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.25s, opacity 0.25s;
}
#hamburger-btn.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
#hamburger-btn.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
#hamburger-btn.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── SLIDE-OUT MENU ── */
#menu-backdrop {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(0,0,0,0.45);
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s ease;
}
#menu-backdrop.open { opacity: 1; pointer-events: all; }

#slide-menu {
  position: fixed; top: 0; right: 0;
  width: 220px; height: 100%;
  background: linear-gradient(180deg, #0e0e16 0%, #12121c 100%);
  border-left: 1px solid rgba(192,57,43,0.3);
  box-shadow: -6px 0 30px rgba(0,0,0,0.6);
  z-index: 9001;
  display: flex; flex-direction: column;
  padding-top: 60px;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
}
#slide-menu.open { transform: translateX(0); }

#menu-close {
  position: absolute; top: 16px; right: 16px;
  background: none; border: none; cursor: pointer;
  font-size: 20px; color: var(--muted);
  line-height: 1; padding: 6px;
  transition: color 0.2s;
}
#menu-close:hover { color: var(--text); }

.menu-item {
  font-family: 'Trackim', cursive; font-size: 22px;
  letter-spacing: 0.12em; color: var(--text);
  background: none; border: none; cursor: pointer;
  padding: 20px 32px; text-align: left;
  border-top: 1px solid rgba(192,57,43,0.2);
  transition: color 0.2s, background 0.2s;
}
.menu-item:last-child { border-bottom: 1px solid rgba(192,57,43,0.2); }
.menu-item:hover { color: #fff; background: rgba(192,57,43,0.15); }
.menu-item:active { background: rgba(192,57,43,0.3); }
.menu-item--leave { color: var(--accent); }
.menu-item--leave:hover { color: #e74c3c; }
.menu-item--mute { color: var(--muted); font-size: 18px; }
.menu-item--mute:hover { color: var(--text); }

/* ── PLAY AREA ── */
#play-area {
  flex: 1; position: relative; overflow: hidden;
  touch-action: none;
  background-color: #1a1a1a;
  background-image: url('art/background.webp');
  background-size: cover;
  background-position: center;
}

/* ── BOTTOM BAR ── */
#bottom-bar {
  flex-shrink: 0;
  height: var(--bottom-h);
  background: linear-gradient(0deg,#0e0e16 0%,rgba(10,10,15,0.9) 100%);
  border-top: 1px solid rgba(192,57,43,0.25);
  display: flex; flex-direction: column;
  z-index: 100;
}

#timer-track {
  width: 100%; height: 5px;
  background: rgba(255,255,255,0.05);
  flex-shrink: 0;
}
#timer-fill {
  height: 100%;
  background: linear-gradient(90deg,var(--accent),var(--accent2));
  box-shadow: 0 0 8px var(--glow); transition: width 1s linear;
}
#timer-fill.urgent { background:#e74c3c; animation:blink-bar 0.5s ease-in-out infinite; }
@keyframes blink-bar { 50% { opacity:0.3; } }

#bottom-stats {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  gap: 40px;
}

.bottom-stat {
  display: flex; flex-direction: column;
  align-items: center; gap: 2px;
}
.bottom-label {
  font-size: 10px; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--muted);
}
.bottom-value {
  font-family: 'Trackim', cursive;
  font-size: clamp(28px, 5vw, 42px);
  color: var(--text);
  text-shadow: 0 0 12px rgba(232,220,200,0.4);
  line-height: 1;
}
.bottom-value.urgent {
  color: #e74c3c;
  text-shadow: 0 0 14px rgba(231,76,60,0.8);
  animation: pulse-time 0.5s ease-in-out infinite alternate;
}
@keyframes pulse-time { from { opacity:1; } to { opacity:0.5; } }

.bottom-divider {
  width: 1px; height: 40px;
  background: rgba(192,57,43,0.2);
}

/* ── MONSTERS ── */
.monster {
  position: absolute;
  cursor: pointer;
  transform-origin: center center;
  user-select: none; -webkit-user-select: none;
  touch-action: none;
  transition: opacity 0.38s ease, transform 0.38s cubic-bezier(0.34,1.5,0.64,1), filter 0.38s ease;
}

.monster img {
  display: block; width: 100%; height: 100%;
  object-fit: contain; pointer-events: none;
  user-select: none; -webkit-user-select: none;
  filter: contrast(1.4) saturate(1.2);
}

.monster:hover {
  filter: brightness(1.15) drop-shadow(0 0 5px rgba(255,255,255,0.25));
  z-index: 9000 !important;
}

.monster.selected {
  animation: pulse-select 0.7s ease-in-out infinite alternate;
  z-index: 9001 !important;
  transform: scale(1.18) !important;
}
@keyframes pulse-select {
  from { filter: brightness(1.25) drop-shadow(0 0 8px rgba(255,255,255,0.7)); }
  to   { filter: brightness(1.45) drop-shadow(0 0 20px rgba(255,255,255,1)); }
}

.monster.matched {
  pointer-events: none;
  cursor: default;
}

.monster.wrong { animation: wrong-shake 0.42s ease forwards; }
@keyframes wrong-shake {
  0%,100% { filter:none; }
  15%  { transform:translateX(-11px) scale(1.04); filter:drop-shadow(0 0 10px rgba(255,30,30,0.9)); }
  35%  { transform:translateX( 11px) scale(1.04); filter:drop-shadow(0 0 10px rgba(255,30,30,0.9)); }
  55%  { transform:translateX(-6px); }
  75%  { transform:translateX( 6px); }
}

.monster.spawning {
  opacity: 0 !important;
  transform: scale(0.35) !important;
  filter: brightness(2.5) drop-shadow(0 0 14px rgba(180,120,255,0.9)) !important;
  pointer-events: none;
}

/* ── MATCH POPUP ── */
.match-pop {
  position: absolute; pointer-events: none; z-index: 9999;
  font-family: 'Trackim', cursive;
  color: #ffffff;
  text-shadow: 0 0 8px rgba(255,255,255,0.6);
  white-space: nowrap; text-align: center;
  line-height: 1.2;
  animation: pop-float 1.1s cubic-bezier(0.2,0.8,0.4,1) forwards;
}
@keyframes pop-float {
  0%   { opacity:1; transform:translateY(0) scale(1); }
  100% { opacity:0; transform:translateY(-80px) scale(1.2); }
}

.match-pop .pop-time {
  display: block;
  font-size: 32px;
}
.match-pop .pop-combo {
  display: block;
  font-size: 20px;
  color: var(--accent2);
  text-shadow: 0 0 10px rgba(230,126,34,0.9);
}

.match-pop.penalty {
  color: #e74c3c;
  text-shadow: 0 0 8px rgba(231,76,60,0.7);
  animation: pop-sink 1s cubic-bezier(0.2,0.8,0.4,1) forwards;
}
.match-pop.penalty .pop-time { font-size: 28px; }
@keyframes pop-sink {
  0%   { opacity:1; transform:translateY(0) scale(1); }
  100% { opacity:0; transform:translateY(44px) scale(0.85); }
}

/* ── OVERLAYS ── */
.overlay {
  position: fixed; inset: 0;
  background: rgba(4,4,10,0.92);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 10000; gap: 18px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.overlay.hidden { display: none; }

.overlay-title {
  font-family: 'Trackim', cursive;
  font-size: clamp(48px,10vw,100px);
  color: var(--accent); text-shadow: 0 0 30px var(--glow);
  animation: flicker 2.5s infinite; letter-spacing: 0.06em;
}
@keyframes flicker {
  0%,19%,21%,23%,25%,54%,56%,100% { opacity:1; }
  20%,22%,24%,55% { opacity:0.6; }
}

.overlay-sub {
  font-size: clamp(14px,2vw,19px); color: var(--text);
  text-align: center; line-height: 1.65; max-width: 440px; opacity: 0.82;
}

.overlay-btn {
  font-family: 'Trackim', cursive; font-size: 22px;
  letter-spacing: 0.12em; background: var(--accent);
  color: #fff; border: none; padding: 13px 40px;
  border-radius: 5px; cursor: pointer;
  box-shadow: 0 0 20px var(--glow);
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s; margin-top: 8px;
}
.overlay-btn:hover { background:#e74c3c; transform:scale(1.07); box-shadow:0 0 40px var(--glow); }

/* ── STRIPE / AD-FREE BUTTON ── */
.overlay-btn--stripe {
  background: transparent;
  color: var(--gold);
  border: 1px solid rgba(241,196,15,0.4);
  box-shadow: 0 0 16px rgba(241,196,15,0.15);
  font-size: 17px;
  padding: 10px 32px;
  margin-top: -2px;
}
.overlay-btn--stripe:hover {
  background: rgba(241,196,15,0.12);
  border-color: var(--gold);
  box-shadow: 0 0 28px rgba(241,196,15,0.35);
  color: #fff;
  transform: scale(1.05);
}

.menu-item--stripe {
  color: var(--gold);
  font-size: 18px;
  letter-spacing: 0.08em;
  border-top: 1px solid rgba(241,196,15,0.15);
  margin-top: auto;
}
.menu-item--stripe:hover {
  color: #fff;
  background: rgba(241,196,15,0.12);
}

/* ── LOADING ── */
#loading-overlay { gap: 24px; }
#loading-overlay .overlay-title { font-size: clamp(36px,7vw,72px); }
#loading-track {
  width: min(420px,80vw); height: 8px;
  background: rgba(255,255,255,0.07); border-radius: 4px;
  overflow: hidden; border: 1px solid rgba(192,57,43,0.25);
}
#loading-bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg,var(--accent),var(--accent2));
  box-shadow: 0 0 10px var(--glow); transition: width 0.3s ease; border-radius: 4px;
}
#loading-label { font-size: 13px; letter-spacing: 0.12em; color: var(--muted); }

/* ── AD SLOTS ── */
.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 4px 0;
}
.ad-slot.hidden { display: none; }

.ad-frame {
  border: none;
  border-radius: 12px;
  overflow: hidden;
  display: block;
}
.ad-frame--small {
  width: 320px;
  height: 100px;
}
.ad-frame--large {
  width: 336px;
  height: 280px;
}

/* ── INTERSTITIAL ── */
#interstitial-overlay {
  gap: 16px;
}
#interstitial-skip-row {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 38px;
}
#interstitial-countdown {
  font-size: 13px;
  letter-spacing: 0.1em;
  color: var(--muted);
}
#interstitial-countdown b { color: var(--text); }

.overlay-btn--skip {
  font-size: 14px;
  padding: 7px 22px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  box-shadow: none;
}
.overlay-btn--skip:hover {
  background: rgba(255,255,255,0.16);
  transform: scale(1.04);
  box-shadow: none;
}
.overlay-btn--skip.hidden { display: none; }
