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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #ffffff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  background-color: #ffffff;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

#ui-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#top-left-controls {
  position: absolute;
  top: 20px;
  left: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: auto;
}

.pencil-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  border: 2px solid #000000;
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 3px 3px 0px #000000;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.pencil-box:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0px #000000;
}

.pencil-box:active, .pencil-box.active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0px #000000;
  background: #f0f0f0;
}

#pencil-label {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #000000;
}

#zoom-controls {
  display: flex;
  gap: 6px;
}

.zoom-btn {
  background: #ffffff;
  border: 2px solid #000000;
  padding: 6px 12px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 2px 2px 0px #000000;
  border-radius: 4px;
  transition: transform 0.1s ease;
}

.zoom-btn:hover {
  transform: translate(-1px, -1px);
}

.zoom-btn:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0px #000000;
  background: #f0f0f0;
}

#level-display {
  position: absolute;
  top: 20px;
  right: 24px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #000000;
  background: #ffffff;
  border: 2px solid #000000;
  padding: 6px 16px;
  box-shadow: 3px 3px 0px #000000;
}

#controls-hint {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 16px;
  font-size: 13px;
  font-weight: 600;
  color: #000000;
  background: rgba(255, 255, 255, 0.9);
  padding: 6px 16px;
  border: 1px solid #cccccc;
  border-radius: 20px;
}

#modal-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.88);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

#modal-screen.hidden {
  display: none;
}

#modal-content {
  text-align: center;
  background: #ffffff;
  border: 3px solid #000000;
  padding: 36px 44px;
  box-shadow: 6px 6px 0px #000000;
  max-width: 440px;
}

#modal-title {
  font-size: 32px;
  font-weight: 900;
  margin-bottom: 12px;
  letter-spacing: 2px;
}

#modal-desc {
  font-size: 16px;
  color: #333333;
  margin-bottom: 24px;
  line-height: 1.5;
}

#modal-btn {
  background: #000000;
  color: #ffffff;
  border: none;
  padding: 12px 30px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 3px 3px 0px #888888;
  transition: transform 0.1s ease;
}

#modal-btn:hover {
  transform: translate(-1px, -1px);
}

#modal-btn:active {
  transform: translate(2px, 2px);
}

#touch-controls {
  position: absolute;
  bottom: 20px;
  width: 100%;
  display: flex;
  justify-content: space-between;
  padding: 0 24px;
  pointer-events: none;
}

.touch-group {
  display: flex;
  gap: 12px;
}

.t-btn {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  border: 2px solid #000000;
  font-size: 22px;
  font-weight: bold;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 2px 2px 0px #000000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.t-btn:active {
  transform: scale(0.92);
  background: #e0e0e0;
}

@media (min-width: 900px) {
  #touch-controls {
    display: none;
  }
}
