/* ============================================================
   깨알도구
   벌칙 뽑기
   ============================================================ */

.penalty-page {
  --tool-page-max-width: 920px;
}

/* ============================================================
   TEXTAREA
   ============================================================ */

.penalty-textarea {
  display: block;

  width: 100%;
  min-height: 220px;

  padding: 13px 14px;

  resize: vertical;

  border: 1px solid var(--line);
  border-radius: var(--tool-input-radius);

  background: #ffffff;

  color: var(--text);

  outline: none;

  font-family: inherit;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.75;

  box-sizing: border-box;

  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.penalty-textarea:focus {
  border-color: var(--accent);

  box-shadow: 0 0 0 3px rgba(217, 164, 65, 0.1);
}

.penalty-textarea:disabled {
  opacity: 0.65;

  background: var(--surface-soft);

  cursor: not-allowed;
}

/* ============================================================
   INPUT META
   ============================================================ */

.penalty-input-meta {
  display: flex;

  align-items: center;
  justify-content: space-between;

  gap: 10px;

  margin-top: 6px;

  color: var(--text-soft);

  font-size: var(--tool-help-size);
}

.penalty-input-meta span:last-child {
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   CHECK
   ============================================================ */

.penalty-check {
  display: flex;

  align-items: center;

  gap: 10px;

  min-height: 58px;

  padding: 9px 11px;

  border: 1px solid var(--line);
  border-radius: 11px;

  background: var(--surface-soft);

  cursor: pointer;
}

.penalty-check input {
  position: absolute;

  width: 1px;
  height: 1px;

  opacity: 0;
}

.penalty-check-ui {
  position: relative;

  width: 36px;
  height: 20px;

  flex: 0 0 36px;

  border-radius: 999px;

  background: #d9d9d4;

  transition: background 0.18s ease;
}

.penalty-check-ui::after {
  content: '';

  position: absolute;

  top: 3px;
  left: 3px;

  width: 14px;
  height: 14px;

  border-radius: 50%;

  background: #ffffff;

  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);

  transition: left 0.18s ease;
}

.penalty-check input:checked + .penalty-check-ui {
  background: var(--brand);
}

.penalty-check input:checked + .penalty-check-ui::after {
  left: 19px;
}

.penalty-check-text {
  min-width: 0;
}

.penalty-check-text strong {
  display: block;

  color: var(--text);

  font-size: 12px;
  font-weight: 800;
}

.penalty-check-text small {
  display: block;

  margin-top: 2px;

  color: var(--text-soft);

  font-size: 12px;
  line-height: 1.45;
}

/* ============================================================
   POOL RESET
   ============================================================ */

.penalty-pool-reset {
  width: 100%;

  margin-top: 7px;

  padding: 8px 10px;

  border: 1px solid var(--line);
  border-radius: 9px;

  background: #ffffff;

  color: var(--text-soft);

  font-family: inherit;
  font-size: 12px;
  font-weight: 800;

  cursor: pointer;
}

.penalty-pool-reset:hover:not(:disabled) {
  background: var(--surface-soft);

  color: var(--text);
}

.penalty-pool-reset:disabled {
  opacity: 0.4;

  cursor: not-allowed;
}

/* ============================================================
   CHIP LIST
   ============================================================ */

.penalty-chip-list {
  display: flex;

  flex-wrap: wrap;

  gap: 6px;
}

.penalty-chip {
  max-width: 100%;

  display: inline-flex;

  align-items: center;

  gap: 5px;

  min-height: 30px;

  padding: 4px 8px;

  border: 1px solid var(--line);
  border-radius: 999px;

  background: #ffffff;

  color: var(--text);

  font-family: inherit;
  font-size: 12px;
  font-weight: 750;

  cursor: pointer;
}

.penalty-chip:hover:not(:disabled) {
  background: var(--surface-soft);
}

.penalty-chip i {
  width: 7px;
  height: 7px;

  flex: 0 0 7px;

  border-radius: 50%;

  background: var(--accent);
}

.penalty-chip span {
  min-width: 0;

  overflow: hidden;

  text-overflow: ellipsis;

  white-space: nowrap;
}

.penalty-chip b {
  color: var(--text-soft);

  font-size: 12px;
}

.penalty-empty-list {
  width: 100%;

  padding: 13px 10px;

  border-radius: 9px;

  background: var(--surface-soft);

  color: var(--text-soft);

  font-size: 12px;

  text-align: center;
}

/* ============================================================
   RESULT PANEL
   ============================================================ */

.penalty-result-panel {
  position: relative;

  min-height: 0;

  justify-content: flex-start;

  overflow: hidden;
}

/* ============================================================
   STATUS
   ============================================================ */

.penalty-status {
  width: 100%;

  min-height: 35px;

  display: flex;

  align-items: center;
  justify-content: center;

  margin-bottom: 10px;

  padding: 7px 10px;

  border-radius: 9px;

  background: var(--surface-soft);

  color: var(--text-soft);

  font-size: 12px;
  font-weight: 750;

  text-align: center;

  box-sizing: border-box;
}

.penalty-status.is-error {
  background: #fff1ed;

  color: #a24b3b;
}

.penalty-status.is-success {
  background: #eef9f2;

  color: #34714a;
}

/* ============================================================
   MACHINE
   ============================================================ */

.penalty-machine {
  width: min(100%, 370px);

  margin: 0 auto;

  padding: 12px;

  border: 1px solid #d9d6cc;
  border-radius: 22px;

  background: linear-gradient(180deg, #262d3c 0%, #171d2b 100%);

  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);

  box-sizing: border-box;
}

.penalty-machine-title {
  margin-bottom: 9px;

  color: rgba(255, 255, 255, 0.72);

  font-size: 12px;
  font-weight: 900;
  letter-spacing: 1.5px;

  text-align: center;
}

/* ============================================================
   WINDOW
   ============================================================ */

.penalty-machine-window {
  position: relative;

  height: 270px;

  overflow: hidden;

  border: 6px solid #ffffff;
  border-radius: 50% 50% 24px 24px;

  background: radial-gradient(
    circle at 50% 30%,
    #fffdf5 0%,
    #f8edd9 55%,
    #e8d9c0 100%
  );
}

/* ============================================================
   DECORATIVE BALLS
   ============================================================ */

.penalty-ball {
  position: absolute;

  width: 47px;
  height: 47px;

  border-radius: 50%;

  opacity: 0.82;

  box-shadow: inset 0 -8px 10px rgba(0, 0, 0, 0.08);
}

.ball-1 {
  left: 8%;
  bottom: 12%;

  background: #ef767a;

  transform: rotate(-12deg);
}

.ball-2 {
  left: 27%;
  bottom: 4%;

  background: #68b1e8;
}

.ball-3 {
  right: 8%;
  bottom: 11%;

  background: #f0bf58;
}

.ball-4 {
  right: 26%;
  bottom: 3%;

  background: #75c992;
}

.ball-5 {
  left: 17%;
  bottom: 30%;

  background: #af8be8;
}

.ball-6 {
  right: 17%;
  bottom: 30%;

  background: #ec91bb;
}

/* ============================================================
   CAPSULE
   ============================================================ */

.penalty-capsule {
  position: absolute;

  z-index: 5;

  top: 50%;
  left: 50%;

  width: 166px;
  min-height: 108px;

  transform: translate(-50%, -50%);

  display: flex;

  flex-direction: column;

  align-items: center;
  justify-content: center;

  padding: 13px;

  border: 6px solid #ffffff;
  border-radius: 55px;

  background: linear-gradient(
    180deg,
    #ff8d8d 0%,
    #ef666d 50%,
    #ffffff 50%,
    #ffffff 100%
  );

  color: #22252c;

  box-shadow: 0 9px 18px rgba(0, 0, 0, 0.2);

  box-sizing: border-box;

  text-align: center;
}

.penalty-capsule span {
  display: block;

  margin-top: -5px;

  font-size: 29px;
}

.penalty-capsule strong {
  display: block;

  max-width: 135px;

  margin-top: 17px;

  font-size: 12px;
  font-weight: 900;
  line-height: 1.3;

  overflow-wrap: anywhere;
}

/* ============================================================
   SPINNING
   ============================================================ */

.penalty-machine.is-spinning .penalty-machine-window {
  animation: penalty-machine-shake 0.18s linear infinite;
}

.penalty-machine.is-spinning .penalty-ball {
  animation: penalty-ball-bounce 0.36s ease-in-out infinite alternate;
}

.penalty-machine.is-spinning .ball-2 {
  animation-delay: 0.08s;
}

.penalty-machine.is-spinning .ball-3 {
  animation-delay: 0.14s;
}

.penalty-machine.is-spinning .ball-4 {
  animation-delay: 0.2s;
}

.penalty-machine.is-spinning .ball-5 {
  animation-delay: 0.04s;
}

.penalty-machine.is-spinning .ball-6 {
  animation-delay: 0.12s;
}

.penalty-machine.is-spinning .penalty-capsule {
  animation: penalty-capsule-spin 0.3s ease-in-out infinite alternate;
}

.penalty-machine.is-revealed .penalty-capsule {
  animation: penalty-capsule-pop 0.38s cubic-bezier(0.2, 1.4, 0.4, 1);
}

@keyframes penalty-machine-shake {
  0% {
    transform: translateX(-2px);
  }

  50% {
    transform: translateX(2px);
  }

  100% {
    transform: translateX(-1px);
  }
}

@keyframes penalty-ball-bounce {
  from {
    transform: translateY(2px) rotate(-7deg);
  }

  to {
    transform: translateY(-16px) rotate(9deg);
  }
}

@keyframes penalty-capsule-spin {
  from {
    transform: translate(-50%, -50%) rotate(-5deg) scale(0.96);
  }

  to {
    transform: translate(-50%, -50%) rotate(5deg) scale(1.04);
  }
}

@keyframes penalty-capsule-pop {
  0% {
    transform: translate(-50%, -50%) scale(0.75);
  }

  70% {
    transform: translate(-50%, -50%) scale(1.08);
  }

  100% {
    transform: translate(-50%, -50%) scale(1);
  }
}

/* ============================================================
   MACHINE BOTTOM
   ============================================================ */

.penalty-machine-bottom {
  display: flex;

  align-items: center;
  justify-content: center;

  gap: 6px;

  margin-top: 9px;

  color: rgba(255, 255, 255, 0.62);

  font-size: 12px;
  font-weight: 700;
}

.penalty-machine-bottom strong {
  color: #ffffff;

  font-size: 12px;
  font-weight: 900;
}

/* ============================================================
   DRAW
   ============================================================ */

.penalty-draw-button {
  margin-top: 13px;
}

.penalty-key-guide {
  margin-top: 5px;

  color: var(--text-soft);

  font-size: 12px;

  text-align: center;
}

/* ============================================================
   RESULT
   ============================================================ */

.penalty-result-content {
  margin-top: 15px;

  padding-top: 15px;

  border-top: 1px solid var(--line);

  text-align: center;
}

.penalty-result-content[hidden] {
  display: none;
}

.penalty-result-content .tool-result-main strong {
  margin-top: 3px;

  font-size: 25px;

  overflow-wrap: anywhere;
}

.penalty-result-actions {
  display: grid;

  grid-template-columns: repeat(2, minmax(0, 1fr));

  gap: 7px;

  margin-top: 14px;
}

.penalty-result-actions .tool-result-action {
  width: 100%;
}

/* ============================================================
   HISTORY
   ============================================================ */

.penalty-history {
  width: 100%;

  margin-top: 14px;

  padding-top: 13px;

  border-top: 1px solid var(--line);
}

.penalty-history[hidden] {
  display: none;
}

.penalty-history-head {
  display: flex;

  align-items: center;
  justify-content: space-between;

  gap: 10px;

  margin-bottom: 7px;
}

.penalty-history-head strong {
  color: var(--text);

  font-size: 12px;
  font-weight: 850;
}

.penalty-history-head button {
  padding: 5px 8px;

  border: 1px solid var(--line);
  border-radius: 7px;

  background: #ffffff;

  color: var(--text-soft);

  font-family: inherit;
  font-size: 12px;
  font-weight: 800;

  cursor: pointer;
}

.penalty-history-list {
  display: grid;

  gap: 5px;
}

.penalty-history-item {
  display: grid;

  grid-template-columns:
    24px
    minmax(0, 1fr);

  align-items: center;

  gap: 7px;

  padding: 8px 9px;

  border-radius: 8px;

  background: var(--surface-soft);

  animation: penalty-history-in 0.25s ease;
}

.penalty-history-number {
  width: 22px;
  height: 22px;

  display: flex;

  align-items: center;
  justify-content: center;

  border-radius: 50%;

  background: #ffffff;

  color: var(--text-soft);

  font-size: 12px;
  font-weight: 900;
}

.penalty-history-text {
  min-width: 0;

  color: var(--text);

  font-size: 12px;
  font-weight: 800;

  overflow-wrap: anywhere;
}

@keyframes penalty-history-in {
  from {
    opacity: 0;

    transform: translateY(4px);
  }

  to {
    opacity: 1;

    transform: translateY(0);
  }
}

/* ============================================================
   CONFETTI
   ============================================================ */

.penalty-confetti {
  position: absolute;

  inset: 0;

  z-index: 20;

  overflow: hidden;

  pointer-events: none;
}

.penalty-confetti i {
  position: absolute;

  top: -20px;

  border-radius: 2px;

  animation: penalty-confetti-fall 1.3s ease-in forwards;
}

@keyframes penalty-confetti-fall {
  from {
    opacity: 1;

    transform: translateY(-20px) rotate(0deg);
  }

  to {
    opacity: 0;

    transform: translateY(650px) rotate(600deg);
  }
}

/* ============================================================
   MOBILE
   ============================================================ */

@media (max-width: 760px) {
  .penalty-result-panel {
    order: -1;
  }
}

@media (max-width: 520px) {
  .penalty-textarea {
    min-height: 185px;

    font-size: 12px;
  }

  .penalty-machine {
    width: min(100%, 340px);
  }

  .penalty-machine-window {
    height: 245px;
  }

  .penalty-capsule {
    width: 150px;
    min-height: 100px;
  }

  .penalty-result-actions {
    grid-template-columns: 1fr;
  }
}
