@import url('https://fonts.googleapis.com/css2?family=Gaegu:wght@400;700&family=Nanum+Pen+Script&display=swap');

:root {
  --paper: #f3efe0;
  --paper-line: #d8d2b8;
  --ink: #1a1a1a;
  --accent: #e8890a;
  --accent-dark: #c96f00;
  --egg: #e8d24a;
  --egg-line: #b89a1a;
  --danger: #c0392b;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #111;
  font-family: 'Gaegu', sans-serif;
  touch-action: none;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 560px;
  margin: 0 auto;
  background: var(--paper);
  overflow: hidden;
}

#app canvas {
  position: absolute;
  top: 50%;
  left: 50%;
  max-width: 100%;
  max-height: 100%;
  transform: translate(-50%, -50%);
  /* 실제 aspect-ratio 값은 game.js가 캔버스를 만들 때 인라인 스타일로
     직접 설정한다(level.world의 width/height 비율) — width/height를
     각각 100%로 늘리면 종횡비가 달라져 원/사각형이 찌그러지는 문제가
     있었음. */
  display: block;
}

/* ---------- shared button ---------- */
.rb-btn {
  font-family: 'Gaegu', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--ink);
  background: var(--accent);
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 10px 22px;
  box-shadow: 3px 4px 0 var(--ink);
  cursor: pointer;
}

.rb-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 2px 0 var(--ink);
}

.rb-btn.secondary {
  background: var(--paper);
}

.rb-btn.danger {
  background: var(--danger);
  color: #fff;
}

/* ---------- menu screens ---------- */
.rb-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 24px;
  text-align: center;
}

.rb-title {
  font-size: 3rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -1px;
}

.rb-subtitle {
  font-size: 1.2rem;
  color: #6b6b63;
  margin-top: -16px;
}

.rb-mascot {
  width: 160px;
  height: 160px;
  object-fit: contain;
}

.rb-level-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  max-width: 400px;
  width: 100%;
}

.rb-level-btn {
  aspect-ratio: 1;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: #fff;
  font-family: 'Gaegu', sans-serif;
  font-weight: 700;
  font-size: 1.3rem;
  box-shadow: 2px 3px 0 var(--ink);
  cursor: pointer;
}

.rb-level-btn.locked {
  background: #d8d2b8;
  color: #9a9482;
  cursor: not-allowed;
  box-shadow: none;
}

.rb-level-btn.cleared {
  background: var(--accent);
}

.rb-level-btn.coming-soon {
  background: transparent;
  border: 3px dashed var(--paper-line);
  color: #9a9482;
  cursor: default;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 0.62rem;
  line-height: 1.15;
}

.rb-level-btn.coming-soon .rb-coming-plus {
  font-size: 1.4rem;
  line-height: 1;
}

/* ---------- in-game HUD ---------- */
.rb-hud-top {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.rb-hint-banner {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: 10px;
  padding: 8px 16px;
  font-size: 1rem;
  white-space: nowrap;
  box-shadow: 2px 3px 0 var(--ink);
}

.rb-hud-bottom {
  position: absolute;
  bottom: 31px; /* 16px + 15px — 바닥에 너무 딱 붙어 보여서 여백을 더 줌 */
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: center;
  gap: 16px;
}

.rb-palette {
  position: absolute;
  bottom: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

/* 화면 위쪽의 "아직 세계에 없는 블록/밧줄" 서랍 — 게임 월드(캔버스)와
   확실히 구분되는 UI 트레이처럼 보이도록 자체 배경/테두리/그림자를 준다. */
.rb-drawer-wrap {
  position: absolute;
  top: 76px;
  left: 16px;
  right: 16px;
  background: repeating-linear-gradient(
    -45deg,
    #ded6bd,
    #ded6bd 3px,
    #e9e2cc 3px,
    #e9e2cc 8px
  );
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  box-shadow: 3px 4px 0 var(--ink);
  padding: 6px 10px 10px;
}

.rb-drawer-label {
  font-size: 0.85rem;
  color: #6b6b63;
  margin-bottom: 4px;
}

.rb-drawer {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  min-height: 40px;
}

.rb-palette-item {
  min-width: 40px;
  min-height: 32px;
  border: 2.5px solid var(--ink);
  border-radius: 6px;
  background: #fbf9f1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  box-shadow: 2px 2px 0 var(--ink);
  touch-action: none;
}

.rb-palette-item.used {
  opacity: 0.35;
  cursor: not-allowed;
}

.rb-result-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
}

.rb-result-card {
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 18px;
  padding: 28px 32px;
  box-shadow: 5px 6px 0 var(--ink);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  min-width: 240px;
}

.rb-result-title {
  font-size: 1.8rem;
  font-weight: 700;
}
