@font-face {
  font-display: swap;
  font-family: "Cinzel";
  font-style: normal;
  font-weight: 400;
  src: url("cinzel.woff2") format("woff2");
}

@font-face {
  font-display: swap;
  font-family: "Cinzel";
  font-style: normal;
  font-weight: 700;
  src: url("cinzel.woff2") format("woff2");
}

:root {
  --crimson: #c41e3a;
  --crimson-bright: #ff2d55;
  --crimson-glow: rgba(196, 30, 58, 0.6);
  --blood: #8b0000;
  --gold: #c9a84c;
  --gold-dim: rgba(201, 168, 76, 0.3);
  --gold-bright: #e8c547;
  --void: #08080c;
  --void-light: #0e0e14;
  --void-card: #0c0c12;
  --void-border: #1a1a24;
  --smoke: #1e1e2a;
  --ash: #2a2a38;
  --mist: #6b6b80;
  --bone: #a8a090;
  --parchment: #d4c8a8;
  --font-display: "Cinzel", "Palatino Linotype", "Book Antiqua", serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background-color: var(--void);
  font-family: var(--font-display);
  color: var(--crimson);
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(196, 30, 58, 0.04) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(201, 168, 76, 0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(139, 0, 0, 0.05) 0%, transparent 60%),
    radial-gradient(ellipse at 0% 50%, rgba(255, 120, 40, 0.06) 0%, transparent 40%),
    radial-gradient(ellipse at 100% 50%, rgba(255, 100, 30, 0.06) 0%, transparent 40%),
    radial-gradient(ellipse at 50% 50%, transparent 30%, rgba(0, 0, 0, 0.4) 70%, rgba(0, 0, 0, 0.85) 100%);
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

/* ============================================
   AMBIENT BACKGROUND - Floating Runes
   ============================================ */

.ambient-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.floating-rune {
  position: absolute;
  font-size: 1.5rem;
  color: rgba(196, 30, 58, 0.06);
  animation: floatRune linear infinite;
  text-shadow: 0 0 20px rgba(196, 30, 58, 0.1);
}

.rune-1 { left: 5%; animation-duration: 28s; animation-delay: 0s; font-size: 2rem; }
.rune-2 { left: 18%; animation-duration: 34s; animation-delay: -5s; }
.rune-3 { left: 32%; animation-duration: 26s; animation-delay: -12s; font-size: 1.8rem; }
.rune-4 { left: 48%; animation-duration: 31s; animation-delay: -8s; }
.rune-5 { left: 62%; animation-duration: 29s; animation-delay: -15s; font-size: 2.2rem; }
.rune-6 { left: 76%; animation-duration: 33s; animation-delay: -3s; }
.rune-7 { left: 88%; animation-duration: 27s; animation-delay: -20s; font-size: 1.6rem; }
.rune-8 { left: 95%; animation-duration: 35s; animation-delay: -10s; }

/* ============================================
   PENTAGRAM WATERMARK - Slowly Rotating
   ============================================ */

.pentagram-watermark {
  position: fixed;
  top: 50%;
  left: 50%;
  width: min(80vw, 80vh);
  height: min(80vw, 80vh);
  transform: translate(-50%, -50%);
  color: rgba(196, 30, 58, 0.035);
  animation: pentagramSpin 120s linear infinite;
  pointer-events: none;
  z-index: 0;
}

.pentagram-watermark svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 30px rgba(196, 30, 58, 0.03));
}

@keyframes pentagramSpin {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ============================================
   EMBER PARTICLES - Orange Rising Micro-particles
   ============================================ */

.ember-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.ember {
  position: absolute;
  bottom: -10px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 160, 40, 0.9), rgba(255, 100, 20, 0.4), transparent);
  box-shadow:
    0 0 4px rgba(255, 140, 30, 0.6),
    0 0 8px rgba(255, 100, 20, 0.3);
  animation: emberRise linear infinite;
  opacity: 0;
}

