:root {
  --bg: #0E1325;
  --amba: #FFB320;
  --amba-deep: #A35E00;
  --tahini: #F6EEDC;
  --muted: #A9B0C7;
  --soft: #CDD2E2;
  --line: #2A3355;
  --line-2: #3A4566;
  --harif: #E5432F;
  --display: 'Secular One', 'Rubik', system-ui, sans-serif;
  --body: 'Rubik', system-ui, -apple-system, sans-serif;
  --ring: min(176px, 24vh);
  --tile: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cg fill='none' stroke='%2319223F' stroke-width='2'%3E%3Crect x='24' y='24' width='32' height='32'/%3E%3Crect x='24' y='24' width='32' height='32' transform='rotate(45 40 40)'/%3E%3C/g%3E%3Cg fill='%2319223F'%3E%3Ccircle cx='40' cy='40' r='4'/%3E%3Ccircle cx='0' cy='0' r='3'/%3E%3Ccircle cx='80' cy='0' r='3'/%3E%3Ccircle cx='0' cy='80' r='3'/%3E%3Ccircle cx='80' cy='80' r='3'/%3E%3C/g%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--bg) var(--tile) center / 80px 80px;
  color: var(--tahini);
  font-family: var(--body);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
img { -webkit-user-drag: none; }

#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--amba); outline-offset: 3px; }

.label { font-size: 13px; font-weight: 500; letter-spacing: .16em; color: var(--muted); }

.icon-btn {
  width: 48px; height: 48px; padding: 0;
  display: grid; place-items: center;
  background: rgba(14, 19, 37, .6);
  border: 1.5px solid var(--line);
  color: var(--tahini);
}
.icon-btn:hover { border-color: var(--line-2); }
.icon-btn svg { width: 22px; height: 22px; }
#sound-btn .snd-off { display: none; }
#sound-btn[aria-pressed="false"] .snd-on { display: none; }
#sound-btn[aria-pressed="false"] .snd-off { display: block; }

.screen { position: fixed; inset: 0; z-index: 5; }

/* ---------- title ---------- */
.title { pointer-events: none; }
.title button { pointer-events: auto; }

.decor { position: absolute; pointer-events: none; height: auto; animation: float 5s ease-in-out infinite; }
.d-shawarma { left: 9%; top: 10%; width: clamp(70px, 10vw, 130px); --r: -16deg; }
.d-pom { left: 82%; top: 19%; width: clamp(60px, 9.5vw, 124px); --r: 14deg; animation-delay: -1.2s; }
.d-burekas { left: 15%; top: 72%; width: clamp(60px, 9vw, 118px); --r: 14deg; animation-delay: -2.1s; }
.d-eggplant { left: 78%; top: 59%; width: clamp(70px, 11vw, 140px); --r: -24deg; animation-delay: -3s; }
.d-harif { left: 70%; top: 80%; width: clamp(56px, 8.5vw, 110px); --r: -8deg; animation-delay: -.6s; }
@keyframes float {
  0%, 100% { transform: translateY(0) rotate(var(--r)); }
  50% { transform: translateY(-12px) rotate(calc(var(--r) + 4deg)); }
}

.title-best {
  position: absolute;
  left: max(24px, env(safe-area-inset-left)); top: max(24px, env(safe-area-inset-top));
  display: flex; flex-direction: column; gap: 2px;
}
.title-best .num { font-family: var(--display); font-size: 32px; line-height: 1; }
.title-tools {
  position: absolute;
  right: max(24px, env(safe-area-inset-right)); top: max(24px, env(safe-area-inset-top));
  display: flex; gap: 12px;
}

.title-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 88px 16px 72px;
  text-align: center;
}
.he { font-family: var(--display); font-size: clamp(16px, 2.4vw, 22px); letter-spacing: .06em; color: var(--muted); }

