:root {
  --bg: #f4efe6;
  --card: #ffffff;
  --ink: #1f1a17;
  --muted: #6f655c;
  --line: #e6ddd2;
  --orange: #e25b12;
  --orange-deep: #b8430c;
  --orange-soft: #fff1e6;
  --gold: #c48a12;
  --gold-bg: #fff3cc;
  --miss: #e7e0d6;
  --miss-ink: #6b625a;
  --shadow: 0 12px 32px rgba(90, 52, 20, 0.08);
  --radius: 22px;
  color-scheme: light;
  font-size: 18px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(800px 380px at 50% -10%, #fff8f0 0%, transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", "Nunito", "Helvetica Neue", sans-serif;
}
html[dir="rtl"] body { font-family: "Segoe UI", Tahoma, "Noto Naskh Arabic", "Geeza Pro", sans-serif; }
body { padding: env(safe-area-inset-top) 16px calc(20px + env(safe-area-inset-bottom)); }
button, select { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }

.app { width: min(520px, 100%); margin: 0 auto; }
.top { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; }
.brand { font-weight: 800; color: var(--orange-deep); }
.lang { background: white; border: 1px solid var(--line); border-radius: 999px; padding: 8px 12px; min-height: 44px; }
h1 { font-size: clamp(2rem, 8vw, 2.8rem); line-height: 1.05; margin: 4px 0; }
.tag, .note, .how { color: var(--muted); }
.card { background: white; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.hero { text-align: center; }
.lock { width: 96px; height: 96px; }
.lock .ring { fill: none; stroke: #efe6dc; stroke-width: 5; }
.lock .progress {
  fill: none; stroke: var(--orange); stroke-width: 5; stroke-linecap: round;
  stroke-dasharray: 226; transform: rotate(-90deg); transform-origin: 40px 40px;
}
.lock .body { fill: var(--orange); }
.lock .shackle { fill: none; stroke: var(--orange-deep); stroke-width: 4; }
.lock.urgent .shackle { animation: tick 0.35s ease-in-out infinite; transform-origin: 40px 34px; }
@keyframes tick { 50% { transform: rotate(8deg); } }
.clock { font-size: 3rem; font-weight: 800; font-variant-numeric: tabular-nums; margin: 4px 0; letter-spacing: -0.03em; }
.clock.urgent { color: var(--orange-deep); }
.primary, .ghost {
  width: 100%; min-height: 56px; border: 0; border-radius: 999px; font-weight: 800; margin-top: 8px;
}
.primary { background: var(--orange); color: white; box-shadow: 0 8px 18px rgba(226, 91, 18, 0.28); }
.ghost { background: var(--orange-soft); color: var(--orange-deep); }
.grid { display: grid; gap: 8px; margin: 12px 0; }
.row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.cell {
  aspect-ratio: 1; border-radius: 12px; display: grid; place-items: center;
  font-size: 1.6rem; font-weight: 800; background: #f7f2eb; border: 2px solid transparent; text-transform: uppercase;
}
.cell.g { background: var(--orange); color: white; }
.cell.y { background: var(--gold-bg); color: #7a5a08; border-color: var(--gold); }
.cell.b { background: var(--miss); color: var(--miss-ink); }
.cell.lock { border-color: var(--orange); }
.cell.shake { animation: shake 0.35s linear; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.combo {
  display: inline-block; background: var(--orange); color: white; font-weight: 800;
  border-radius: 999px; padding: 4px 12px; margin: 4px 0;
}
.keys { display: grid; gap: 6px; margin-top: 8px; touch-action: manipulation; }
.key-row { display: flex; gap: 6px; justify-content: center; }
.key {
  min-width: 0; flex: 1 1 0; min-height: 46px; border: 0; border-radius: 10px; background: white;
  box-shadow: 0 1px 0 var(--line); font-weight: 800; font-size: 1rem; padding: 0;
}
.key.wide { flex: 1.4; font-size: 0.85rem; }
.key.g { background: var(--orange); color: white; }
.key.y { background: var(--gold-bg); color: #7a5a08; }
.key.b { background: var(--miss); color: var(--miss-ink); }
.stats { display: flex; justify-content: space-between; gap: 8px; font-weight: 800; }
.piece { color: var(--orange-deep); font-size: 1.4rem; font-weight: 800; }
.error { background: #fff4f0; color: var(--orange-deep); border-radius: 12px; padding: 10px 12px; font-weight: 700; }
.banner { background: var(--orange-soft); color: var(--orange-deep); border-radius: 14px; padding: 10px 12px; font-weight: 700; }
#ad-banner { display: none; }
body.show-ads #ad-banner { display: block; min-height: 50px; margin-top: 12px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0;
}
.loading { padding: 40px 0; font-size: 1.2rem; }
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