.e1  { left: 3%;  animation-duration: 14s; animation-delay: 0s; width: 2px; height: 2px; }
.e2  { left: 9%;  animation-duration: 18s; animation-delay: -3s; }
.e3  { left: 15%; animation-duration: 12s; animation-delay: -7s; width: 2.5px; height: 2.5px; }
.e4  { left: 22%; animation-duration: 16s; animation-delay: -2s; }
.e5  { left: 28%; animation-duration: 20s; animation-delay: -9s; width: 2px; height: 2px; }
.e6  { left: 35%; animation-duration: 13s; animation-delay: -5s; }
.e7  { left: 41%; animation-duration: 17s; animation-delay: -11s; width: 3.5px; height: 3.5px; }
.e8  { left: 48%; animation-duration: 15s; animation-delay: -1s; }
.e9  { left: 55%; animation-duration: 19s; animation-delay: -8s; width: 2px; height: 2px; }
.e10 { left: 61%; animation-duration: 14s; animation-delay: -4s; }
.e11 { left: 67%; animation-duration: 16s; animation-delay: -10s; width: 2.5px; height: 2.5px; }
.e12 { left: 73%; animation-duration: 12s; animation-delay: -6s; }
.e13 { left: 79%; animation-duration: 18s; animation-delay: -12s; width: 2px; height: 2px; }
.e14 { left: 84%; animation-duration: 15s; animation-delay: -2s; }
.e15 { left: 90%; animation-duration: 13s; animation-delay: -7s; }
.e16 { left: 95%; animation-duration: 17s; animation-delay: -3s; width: 2.5px; height: 2.5px; }
.e17 { left: 12%; animation-duration: 21s; animation-delay: -13s; width: 2px; height: 2px; }
.e18 { left: 38%; animation-duration: 14s; animation-delay: -9s; }
.e19 { left: 58%; animation-duration: 16s; animation-delay: -5s; width: 2px; height: 2px; }
.e20 { left: 87%; animation-duration: 19s; animation-delay: -11s; }

@keyframes emberRise {
  0% {
    transform: translateY(0) translateX(0) scale(1);
    opacity: 0;
  }
  5% {
    opacity: 0.8;
  }
  25% {
    transform: translateY(-25vh) translateX(15px) scale(0.9);
    opacity: 0.6;
  }
  50% {
    transform: translateY(-50vh) translateX(-10px) scale(0.7);
    opacity: 0.4;
  }
  75% {
    transform: translateY(-75vh) translateX(8px) scale(0.4);
    opacity: 0.2;
  }
  100% {
    transform: translateY(-105vh) translateX(-5px) scale(0);
    opacity: 0;
  }
}

@keyframes floatRune {
  0% {
    transform: translateY(110vh) rotate(0deg);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translateY(-10vh) rotate(360deg);
    opacity: 0;
  }
}

/* ============================================
   HEADER
   ============================================ */

.site-header {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 2.5rem 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
}

.header-ornament {
  width: 80px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--crimson), transparent);
  position: relative;
  flex-shrink: 0;
}

.header-ornament::before {
  content: "";
  position: absolute;
  top: -1px;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--crimson-glow), transparent);
  filter: blur(3px);
}

.header-ornament::after {
  content: "";
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  background: var(--crimson);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--crimson-glow);
}

.header-ornament.left::after { right: -3px; }
.header-ornament.right::after { left: -3px; }

.header-content {
  flex-shrink: 0;
}

.game-title {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--crimson);
  text-shadow:
    0 0 20px var(--crimson-glow),
    0 0 40px rgba(196, 30, 58, 0.3),
    0 0 80px rgba(196, 30, 58, 0.1);
  margin: 0;
  padding: 0;
  line-height: 1.2;
  animation: titlePulse 4s ease-in-out infinite;
}

.title-icon {
  font-size: 0.7em;
  vertical-align: middle;
  opacity: 0.6;
  animation: twinkle 3s ease-in-out infinite;
}

.title-icon:last-child {
  animation-delay: 1.5s;
}

@keyframes titlePulse {
  0%, 100% {
    text-shadow:
      0 0 20px var(--crimson-glow),
      0 0 40px rgba(196, 30, 58, 0.3);
  }
  50% {
    text-shadow:
      0 0 30px var(--crimson-glow),
      0 0 60px rgba(196, 30, 58, 0.4),
      0 0 100px rgba(196, 30, 58, 0.15);
  }
}

@keyframes twinkle {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.2); }
}

.subtitle {
  font-family: var(--font-display);
  font-size: 0.75rem;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0.6;
  margin-top: 0.5rem;
}

/* ============================================
   GAME SECTION
   ============================================ */

.game-section {
  position: relative;
  z-index: 1;
  padding: 0 1rem;
}

