/* ─────────────────────────────────────────────
   MY CAFE-TERIA · 픽셀 카페 스타일
   ───────────────────────────────────────────── */
:root {
  --ink: #3b2a20;
  --paper: #fff8ec;
  --cream: #fdf0d8;
  --wall-a: #f8e7c8;
  --wall-b: #f3dfbb;
  --wood: #9b6a43;
  --wood-dark: #6b4226;
  --red: #e06666;
  --mint: #7cc6a4;
  --yellow: #ffd166;
  --muted: #8a7260;
  --px: 4px;
  --font: 'Galmuri11', 'Galmuri9', 'NeoDunggeunmo', ui-monospace, monospace;
  --mono: 'GalmuriMono11', 'Galmuri11', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  background-color: var(--wall-a);
  background-image:
    linear-gradient(45deg, var(--wall-b) 25%, transparent 25%, transparent 75%, var(--wall-b) 75%),
    linear-gradient(45deg, var(--wall-b) 25%, transparent 25%, transparent 75%, var(--wall-b) 75%);
  background-size: 32px 32px;
  background-position: 0 0, 16px 16px;
  min-height: 100vh;
}
button, input { font: inherit; color: inherit; }
canvas { image-rendering: pixelated; image-rendering: crisp-edges; }
[hidden] { display: none !important; }
.muted { color: var(--muted); font-size: 12px; }

/* 픽셀 테두리 */
.panel, .btn, .bubble, .modal-inner, .toast, input, pre, .dex-item, .diary-item, .signboard {
  box-shadow:
    0 calc(-1 * var(--px)) 0 0 var(--ink),
    0 var(--px) 0 0 var(--ink),
    calc(-1 * var(--px)) 0 0 0 var(--ink),
    var(--px) 0 0 0 var(--ink);
  margin: var(--px);
}

