* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html,
body {
  margin: 0;
  width: 100%;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  font-family: Pretendard, "Apple SD Gothic Neo", sans-serif;
  background: #f6f4ef;
  color: #222;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

button,
input,
select,
textarea {
  font: inherit;
  font-size: 16px;
}

.app {
  width: min(400px, 100%);
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px 16px;
}

body:has(.admin-page:not([hidden])) .app,
body.is-admin .app {
  width: min(720px, 100%);
}

.page[hidden],
[hidden] {
  display: none !important;
}

.login-page,
.user-page,
.admin-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: calc(100vh - 48px);
  min-height: calc(100dvh - 48px);
}

.login-page {
  justify-content: center;
}

.login-form,
.register-form,
.register-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(280px, 100%);
}

.login-field,
.profile-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  margin-bottom: 16px;
}

.profile-field {
  margin-top: 20px;
  margin-bottom: 0;
}

.login-form label,
.profile-field label {
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 700;
  color: #5c574e;
}

.login-form input,
.profile-field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #ddd4c4;
  border-radius: 12px;
  background: #fff;
  text-align: center;
}

.login-form input:focus,
.profile-field input:focus {
  border-color: #d97706;
  outline: 2px solid rgba(217, 119, 6, 0.2);
}

.login-error {
  margin: 0 0 8px;
  text-align: center;
  color: #b42318;
  font-size: 13px;
}

.login-error[hidden] {
  display: none;
}

.submit-done {
  width: 100%;
  margin: 24px 0 0;
  text-align: center;
  color: #8a8174;
  font-size: 14px;
  font-weight: 700;
}

.register-stage .btn-primary {
  margin-top: 24px;
}

.btn-primary {
  width: 100%;
  margin-top: 8px;
  padding: 13px 16px;
  border: 0;
  border-radius: 12px;
  background: #d97706;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.btn-primary:hover,
.btn-primary:focus-visible {
  background: #b45309;
  outline: none;
}

.page-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 20px;
}

.page-role {
  margin: 0;
  color: #8a8174;
  font-size: 13px;
  font-weight: 700;
}

.btn-text {
  padding: 0;
  border: 0;
  background: none;
  color: #8a8174;
  text-decoration: underline;
  cursor: pointer;
}

.user-page .register-form,
.wait-screen,
.play-screen,
#adminPlay,
.admin-main,
.center-form {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
}

.center-form {
  width: min(280px, 100%);
  flex: 0;
}

.center-form .btn-primary {
  margin-top: 24px;
}

.wait-screen p {
  margin: 0;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
}

.ai-talk {
  width: min(320px, 100%);
}

.ai-talk__line {
  margin: 0;
  min-height: 3.4em;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.7;
}

.price-accent {
  color: #dc2626;
}

.digit-board {
  display: flex;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 28px;
}

.digit-slot {
  display: grid;
  place-items: center;
  width: 48px;
  height: 64px;
  border: 2px solid #ddd4c4;
  border-radius: 12px;
  background: #fffdf8;
  font-size: 28px;
  font-weight: 800;
  color: transparent;
}

.digit-slot.is-filled {
  color: #222;
}

.digit-slot.is-pop {
  color: #dc2626;
  border-color: #dc2626;
  background: #fff1f1;
  transform: scale(1.12);
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.18);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.celebrate-screen,
.payout-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(320px, 100%);
  text-align: center;
}

.celebrate-title {
  margin: 0 0 12px;
  font-size: 28px;
  font-weight: 800;
}

.celebrate-lead {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.6;
}

.account-copy {
  margin: 0 0 8px;
  padding: 0;
  border: 0;
  background: none;
  color: #8a8174;
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
}

.payout-copy {
  margin: 0 0 20px;
  color: #d97706;
  font-size: 12px;
}

.payout-label {
  margin: 16px 0 6px;
  color: #8a8174;
  font-size: 13px;
  font-weight: 700;
}

.payout-value {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
}

.result-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.result-table th,
.result-table td {
  padding: 10px 8px;
  border-bottom: 1px solid #ece6d8;
  text-align: center;
}

.result-table th {
  color: #8a8174;
  font-size: 13px;
}

.admin-nav {
  display: flex;
  justify-content: center;
  gap: 16px;
  width: 100%;
  margin-bottom: 28px;
}

.admin-nav button {
  padding: 0;
  border: 0;
  background: none;
  color: #8a8174;
  font-weight: 700;
  cursor: pointer;
}

.admin-nav button.is-active {
  color: #d97706;
  text-decoration: underline;
}

.game-choices {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: min(280px, 100%);
}

.game-choices .btn-primary {
  margin-top: 0;
}

.game-choices .btn-primary.is-selected {
  background: #b45309;
}

.photo-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.photo-button,
.admin-photo {
  display: grid;
  place-items: center;
  width: 180px;
  height: 180px;
  padding: 0;
  overflow: hidden;
  border: 2px dashed #d7cfc0;
  border-radius: 50%;
  background: #fffdf8;
  line-height: 1.2;
  text-align: center;
}

.photo-button {
  cursor: pointer;
}

.photo-button.is-locked {
  cursor: default;
}

.photo-button.is-locked:hover,
.photo-button.is-locked:focus-visible {
  border-color: #d7cfc0;
}

