:root {
  color: #3e3150;
  background: linear-gradient(180deg, #ffe6f2 0%, #e6f7ff 55%, #fff7d6 100%);
  font-family: "Trebuchet MS", Inter, ui-sans-serif, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
}

.page {
  display: grid;
  min-height: 100vh;
  padding: 1.25rem;
  place-items: center;
}

.game-card {
  width: min(96vw, 560px);
  padding: 1rem;
  border: 4px solid rgba(255, 255, 255, 0.85);
  border-radius: 2rem;
  background: rgba(255, 255, 255, 0.62);
  box-shadow: 0 22px 70px rgba(156, 91, 142, 0.22);
  backdrop-filter: blur(8px);
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.25rem 0.5rem 0.85rem;
}

.eyebrow {
  margin: 0 0 0.2rem;
  color: #d76ba6;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  color: #7052b8;
  font-size: clamp(1.7rem, 7vw, 3rem);
  line-height: 0.95;
  text-shadow: 2px 3px 0 #fff;
}

.score-box {
  min-width: 86px;
  padding: 0.7rem 0.9rem;
  border-radius: 1.2rem;
  background: #fff4a8;
  color: #8a5b00;
  text-align: center;
  box-shadow: inset 0 -5px 0 rgba(255, 181, 70, 0.35);
}

.score-box span {
  display: block;
  font-size: 0.75rem;
  font-weight: 800;
}

.score-box strong {
  display: block;
  font-size: 1.5rem;
}

.game-wrap {
  position: relative;
  overflow: hidden;
  border: 5px solid #fff;
  border-radius: 1.5rem;
  background: #bfefff;
  box-shadow: inset 0 0 0 3px rgba(112, 82, 184, 0.1);
}

canvas {
  display: block;
  width: 100%;
  max-height: 72vh;
  aspect-ratio: 420 / 620;
  touch-action: none;
  user-select: none;
}

.message {
  position: absolute;
  inset: 1rem 1rem auto;
  display: grid;
  pointer-events: none;
  gap: 0.25rem;
  padding: 0.9rem 1rem;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.86);
  color: #7052b8;
  text-align: center;
  box-shadow: 0 10px 24px rgba(88, 75, 130, 0.18);
}

.message.hide {
  display: none;
}

.message strong {
  font-size: 1.1rem;
}

.touch-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
  padding: 0.9rem 0.45rem 0;
}

.move-button {
  min-height: 64px;
  border-radius: 1.3rem;
  font-size: 2rem;
  touch-action: none;
  user-select: none;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 0.45rem 0.2rem;
}

button {
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #ff8cc6, #9c7bff);
  color: white;
  cursor: pointer;
  font: inherit;
  font-weight: 900;
  padding: 0.9rem 1.2rem;
  box-shadow: 0 8px 0 #7655c9;
}

button:active {
  transform: translateY(4px);
  box-shadow: 0 4px 0 #7655c9;
}

.controls p {
  margin: 0;
  color: #766789;
  font-size: 0.95rem;
}

@media (max-width: 520px) {
  .page {
    padding: 0.5rem;
  }

  .game-card {
    padding: 0.65rem;
  }

  .header,
  .controls {
    align-items: stretch;
    flex-direction: column;
  }

  canvas {
    max-height: 48vh;
  }

  .message {
    inset: 0.65rem 0.65rem auto;
    padding: 0.55rem 0.7rem;
  }

  .message strong {
    font-size: 0.95rem;
  }

  .message span {
    font-size: 0.85rem;
  }

  .move-button {
    min-height: 54px;
  }
}
