/* ===== Fonts ===== */

@font-face {
  font-family: "Fredoka";
  src: url("fonts/fredoka.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
}

/* ===== Base ===== */

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

body {
  font-family: "Fredoka", "Comic Sans MS", "Chalkboard SE", system-ui, sans-serif;
  background: linear-gradient(160deg, #5b2be0 0%, #2d9cdb 55%, #00c48c 100%) fixed;
  color: #222;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== Header ===== */

.site-header {
  position: relative;
  text-align: center;
  padding: 2rem 3.5rem 1.5rem;
  color: #fff;
}

.site-header h1 {
  font-size: clamp(1.5rem, 4.5vw, 2.6rem);
  font-weight: 600;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);
  letter-spacing: 0.5px;
}

.mute-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  font-size: 1.3rem;
  width: 2.6rem;
  height: 2.6rem;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
}

.mute-btn:hover {
  background: rgba(255, 255, 255, 0.4);
  transform: scale(1.1);
}

/* ===== Tool cards ===== */

.tools {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  max-width: 1100px;
  width: 100%;
  margin: 1.5rem auto;
  padding: 0 1rem;
}

@media (max-width: 820px) {
  .tools {
    grid-template-columns: 1fr;
    max-width: 480px;
  }
}

.tool-card {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 22px;
  padding: 1.4rem 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  border-top: 8px solid;
  transition: transform 0.2s;
}

.tool-card:hover {
  transform: translateY(-4px);
}

#coin-card { border-color: #ff9f1c; }
#dice-card { border-color: #06c258; }
#eightball-card { border-color: #8338ec; }

.tool-card h2 {
  font-size: 1.4rem;
  font-weight: 600;
}

#coin-card h2 { color: #e07b00; }
#dice-card h2 { color: #04903f; }
#eightball-card h2 { color: #6a1fd0; }

.tool-display {
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.result {
  font-size: 1.15rem;
  font-weight: 600;
  min-height: 1.5em;
}

#coin-result { color: #e07b00; }
#dice-result { color: #04903f; }
#eightball-result { color: #6a1fd0; }

/* ===== Buttons ===== */

.go-btn {
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  padding: 0.65rem 1.6rem;
  border: none;
  border-radius: 999px;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
  transition: transform 0.1s, box-shadow 0.1s, filter 0.15s;
}

.go-btn:hover { filter: brightness(1.1); }

.go-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}

.go-btn:disabled {
  filter: grayscale(0.4) brightness(0.9);
  cursor: wait;
}

#coin-btn { background: #ff9f1c; }
#dice-btn { background: #06c258; }
#eightball-btn { background: #8338ec; }

/* ===== Coin (3-D flip) ===== */

.coin-scene {
  width: 110px;
  height: 110px;
  perspective: 600px;
}

.coin {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  /* transition applied inline by script.js during a flip */
}

.coin-face {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.6rem;
  font-weight: 600;
  backface-visibility: hidden;
  border: 5px solid #c99a1e;
  color: #7a5c00;
  background: radial-gradient(circle at 35% 30%, #ffe27a, #f5c542 60%, #dba821);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);
}

.coin-back {
  transform: rotateY(180deg);
  background: radial-gradient(circle at 35% 30%, #ffd9a0, #f0a940 60%, #d18c1e);
}

/* ===== Die with pips ===== */

.die {
  width: 105px;
  height: 105px;
  border-radius: 20px;
  background: linear-gradient(145deg, #ffffff, #e8ecf5);
  border: 3px solid #2b3550;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 13px;
  gap: 4px;
}

.die.rolling {
  animation: die-tumble 0.6s ease-in-out;
}

@keyframes die-tumble {
  0%   { transform: translate(0, 0) rotate(0deg); }
  15%  { transform: translate(-8px, -14px) rotate(-25deg); }
  35%  { transform: translate(9px, -20px) rotate(20deg); }
  55%  { transform: translate(-7px, -10px) rotate(-15deg); }
  75%  { transform: translate(6px, -4px) rotate(10deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

.pip {
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: #2b3550;
  align-self: center;
  justify-self: center;
}

.die[data-value="1"] .pip:nth-child(1) { grid-area: 2 / 2; }

.die[data-value="2"] .pip:nth-child(1) { grid-area: 1 / 1; }
.die[data-value="2"] .pip:nth-child(2) { grid-area: 3 / 3; }

.die[data-value="3"] .pip:nth-child(1) { grid-area: 1 / 1; }
.die[data-value="3"] .pip:nth-child(2) { grid-area: 2 / 2; }
.die[data-value="3"] .pip:nth-child(3) { grid-area: 3 / 3; }

.die[data-value="4"] .pip:nth-child(1) { grid-area: 1 / 1; }
.die[data-value="4"] .pip:nth-child(2) { grid-area: 1 / 3; }
.die[data-value="4"] .pip:nth-child(3) { grid-area: 3 / 1; }
.die[data-value="4"] .pip:nth-child(4) { grid-area: 3 / 3; }

.die[data-value="5"] .pip:nth-child(1) { grid-area: 1 / 1; }
.die[data-value="5"] .pip:nth-child(2) { grid-area: 1 / 3; }
.die[data-value="5"] .pip:nth-child(3) { grid-area: 2 / 2; }
.die[data-value="5"] .pip:nth-child(4) { grid-area: 3 / 1; }
.die[data-value="5"] .pip:nth-child(5) { grid-area: 3 / 3; }

.die[data-value="6"] .pip:nth-child(1) { grid-area: 1 / 1; }
.die[data-value="6"] .pip:nth-child(2) { grid-area: 1 / 3; }
.die[data-value="6"] .pip:nth-child(3) { grid-area: 2 / 1; }
.die[data-value="6"] .pip:nth-child(4) { grid-area: 2 / 3; }
.die[data-value="6"] .pip:nth-child(5) { grid-area: 3 / 1; }
.die[data-value="6"] .pip:nth-child(6) { grid-area: 3 / 3; }

/* ===== Magic 8-ball ===== */

.eightball {
  width: 125px;
  height: 125px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #4a4a4a, #111 55%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35);
}

.eightball.shaking {
  animation: ball-shake 0.7s ease-in-out;
}

@keyframes ball-shake {
  0%   { transform: translate(0, 0) rotate(0deg); }
  15%  { transform: translate(-10px, 2px) rotate(-8deg); }
  30%  { transform: translate(10px, -3px) rotate(8deg); }
  45%  { transform: translate(-9px, 1px) rotate(-6deg); }
  60%  { transform: translate(8px, -2px) rotate(6deg); }
  75%  { transform: translate(-5px, 1px) rotate(-3deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

.eightball-window {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #3d51c9, #1d2a75 70%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 0.62rem;
  font-weight: 600;
  padding: 7px;
  line-height: 1.25;
  transition: opacity 0.4s;
}

.eightball-window.idle { font-size: 2.1rem; }
.eightball-window.hidden { opacity: 0; }

/* ===== Photo ===== */

.photo-section {
  display: flex;
  justify-content: center;
  padding: 1.5rem 1rem 0.5rem;
}

.photo-frame {
  position: relative;
  background: #fff;
  padding: 12px 12px 16px;
  border-radius: 18px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.3);
  transform: rotate(-1.5deg);
  transition: transform 0.25s;
}

/* Hover only exists on mouse devices — touch browsers "stick" the
   hover state after a tap, so phones use the .burning class from
   script.js instead (3 s timeout, or tap again to put it out) */
@media (hover: hover) {
  .photo-frame:hover {
    transform: rotate(0deg) scale(1.02);
    animation: fire-glow 0.6s infinite alternate;
  }

  .photo-frame:hover .flames span {
    opacity: 1;
    animation: flame-dance 0.3s ease-in-out infinite alternate;
  }
}

.photo-frame.burning {
  transform: rotate(0deg) scale(1.02);
  animation: fire-glow 0.6s infinite alternate;
}

@keyframes fire-glow {
  from {
    box-shadow:
      0 10px 26px rgba(0, 0, 0, 0.3),
      0 0 22px 8px rgba(255, 130, 0, 0.55),
      0 0 55px 20px rgba(255, 60, 0, 0.3);
  }
  to {
    box-shadow:
      0 10px 26px rgba(0, 0, 0, 0.3),
      0 0 32px 12px rgba(255, 170, 0, 0.7),
      0 0 75px 28px rgba(255, 80, 0, 0.4);
  }
}

/* Individual flame emojis all around the frame. Each gets its own
   size, speed, and phase offset so the fire flickers chaotically
   instead of in lockstep — that desync is what sells the effect. */
.flames {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.flames span {
  position: absolute;
  opacity: 0;
  transform-origin: 50% 100%;
  transition: opacity 0.25s;
}

.photo-frame.burning .flames span {
  opacity: 1;
  animation: flame-dance 0.3s ease-in-out infinite alternate;
}

@keyframes flame-dance {
  from { transform: translateY(2px) scale(1, 0.9) rotate(-3deg); filter: brightness(0.95); }
  to { transform: translateY(-6px) scale(1.08, 1.18) rotate(3deg); filter: brightness(1.35) saturate(1.3); }
}

/* Bottom row — the big blaze */
.flames span:nth-child(1) { left: 2%; bottom: -20px; font-size: 3rem; animation-duration: 0.30s; animation-delay: -0.05s; }
.flames span:nth-child(2) { left: 20%; bottom: -26px; font-size: 3.8rem; animation-duration: 0.26s; animation-delay: -0.12s; }
.flames span:nth-child(3) { left: 41%; bottom: -22px; font-size: 3.3rem; animation-duration: 0.33s; animation-delay: -0.20s; }
.flames span:nth-child(4) { left: 60%; bottom: -28px; font-size: 4rem; animation-duration: 0.28s; animation-delay: -0.08s; }
.flames span:nth-child(5) { left: 81%; bottom: -20px; font-size: 3.1rem; animation-duration: 0.31s; animation-delay: -0.16s; }

/* Sides — licking up the edges */
.flames span:nth-child(6) { left: -18px; bottom: 22%; font-size: 2.6rem; animation-duration: 0.29s; animation-delay: -0.10s; }
.flames span:nth-child(7) { left: -14px; bottom: 55%; font-size: 2.1rem; animation-duration: 0.35s; animation-delay: -0.22s; }
.flames span:nth-child(8) { right: -18px; bottom: 28%; font-size: 2.7rem; animation-duration: 0.27s; animation-delay: -0.14s; }
.flames span:nth-child(9) { right: -14px; bottom: 60%; font-size: 2.1rem; animation-duration: 0.34s; animation-delay: -0.03s; }

/* Top — tips curling over the edge */
.flames span:nth-child(10) { left: 14%; top: -26px; font-size: 2.2rem; animation-duration: 0.30s; animation-delay: -0.18s; }
.flames span:nth-child(11) { left: 46%; top: -30px; font-size: 2.5rem; animation-duration: 0.25s; animation-delay: -0.07s; }
.flames span:nth-child(12) { right: 14%; top: -26px; font-size: 2.1rem; animation-duration: 0.32s; animation-delay: -0.24s; }

.photo-frame img {
  display: block;
  max-width: 100%;
  max-height: 420px;
  border-radius: 10px;
}

/* ===== Footer ===== */

.site-footer {
  margin-top: auto;
  padding: 0.6rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.visit-counter {
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
}

.signoff {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.75);
  margin-left: auto;
}

/* ===== Reduced motion ===== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