.logo { position: relative; margin: 6px 0 0; display: flex; flex-direction: column; align-items: center; font-weight: 400; }
.logo-line {
  display: block;
  font-family: var(--display);
  font-size: clamp(52px, min(11.5vw, 17vh), 136px);
  line-height: .92;
  color: var(--amba);
  letter-spacing: -.01em;
  text-shadow: 0 .06em 0 var(--amba-deep), 0 .13em .22em rgba(0, 0, 0, .5);
}
.slash { position: relative; display: block; }
.slash-a { clip-path: polygon(0 0, 100% 0, 100% 30%, 0 74%); }
.slash-b {
  position: absolute; left: 0; top: 0;
  clip-path: polygon(0 74%, 100% 30%, 100% 100%, 0 100%);
  transform: translate(.12em, .07em) rotate(2deg);
  animation: split .5s .55s cubic-bezier(.2, .9, .3, 1.4) both;
}
@keyframes split { from { transform: translate(0, 0) rotate(0); } }
.blade {
  position: absolute; left: -2%; top: 76%;
  width: 104%; height: 5px; margin-top: -2px; border-radius: 3px;
  background: #fff;
  box-shadow: 0 0 18px 4px rgba(255, 179, 32, .65);
  transform: rotate(-10deg);
  animation: blade .4s .2s ease-out both;
}
@keyframes blade { from { transform: rotate(-10deg) scaleX(0); } }

.tagline { margin: 40px 0 0; max-width: 620px; text-wrap: balance; font-size: clamp(15px, 1.6vw, 20px); line-height: 1.5; color: var(--soft); }

.ring {
  margin-top: 30px; padding: 8px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  background: none; border: 0; color: var(--amba);
}
.ring-circle {
  position: relative;
  width: var(--ring); height: var(--ring); border-radius: 50%;
  display: grid; place-items: center;
  box-shadow: 0 0 0 10px rgba(255, 179, 32, .08);
  transition: box-shadow .2s;
}
.ring-circle::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 3px dashed var(--amba);
  animation: spin 16s linear infinite;
}
.ring-circle img { width: 64%; height: 64%; animation: bob 2.4s ease-in-out infinite; }
.ring:hover .ring-circle { box-shadow: 0 0 0 14px rgba(255, 179, 32, .16); }
.ring-label { font-family: var(--display); font-size: 30px; line-height: 1; letter-spacing: .04em; }
.ring-sub { margin-top: -6px; font-size: 14px; color: var(--muted); }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes bob { 50% { transform: translateY(-6px) rotate(8deg); } }

.title-hint {
  position: absolute; left: 0; right: 0; bottom: max(24px, env(safe-area-inset-bottom));
  display: flex; justify-content: center; align-items: center; gap: 8px;
  font-size: 14px; color: var(--muted);
}
.title-hint img { width: 20px; height: 20px; }
.title-link {
  position: absolute;
  right: max(24px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom));
  min-height: 44px; padding: 0 14px;
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 500; color: var(--soft); text-decoration: none;
  border: 1.5px solid var(--line); background: rgba(14, 19, 37, .6);
  pointer-events: auto;
}
.title-link:hover { color: var(--amba); border-color: var(--line-2); }
.title-link svg { width: 16px; height: 16px; }

/* ---------- HUD ---------- */
.hud {
  position: fixed; left: 0; right: 0; top: 0; z-index: 4;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: max(24px, env(safe-area-inset-top)) max(32px, env(safe-area-inset-right)) 0 max(32px, env(safe-area-inset-left));
  pointer-events: none;
}
.hud button { pointer-events: auto; }
.hud-score-row { display: flex; align-items: center; gap: 12px; }
.hud-ico { width: 38px; height: auto; }
.score {
  display: inline-block;
  font-family: var(--display);
  font-size: clamp(48px, 6vw, 72px); line-height: 1;
  color: var(--amba);
  text-shadow: 0 .08em 0 var(--amba-deep);
  font-variant-numeric: tabular-nums;
  transform-origin: left center;
}
.score.bump { animation: bump .18s ease-out; }
@keyframes bump { 50% { transform: scale(1.12); } }
.best { margin-top: 4px; font-size: 14px; font-weight: 500; letter-spacing: .16em; color: var(--muted); }
.hud-right { display: flex; align-items: center; gap: 24px; }
.misses { display: flex; align-items: center; gap: 10px; }
.misses svg { fill: none; stroke: var(--line-2); stroke-linecap: round; transition: stroke .2s; }
.misses .x1 { width: 40px; height: 40px; stroke-width: 4; }
.misses .x2 { width: 32px; height: 32px; stroke-width: 3.5; }
.misses .x3 { width: 26px; height: 26px; stroke-width: 3; }
.misses svg.on { stroke: var(--harif); animation: hitx .3s ease-out; }
@keyframes hitx { 50% { transform: scale(1.4); } }

