﻿:root {
  --bg: #151722;
  --panel: rgba(14, 18, 31, 0.78);
  --panel-strong: rgba(255, 251, 235, 0.95);
  --line: rgba(255, 251, 235, 0.16);
  --text: #fffbed;
  --muted: rgba(255, 251, 235, 0.68);
  --accent: #d9aa36;
  --accent-2: #35b7a5;
  --danger: #e7624f;
  --radius: 8px;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  font-family: Arial, "Noto Sans Hebrew", "Segoe UI", sans-serif;
  background:
    linear-gradient(135deg, rgba(21, 23, 34, 0.96), rgba(28, 57, 65, 0.94)),
    linear-gradient(45deg, #151722, #1f3942 45%, #331b30);
  color: var(--text);
}

button {
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(1240px, calc(100vw - 1.25rem));
  margin: 0 auto;
  padding: 1.25rem 0 1.75rem;
}

.game-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: end;
  margin-bottom: 1rem;
}

.kicker {
  margin: 0 0 0.45rem;
  color: #8ee0d0;
  font-size: 0.95rem;
  font-weight: 800;
}

h1 {
  margin: 0;
  font-size: clamp(2.1rem, 5vw, 4.5rem);
  line-height: 1;
}

.lead {
  margin: 0.6rem 0 0;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1.6;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  justify-content: flex-start;
}

.game-button,
.mobile-control {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 251, 235, 0.08);
  color: var(--text);
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.game-button {
  min-width: 78px;
  padding: 0 1rem;
}

.game-button:hover:not(:disabled),
.mobile-control:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(255, 251, 235, 0.36);
  background: rgba(255, 251, 235, 0.13);
}

.game-button:disabled,
.mobile-control:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.game-button-primary,
.mobile-control-action {
  border-color: #e0b344;
  background: #e0b344;
  color: #151722;
  font-weight: 900;
}

.game-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 302px;
  gap: 1rem;
  align-items: stretch;
}

.stage-panel,
.side-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.stage-panel {
  overflow: hidden;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: clamp(540px, 73vh, 740px);
  touch-action: none;
  user-select: none;
}

.mobile-control-pad {
  display: none;
}

.side-panel {
  display: grid;
  gap: 0.8rem;
  align-content: start;
  padding: 0.85rem;
}

.status-card,
.current-card,
.lag-card,
.sefirot-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 251, 235, 0.08);
}

.status-card {
  display: grid;
  gap: 0.25rem;
  padding: 0.75rem;
}

.status-card-wide {
  grid-template-columns: 1fr auto;
  align-items: baseline;
}

.status-card span,
.current-card span,
.lag-card span,
.sefirot-card > span {
  color: var(--muted);
  font-size: 0.86rem;
}

.status-card strong {
  font-size: 1.55rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
}

.current-card,
.lag-card,
.sefirot-card {
  display: grid;
  gap: 0.65rem;
  padding: 1rem;
}

.current-card strong {
  font-size: 2rem;
}

.current-card p {
  margin: 0;
  color: #8ee0d0;
  font-size: 1.25rem;
  font-weight: 900;
}

.current-card small {
  color: var(--muted);
  line-height: 1.5;
}

.current-card.is-lag,
.lag-card {
  border-color: rgba(224, 179, 68, 0.75);
  background:
    linear-gradient(135deg, rgba(224, 179, 68, 0.22), rgba(255, 251, 235, 0.08)),
    rgba(255, 251, 235, 0.08);
  box-shadow: 0 0 30px rgba(224, 179, 68, 0.14);
}

.current-card.is-lag p,
.lag-card strong {
  color: #ffe184;
}

.lag-card strong {
  font-size: 1.6rem;
}

.lag-card p {
  margin: 0;
  color: #fff2b8;
  line-height: 1.55;
  font-weight: 800;
}

.sefirot-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.sefira-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 0.65rem;
  border-radius: var(--radius);
  background: var(--chip-color);
  color: #fffbed;
  font-size: 0.9rem;
  font-weight: 900;
}

@media (max-width: 960px) {
  .game-header,
  .game-grid {
    grid-template-columns: 1fr;
  }

  .header-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 700px) {
  .app-shell {
    width: min(100vw - 0.75rem, 1240px);
    padding-top: max(0.65rem, env(safe-area-inset-top));
    padding-bottom: max(0.8rem, env(safe-area-inset-bottom));
  }

  .game-header {
    gap: 0.7rem;
    margin-bottom: 0.65rem;
  }

  .kicker {
    margin-bottom: 0.25rem;
    font-size: 0.84rem;
  }

  h1 {
    font-size: clamp(1.9rem, 9vw, 2.55rem);
  }

  .lead {
    margin-top: 0.45rem;
    font-size: 0.92rem;
    line-height: 1.45;
  }

  .header-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.45rem;
  }

  .game-button {
    min-width: 0;
    min-height: 40px;
    padding: 0 0.55rem;
  }

  .stage-panel,
  .side-panel {
    border-radius: 6px;
  }

  #gameCanvas {
    height: clamp(455px, 63dvh, 610px);
  }

  .mobile-control-pad {
    position: sticky;
    bottom: 0;
    display: grid;
    grid-template-columns: 1fr 1.15fr 1fr;
    gap: 0.55rem;
    padding: 0.65rem;
    border-top: 1px solid var(--line);
    background: rgba(14, 18, 31, 0.96);
    backdrop-filter: blur(14px);
  }

  .mobile-control {
    min-height: 56px;
    padding: 0 0.8rem;
    font-weight: 900;
  }

  .mobile-control-side {
    font-size: 2.1rem;
    line-height: 1;
  }

  .side-panel {
    gap: 0.55rem;
    padding: 0.65rem;
  }

  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.45rem;
  }

  .status-card,
  .current-card,
  .lag-card,
  .sefirot-card {
    padding: 0.65rem;
  }

  .status-card strong {
    font-size: 1.25rem;
  }

  .current-card {
    gap: 0.38rem;
  }

  .current-card strong {
    font-size: 1.45rem;
  }

  .current-card p {
    font-size: 1.05rem;
  }

  .lag-card strong {
    font-size: 1.25rem;
  }

  .sefirot-list {
    gap: 0.35rem;
  }

  .sefira-chip {
    min-height: 28px;
    padding: 0 0.5rem;
    font-size: 0.82rem;
  }
}

@media (max-width: 390px) {
  .lead {
    display: none;
  }

  #gameCanvas {
    height: clamp(430px, 61dvh, 565px);
  }

  .mobile-control {
    min-height: 52px;
  }

  .status-card span,
  .current-card span,
  .lag-card span,
  .sefirot-card > span {
    font-size: 0.78rem;
  }
}
