:root {
  --ink: #101713;
  --panel: rgba(255, 255, 255, 0.9);
  --line: rgba(255, 255, 255, 0.52);
  --green: #3ab36b;
  --red: #ef5b4a;
  --blue: #4a88df;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background: #101713;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  user-select: none;
}

.game-wrap {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-width: 320px;
  min-height: 220px;
  overflow: hidden;
  background: #101713;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.hud {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 12px;
  display: flex;
  gap: 8px;
  pointer-events: none;
}

.hud > div {
  min-width: 78px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
}

.label {
  display: block;
  color: #52605a;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hud strong {
  display: block;
  margin-top: 2px;
  font-size: 1.1rem;
  line-height: 1;
}

.color-panel {
  position: absolute;
  right: 12px;
  bottom: max(12px, env(safe-area-inset-bottom));
  display: flex;
  gap: 8px;
}

.color-button {
  min-width: 74px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  cursor: pointer;
  font-weight: 850;
}

.color-button[data-color="green"] {
  box-shadow: inset 0 -4px 0 var(--green);
}

.color-button[data-color="red"] {
  box-shadow: inset 0 -4px 0 var(--red);
}

.color-button[data-color="blue"] {
  box-shadow: inset 0 -4px 0 var(--blue);
}

.color-button.active {
  color: #ffffff;
  border-color: rgba(0, 0, 0, 0.08);
}

.color-button.active[data-color="green"] {
  background: var(--green);
}

.color-button.active[data-color="red"] {
  background: var(--red);
}

.color-button.active[data-color="blue"] {
  background: var(--blue);
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(16, 23, 19, 0.48);
}

.overlay.hidden {
  display: none;
}

.overlay-panel {
  width: min(420px, 100%);
  padding: clamp(22px, 5vw, 34px);
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.24);
}

.overlay-panel h1 {
  margin: 0 0 10px;
  font-size: clamp(2rem, 7vw, 3.6rem);
  line-height: 0.96;
  letter-spacing: 0;
}

.overlay-panel p {
  margin: 0 0 22px;
  color: #52605a;
  line-height: 1.55;
}

.overlay-panel button {
  min-width: 132px;
  min-height: 48px;
  color: #ffffff;
  background: #ef5b4a;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 900;
}

@media (max-width: 560px) {
  .hud {
    gap: 6px;
  }

  .hud > div {
    min-width: 64px;
    padding: 7px 8px;
  }

  .color-panel {
    left: 12px;
    right: 12px;
  }

  .color-button {
    flex: 1;
    min-width: 0;
    padding: 0 6px;
  }
}