/* 차양 */
.awning {
  height: 44px;
  background: repeating-linear-gradient(90deg, var(--red) 0 40px, var(--paper) 40px 80px);
  border-top: 6px solid var(--ink);
  position: relative;
}
.awning::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -12px; height: 12px;
  background:
    repeating-linear-gradient(90deg, var(--red) 0 40px, var(--paper) 40px 80px);
  -webkit-mask: repeating-linear-gradient(90deg, transparent 0 4px, #000 4px 36px, transparent 36px 40px);
  mask: repeating-linear-gradient(90deg, transparent 0 4px, #000 4px 36px, transparent 36px 40px);
}

/* 간판 */
.signboard {
  max-width: 720px;
  margin: 28px auto 12px;
  background: var(--wood-dark);
  color: #ffe8b0;
  text-align: center;
  padding: 14px 12px 12px;
}
.signboard h1 { margin: 0; font-size: 28px; letter-spacing: 2px; text-shadow: 3px 3px 0 var(--ink); }
.sign-cup { display: inline-block; animation: bob 1.6s steps(2) infinite; }
.today { margin: 4px 0 10px; color: #f6d8a8; }
.top-nav { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
@keyframes bob { 50% { transform: translateY(-3px); } }

/* 버튼 */
.btn {
  background: var(--paper);
  border: 0;
  padding: 8px 12px;
  cursor: pointer;
  position: relative;
  box-shadow:
    0 calc(-1 * var(--px)) 0 0 var(--ink),
    0 var(--px) 0 0 var(--ink),
    calc(-1 * var(--px)) 0 0 0 var(--ink),
    var(--px) 0 0 0 var(--ink),
    inset -4px -4px 0 0 rgba(59, 42, 32, 0.15);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 40ms steps(1);
}
.btn:hover { background: #fff; }
.btn:active { transform: translateY(2px); box-shadow:
    0 calc(-1 * var(--px)) 0 0 var(--ink),
    0 var(--px) 0 0 var(--ink),
    calc(-1 * var(--px)) 0 0 0 var(--ink),
    var(--px) 0 0 0 var(--ink),
    inset 4px 4px 0 0 rgba(59, 42, 32, 0.15); }
.btn:focus-visible { outline: 3px dashed var(--red); outline-offset: 6px; }
.btn.small { font-size: 13px; padding: 6px 10px; }
.btn.tiny { font-size: 12px; padding: 4px 8px; }
.btn.big { font-size: 18px; padding: 14px 22px; background: var(--yellow); }
.btn.primary { background: var(--mint); }
.btn.on { background: var(--yellow); }
.signboard .btn { color: var(--ink); }

/* 모드 탭 */
.mode-tabs { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 18px auto 4px; padding: 0 12px; }
.mode { font-size: 16px; padding: 10px 18px; }
.mode.on { background: var(--yellow); transform: translateY(-2px); }
.mode-desc { text-align: center; margin: 8px 12px 0; color: var(--muted); font-size: 13px; }
body[data-mode='my'] .order { display: none; }
body[data-mode='my'] .cafe { grid-template-areas: 'bar shelf' 'done done'; }
body[data-mode='my'] [data-only='game'],
body[data-mode='game'] [data-only='my'] { display: none !important; }
.modal[data-mode='my'] [data-only='game'],
.modal[data-mode='game'] [data-only='my'] { display: none !important; }

/* 레이아웃 */
.cafe {
  max-width: 1080px;
  margin: 0 auto;
  padding: 8px 14px 24px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}
@media (min-width: 900px) {
  .cafe { grid-template-columns: 420px 1fr; grid-template-areas: 'order order' 'bar shelf' 'done done'; }
  .order { grid-area: order; }
  .bar { grid-area: bar; }
  .shelf { grid-area: shelf; }
  .done-wrap { grid-area: done; }
}
.panel { background: var(--paper); padding: 14px; }

/* 손님 */
.order { display: flex; gap: 14px; align-items: center; background: var(--cream); }
.customer { width: 80px; height: 80px; flex: none; animation: bob 2s steps(2) infinite; }
.bubble { background: #fff; padding: 10px 12px; flex: 1; position: relative; }
.bubble::before {
  content: '';
  position: absolute;
  left: -14px; top: 22px;
  width: 8px; height: 8px;
  background: #fff;
  box-shadow: -4px 0 0 0 var(--ink), 0 -4px 0 0 var(--ink), 0 4px 0 0 var(--ink);
}
.who { margin: 0; font-size: 12px; color: var(--muted); }
.line { margin: 2px 0 6px; font-size: 17px; }
.hint { margin: 4px 0 8px; font-size: 13px; background: var(--cream); padding: 6px 8px; }
.order-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* 제조대 */
.bar { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.cup-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.cup-btn { display: flex; flex-direction: column; align-items: center; padding: 4px 6px; font-size: 11px; min-width: 62px; }
.cup-btn canvas { width: 48px; height: 54px; }
.temp-row { display: flex; gap: 12px; }
.temp { min-width: 92px; }
.temp[data-temp='hot'].on { background: #ffb3a1; }
.temp[data-temp='ice'].on { background: #b9e3f2; }

.stage {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 10px;
  padding: 10px 0 0;
  background:
    linear-gradient(to bottom, transparent 85%, var(--wood) 85%, var(--wood) 92%, var(--wood-dark) 92%);
}
#cup { width: min(320px, 72vw); aspect-ratio: 64 / 72; }
#cup.shake { animation: shake 0.35s steps(4) 2; }
@keyframes shake { 25% { transform: translate(-3px, 0); } 50% { transform: translate(3px, -2px); } 75% { transform: translate(-2px, 2px); } }
.gauge { display: flex; flex-direction: column-reverse; gap: 2px; margin-bottom: 18%; }
.gauge i { width: 14px; height: 8px; background: #e9dcc5; box-shadow: 0 0 0 2px var(--ink); }
.gauge i.f { background: var(--wood); }

.now { text-align: center; min-height: 82px; }
.now-label { margin: 0; font-size: 12px; color: var(--muted); }
.now-name { margin: 2px 0; font-size: 20px; word-break: keep-all; }
.chips { margin: 0; display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; min-height: 22px; }
.chip { font-size: 12px; padding: 1px 8px; background: var(--cream); box-shadow: 0 0 0 2px var(--ink); }
.chip.new { background: var(--yellow); animation: bob 0.8s steps(2) infinite; }
.chip.exp { background: #e7d4f7; }
.chip.slang { background: #c9ecd9; }
.tools { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* 선반 */
.shelf { background: #f7e2c2; align-self: start; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.tab { font-size: 13px; padding: 6px 10px; }
.ings {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 12px;
  padding: 4px;
}
.ing {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px 10px;
  font-size: 12px;
  word-break: keep-all;
  text-align: center;
  line-height: 1.25;
}
.ing .e { font-size: 26px; line-height: 1.1; }
.ing .sw { width: 70%; height: 6px; margin-top: 4px; box-shadow: 0 0 0 2px var(--ink); }
.ing .cnt { position: absolute; top: -10px; right: -10px; background: var(--red); color: #fff; font-size: 11px; padding: 0 5px; box-shadow: 0 0 0 2px var(--ink); }
.ing.on { background: var(--yellow); }
.shelf-tip { margin: 14px 4px 0; }

.done-wrap { text-align: center; padding: 6px 0 10px; }

.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 10px 0 30px; }

/* 모달 */
.modal { border: 0; padding: 0; background: transparent; max-width: min(980px, 94vw); width: 100%; color: var(--ink); }
.modal::backdrop { background: rgba(59, 42, 32, 0.55); }
.modal-inner { background: var(--paper); padding: 18px; position: relative; max-height: 88vh; overflow: auto; }
.modal h2 { margin: 0 0 10px; font-size: 20px; }
.close { position: absolute; right: 10px; top: 8px; border: 0; background: none; font-size: 20px; cursor: pointer; }
.reaction { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; background: var(--cream); padding: 8px 10px; }
.reaction canvas { width: 48px; height: 48px; }
.reaction .score { font-size: 22px; white-space: nowrap; margin-left: auto; }
.result-grid { display: grid; gap: 18px; grid-template-columns: 1fr; }
@media (min-width: 820px) { .result-grid { grid-template-columns: 340px 1fr; } }
.card-wrap img { width: 100%; max-width: 360px; display: block; margin: 0 auto; box-shadow: 6px 6px 0 rgba(59, 42, 32, 0.25); }
.result-form { display: flex; flex-direction: column; gap: 12px; }
.result-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.result-form label.check { flex-direction: row; align-items: center; gap: 6px; }
input[type='text'], input:not([type]) { border: 0; padding: 8px 10px; background: #fff; }
input:focus { outline: 3px dashed var(--red); outline-offset: 4px; }
.seg { display: flex; gap: 10px; flex-wrap: wrap; }
pre {
  font-family: var(--mono);
  background: #2b211b;
  color: #ffe8c2;
  padding: 12px;
  font-size: 13px;
  line-height: 1.35;
  white-space: pre;
  overflow: auto;
  max-height: 360px;
}
.result-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin-top: 18px; }

/* 도감 */
.dex-group h3 { margin: 16px 0 8px; font-size: 15px; }
.dex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.dex-item { background: #fff; padding: 8px 10px; position: relative; }
.dex-item.got { background: #eaf7ef; }
.dex-item .t { font-size: 14px; }
.dex-item .r { font-size: 13px; color: var(--muted); word-break: break-all; }
.dex-item .stamp { position: absolute; right: 6px; top: 2px; color: var(--red); font-size: 18px; transform: rotate(12deg); }

/* 일기 */
.diary-item { background: #fff; padding: 8px 10px; margin-bottom: 12px; }
.diary-item .d { font-size: 12px; color: var(--muted); }
.diary-item .n { font-size: 16px; }

/* 토스트 */
.toast {
  position: fixed;
  left: 50%; bottom: 24px;
  transform: translate(-50%, 140%);
  background: var(--ink);
  color: #ffe8b0;
  padding: 10px 16px;
  transition: transform 0.2s steps(3);
  z-index: 50;
  pointer-events: none;
  max-width: 92vw;
  text-align: center;
}
.toast:not(.show) { visibility: hidden; }
.toast.show { transform: translate(-50%, 0); }

@media (max-width: 520px) {
  body { font-size: 14px; }
  .signboard h1 { font-size: 22px; }
  .order { flex-direction: column; text-align: center; }
  .bubble::before { display: none; }
  .order-actions { justify-content: center; }
  .ings { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .cup-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; width: 100%; }
  .cup-btn { min-width: 0; padding: 4px 2px; font-size: 10px; }
  .cup-btn canvas { width: 36px; height: 40px; }
  .cup-btn .muted { font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