.game-wrapper {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.game-frame {
  position: relative;
  width: 100%;
  border: 1px solid var(--void-border);
  background: linear-gradient(180deg, rgba(14, 14, 20, 0.9), rgba(8, 8, 12, 0.95));
  padding: 0.75rem;
  box-shadow:
    inset 0 0 60px rgba(0, 0, 0, 0.5),
    0 0 40px rgba(196, 30, 58, 0.05);
}

.game-frame::before {
  content: "";
  position: absolute;
  top: -1px;
  left: -1px;
  right: -1px;
  bottom: -1px;
  border: 1px solid transparent;
  background: linear-gradient(180deg, rgba(196, 30, 58, 0.15), transparent 30%, transparent 70%, rgba(139, 0, 0, 0.15)) border-box;
  -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

/* Frame corner ornaments */
.frame-corner {
  position: absolute;
  width: 20px;
  height: 20px;
  z-index: 2;
  pointer-events: none;
}

.frame-corner::before,
.frame-corner::after {
  content: "";
  position: absolute;
  background: var(--crimson);
}

.frame-corner.tl { top: -1px; left: -1px; }
.frame-corner.tr { top: -1px; right: -1px; }
.frame-corner.bl { bottom: -1px; left: -1px; }
.frame-corner.br { bottom: -1px; right: -1px; }

.frame-corner.tl::before { top: 0; left: 0; width: 20px; height: 1px; }
.frame-corner.tl::after  { top: 0; left: 0; width: 1px; height: 20px; }
.frame-corner.tr::before { top: 0; right: 0; width: 20px; height: 1px; }
.frame-corner.tr::after  { top: 0; right: 0; width: 1px; height: 20px; }
.frame-corner.bl::before { bottom: 0; left: 0; width: 20px; height: 1px; }
.frame-corner.bl::after  { bottom: 0; left: 0; width: 1px; height: 20px; }
.frame-corner.br::before { bottom: 0; right: 0; width: 20px; height: 1px; }
.frame-corner.br::after  { bottom: 0; right: 0; width: 1px; height: 20px; }

/* ============================================
   UI BAR - Timer, Hint, Restart
   ============================================ */

.ui-bar {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.25rem;
  margin-bottom: 0.25rem;
}

.ui-btn {
  position: relative;
  background: transparent;
  border: 1px solid var(--void-border);
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--crimson);
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  transition: all 0.3s ease;
  overflow: hidden;
}

.ui-btn:hover {
  border-color: var(--crimson);
  background: rgba(196, 30, 58, 0.08);
  box-shadow: 0 0 20px rgba(196, 30, 58, 0.15);
}

.ui-btn:active {
  transform: scale(0.97);
}

.btn-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: radial-gradient(circle, rgba(196, 30, 58, 0.3), transparent);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.4s ease, height 0.4s ease;
  pointer-events: none;
}

.ui-btn:hover .btn-glow {
  width: 150px;
  height: 150px;
}

.ui-btn svg {
  width: 18px;
  height: 18px;
  fill: var(--crimson);
  flex-shrink: 0;
  transition: filter 0.3s ease;
}

.ui-btn:hover svg {
  filter: drop-shadow(0 0 6px var(--crimson-glow));
}

.btn-label {
  display: none;
}

.timer-display {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--void-border);
  background: rgba(8, 8, 12, 0.8);
  position: relative;
}

.timer-display::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 20%;
  right: 20%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--crimson-glow), transparent);
}

.timer-icon {
  font-size: 1.2rem;
  color: var(--gold);
  opacity: 0.6;
  animation: timerTick 2s ease-in-out infinite;
}

@keyframes timerTick {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.8; }
}

.timer-value {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--crimson);
  text-shadow: 0 0 15px var(--crimson-glow);
  min-width: 3rem;
  text-align: center;
}

/* ============================================
   GAME CANVAS
   ============================================ */

.game-canvas-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  touch-action: none;
}

canvas {
  display: block;
  touch-action: none;
}

/* ============================================
   INFO SECTION - Rules, Intro, Notes
   ============================================ */

.info-section {
  position: relative;
  z-index: 1;
  padding: 2.5rem 1rem;
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

.info-card {
  position: relative;
  background: linear-gradient(135deg, var(--void-card), rgba(14, 14, 20, 0.6));
  border: 1px solid var(--void-border);
  padding: 0;
  overflow: hidden;
  transition: border-color 0.4s ease, box-shadow 0.4s ease;
}

.info-card:hover {
  border-color: rgba(196, 30, 58, 0.2);
  box-shadow: 0 0 30px rgba(196, 30, 58, 0.06);
}

.info-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(196, 30, 58, 0.2), transparent);
}

