/* Fruit Crush — match-3 game (portfolio page) */

/* Standalone: native Capacitor app / installed PWA */
html.app-standalone .diamond-mini-bar,
html.app-standalone .fruit-crush-back,
html.app-standalone .fruit-crush-unity-note {
  display: none !important;
}
html.app-standalone .fruit-crush-wrap {
  padding-top: calc(env(safe-area-inset-top, 0px) + 8px);
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
}

.fruit-crush-page {
  --fc-bg1: #ff9a6c;
  --fc-bg2: #ff6fae;
  --fc-bg3: #9b6bff;
  --fc-panel: rgba(255, 255, 255, 0.16);
  --fc-board: #5b2a82;
  --fc-board-cell: rgba(255, 255, 255, 0.07);
  --fc-ink: #3a1457;
  --fc-gold: #ffd23f;
  --fc-shadow: 0 10px 24px rgba(60, 10, 80, 0.35);
  --fc-tile-radius: 22%;
}

.fruit-crush-page {
  font-family: 'Fredoka', system-ui, sans-serif;
  color: #fff;
  background:
    radial-gradient(120% 80% at 80% -10%, var(--fc-bg1), transparent 60%),
    radial-gradient(120% 80% at 10% 0%, var(--fc-bg2), transparent 55%),
    linear-gradient(160deg, var(--fc-bg2), var(--fc-bg3));
  background-attachment: fixed;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 72px 12px 28px;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.fruit-crush-back {
  position: fixed;
  top: 58px;
  left: 12px;
  z-index: 30;
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.fruit-crush-back:hover {
  background: rgba(0, 0, 0, 0.35);
}

.fruit-crush-wrap {
  width: 100%;
  max-width: 480px;
}

.fruit-crush-hud {
  width: 100%;
}

.fruit-crush-hud-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.fruit-crush-level-badge {
  background: var(--fc-gold);
  color: var(--fc-ink);
  font-weight: 700;
  font-size: 1.05rem;
  padding: 8px 16px;
  border-radius: 16px;
  box-shadow: var(--fc-shadow);
  line-height: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.fruit-crush-level-badge small {
  font-size: 0.62rem;
  opacity: 0.7;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.fruit-crush-best {
  font-size: 0.85rem;
  opacity: 0.9;
  text-align: right;
  font-weight: 500;
}

.fruit-crush-best b {
  display: block;
  font-size: 1.15rem;
  font-weight: 700;
}

.fruit-crush-stats {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.fruit-crush-stat {
  flex: 1;
  background: var(--fc-panel);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 16px;
  padding: 8px 10px;
  text-align: center;
}

.fruit-crush-stat .label {
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  opacity: 0.85;
  font-weight: 600;
  text-transform: uppercase;
}

.fruit-crush-stat .value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.1;
}

.fruit-crush-stat.moves .value {
  color: var(--fc-gold);
}

.fruit-crush-progress {
  height: 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.22);
  overflow: hidden;
  margin-bottom: 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.fruit-crush-progress .fill {
  height: 100%;
  width: 0%;
  border-radius: 10px;
  background: linear-gradient(90deg, #7dffb0, #ffd23f);
  transition: width 0.35s ease;
}

.fruit-crush-board-wrap {
  position: relative;
}

#fruitCrushBoard {
  position: relative;
  overflow: hidden;
  background: linear-gradient(160deg, #6a2f96, #3f1b63);
  border-radius: 24px;
  box-shadow: var(--fc-shadow), inset 0 0 0 4px rgba(255, 255, 255, 0.06);
  padding: 6px;
  touch-action: none;
}

.fruit-crush-cell-bg {
  position: absolute;
  border-radius: 14%;
  background: var(--fc-board-cell);
}

.fruit-crush-tile {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--fc-tile-radius);
  font-size: 1.6rem;
  cursor: pointer;
  transition: transform 0.26s cubic-bezier(0.34, 1.3, 0.5, 1);
  will-change: transform;
  box-shadow:
    inset 0 3px 6px rgba(255, 255, 255, 0.45),
    inset 0 -5px 8px rgba(0, 0, 0, 0.22),
    0 3px 6px rgba(0, 0, 0, 0.25);
}

.fruit-crush-tile .face {
  transform: translateY(-1px);
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.25));
  pointer-events: none;
}

.fruit-crush-tile::before {
  content: '';
  position: absolute;
  top: 10%;
  left: 14%;
  width: 42%;
  height: 30%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  filter: blur(2px);
  pointer-events: none;
}

.fruit-crush-tile.selected {
  outline: 3px solid #fff;
  outline-offset: -2px;
  animation: fruit-crush-pulse 0.6s ease-in-out infinite;
  z-index: 5;
}

@keyframes fruit-crush-pulse {
  50% {
    filter: brightness(1.15);
  }
}

.fruit-crush-tile.pop {
  animation: fruit-crush-pop 0.22s ease forwards;
}

@keyframes fruit-crush-pop {
  60% {
    transform: scale(1.18);
  }
  100% {
    transform: scale(0);
    opacity: 0;
  }
}

.fruit-crush-tile.shake {
  animation: fruit-crush-shake 0.3s;
}

@keyframes fruit-crush-shake {
  25% {
    transform: translateX(-4px);
  }
  75% {
    transform: translateX(4px);
  }
}

.fruit-crush-t0 {
  background: radial-gradient(circle at 35% 30%, #ff8a8a, #e53935);
}
.fruit-crush-t1 {
  background: radial-gradient(circle at 35% 30%, #ffe07a, #fbb900);
}
.fruit-crush-t2 {
  background: radial-gradient(circle at 35% 30%, #caa6ff, #7c3aed);
}
.fruit-crush-t3 {
  background: radial-gradient(circle at 35% 30%, #ffc27a, #f57c00);
}
.fruit-crush-t4 {
  background: radial-gradient(circle at 35% 30%, #9fe88a, #43a047);
}
.fruit-crush-t5 {
  background: radial-gradient(circle at 35% 30%, #8fd6ff, #1e88e5);
}

.fruit-crush-popup {
  position: absolute;
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  z-index: 8;
  animation: fruit-crush-float-up 0.8s ease forwards;
}

@keyframes fruit-crush-float-up {
  to {
    transform: translateY(-34px);
    opacity: 0;
  }
}

.fruit-crush-combo-flash {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--fc-gold);
  text-shadow:
    0 3px 0 var(--fc-ink),
    0 0 22px rgba(255, 210, 63, 0.8);
  pointer-events: none;
  z-index: 9;
  opacity: 0;
  white-space: nowrap;
}

.fruit-crush-combo-flash.show {
  animation: fruit-crush-combo-pop 0.7s ease;
}

@keyframes fruit-crush-combo-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5);
  }
  30% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1);
  }
}

.fruit-crush-overlay {
  position: absolute;
  inset: 0;
  border-radius: 24px;
  background: rgba(40, 10, 60, 0.78);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  padding: 24px;
  z-index: 20;
}

.fruit-crush-overlay.show {
  display: flex;
  animation: fruit-crush-fade 0.3s ease;
}

@keyframes fruit-crush-fade {
  from {
    opacity: 0;
  }
}

.fruit-crush-overlay h2 {
  margin: 0;
  font-size: 2rem;
}

.fruit-crush-overlay .sub {
  opacity: 0.9;
  margin: 0;
  font-size: 1rem;
}

.fruit-crush-overlay .big {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--fc-gold);
}

.fruit-crush-milestone {
  color: var(--fc-gold);
  font-weight: 700;
  letter-spacing: 0.05em;
}

.fruit-crush-btn {
  font-family: inherit;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--fc-ink);
  background: linear-gradient(180deg, #fff, #ffe9a8);
  border: none;
  border-radius: 16px;
  padding: 13px 30px;
  cursor: pointer;
  box-shadow:
    0 5px 0 #cf9b00,
    var(--fc-shadow);
  transition:
    transform 0.08s,
    box-shadow 0.08s;
}

.fruit-crush-btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #cf9b00;
}

