body, p {
  margin: 0px;
  touch-action: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.controls-bar {
  position: relative;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 12px;
  background: #f5f5f5;
  border-bottom: 1px solid #ddd;
  width: min(100vw, 480px);
  margin: 0 auto;
  box-sizing: border-box;
  transition: padding 0.3s ease;
}

.controls-bar.compact {
  padding: 2px 12px;
}

.file-upload-collapse {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.3s ease, opacity 0.3s ease;
}

.controls-bar.compact .file-upload-collapse {
  grid-template-rows: 0fr;
  opacity: 0;
}

.file-upload {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
  min-height: 0;
}

.file-upload input[type=file] {
  min-width: 0;
  flex: 1;
}

.file-upload button {
  background: #333;
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9em;
  white-space: nowrap;
  flex-shrink: 0;
}

.file-upload button:hover,
.file-upload a:hover {
  background: #555;
}

.file-upload a {
  background: #333;
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 16px;
  font-size: 16px;
  box-sizing: border-box;
}

.ad-banner {
  width: min(100vw, 480px);
  height: 50px;
  margin: 0 auto;
}

.canvas-wrapper {
  position: relative;
  display: block;
  margin: 0 auto;
  aspect-ratio: 3/4;
  width: min(100vw, 480px);
}

#canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.settings-toggle {
  background: transparent;
  color: #999;
  border: none;
  padding: 2px 4px;
  font-size: 0.85em;
  cursor: pointer;
  line-height: 1;
  margin-left: auto;
  flex-shrink: 0;
}

.settings-toggle:hover {
  color: #555;
}

.settings-panel {
  display: none;
  position: absolute;
  top: 100%;
  right: 8px;
  z-index: 100;
  background: #333;
  color: #fff;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 0.85em;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.settings-panel.visible {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.settings-panel label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.settings-panel input[type=range] {
  width: 120px;
  margin-left: auto;
}

.button-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: min(1vw, 4px);
}

.button-container > p {
  display: flex;
  width: 100%;
  justify-content: center;
  gap: min(1vw, 4px);
}

.button-container > p > button {
  width: min(20vw, 96px);
  height: 2vh;
  margin: 0;
  font-size: 0.5em;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.tutorial-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.tutorial-overlay.visible {
  display: flex;
}

.tutorial-modal {
  background: #fff;
  border-radius: 8px;
  padding: 24px;
  max-width: 400px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.tutorial-modal h2 {
  margin: 0 0 16px 0;
  font-size: 1.5em;
  border-bottom: 2px solid #333;
  padding-bottom: 8px;
}

.tutorial-modal h3 {
  margin: 16px 0 8px 0;
  font-size: 1.1em;
  color: #333;
}

.tutorial-modal p {
  margin: 8px 0;
  line-height: 1.5;
}

.tutorial-modal .note {
  color: #666;
  font-size: 0.9em;
}

.tutorial-modal table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 0.9em;
}

.tutorial-modal td {
  padding: 6px 8px;
  border-bottom: 1px solid #eee;
}

.tutorial-modal td:first-child {
  white-space: nowrap;
}

.tutorial-modal kbd {
  background: #f4f4f4;
  border: 1px solid #ccc;
  border-radius: 3px;
  padding: 2px 6px;
  font-family: monospace;
  font-size: 0.9em;
}

.tutorial-footer {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tutorial-footer label {
  font-size: 0.9em;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tutorial-footer button {
  background: #333;
  color: #fff;
  border: none;
  padding: 8px 20px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1em;
}

.tutorial-footer button:hover {
  background: #555;
}