:root {
  --ink: #17212b;
  --muted: #5f6b76;
  --paper: #fffdf6;
  --panel: #ffffff;
  --road: #59626c;
  --line: #f8eec1;
  --sun: #ffd84d;
  --green: #2f9e6d;
  --blue: #2f6fbd;
  --red: #db4f43;
  --shadow: 0 18px 45px rgba(23, 33, 43, 0.16);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  color: var(--ink);
  font-family: Arial, "Noto Sans Hebrew", "Segoe UI", sans-serif;
  background:
    linear-gradient(180deg, rgba(255, 216, 77, 0.35), transparent 34%),
    linear-gradient(135deg, #d8f3dc 0%, #e9f7ff 44%, #fff4cf 100%);
}

button {
  font: inherit;
}

.game-menu-link {
  position: fixed;
  z-index: 50;
  top: 12px;
  left: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 8px;
  background: rgba(17, 24, 39, 0.82);
  color: #fff;
  font-weight: 900;
  text-decoration: none;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(10px);
}

.game-menu-link:hover,
.game-menu-link:focus-visible {
  background: rgba(22, 132, 95, 0.94);
  outline: none;
}

.app {
  width: min(1220px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 18px 0 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 3px solid #f0b429;
  border-radius: 50%;
  background: #fff6c7;
  color: #935b00;
  font-weight: 900;
  box-shadow: 0 8px 0 rgba(240, 180, 41, 0.22);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.7rem, 4vw, 3rem);
  line-height: 1;
  letter-spacing: 0;
}

.brand p,
.panel-heading span,
.stat span {
  color: var(--muted);
}

.brand p {
  margin-top: 6px;
  font-weight: 700;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(70px, 1fr));
  gap: 8px;
  width: min(520px, 100%);
}

.stat {
  min-height: 64px;
  padding: 9px 10px;
  border: 1px solid rgba(23, 33, 43, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 8px 25px rgba(23, 33, 43, 0.08);
  text-align: center;
}

.stat strong {
  display: block;
  font-size: 1.25rem;
  line-height: 1.1;
}

.stat span {
  display: block;
  margin-top: 5px;
  font-size: 0.82rem;
  font-weight: 700;
}

.play-layout {
  display: grid;
  grid-template-columns: minmax(340px, 1fr) 330px;
  gap: 16px;
  align-items: start;
}

.stage,
.side-panel {
  border: 1px solid rgba(23, 33, 43, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow);
}

.stage {
  padding: 12px;
}

.side-panel {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.meter-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.light-meter {
  position: relative;
  min-height: 38px;
  overflow: hidden;
  border: 2px solid rgba(147, 91, 0, 0.24);
  border-radius: 8px;
  background: #f3f0e3;
}

.light-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.58), transparent 35%),
    linear-gradient(90deg, #ffe066, #ffb703);
  transition: width 180ms ease;
}

.light-meter span {
  position: relative;
  z-index: 1;
  display: grid;
  min-height: 34px;
  place-items: center;
  color: #513600;
  font-weight: 900;
}

.star-timer {
  min-width: 84px;
  min-height: 38px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(240, 180, 41, 0.45);
  border-radius: 8px;
  background: #fff8cf;
  color: #7a4b00;
  font-weight: 900;
}

.canvas-wrap {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: #7cc7d7;
}

canvas {
  display: block;
  width: 100%;
  aspect-ratio: 45 / 64;
  touch-action: manipulation;
}

.message {
  position: absolute;
  inset: auto 18px 20px 18px;
  display: none;
  padding: 14px 16px;
  border: 1px solid rgba(23, 33, 43, 0.12);
  border-radius: 8px;
  background: rgba(255, 253, 246, 0.94);
  box-shadow: 0 14px 36px rgba(23, 33, 43, 0.22);
  text-align: center;
}

.message.visible {
  display: grid;
  gap: 4px;
}

.message strong {
  font-size: clamp(1.25rem, 3vw, 2rem);
}

.message span {
  color: var(--muted);
  font-weight: 800;
}

.controls {
  display: grid;
  grid-template-columns: 64px minmax(120px, 1fr) 64px;
  grid-template-areas: "left start right";
  gap: 10px;
  margin-top: 10px;
  direction: ltr;
}

#moveLeft {
  grid-area: left;
}

#startBtn {
  grid-area: start;
  direction: rtl;
}

#moveRight {
  grid-area: right;
}

.icon-button,
.primary-button,
.tank-action {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 900;
  transition:
    transform 120ms ease,
    box-shadow 120ms ease,
    filter 120ms ease;
}

.icon-button {
  min-height: 54px;
  background: #e7f5ff;
  color: var(--blue);
  font-size: 2.1rem;
  box-shadow: 0 6px 0 #b6d9ee;
}

.primary-button {
  min-height: 54px;
  background: var(--green);
  color: white;
  box-shadow: 0 6px 0 #1d754f;
}

.icon-button:active,
.primary-button:active,
.tank-action:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 rgba(23, 33, 43, 0.22);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.panel-heading h2 {
  font-size: 1.05rem;
}

.panel-heading span {
  font-size: 0.9rem;
  font-weight: 800;
}

.request-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.request-list li {
  min-height: 42px;
  display: grid;
  place-items: center;
  padding: 6px 8px;
  border: 1px solid rgba(47, 111, 189, 0.16);
  border-radius: 8px;
  background: #edf7ff;
  color: #1e538d;
  font-weight: 900;
  text-align: center;
}

.shop-grid {
  display: grid;
  gap: 10px;
}

.tank-card {
  display: grid;
  grid-template-columns: 58px 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 88px;
  padding: 10px;
  border: 2px solid rgba(23, 33, 43, 0.1);
  border-radius: 8px;
  background: var(--panel);
}

.tank-card.selected {
  border-color: #f0b429;
  background: #fff9df;
}

.tank-swatch {
  width: 58px;
  height: 58px;
  border-radius: 8px;
  border: 2px solid rgba(23, 33, 43, 0.13);
  box-shadow: inset 0 -10px rgba(23, 33, 43, 0.08);
}

.tank-info {
  min-width: 0;
}

.tank-info strong {
  display: block;
  font-size: 1rem;
  line-height: 1.2;
}

.tank-info span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.35;
}

.tank-action {
  min-width: 82px;
  min-height: 40px;
  padding: 0 10px;
  background: var(--blue);
  color: white;
  box-shadow: 0 5px 0 #1f4f88;
  white-space: nowrap;
}

.tank-action:disabled {
  cursor: default;
  filter: grayscale(0.3);
  opacity: 0.68;
  transform: none;
}

@media (max-width: 920px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .stats {
    width: 100%;
  }

  .play-layout {
    grid-template-columns: 1fr;
  }

  .side-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .app {
    width: min(100vw - 18px, 1220px);
    padding-top: 10px;
  }

  .brand-mark {
    width: 46px;
    height: 46px;
    font-size: 0.9rem;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stage,
  .side-panel {
    padding: 9px;
  }

  .meter-row {
    grid-template-columns: 1fr;
  }

  .star-timer {
    width: 100%;
  }

  .controls {
    grid-template-columns: 58px minmax(110px, 1fr) 58px;
  }

  .tank-card {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .tank-swatch {
    width: 48px;
    height: 48px;
  }

  .tank-action {
    grid-column: 1 / -1;
    width: 100%;
  }
}
