:root {
  --sky-top: #1a6b8a;
  --sky-mid: #3aa0c8;
  --sky-bot: #c8e8f5;
  --sand: #f4e4c1;
  --ink: #14323f;
  --gold: #e8b84a;
  --emerald: #1f8a6e;
  --card: rgba(255, 252, 245, 0.94);
  --shadow: 0 18px 40px rgba(10, 40, 55, 0.22);
  font-family: Nunito, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  position: fixed;
  inset: 0;
  background: var(--sky-top);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}

#app {
  height: 100%;
  height: 100dvh;
  width: 100%;
  display: flex;
  flex-direction: column;
  padding:
    env(safe-area-inset-top, 0)
    env(safe-area-inset-right, 0)
    env(safe-area-inset-bottom, 0)
    env(safe-area-inset-left, 0);
}

.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 0.75rem;
  background: linear-gradient(180deg, rgba(12, 48, 64, 0.92), rgba(12, 48, 64, 0.6));
  color: #fff;
  z-index: 5;
}

.brand { display: flex; flex-direction: column; min-width: 0; }
.brand-ar {
  font-family: Amiri, serif;
  font-size: 1.25rem;
  line-height: 1.1;
  direction: rtl;
}
.brand-ru { font-size: 0.72rem; opacity: 0.85; font-weight: 700; }

.hud {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}
.hud-pill {
  font-family: Amiri, serif;
  font-size: 1.7rem;
  font-weight: 700;
  background: #fff;
  color: var(--emerald);
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 0.75rem;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 0 rgba(0,0,0,0.15);
  flex-shrink: 0;
}
.hud-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 800;
}
.hud-meta span {
  background: rgba(255,255,255,0.14);
  padding: 0.18rem 0.45rem;
  border-radius: 999px;
}

.icon-btn {
  border: 0;
  background: rgba(255,255,255,0.16);
  color: #fff;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 999px;
  font-size: 1.1rem;
  cursor: pointer;
  flex-shrink: 0;
  touch-action: manipulation;
}

#stage {
  position: relative;
  flex: 1;
  min-height: 0;
  background: linear-gradient(180deg, var(--sky-top), var(--sky-mid) 45%, var(--sky-bot) 78%, var(--sand));
}
#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: radial-gradient(ellipse at center, rgba(8,40,55,0.25), rgba(8,30,40,0.55));
  z-index: 4;
}
.overlay[hidden] { display: none !important; }

.card {
  width: min(420px, 100%);
  background: var(--card);
  border-radius: 1.5rem;
  padding: 1.25rem 1.2rem 1.35rem;
  box-shadow: var(--shadow);
  text-align: center;
  max-height: min(90dvh, 100%);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.card-ar {
  font-family: Amiri, serif;
  font-size: 1.65rem;
  color: var(--emerald);
  margin: 0;
}
.card h1 {
  margin: 0.2rem 0 0.65rem;
  font-size: 1.5rem;
  font-weight: 900;
}
.card-text {
  margin: 0 0 1rem;
  font-size: 0.92rem;
  line-height: 1.45;
  text-align: start;
  color: #355;
}
.btn-primary {
  border: 0;
  background: linear-gradient(180deg, #2bb88a, var(--emerald));
  color: #fff;
  font: inherit;
  font-weight: 900;
  font-size: 1.1rem;
  padding: 0.85rem 1.6rem;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 6px 0 #14604c;
  touch-action: manipulation;
}
.btn-primary:active { transform: translateY(3px); box-shadow: 0 3px 0 #14604c; }
.btn-ghost {
  margin-top: 0.65rem;
  border: 0;
  background: transparent;
  color: var(--emerald);
  font-weight: 800;
  cursor: pointer;
  text-decoration: underline;
  touch-action: manipulation;
}

.toast {
  position: absolute;
  left: 50%;
  top: 16%;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.95);
  color: var(--ink);
  font-weight: 900;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  box-shadow: var(--shadow);
  z-index: 6;
  pointer-events: none;
  max-width: 90%;
  text-align: center;
}
.toast[hidden] { display: none !important; }

/* Крупный тачбар для iPhone — всегда на телефоне/планшете без мыши */
.touchbar {
  display: flex;
  gap: 0.55rem;
  padding: 0.55rem 0.7rem calc(0.55rem + env(safe-area-inset-bottom, 0));
  background: rgba(8, 24, 36, 0.94);
  z-index: 8;
  flex: 0 0 auto;
  touch-action: none;
}
.touchbar[hidden] { display: none !important; }
.touch {
  flex: 1;
  border: 0;
  background: linear-gradient(180deg, #3a8eaa, #1f5f78);
  color: #fff;
  font-weight: 900;
  font-size: 1.55rem;
  border-radius: 1.15rem;
  min-height: 64px;
  padding: 0.85rem 0.5rem;
  cursor: pointer;
  box-shadow: 0 5px 0 #0d3a4a;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.touch:active,
.touch.is-down {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #0d3a4a;
  filter: brightness(1.08);
}
.touch-jump {
  flex: 1.35;
  background: linear-gradient(180deg, #ffd56a, #e8a820);
  color: #3a2a00;
  font-size: 1.05rem;
  box-shadow: 0 5px 0 #9a6a10;
}
.touch-jump:active,
.touch-jump.is-down {
  box-shadow: 0 2px 0 #9a6a10;
}

/* Только настоящий десктоп с мышкой — клавиатура вместо тачбара */
@media (hover: hover) and (pointer: fine) and (min-width: 900px) {
  .touchbar:not([data-force="1"]) { display: none !important; }
}
