/* ─── Reset ──────────────────────────────────────────────────────────────────*/

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

/* ─── Base ───────────────────────────────────────────────────────────────────*/

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: black;
  font-family: Arial, sans-serif;
}

/* ─── Game container ─────────────────────────────────────────────────────────*/

.game {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
  touch-action: none;
  background-image: url("images/table.png");
  background-size: cover;
  background-position: center top;
}

/* Dark overlay so panels/text pop */
.game::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.18);
  pointer-events: none;
  z-index: 0;
}

/* ─── HUD ────────────────────────────────────────────────────────────────────*/

.hud {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.hud-item {
  background: rgba(0,0,0,0.45);
  color: white;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 22px;
  font-weight: bold;
  min-width: 110px;
  text-align: center;
  backdrop-filter: blur(4px);
  box-shadow: 0 0 12px rgba(0,0,0,0.4);
}

/* ─── Panel ──────────────────────────────────────────────────────────────────*/

.panel {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%) scale(0.25);
  z-index: 65;
  color: white;
  background: rgba(0,0,0,0.65);
  padding: 28px 36px;
  border-radius: 24px;
  font-size: 32px;
  font-weight: bold;
  text-align: center;
  backdrop-filter: blur(4px);
  max-width: min(72%, 420px);
  opacity: 0;
  visibility: hidden;
  filter: blur(8px);
  transition:
    opacity 0.45s ease,
    transform 0.45s ease,
    filter 0.45s ease,
    visibility 0s linear 0.45s;
  pointer-events: none;
  line-height: 1;
}

.panel.visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
  filter: blur(0);
  transition:
    opacity 0.8s ease,
    transform 0.8s ease,
    filter 0.8s ease,
    visibility 0s linear 0s;
  pointer-events: auto;
}

.panel .sub {
  font-size: 20px;
  font-weight: normal;
  margin-top: 10px;
  opacity: 0.85;
}

/* ─── Action button ──────────────────────────────────────────────────────────*/

.action {
  position: absolute;
  left: 50%;
  bottom: calc(30px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 70;
  border: none;
  border-radius: 24px;
  padding: 16px 40px;
  font-size: 30px;
  font-weight: bold;
  background: gold;
  color: black;
  box-shadow: 0 4px 14px rgba(0,0,0,0.4);
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
}

.action:active {
  transform: translateX(-50%) scale(0.95);
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

/* ─── Snack grid (2×2) ───────────────────────────────────────────────────────*/

#grid-2x2 {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 20px;
  padding: 100px 30px 120px;
  z-index: 10;
}

/* ─── Each food cell ─────────────────────────────────────────────────────────*/

.food-btn {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 28px;
  cursor: pointer;
  transition: transform 0.12s ease;
  overflow: visible;
  background: transparent;
  border: none;
  -webkit-tap-highlight-color: transparent;
}

.food-btn img {
  width: 100%;
  height: 100%;
  max-width: 200px;
  max-height: 200px;
  object-fit: contain;
  filter: drop-shadow(0 6px 18px rgba(0,0,0,0.55)) brightness(0.72);
  transition: transform 0.12s ease, filter 0.12s ease;
  pointer-events: none;
  user-select: none;
}

/* ─── Ring ───────────────────────────────────────────────────────────────────*/

.ring {
  position: absolute;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  border: 8px solid rgba(255,255,255,0.92);
  opacity: 1;
  transform: scale(1);
  box-shadow:
    0 0 22px rgba(255,255,255,0.95),
    inset 0 0 14px rgba(255,255,255,0.8);
  z-index: -1;
  pointer-events: none;
  transition: transform 0.15s ease, opacity 0.15s ease;
  animation: ringPulse 2.4s ease-in-out infinite;
}

@keyframes ringPulse {
  0%,100% { box-shadow: 0 0 14px rgba(255,255,255,0.7),  inset 0 0 8px  rgba(255,255,255,0.5); }
  50%     { box-shadow: 0 0 32px rgba(255,255,255,1.0),  inset 0 0 18px rgba(255,255,255,0.9); }
}

/* On lit: image grows, ring shrinks */
.food-btn.lit img {
  transform: scale(1.25);
}

.food-btn.lit .ring {
  animation: none;
  transform: scale(0.95);
  transition: transform 0.15s ease;
  opacity: 0.6;
}

/* ─── Disabled state ─────────────────────────────────────────────────────────*/

.food-btn.disabled {
  pointer-events: none;
}

/* ─── Floating emoji feedback ────────────────────────────────────────────────*/

.star {
  position: fixed;
  z-index: 200;
  font-size: 70px;
  pointer-events: none;
  animation: floatStar 0.55s ease-out forwards;
}

@keyframes floatStar {
  0%   { opacity: 1;   transform: translateY(0)      scale(0.5); }
  25%  { opacity: 1;   transform: translateY(-14px)  scale(1.1); }
  100% { opacity: 0;   transform: translateY(-110px) scale(2.2); }
}

/* ─── Wrong shake ────────────────────────────────────────────────────────────*/

@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%     { transform: translateX(-10px); }
  40%     { transform: translateX(10px); }
  60%     { transform: translateX(-8px); }
  80%     { transform: translateX(8px); }
}

.shake { animation: shake 0.4s ease; }

/* ─── Desktop shell ──────────────────────────────────────────────────────────*/

@media (min-width: 700px) {
  body {
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at center, #333 0%, #111 45%, #000 100%);
  }

  .game {
    position: relative;
    inset: auto;
    width: min(430px, 94vw);
    height: min(932px, 94dvh);
    border: 12px solid #111;
    border-radius: 46px;
    box-shadow: 0 0 0 2px #333, 0 24px 70px rgba(0,0,0,0.75);
  }

  .game::before {
    content: "";
    position: absolute;
    left: 50%; top: 10px;
    transform: translateX(-50%);
    width: 120px; height: 28px;
    border-radius: 0 0 18px 18px;
    background: #111;
    z-index: 100;
    pointer-events: none;
  }
}