/* ---------- combo + hint ---------- */
.combo { position: fixed; left: 0; top: 0; z-index: 3; pointer-events: none; opacity: 0; transform-origin: left center; }
.combo.show { animation: combo 1.3s ease-out both; }
@keyframes combo {
  0% { opacity: 0; transform: translate(var(--x), var(--y)) rotate(-6deg) scale(.6); }
  12% { opacity: 1; transform: translate(var(--x), var(--y)) rotate(-6deg) scale(1.08); }
  22% { transform: translate(var(--x), var(--y)) rotate(-6deg) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--x), calc(var(--y) - 30px)) rotate(-6deg) scale(1); }
}
.combo-row { display: flex; align-items: baseline; gap: 14px; white-space: nowrap; }
.combo-x { font-family: var(--display); font-size: clamp(28px, 3.2vw, 40px); line-height: 1; color: var(--tahini); text-shadow: 0 4px 0 #000; }
.combo-word {
  font-family: var(--display); font-size: clamp(56px, 6.4vw, 80px); line-height: 1; color: var(--amba);
  text-shadow: 0 6px 0 var(--amba-deep), 0 14px 24px rgba(0, 0, 0, .5);
}
.combo-sub { display: flex; gap: 10px; align-items: center; margin-top: 8px; font-size: 16px; color: var(--soft); white-space: nowrap; }
.combo-sub [lang="he"] { font-family: var(--display); font-size: 20px; color: var(--muted); }

.hint {
  position: fixed; left: 50%; bottom: max(40px, env(safe-area-inset-bottom)); z-index: 3;
  transform: translateX(-50%);
  padding: 10px 18px;
  font-size: 16px; color: var(--soft); white-space: nowrap;
  border: 1.5px solid var(--line); background: rgba(14, 19, 37, .75);
  pointer-events: none;
  animation: hint 4s ease both;
}
@keyframes hint { 0% { opacity: 0; } 10%, 80% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- overlays ---------- */
.overlay {
  display: flex; align-items: center; justify-content: center;
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  background: rgba(8, 10, 22, .62);
  overflow-y: auto;
  touch-action: pan-y;
}
.panel {
  width: 100%; max-width: 760px; margin: auto;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  animation: panel .35s ease-out both;
}
@keyframes panel { from { opacity: 0; transform: translateY(16px); } }

.big { margin: 0; font-family: var(--display); font-weight: 400; font-size: clamp(56px, 8vw, 96px); line-height: 1; color: var(--amba); text-shadow: 0 .06em 0 var(--amba-deep); }

.cut-ico { position: relative; width: clamp(104px, 13vw, 160px); aspect-ratio: 1; }
.cut-ico img { position: absolute; inset: 0; width: 100%; height: 100%; }
.cut-a { clip-path: polygon(0 0, 100% 0, 100% 33%, 0 90%); transform: translate(-6%, -6%) rotate(-6deg); }
.cut-b { clip-path: polygon(0 90%, 100% 33%, 100% 100%, 0 100%); transform: translate(6%, 6%) rotate(6deg); }
.cut-line { position: absolute; left: 0; top: 61%; width: 100%; height: 3px; border-radius: 2px; background: #fff; opacity: .85; transform: rotate(-30deg); }

.oy {
  margin: 6px 0 0;
  font-family: var(--display); font-weight: 400;
  font-size: clamp(72px, 10vw, 128px); line-height: .95;
  color: var(--amba);
  text-shadow: 0 .06em 0 var(--amba-deep), 0 .14em .24em rgba(0, 0, 0, .5);
}
.over-sub { margin: 18px 0 0; font-size: clamp(17px, 1.8vw, 22px); color: var(--soft); }
.newbest { margin: 14px 0 0; padding: 6px 14px; background: var(--amba); color: var(--bg); font-family: var(--display); font-size: 18px; letter-spacing: .04em; }

.stats { margin-top: 36px; width: 100%; max-width: 664px; display: flex; border-top: 1.5px solid var(--line); border-bottom: 1.5px solid var(--line); }
.stat { flex: 1 1 0; min-width: 0; padding: 20px 8px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.stat + .stat { border-left: 1.5px solid var(--line); }
.stat .num { font-family: var(--display); font-size: clamp(36px, 4.4vw, 56px); line-height: 1; }

.counts { list-style: none; margin: 24px 0 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 12px 28px; font-size: 18px; font-weight: 500; }
.counts li { display: flex; align-items: center; gap: 8px; }
.counts img { width: 34px; height: 34px; }
.counts .none { color: var(--muted); font-weight: 400; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.btn-row { margin-top: 36px; display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; }
.btn {
  min-height: 60px; padding: 0 36px;
  display: inline-flex; align-items: center; justify-content: center; gap: 12px;
  font-family: var(--display); font-size: 22px; border: 0;
}
.btn svg { width: 22px; height: 22px; }
.btn-primary { background: var(--amba); color: var(--bg); box-shadow: 0 5px 0 var(--amba-deep); }
.btn-primary:hover { background: #FFC24D; }
.btn-primary:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--amba-deep); }
.btn-ghost { background: transparent; border: 1.5px solid var(--line-2); color: var(--tahini); }
.btn-ghost:hover { border-color: var(--muted); }

/* ---------- phones ---------- */
@media (max-width: 640px) {
  body { background-size: 64px 64px; }
  .hud { padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .hud-ico { width: 28px; }
  .hud-score-row { gap: 8px; }
  .best { font-size: 12px; }
  .hud-right { gap: 12px; }
  .misses { gap: 6px; }
  .misses .x1 { width: 28px; height: 28px; }
  .misses .x2 { width: 22px; height: 22px; }
  .misses .x3 { width: 18px; height: 18px; }
  .icon-btn { width: 44px; height: 44px; }
  .combo-sub { font-size: 14px; }

  .d-shawarma { left: 4%; top: 12%; }
  .d-pom { left: auto; right: 5%; top: 14%; }
  .d-burekas { left: 5%; top: auto; bottom: 9%; }
  .d-eggplant { left: auto; right: 4%; top: auto; bottom: 12%; }
  .d-harif { display: none; }
  .title-center { padding-top: 96px; padding-bottom: 128px; }
  .title-hint { bottom: max(76px, calc(env(safe-area-inset-bottom) + 60px)); }
  .title-link { right: 50%; transform: translateX(50%); white-space: nowrap; }

  .label { font-size: 11px; letter-spacing: .1em; }
  .stat { padding: 16px 4px; }
  .counts { gap: 10px 18px; font-size: 16px; }
  .counts img { width: 28px; height: 28px; }
  .btn { padding: 0 24px; font-size: 20px; }
}
@media (max-height: 520px) {
  .tagline, .he, .d-harif, .title-hint { display: none; }
  .title-center { padding: 16px; }
  .ring { margin-top: 14px; }
  .oy { font-size: 64px; }
  .stats { margin-top: 18px; }
  .btn-row { margin-top: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .decor, .ring-circle::before, .ring-circle img { animation: none; }
}
