* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}

body {
  background-color: var(--outer-bg, #e8c98a);
  overscroll-behavior: none;
  touch-action: none;
  background-image: repeating-linear-gradient(
    45deg,
    var(--body-pattern, rgba(160, 100, 30, 0.08)) 0px,
    var(--body-pattern, rgba(160, 100, 30, 0.08)) 1px,
    transparent 1px,
    transparent 28px
  );
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
}

#mainCanvas {
  position: fixed;
  top: 0;
  left: 0;
  display: block;
  width: 100vw;
  height: 100dvh;
  z-index: 100;
  cursor: pointer;
  background-color: transparent;
}

.game-wrapper {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 16px 16px calc(64px + env(safe-area-inset-bottom));
  overflow: hidden;
}

.game-inner {
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: center;
  width: min(100%, 560px);
  flex: 0 1 auto;
  min-height: 0;
  background: transparent;
  border-radius: 22px;
  padding: 12px;
  box-shadow: 0 4px 32px rgba(0, 0, 0, 0.20);
}

#gameCanvas {
  cursor: crosshair;
  display: block;
  flex-shrink: 0;
  touch-action: none;
  border-radius: 14px;
}

#gameCanvas.dragging {
  cursor: grabbing;
}

.shapes-panel-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 75%;
  align-self: center;
}

.shapes-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  padding: 10px;
  background: var(--panel-bg, #d4a055);
  border: 2px solid var(--interactive-border, #7a3a10);
  border-radius: 16px;
  width: 100%;
  box-sizing: border-box;
  overflow: visible;
}

.shape-item {
  cursor: grab;
  touch-action: none;
  transform-origin: center center;
}

@keyframes shape-idle-wiggle {
  0%, 80%, 100% { transform: rotate(0deg); }
  84%            { transform: rotate(-9deg); }
  91%            { transform: rotate(9deg); }
  97%            { transform: rotate(-4deg); }
}

.shape-item:active {
  cursor: grabbing;
}

.shapes-count {
  text-align: center;
  font-family: Georgia, serif;
  color: var(--ui-text, #3d1505);
  font-size: 15px;
  font-weight: bold;
  opacity: 0.7;
  pointer-events: none;
  padding: 4px 0 0;
}

.edit-seed-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding-top: 2px;
}

.edit-seed-row .shapes-count {
  padding: 0;
}

.edit-seed-row .ctrl-btn {
  font-size: 12px;
  padding: 2px 10px;
  min-width: 0;
}

.rules-panel {
  display: flex;
  justify-content: center;
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 8px 0 0;
  margin-top: 8px;
  width: 100%;
  box-sizing: border-box;
}

#rulesCanvas {
  display: block;
  max-width: 100%;
}

.game-controls {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: row;
  justify-content: center;
  gap: 32px;
  width: min(100vw, 560px);
  flex-shrink: 0;
  padding: 10px 16px calc(14px + env(safe-area-inset-bottom));
  z-index: 20;
}

.ctrl-btn {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--interactive-bg, #7a3a10);
  color: var(--button-text, #e8c98a);
  border: 2.5px solid var(--interactive-border, #7a3a10);
  border-radius: 50%;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.36);
  touch-action: manipulation;
}

.ctrl-btn:active {
  opacity: 0.75;
  box-shadow: 0 2px 7px rgba(0, 0, 0, 0.34);
}
