:root {
  color-scheme: dark;
  --bg: #071018;
  --ink: #f7fbff;
  --muted: #a9bac8;
  --panel: rgba(8, 20, 31, 0.72);
  --panel-strong: rgba(7, 16, 24, 0.9);
  --line: rgba(255, 255, 255, 0.18);
  --cyan: #5be7ff;
  --mint: #87ffd7;
  --rose: #ff7ab6;
  --amber: #ffd166;
  --danger: #ff5c7a;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.34);
  font-family: "Cairo", "Tajawal", "Noto Sans Hebrew", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at 18% 14%, rgba(91, 231, 255, 0.22), transparent 26%),
    radial-gradient(circle at 80% 84%, rgba(255, 122, 182, 0.18), transparent 28%),
    linear-gradient(135deg, #071018, #102634 48%, #101525);
  color: var(--ink);
}

body {
  overflow: hidden;
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.game-shell {
  width: 100vw;
  height: 100vh;
  min-height: 520px;
  padding: clamp(10px, 2vw, 20px);
}

.playfield {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(180deg, rgba(91, 231, 255, 0.1), transparent 42%),
    #071018;
  background-size: 64px 64px, 64px 64px, auto, auto;
  box-shadow: var(--shadow);
  isolation: isolate;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.hud {
  position: absolute;
  inset: 14px 14px auto 14px;
  z-index: 4;
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto 42px;
  gap: 12px;
  align-items: center;
  pointer-events: none;
}

.brand,
.stats,
.icon-button,
.pressure-wrap,
.panel {
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 9px 12px;
  border-radius: 8px;
}

.brand-mark {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 28%, #fff, rgba(255, 255, 255, 0.12) 30%, transparent 31%),
    linear-gradient(135deg, var(--cyan), var(--rose));
  box-shadow: inset 0 -7px 16px rgba(0, 0, 0, 0.22), 0 0 24px rgba(91, 231, 255, 0.3);
}

.brand h1 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.1;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(74px, 1fr));
  gap: 1px;
  overflow: hidden;
  border-radius: 8px;
}

.stat {
  min-width: 0;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.045);
  text-align: center;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1;
}

.stat strong {
  display: block;
  margin-top: 4px;
  font-size: 1.08rem;
  line-height: 1;
}

.icon-button {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  pointer-events: auto;
}

.icon-button:hover,
.primary-button:hover,
.ghost-button:hover {
  filter: brightness(1.12);
}

.pressure-wrap {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  z-index: 4;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 8px;
  pointer-events: none;
}

.pressure-label {
  display: flex;
  gap: 8px;
  align-items: baseline;
  min-width: 82px;
}

.pressure-label span {
  color: var(--muted);
  font-size: 0.78rem;
}

.pressure-label strong {
  font-size: 0.92rem;
}

.pressure-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.pressure-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--mint), var(--amber), var(--danger));
  transition: width 140ms ease;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 10, 16, 0.34);
}

.overlay.hidden {
  display: none;
}

.panel {
  width: min(520px, 100%);
  padding: clamp(22px, 5vw, 38px);
  border-radius: 8px;
  text-align: center;
}

.kicker {
  margin: 0 0 8px;
  color: var(--mint);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
}

.panel h2 {
  margin: 0;
  font-size: clamp(2.4rem, 9vw, 5.8rem);
  line-height: 0.92;
}

.panel p {
  margin: 16px auto 0;
  max-width: 34rem;
  color: var(--muted);
  font-size: clamp(0.98rem, 2.6vw, 1.08rem);
  line-height: 1.7;
}

.actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.primary-button,
.ghost-button {
  min-height: 44px;
  border-radius: 8px;
  padding: 0 18px;
  font-weight: 900;
}

.primary-button {
  background: linear-gradient(135deg, var(--cyan), var(--mint));
  color: #071018;
}

.ghost-button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
}

@media (max-width: 720px) {
  .game-shell {
    min-height: 100vh;
    padding: 0;
  }

  .playfield {
    border: 0;
    border-radius: 0;
  }

  .hud {
    grid-template-columns: 1fr 42px;
  }

  .stats {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .brand p {
    white-space: normal;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pressure-track span {
    transition: none;
  }
}
