* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  color: #222;
  background: #f7f8fb;
  padding: 10px;
}

h1 {
  font-size: 1.3rem;
  margin: 10px 0;
  text-align: center;
}

.controls {
  display: flex;
  flex-wrap: wrap; /* ✅ 讓小螢幕會自動換行 */
  gap: 8px;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}

button {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid #ccc;
  background: #fff;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s;
}

button:hover {
  background: #f0f0f0;
}

input[type="range"] {
  width: 100px;
}

canvas {
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #fff;
  display: block;
  max-width: 100%; /* ✅ 手機螢幕自適應 */
  height: auto;
}

.time-box {
  display: inline-block;
  padding: 5px 10px;
  background-color: #e3e3e3;
  border-radius: 5px;
  font-size: 0.9rem;
  margin-left: 5px;
}

/* ✅ RWD: 手機螢幕調整 */
@media (max-width: 600px) {
  .controls {
    flex-direction: column;
    gap: 6px;
  }

  h1 {
    font-size: 1.1rem;
  }

  button, label, span {
    font-size: 0.9rem;
  }

  input[type="range"] {
    width: 80%;
  }

  canvas {
    width: 100%;
    max-width: 350px; /* 防止太大 */
  }
}