.info-card::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 40%;
  height: 100%;
  background: linear-gradient(135deg, transparent, rgba(196, 30, 58, 0.02));
  pointer-events: none;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.25rem 1.5rem 0.75rem;
  border-bottom: 1px solid var(--void-border);
}

.card-header h2 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--crimson);
  text-shadow: 0 0 10px rgba(196, 30, 58, 0.3);
}

.card-icon {
  font-size: 0.9rem;
  color: var(--gold);
  opacity: 0.5;
}

.card-body {
  padding: 1.25rem 1.75rem 1.5rem;
}

.card-body p {
  font-family: var(--font-display);
  font-size: 0.85rem;
  line-height: 1.9;
  color: var(--bone);
  opacity: 0.8;
}

/* Rules list styling */
.rules-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.rules-list li {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.6rem 0;
  font-family: var(--font-display);
  font-size: 0.85rem;
  line-height: 1.7;
  color: var(--bone);
  opacity: 0.8;
}

.rules-list li + li {
  border-top: 1px solid rgba(26, 26, 36, 0.6);
}

.rule-number {
  font-size: 0.7rem;
  color: var(--gold);
  opacity: 0.5;
  letter-spacing: 0.1em;
  flex-shrink: 0;
  padding-top: 0.15rem;
  min-width: 1.5rem;
}

/* ============================================
   FOOTER
   ============================================ */

.site-footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 2rem 1rem 2.5rem;
  margin-top: auto;
}

.footer-ornament {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  color: var(--crimson);
  opacity: 0.2;
  font-size: 0.7rem;
  margin-bottom: 1rem;
}

.footer-ornament.bottom {
  margin-bottom: 0;
  margin-top: 0.75rem;
}

.ornament-line {
  display: inline-block;
  width: 40px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--crimson), transparent);
}

.footer-text {
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--mist);
}

.footer-link {
  color: var(--crimson);
  text-decoration: none;
  transition: color 0.3s ease, text-shadow 0.3s ease;
}

.footer-link:hover {
  color: var(--crimson-bright);
  text-shadow: 0 0 10px var(--crimson-glow);
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (min-width: 640px) {
  .site-header {
    padding: 3rem 2rem 2rem;
  }

  .header-ornament {
    width: 120px;
  }

  .game-title {
    font-size: 3rem;
  }

  .btn-label {
    display: inline;
  }

  .card-body p,
  .rules-list li {
    font-size: 0.9rem;
  }
}

@media (min-width: 768px) {
  .info-grid {
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
  }

  .rules-card {
    grid-column: 1 / -1;
  }

  .game-title {
    font-size: 3.5rem;
  }
}

@media (min-width: 960px) {
  .info-grid {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1.25rem;
  }

  .rules-card {
    grid-column: auto;
  }
}

@media (max-width: 480px) {
  .game-title {
    font-size: 1.6rem;
    letter-spacing: 0.1em;
  }

  .subtitle {
    font-size: 0.6rem;
    letter-spacing: 0.25em;
  }

  .header-ornament {
    width: 40px;
  }

  .site-header {
    padding: 1.5rem 0.75rem 1rem;
    gap: 0.75rem;
  }

  .timer-display {
    padding: 0.4rem 0.6rem;
  }

  .timer-value {
    font-size: 1.1rem;
  }

  .ui-btn {
    padding: 0.4rem 0.5rem;
  }

  .ui-btn svg {
    width: 16px;
    height: 16px;
  }

  .card-header {
    padding: 1rem 1rem 0.5rem;
  }

  .card-body {
    padding: 1rem 1.25rem 1.25rem;
  }

  .info-section {
    padding: 1.5rem 0.75rem;
  }
}

/* ============================================
   SCROLL REVEAL ANIMATION
   ============================================ */

.info-card {
  opacity: 0;
  transform: translateY(20px);
  animation: cardReveal 0.6s ease forwards;
}

.info-card:nth-child(1) { animation-delay: 0.1s; }
.info-card:nth-child(2) { animation-delay: 0.25s; }
.info-card:nth-child(3) { animation-delay: 0.4s; }

@keyframes cardReveal {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   SELECTION STYLING
   ============================================ */

::selection {
  background: rgba(196, 30, 58, 0.3);
  color: var(--parchment);
}

/* ============================================
   SCROLLBAR
   ============================================ */

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--void);
}

::-webkit-scrollbar-thumb {
  background: var(--ash);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--crimson);
}