.profile-field input[readonly] {
  background: #f3efe6;
  color: #5c574e;
}

.photo-button:hover,
.photo-button:focus-visible {
  border-color: #d97706;
  outline: none;
}

.photo-button.has-photo,
.admin-photo.has-photo {
  border-style: solid;
}

.photo-button img,
.admin-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 100%;
  color: #8a8174;
  font-size: 14px;
}

.photo-placeholder svg {
  display: block;
  flex: none;
  width: 36px;
  height: 36px;
  margin: 0;
}

.photo-placeholder__text {
  line-height: 1.2;
  text-align: center;
}

.photo-remove {
  padding: 0;
  border: 0;
  background: none;
  color: #8a8174;
  text-decoration: underline;
  cursor: pointer;
}

.photo-remove[hidden] {
  display: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#adminSettings {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.admin-list {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 40px;
  width: 100%;
  padding-bottom: 24px;
}

#adminSettings .admin-list,
.admin-list--people {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: start;
  justify-content: center;
  gap: 10px;
}

.admin-list--people .admin-card,
#adminSettings .admin-card {
  width: auto;
  min-width: 0;
}

.admin-list--people .admin-photo,
#adminSettings .admin-photo {
  width: min(96px, 24vw);
  height: min(96px, 24vw);
}

.admin-list--people .photo-placeholder,
#adminSettings .admin-photo .photo-placeholder {
  font-size: 11px;
  gap: 4px;
}

.admin-list--people .photo-placeholder svg,
#adminSettings .admin-photo .photo-placeholder svg {
  width: 22px;
  height: 22px;
}

.admin-list--people .admin-card__id,
#adminSettings .admin-card__id {
  margin-bottom: 10px;
  font-size: 12px;
}

.admin-list--people .admin-card__text,
#adminSettings .admin-card__text {
  margin-top: 10px;
}

.admin-list--people .admin-card__value,
#adminSettings .admin-card__value {
  font-size: 13px;
  word-break: break-word;
}

.admin-refresh-status {
  width: min(280px, 100%);
  margin: 0 0 4px;
  text-align: center;
  color: #d97706;
  font-size: 13px;
  font-weight: 700;
}

.btn-refresh,
.btn-reset {
  width: min(280px, 100%);
  margin: 8px 0 0;
  padding: 13px 16px;
  border: 1px solid #ddd4c4;
  border-radius: 12px;
  background: #fff;
  color: #8a8174;
  font-weight: 700;
  cursor: pointer;
}

.btn-reset {
  margin-bottom: 32px;
}

.btn-refresh:hover,
.btn-refresh:focus-visible {
  border-color: #d97706;
  color: #d97706;
  outline: none;
}

.btn-reset:hover,
.btn-reset:focus-visible {
  border-color: #b42318;
  color: #b42318;
  outline: none;
}

.admin-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.admin-card__id {
  margin: 0 0 16px;
  color: #8a8174;
  font-size: 13px;
  font-weight: 700;
}

.admin-card__text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  margin-top: 20px;
}

.admin-card__label {
  color: #8a8174;
  font-size: 13px;
  font-weight: 700;
}

.admin-card__value {
  margin: 0;
  text-align: center;
  font-size: 16px;
}

.admin-card__value.is-empty {
  color: #b3aaa0;
}

.admin-play-review,
.admin-main .admin-list {
  width: 100%;
}

.admin-main .admin-list + .btn-primary {
  width: min(280px, 100%);
  margin-top: 12px;
}

.reveal-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.reveal-title {
  margin: 0 0 28px;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
}

.reveal-result {
  margin: 0;
  text-align: center;
  font-size: 28px;
  font-weight: 700;
  animation: fade-in 0.35s ease;
}

.gift-button {
  padding: 0;
  border: 0;
  background: none;
  font-size: 88px;
  line-height: 1;
  cursor: pointer;
}

.gift-button.is-opening {
  animation: unwrap 0.9s ease forwards;
}

.refresh-btn {
  margin-top: 28px;
}

.next-btn {
  width: min(280px, 100%);
  margin-top: 36px;
}

.after-reveal {
  width: min(280px, 100%);
  margin-top: 36px;
}

@keyframes unwrap {
  0% {
    transform: scale(1) rotate(0);
  }

  20% {
    transform: scale(1.18) rotate(-14deg);
  }

  40% {
    transform: scale(1.22) rotate(14deg);
  }

  60% {
    transform: scale(1.28) rotate(-8deg);
  }

  80% {
    transform: scale(0.55) rotate(0);
    opacity: 1;
  }

  100% {
    transform: scale(0) rotate(0);
    opacity: 0;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.admin-page {
  width: 100%;
}

@media (max-width: 400px) {
  .photo-button,
  .admin-photo {
    width: min(180px, 56vw);
    height: min(180px, 56vw);
  }

  .admin-list--people .admin-photo,
  #adminSettings .admin-photo {
    width: min(64px, 18vw);
    height: min(64px, 18vw);
  }

  .digit-slot {
    width: clamp(36px, 12vw, 48px);
    height: clamp(48px, 16vw, 64px);
    font-size: clamp(20px, 7vw, 28px);
  }

  .digit-board {
    gap: 6px;
  }

  .gift-button {
    font-size: 72px;
  }
}

.admin-list--people {
  display: grid !important;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  flex-direction: unset;
}
