:root {
  --bg: #f5efe3;
  --panel: rgba(255, 255, 255, 0.94);
  --text: #202124;
  --muted: #65707a;
  --primary: #156c8a;
  --primary-dark: #0f556c;
  --accent: #d64032;
  --border: #ddd4c7;
  --shadow: 0 18px 48px rgba(35, 40, 44, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: "Trebuchet MS", "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(21, 108, 138, 0.18), transparent 34%),
    radial-gradient(circle at bottom right, rgba(214, 64, 50, 0.16), transparent 30%),
    linear-gradient(180deg, #fbf7f0 0%, #f3ecdf 100%);
}

button,
textarea {
  font: inherit;
}

.app {
  width: min(1120px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 28px;
  align-items: center;
  padding: 24px 0;
}

.editor,
.wheel-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.editor {
  padding: 24px;
}

.section-heading h1 {
  margin: 0 0 8px;
  font-size: 30px;
  line-height: 1.1;
}

.section-heading p,
.hint {
  color: var(--muted);
}

.section-heading p {
  margin: 0 0 20px;
  line-height: 1.55;
}

label {
  display: block;
  margin-bottom: 10px;
  font-size: 15px;
  font-weight: 700;
}

textarea {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  padding: 14px;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: #fcfaf5;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(21, 108, 138, 0.14);
}

textarea:disabled {
  color: #6e747b;
  background: #f0ece4;
}

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}

button {
  min-height: 50px;
  padding: 0 20px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  transition: transform 0.16s ease, background 0.16s ease, opacity 0.16s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

button.secondary {
  color: var(--primary);
  background: #e7f0f3;
}

button.secondary:hover {
  background: #d6e6eb;
}

.hint {
  min-height: 24px;
  margin: 14px 0 0;
  font-size: 14px;
  line-height: 1.5;
}

.wheel-panel {
  display: grid;
  justify-items: center;
  gap: 18px;
  min-width: 0;
  padding: 24px;
}

.wheel-wrap {
  position: relative;
  width: min(100%, 560px);
  max-width: min(560px, calc(100vw - 88px));
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  margin: 0 auto;
}

canvas {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  filter: drop-shadow(0 14px 30px rgba(38, 45, 48, 0.22));
}

.pointer {
  position: absolute;
  top: -4px;
  left: 50%;
  z-index: 2;
  width: 34px;
  height: 52px;
  transform: translateX(-50%);
  background: #263238;
  clip-path: polygon(50% 100%, 0 0, 100% 0);
}

.spin-button {
  min-width: 200px;
  min-height: 56px;
  font-size: 18px;
  background: var(--accent);
}

.spin-button:hover {
  background: #b93329;
}

.result {
  min-height: 34px;
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  text-align: center;
  color: var(--accent);
  word-break: break-word;
}

@media (max-width: 920px) {
  .app {
    grid-template-columns: 1fr;
    align-items: start;
    width: min(100%, calc(100% - 24px));
    gap: 18px;
    padding: 18px 0 24px;
  }

  .editor,
  .wheel-panel {
    padding: 20px;
  }

  .wheel-wrap {
    max-width: min(520px, calc(100vw - 64px));
  }
}

@media (max-width: 600px) {
  .app {
    width: calc(100% - 16px);
    gap: 14px;
    padding:
      max(12px, env(safe-area-inset-top))
      0
      max(20px, env(safe-area-inset-bottom));
  }

  .editor,
  .wheel-panel {
    padding: 16px;
  }

  .section-heading h1 {
    font-size: 24px;
  }

  .section-heading p {
    margin-bottom: 16px;
    font-size: 15px;
  }

  textarea {
    min-height: 180px;
    padding: 12px;
  }

  .editor-actions {
    flex-direction: column;
  }

  .editor-actions button,
  .spin-button {
    width: 100%;
  }

  .wheel-wrap {
    width: min(100%, 420px);
    max-width: calc(100vw - 48px);
  }

  .pointer {
    top: 2px;
    width: 28px;
    height: 42px;
  }

  .result {
    font-size: 20px;
  }
}

@media (max-width: 390px) {
  .app {
    width: calc(100% - 12px);
  }

  .editor,
  .wheel-panel {
    padding: 14px;
  }

  .wheel-wrap {
    max-width: calc(100vw - 40px);
  }

  .spin-button,
  .editor-actions button {
    min-height: 52px;
  }
}
