/* Fruit Slash - layout and UI styles */
:root {
  --font: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Nunito", "Trebuchet MS", system-ui, sans-serif;
  --panel: rgba(28, 11, 54, 0.82);
  --line: rgba(255, 255, 255, 0.14);
  --gold: #ffd23f;
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
}

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

html,
body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #1b0d33;
  overscroll-behavior: none;
}

body {
  position: fixed;
  inset: 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  font-family: var(--font);
  color: #fff;
}

#game {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
  outline: none;
}

.hidden { display: none !important; }

button {
  font-family: inherit;
  color: inherit;
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}

/* ---------- HUD ---------- */
.hud {
  position: absolute;
  inset: 0 0 auto 0;
  padding: calc(10px + var(--sat)) calc(14px + var(--sar)) 0 calc(14px + var(--sal));
  pointer-events: none;
  text-shadow: 0 3px 0 rgba(40, 8, 40, 0.65), 0 0 14px rgba(0, 0, 0, 0.4);
}

.score {
  font-size: clamp(34px, 7vmin, 60px);
  font-weight: 900;
  line-height: 1;
  color: var(--gold);
  transition: transform 0.12s;
  transform-origin: left center;
}
.score.pop { transform: scale(1.18); }

.best {
  margin-top: 4px;
  font-size: clamp(14px, 2.4vmin, 19px);
  font-weight: 800;
  opacity: 0.85;
}

