* {
  box-sizing: border-box;
}

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

body {
  font-family: system-ui, -apple-system, "Segoe UI", "Malgun Gothic", sans-serif;
  color: #1f2328;
  background: #eef0f3;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.app {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 도구 모음 */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 8px 12px;
  background: #ffffff;
  border-bottom: 1px solid #e0e3e8;
  flex: 0 0 auto;
}

.swatches {
  display: flex;
  gap: 8px;
}

.swatch {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 50%;
  background: var(--c);
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.swatch.is-active {
  border-color: #1f2328;
}

.swatch:focus-visible,
.actions button:focus-visible,
.size-control input:focus-visible {
  outline: 2px solid #0091ff;
  outline-offset: 2px;
}

.size-control {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #4a5158;
}

.size-control input[type="range"] {
  width: 120px;
}

.size-control output {
  min-width: 22px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.actions button {
  padding: 7px 12px;
  font: inherit;
  font-size: 13px;
  color: #1f2328;
  background: #f4f5f7;
  border: 1px solid #d9dde2;
  border-radius: 8px;
  cursor: pointer;
}

.actions button:active {
  background: #e8eaee;
}

.actions button:disabled {
  opacity: 0.45;
  cursor: default;
}

/* 도형 판정 켜기/끄기 */
.toggle {
  padding: 7px 12px;
  font: inherit;
  font-size: 13px;
  color: #4a5158;
  background: #f4f5f7;
  border: 1px solid #d9dde2;
  border-radius: 8px;
  cursor: pointer;
}

.toggle.is-on {
  color: #ffffff;
  background: #1f2328;
  border-color: #1f2328;
}

.toggle:focus-visible {
  outline: 2px solid #0091ff;
  outline-offset: 2px;
}

/* 시간 / 성공 개수 */
.hud {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 5px 12px;
  background: #f4f5f7;
  border: 1px solid #d9dde2;
  border-radius: 8px;
}

.hud-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.hud-key {
  font-size: 12px;
  color: #6b7178;
}

.hud-val {
  min-width: 1.6em;
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: #1f2328;
}

.hud-val.is-low {
  color: #e5484d;
}

/* 그림 영역 */
.board-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

/* 성공 / 실패 안내 */
.board-status {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 7px 14px;
  max-width: calc(100% - 24px);
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
  color: #ffffff;
  background: #4a5158;
  border-radius: 999px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, visibility 0.18s ease;
  pointer-events: none;
}

.board-status.is-show {
  opacity: 1;
  visibility: visible;
}

.board-status.is-ok {
  background: #30a46c;
}

.board-status.is-no {
  background: #e5484d;
}

/* 그린 자리 근처에 뜨는 판정 결과 */
.float-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.float-label {
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 5px 10px;
  max-width: 200px;
  font-size: 13px;
  line-height: 1.35;
  font-weight: 600;
  text-align: center;
  color: #ffffff;
  background: #4a5158;
  border-radius: 8px;
  animation: floatUp 1.3s ease-out forwards;
}

.float-label.is-ok {
  background: #30a46c;
}

.float-label.is-no {
  background: #e5484d;
}

@keyframes floatUp {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.85);
  }
  15% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  70% {
    opacity: 1;
    transform: translate(-50%, -110%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -150%) scale(0.95);
  }
}

#board {
  display: block;
  background: #ffffff;
  touch-action: none;
  cursor: crosshair;
}

@media (max-width: 420px) {
  .actions {
    margin-left: 0;
  }

  .size-control input[type="range"] {
    width: 90px;
  }
}
