* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #ffffff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #222;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#stage {
  position: fixed;
  inset: 0;
  touch-action: none;
}

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

.cell { cursor: pointer; }
.cell:focus:not(:focus-visible), #center:focus:not(:focus-visible) { outline: none; }
.cell path.base { transition: fill 150ms, stroke 150ms; }
.cell.intensity-live path.base { filter: drop-shadow(0 0 10px rgba(0, 0, 0, 0.6)); }
.cell path.shade { pointer-events: none; }
.cell text { pointer-events: none; }

#center { cursor: pointer; }
#centerGlyph { opacity: 0; transition: opacity 200ms; pointer-events: none; }
#center.active #centerGlyph { opacity: 1; }

/* Corner buttons */
.corner {
  position: fixed;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid #ddd;
  background: rgba(255, 255, 255, 0.92);
  color: #555;
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 20;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}
.corner:active { background: #f0f0f0; }
.top-right { top: calc(env(safe-area-inset-top, 0px) + 12px); right: 12px; }
.bottom-right { bottom: calc(env(safe-area-inset-bottom, 0px) + 12px); right: 12px; }

.badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: #c82838;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Modals */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.38);
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.backdrop[hidden] { display: none; }

.modal {
  position: relative;
  background: #fff;
  border-radius: 14px;
  padding: 20px 22px;
  width: 100%;
  max-width: 480px;
  max-height: 88dvh;
  overflow-y: auto;
  -webkit-user-select: text;
  user-select: text;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.25);
}
.modal.wide { max-width: 640px; }
.modal h2 { margin: 0 0 10px; font-size: 20px; }
.modal h3 { margin: 18px 0 6px; font-size: 14px; text-transform: uppercase; letter-spacing: 0.06em; color: #888; }
.modal .close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: #f2f2f2;
  color: #666;
  font-size: 15px;
  cursor: pointer;
}
.howto { margin: 0; padding-left: 18px; }
.howto li { margin: 6px 0; font-size: 14.5px; line-height: 1.45; }
.hint { color: #999; font-size: 12.5px; font-weight: 400; }
.about { font-size: 13.5px; line-height: 1.5; color: #555; }
.about a { color: #2a6fd6; }

.setting { margin: 12px 0; }
.setting label { display: block; font-size: 14.5px; margin-bottom: 6px; }
.setting.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.setting.row label { margin: 0; }
.setting input[type="range"] { width: 100%; }
.setting select { font-size: 14.5px; padding: 4px 8px; }

/* Summary table */
#summaryTableWrap { overflow-x: auto; }
#summaryTable { border-collapse: collapse; width: 100%; font-size: 14px; }
#summaryTable th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #999;
  padding: 6px 8px;
  border-bottom: 1px solid #e5e5e5;
}
#summaryTable td { padding: 8px; border-bottom: 1px solid #f0f0f0; vertical-align: top; }
.swatch { width: 14px; height: 14px; border-radius: 4px; border: 1px solid rgba(0, 0, 0, 0.2); display: inline-block; }
.feelName { font-weight: 600; }
.feelPath { font-size: 11.5px; color: #999; margin-top: 2px; }
.intCell { white-space: nowrap; }
.intCell button {
  width: 26px;
  height: 26px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fafafa;
  cursor: pointer;
  font-size: 14px;
}
.intVal { display: inline-block; min-width: 26px; text-align: center; font-weight: 600; }
.thoughtInput {
  width: 100%;
  min-width: 160px;
  min-height: 38px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 6px 8px;
  font: inherit;
  font-size: 13.5px;
  resize: vertical;
  background: #fcfcfc;
}

.modal-actions { display: flex; gap: 10px; margin-top: 14px; }
.action {
  flex: 1;
  padding: 10px 12px;
  border: none;
  border-radius: 10px;
  background: #2a6fd6;
  color: #fff;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
}
.action:active { background: #245cb2; }
.action[disabled] { background: #b9cdec; cursor: default; }

#toast {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 70px);
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 9px 16px;
  border-radius: 20px;
  font-size: 13.5px;
  z-index: 50;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}