.hud-mid {
  position: absolute;
  left: 50%;
  top: calc(10px + var(--sat));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.timer {
  font-size: clamp(32px, 6.6vmin, 56px);
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.timer.low { color: #ff5a6e; animation: throb 0.5s infinite alternate; }
.timer.frozen { color: #9eeaff; }
@keyframes throb { to { transform: scale(1.12); } }

.lives { display: flex; gap: 6px; }
.lives svg {
  width: clamp(26px, 5vmin, 38px);
  height: clamp(26px, 5vmin, 38px);
  fill: none;
  stroke: rgba(255, 255, 255, 0.35);
  stroke-width: 4;
  stroke-linecap: round;
  filter: drop-shadow(0 2px 0 rgba(40, 8, 40, 0.6));
  transition: transform 0.2s;
}
.lives svg.lost { stroke: #ff3b55; transform: scale(1.15); }

.powers { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.power {
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.04em;
  padding: 4px 12px;
  border-radius: 999px;
  text-shadow: none;
  color: #1b0d33;
}
.power.freeze { background: linear-gradient(90deg, #c9f6ff, #6fd2ff); }
.power.double { background: linear-gradient(90deg, #fff1a6, #ffbf1f); }

/* ---------- Corner buttons ---------- */
.corner-btns {
  position: absolute;
  top: calc(10px + var(--sat));
  right: calc(12px + var(--sar));
  display: flex;
  gap: 8px;
  z-index: 5;
}
.icon-btn {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: rgba(20, 6, 40, 0.55);
  border: 2px solid var(--line);
  display: grid;
  place-items: center;
}
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 24px; height: 24px; fill: #fff; }
.icon-btn .wave { fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; }
.icon-btn .ico-off { display: none; }
.icon-btn.muted .ico-on { display: none; }
.icon-btn.muted .ico-off { display: block; }

/* ---------- Screens & panels ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(12px + var(--sat)) calc(16px + var(--sar)) calc(12px + var(--sab)) calc(16px + var(--sal));
  pointer-events: none; /* swipes around the panel still reach the canvas */
}
.panel {
  pointer-events: auto;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 28px;
  padding: 22px 24px 24px;
  width: min(100%, 470px);
  text-align: center;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: panelIn 0.35s cubic-bezier(.2, 1.4, .4, 1);
}
@keyframes panelIn { from { transform: scale(0.85); opacity: 0; } }

.menu-panel { background: rgba(28, 11, 54, 0.62); }

.logo {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: clamp(54px, 15vmin, 104px);
  font-weight: 900;
  line-height: 0.88;
  letter-spacing: -0.02em;
  filter: drop-shadow(0 5px 0 #3a0f3c) drop-shadow(0 10px 18px rgba(0, 0, 0, 0.4));
  transform: rotate(-4deg);
  width: fit-content;
  margin: 4px auto 10px;
}
.logo span {
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
}
.logo-a { background-image: linear-gradient(180deg, #fff27a 10%, #ffb21e 60%, #ff7a00 100%); }
.logo-b { background-image: linear-gradient(180deg, #ffa1c0 0%, #ff3d77 55%, #d4114f 100%); margin-left: 0.6em; }
.logo::after {
  /* the slash streak across the title */
  content: "";
  position: absolute;
  left: -6%;
  right: -6%;
  top: 50%;
  height: 5px;
  border-radius: 5px;
  background: linear-gradient(90deg, transparent, #fff 30%, #bdfcff 70%, transparent);
  box-shadow: 0 0 14px 3px rgba(150, 245, 255, 0.8);
  transform: rotate(-12deg) scaleX(0);
  animation: slashIn 0.5s 0.25s cubic-bezier(.3, 1, .4, 1) forwards;
}
@keyframes slashIn { to { transform: rotate(-12deg) scaleX(1); } }

.tagline {
  font-size: clamp(15px, 2.6vmin, 19px);
  font-weight: 700;
  opacity: 0.9;
  margin-bottom: 16px;
}

.modes { display: flex; flex-direction: column; gap: 12px; }
.mode-btn {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "name best" "desc best";
  align-items: center;
  text-align: left;
  gap: 2px 12px;
  min-height: 70px;
  padding: 12px 18px;
  border-radius: 20px;
  background: linear-gradient(135deg, #ff5f7e, #ff9a2e);
  box-shadow: 0 6px 0 #9c1e44, 0 10px 22px rgba(0, 0, 0, 0.35);
  transition: transform 0.1s, box-shadow 0.1s;
}
.mode-btn.alt {
  background: linear-gradient(135deg, #22c7c9, #4a7dff);
  box-shadow: 0 6px 0 #1d3f99, 0 10px 22px rgba(0, 0, 0, 0.35);
}
.mode-btn:hover { transform: translateY(-2px); }
.mode-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #9c1e44; }
.mode-btn.alt:active { box-shadow: 0 2px 0 #1d3f99; }
.mode-name { grid-area: name; font-size: 25px; font-weight: 900; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25); }
.mode-desc { grid-area: desc; font-size: 14px; font-weight: 700; opacity: 0.92; }
.mode-best {
  grid-area: best;
  font-size: 14px;
  font-weight: 900;
  background: rgba(0, 0, 0, 0.22);
  padding: 6px 10px;
  border-radius: 12px;
  white-space: nowrap;
}

h2 {
  font-size: clamp(38px, 8vmin, 60px);
  font-weight: 900;
  line-height: 1;
  color: var(--gold);
  text-shadow: 0 4px 0 #6a1440;
}
.sub { font-size: 17px; font-weight: 700; opacity: 0.85; margin-top: 6px; }
.big-score {
  font-size: clamp(64px, 14vmin, 104px);
  font-weight: 900;
  line-height: 1.05;
  margin-top: 8px;
  text-shadow: 0 5px 0 #6a1440;
}
.new-best {
  display: inline-block;
  font-size: 17px;
  font-weight: 900;
  color: #3a1000;
  background: linear-gradient(90deg, #fff27a, #ffb21e);
  padding: 5px 16px;
  border-radius: 999px;
  animation: throb 0.6s infinite alternate;
}
.stats {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 14px 0 18px;
}
.stats div {
  flex: 1;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 8px 4px;
}
.stats span { display: block; font-size: 26px; font-weight: 900; }
.stats small { font-size: 13px; font-weight: 700; opacity: 0.75; }

.btn-row { display: flex; gap: 12px; justify-content: center; }
.small-panel .btn-row { margin-top: 20px; }
.btn {
  min-height: 56px;
  min-width: 120px;
  padding: 0 22px;
  font-size: 20px;
  font-weight: 900;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.14);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.35);
}
.btn.primary {
  flex: 1;
  background: linear-gradient(135deg, #ff5f7e, #ff9a2e);
  box-shadow: 0 5px 0 #9c1e44;
}
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35); }
.small-panel { width: min(100%, 380px); }

/* Short landscape screens (phones turned sideways) */
@media (max-height: 540px) {
  .panel { padding: 14px 18px 16px; border-radius: 22px; }
  .menu-panel { width: min(100%, 640px); }
  .logo { flex-direction: row; gap: 0.25em; font-size: clamp(44px, 13vh, 72px); margin: 0 auto 8px; }
  .logo-b { margin-left: 0; }
  .tagline { margin-bottom: 12px; }
  .modes { flex-direction: row; }
  .mode-btn { flex: 1; min-height: 64px; padding: 10px 14px; }
  .mode-name { font-size: 21px; }
  .mode-desc { font-size: 13px; }
  .over-panel { width: min(100%, 560px); }
  .big-score { font-size: clamp(48px, 13vh, 76px); margin-top: 2px; }
  .sub { margin-top: 2px; font-size: 15px; }
  .stats { margin: 8px 0 12px; }
  .stats span { font-size: 22px; }
  .btn { min-height: 50px; }
}
@media (max-height: 400px) {
  .over-panel .sub { display: none; }
  h2 { font-size: 36px; }
}

/* Big desktop screens: scale the panels up a bit */
@media (min-width: 1600px) and (min-height: 950px) {
  .panel { zoom: 1.3; }
}
