* {
  box-sizing: border-box;
}

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

body {
  display: flex;
  justify-content: center;
  background: #eef6ff;
  color: #22384f;
  font-family: system-ui, -apple-system, "Malgun Gothic", sans-serif;
}

.game {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(100%, 1040px);
  height: 100%;
  min-height: 0;
  padding: 10px;
}

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 180px;
  overflow: hidden;
  border-radius: 16px;
  background: #b9ddff;
  box-shadow: 0 6px 20px rgba(60, 110, 160, 0.18);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.clear {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(255, 255, 255, 0.72);
}

.clear[hidden] {
  display: none;
}

.clear__title {
  margin: 0;
  font-size: clamp(26px, 6vw, 42px);
  font-weight: 800;
  color: #2b7a55;
}

button {
  font: inherit;
  cursor: pointer;
}

#retryBtn {
  border: 0;
  border-radius: 999px;
  padding: 10px 22px;
  font-weight: 700;
  color: #ffffff;
  background: #2f7fd6;
  box-shadow: 0 4px 12px rgba(47, 127, 214, 0.35);
}

#retryBtn:active {
  transform: translateY(1px);
}

.bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.hint {
  flex: 1 1 240px;
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: #4a6b88;
}

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

.bar__right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolBtn {
  height: 46px;
  padding: 0 16px;
  border: 0;
  border-radius: 12px;
  font-weight: 700;
  color: #7a5a12;
  background: #ffe9a8;
  box-shadow: 0 3px 10px rgba(150, 110, 20, 0.22);
  touch-action: manipulation;
}

.toolBtn:active {
  transform: translateY(1px);
}

.pad__btn {
  width: 60px;
  height: 46px;
  border: 0;
  border-radius: 12px;
  background: #ffffff;
  color: #2f7fd6;
  font-size: 20px;
  font-weight: 700;
  box-shadow: 0 3px 10px rgba(60, 110, 160, 0.18);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.pad__btn.is-down {
  background: #2f7fd6;
  color: #ffffff;
}

.quiz {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  width: min(92%, 340px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 6px 18px rgba(38, 92, 68, 0.26);
  text-align: center;
}

.quiz[hidden] {
  display: none;
}

.quiz__label {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  color: #2f8f5b;
}

.quiz__question {
  margin: 0;
  font-size: clamp(18px, 4.6vw, 24px);
  font-weight: 800;
  color: #1f4b38;
}

.quiz__form {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.quiz__input {
  width: 96px;
  padding: 8px 10px;
  border: 2px solid #7fd3a2;
  border-radius: 10px;
  font: inherit;
  font-weight: 700;
  text-align: center;
  color: #1f4b38;
}

.quiz__btn {
  border: 0;
  border-radius: 10px;
  padding: 8px 16px;
  font-weight: 700;
  color: #ffffff;
  background: #34a35f;
  touch-action: manipulation;
}

.quiz__msg {
  min-height: 18px;
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: #c1503f;
}

/* 수수께끼 구름: 남색 문제 창 */
#riddlePanel .quiz__label {
  color: #2a4794;
}

#riddlePanel .quiz__question {
  color: #1b2c63;
}

.quiz__choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.quiz__choice {
  border: 2px solid #aab8ea;
  border-radius: 10px;
  padding: 9px 8px;
  font-size: 14px;
  line-height: 1.3;
  word-break: keep-all;
  font-weight: 700;
  color: #26377d;
  background: #f2f5ff;
  touch-action: manipulation;
}

.quiz__choice:active {
  transform: translateY(1px);
}

/* 골드 획득 알림 */
.toast {
  position: absolute;
  left: 50%;
  top: 58px;
  margin: 0;
  padding: 6px 14px;
  transform: translate(-50%, 6px);
  border-radius: 999px;
  background: rgba(38, 58, 82, 0.84);
  color: #ffe9a8;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast[hidden] {
  display: none;
}

.toast.is-show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* 상점 */
.shop {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.95);
}

.shop[hidden] {
  display: none;
}

.shop__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.shop__title {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  color: #2b4d6b;
}

.shop__gold {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #a97708;
}

.shop__note {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
  color: #5a7288;
}

.shop__list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.shop__item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border-radius: 12px;
  background: #f1f8ff;
}

.shop__info {
  flex: 1 1 auto;
  min-width: 0;
}

.shop__name {
  margin: 0 0 3px;
  font-size: 14px;
  font-weight: 800;
  color: #22405c;
}

.shop__desc {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
  color: #4a6b88;
}

.shop__own {
  margin: 4px 0 0;
  font-size: 12px;
  font-weight: 700;
  color: #2f7fd6;
}

.shop__buy {
  flex: 0 0 auto;
  border: 0;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
  background: #2f7fd6;
  touch-action: manipulation;
}

.shop__buy:disabled {
  color: #6b8199;
  background: #c9d8e6;
  cursor: default;
}

.shop__msg {
  min-height: 18px;
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: #c1503f;
  text-align: center;
}

.shop__close {
  align-self: center;
  border: 0;
  border-radius: 999px;
  padding: 9px 22px;
  font-weight: 700;
  color: #ffffff;
  background: #34a35f;
  touch-action: manipulation;
}

/* 캐릭터 색 고르기 */
.colors {
  position: absolute;
  left: 50%;
  bottom: 14px;
  z-index: 2;
  transform: translateX(-50%);
  width: min(92%, 340px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 6px 18px rgba(38, 92, 68, 0.26);
}

.colors[hidden] {
  display: none;
}

.colors__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.colors__title {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  color: #2b4d6b;
}

.colors__close {
  border: 0;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
  background: #34a35f;
  touch-action: manipulation;
}

.colors__note {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
  color: #5a7288;
}

.colors__list {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.swatch {
  height: 34px;
  border: 2px solid rgba(43, 77, 107, 0.2);
  border-radius: 10px;
  touch-action: manipulation;
}

.swatch.is-on {
  border-color: #22405c;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.9);
}

/* 랭킹 등록 안내(스테이지 클리어 화면) */
.clear__rank {
  margin: 0;
  max-width: 88%;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  color: #3a6b8f;
  text-align: center;
}

.clear__rank[hidden] {
  display: none;
}