.fruit-crush-btn.ghost {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  box-shadow: none;
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.fruit-crush-unity-note {
  margin-top: 0.5rem;
  font-size: 0.78rem;
  opacity: 0.85;
  text-align: center;
  max-width: 480px;
  line-height: 1.45;
}

.fruit-crush-unity-note a {
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.fruit-crush-hint {
  margin-top: 14px;
  font-size: 0.8rem;
  opacity: 0.85;
  text-align: center;
  max-width: 480px;
  line-height: 1.4;
}

/* iOS / touch: fixed gradients jitter; tighten layout on narrow screens */
@media (max-width: 1024px), (hover: none) and (pointer: coarse) {
  .fruit-crush-page {
    background-attachment: scroll;
    padding-top: calc(64px + env(safe-area-inset-top, 0px));
    padding-left: max(8px, env(safe-area-inset-left, 0px));
    padding-right: max(8px, env(safe-area-inset-right, 0px));
  }

  .fruit-crush-back {
    top: calc(52px + env(safe-area-inset-top, 0px));
    left: max(8px, env(safe-area-inset-left, 0px));
  }
}

@media (max-width: 576px) {
  .fruit-crush-level-badge {
    font-size: 0.95rem;
    padding: 6px 12px;
  }

  .fruit-crush-stat .value {
    font-size: 1.25rem;
  }

  .fruit-crush-overlay h2 {
    font-size: 1.6rem;
  }
}
