:root {
  --ink: #3a2417;
  --ink-soft: rgba(58, 36, 23, 0.25);
  --paper: #fffaf0;
  --cream: #fdf3da;
  --sky: #aee7ff;
  --sky-deep: #7fd4f7;
  --grass: #9ade63;
  --grass-deep: #6cbf3f;
  --dirt: #c98d5c;
  --dirt-deep: #a96f41;
  --rock: #b9aa9d;
  --rock-deep: #93826f;
  --sun: #ffd84d;
  --berry: #ff7d6b;
  --mint: #6fe3c1;
  --violet: #c9a6ff;
  --radius: 18px;
  --border: 3px solid var(--ink);
}

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

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Jua", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.8) 0 38px, transparent 39px),
    radial-gradient(circle at 78% 8%, rgba(255, 255, 255, 0.7) 0 30px, transparent 31px),
    radial-gradient(circle at 55% 20%, rgba(255, 255, 255, 0.55) 0 24px, transparent 25px),
    linear-gradient(180deg, var(--sky) 0%, #cdf0ff 38%, var(--cream) 100%);
  background-attachment: fixed;
  min-height: 100vh;
}

.app {
  max-width: 600px;
  margin: 0 auto;
  padding: 14px 12px calc(96px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.col-main {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

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

.actions-head .section-title {
  margin-bottom: 6px;
}

/* ---------- cards ---------- */
.card {
  background: var(--paper);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: 0 5px 0 var(--ink-soft);
  padding: 12px 14px;
}

.section-title {
  margin: 2px 0 10px;
  font-size: 18px;
  font-weight: 400;
}

.worker-hint {
  font-size: 14px;
  color: var(--dirt-deep);
}

/* ---------- header ---------- */
.title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.title-block {
  flex: 1;
}

.title-block h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 400;
  letter-spacing: 1px;
  text-shadow: 2px 2px 0 rgba(255, 216, 77, 0.6);
}

.round-label {
  margin: 0;
  font-size: 14px;
  color: var(--dirt-deep);
}

.mascot {
  width: 52px;
  height: 52px;
  flex: none;
  animation: bob 2.6s ease-in-out infinite;
}

.mascot svg {
  width: 100%;
  height: 100%;
  display: block;
}

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-4px) rotate(2deg); }
}

.round-track {
  display: flex;
  gap: 5px;
  margin-top: 10px;
  justify-content: space-between;
}

.round-dot {
  flex: 1;
  height: 26px;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  line-height: 1;
  color: var(--ink);
  opacity: 0.65;
}

.round-dot.harvest {
  background: var(--sun);
}

.round-dot.done {
  background: var(--grass);
  opacity: 1;
}

.round-dot.now {
  background: var(--berry);
  color: #fff;
  opacity: 1;
  transform: scale(1.12);
  box-shadow: 0 3px 0 var(--ink-soft);
}

/* ---------- chips ---------- */
.status-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 14px;
  box-shadow: 0 3px 0 var(--ink-soft);
}

.chip .big {
  font-size: 17px;
}

.chip.warn {
  background: #ffe1dc;
}

.chip.good {
  background: #e7ffd6;
}

.chip.pop {
  animation: pop 0.4s ease;
}

@keyframes pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

/* ---------- board ---------- */
.board-card {
  padding: 10px;
}

.board-titles {
  display: flex;
  justify-content: space-between;
  margin: 0 4px 8px;
}

.board-side-label {
  font-size: 14px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 2px 12px;
  box-shadow: 0 3px 0 var(--ink-soft);
}

.grass-label { background: var(--grass); }
.rock-label { background: var(--rock); }

.board {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  border: var(--border);
  border-radius: 14px;
  padding: 8px;
  background: linear-gradient(90deg, var(--grass-deep) 0 50%, var(--dirt-deep) 50% 100%);
}

.tile {
  position: relative;
  aspect-ratio: 1;
  border: 2px solid var(--ink);
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: clamp(20px, 6vw, 30px);
  cursor: default;
  transition: transform 0.15s ease;
  user-select: none;
}

.tile-forest { background: var(--grass); }
.tile-meadow { background: #c4ef9a; }
.tile-field { background: #f0d98c; }
.tile-pasture {
  background: #c4ef9a;
  border-style: dashed;
  border-width: 3px;
}
.tile-rock { background: var(--rock); }
.tile-cavern { background: #8d7763; }
.tile-dwelling { background: #ffca7a; }
.tile-entry { background: #ffca7a; }
.tile-mine { background: #7c6753; }

.tile .corner {
  position: absolute;
  right: 2px;
  bottom: 1px;
  font-size: 12px;
  background: rgba(255, 250, 240, 0.9);
  border-radius: 8px;
  padding: 0 4px;
  line-height: 1.3;
}

.tile .stable-mark {
  position: absolute;
  left: 2px;
  top: 1px;
  font-size: 12px;
}

.tile.targetable {
  cursor: pointer;
  animation: wiggle 0.7s ease-in-out infinite;
  box-shadow: 0 0 0 3px var(--sun), 0 0 14px 4px rgba(255, 216, 77, 0.9);
  z-index: 1;
}

.tile.targetable:hover {
  transform: scale(1.1);
}

@keyframes wiggle {
  0%, 100% { transform: rotate(-2.5deg); }
  50% { transform: rotate(2.5deg); }
}

.target-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  background: var(--sun);
  border: 2px solid var(--ink);
  border-radius: 12px;
  padding: 6px 10px;
  font-size: 14px;
}

/* ---------- speech bubble ---------- */
.bubble-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 0 2px;
}

.mascot-talk {
  width: 46px;
  height: 46px;
}

.speech-bubble {
  position: relative;
  flex: 1;
  background: #fff;
  border: var(--border);
  border-radius: 16px;
  padding: 8px 12px;
  box-shadow: 0 4px 0 var(--ink-soft);
}

.speech-bubble::after {
  content: "";
  position: absolute;
  left: -10px;
  bottom: 10px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-left: 3px solid var(--ink);
  border-bottom: 3px solid var(--ink);
  transform: rotate(45deg);
}

.speech-bubble p {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
}

/* ---------- action cards ---------- */
.action-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

@media (max-width: 420px) {
  .action-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.action-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 4px 0 var(--ink-soft);
  padding: 10px 6px 8px;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  text-align: center;
}

.action-card:not(:disabled):hover {
  transform: translateY(-3px) rotate(-1deg);
  box-shadow: 0 7px 0 var(--ink-soft);
}

.action-card:not(:disabled):active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--ink-soft);
}

.action-card .icon {
  font-size: 28px;
  line-height: 1.1;
}

.action-card .name {
  font-size: 14px;
}

.action-card .detail {
  font-size: 11px;
  color: #8a6a50;
  line-height: 1.3;
  min-height: 28px;
}

.action-card .pile-badge {
  position: absolute;
  top: -8px;
  right: -6px;
  background: var(--sun);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 12px;
  box-shadow: 0 2px 0 var(--ink-soft);
}

.action-card:disabled {
  cursor: not-allowed;
}

.action-card.locked {
  background: #efe7da;
  opacity: 0.75;
  filter: saturate(0.4);
}

.action-card.used {
  background: #f3ead9;
  opacity: 0.9;
}

.action-card.used::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: rgba(58, 36, 23, 0.06);
}

.action-card .worker-token {
  position: absolute;
  top: -10px;
  left: -6px;
  width: 30px;
  height: 30px;
  z-index: 1;
  animation: drop-in 0.3s ease;
}

@keyframes drop-in {
  from { transform: translateY(-12px) scale(0.6); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.action-card.cant {
  opacity: 0.65;
}

/* ---------- buttons ---------- */
.btn {
  font-family: inherit;
  font-size: 16px;
  color: var(--ink);
  border: var(--border);
  border-radius: 14px;
  padding: 10px 18px;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--ink-soft);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  background: #fff;
}

.btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--ink-soft);
}

.btn-primary { background: var(--grass); }
.btn-cook { background: var(--sun); }
.btn-warn { background: var(--berry); color: #fff; }
.btn-ghost { background: #fff; }
.btn-mint { background: var(--mint); }

.btn-small {
  font-size: 13px;
  padding: 6px 12px;
  border-width: 2px;
  border-radius: 10px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.footer-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  display: flex;
  gap: 10px;
  justify-content: center;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent, rgba(253, 243, 218, 0.95) 40%);
  pointer-events: none;
}

.footer-bar .btn {
  pointer-events: auto;
  flex: 1;
  max-width: 280px;
}

/* ---------- modal ---------- */
.modal-root {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 50;
}

.modal-scrim {
  position: absolute;
  inset: 0;
  background: rgba(58, 36, 23, 0.45);
}

.modal-card {
  position: relative;
  width: min(440px, 100%);
  max-height: 82vh;
  overflow-y: auto;
  animation: bounce-in 0.28s ease;
}

@keyframes bounce-in {
  0% { transform: scale(0.7); opacity: 0; }
  70% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

.modal-card h2 {
  margin: 4px 0 8px;
  font-size: 20px;
  font-weight: 400;
  text-align: center;
}

.modal-card .modal-sub {
  margin: 0 0 10px;
  font-size: 14px;
  text-align: center;
  color: #8a6a50;
}

.choice-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.choice-item {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 3px 0 var(--ink-soft);
  padding: 8px 12px;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: transform 0.1s ease;
}

.choice-item:not(:disabled):hover {
  transform: translateX(3px);
}

.choice-item:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.choice-item .icon {
  font-size: 24px;
}

.choice-item .label {
  flex: 1;
}

.choice-item .note {
  font-size: 12px;
  color: #8a6a50;
}

.choice-item.selected {
  background: var(--mint);
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 14px;
}

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

.score-table td {
  padding: 4px 6px;
  border-bottom: 1px dashed rgba(58, 36, 23, 0.25);
}

.score-table td:last-child {
  text-align: right;
}

.score-total {
  text-align: center;
  font-size: 30px;
  margin: 10px 0 2px;
}

.score-grade {
  text-align: center;
  font-size: 18px;
  margin: 0 0 8px;
  color: var(--dirt-deep);
}

.save-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.name-input {
  flex: 1;
  min-width: 0;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  background: #fff;
  border: var(--border);
  border-radius: 12px;
  padding: 8px 12px;
  box-shadow: inset 0 2px 0 var(--ink-soft);
}

.name-input:focus {
  outline: none;
  box-shadow: inset 0 2px 0 var(--ink-soft), 0 0 0 3px var(--sun);
}

.rank-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px;
  border-bottom: 1px dashed rgba(58, 36, 23, 0.25);
  font-size: 15px;
}

.rank-row .rank {
  width: 34px;
  text-align: center;
  font-size: 17px;
}

.rank-row .who {
  flex: 1;
}

.rank-row .who small {
  color: #8a6a50;
  font-size: 11px;
}

.rank-row .pts {
  font-size: 16px;
}

.rank-row.top1 {
  background: #fff3c4;
  border-radius: 10px;
  border-bottom: none;
}

.feed-meter {
  display: flex;
  justify-content: center;
  gap: 10px;
  font-size: 18px;
  margin: 8px 0;
}

.feed-meter .pill {
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 4px 14px;
  background: #fff;
  box-shadow: 0 3px 0 var(--ink-soft);
}

.feed-meter .pill.bad {
  background: #ffe1dc;
}

.feed-meter .pill.ok {
  background: #e7ffd6;
}

/* ---------- toast ---------- */
.toast-root {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 80;
  width: min(380px, calc(100% - 24px));
  pointer-events: none;
}

.toast {
  background: var(--ink);
  color: var(--cream);
  border-radius: 12px;
  padding: 8px 14px;
  font-size: 14px;
  text-align: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
  animation: toast-in 0.25s ease, toast-out 0.3s ease 2.2s forwards;
}

@keyframes toast-in {
  from { transform: translateY(-14px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes toast-out {
  to { transform: translateY(-10px); opacity: 0; }
}

.hidden {
  display: none !important;
}

/* ---------- 움직이는 연출 ---------- */

.app {
  position: relative;
  z-index: 1;
}

.sky {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.cloud {
  position: absolute;
  width: 120px;
  height: 40px;
  background: #fff;
  border-radius: 999px;
  opacity: 0.85;
  animation: drift linear infinite;
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  background: #fff;
  border-radius: 50%;
}

.cloud::before {
  width: 52px;
  height: 52px;
  top: -24px;
  left: 22px;
}

.cloud::after {
  width: 36px;
  height: 36px;
  top: -15px;
  right: 22px;
}

.c1 { top: 5%; scale: 1; animation-duration: 58s; }
.c2 { top: 13%; scale: 0.7; opacity: 0.7; animation-duration: 84s; animation-delay: -34s; }
.c3 { top: 2%; scale: 0.5; opacity: 0.6; animation-duration: 66s; animation-delay: -52s; }

@keyframes drift {
  from { left: -160px; }
  to { left: 110%; }
}

.float-fx {
  position: fixed;
  z-index: 90;
  font-family: inherit;
  font-size: 18px;
  color: var(--ink);
  text-shadow: 1px 1px 0 #fff, -1px 1px 0 #fff, 1px -1px 0 #fff, -1px -1px 0 #fff;
  pointer-events: none;
  animation: float-up 1.1s ease-out forwards;
}

@keyframes float-up {
  0% { transform: translate(-50%, 0) scale(0.6); opacity: 0; }
  18% { transform: translate(-50%, -10px) scale(1.2); opacity: 1; }
  100% { transform: translate(-50%, -48px) scale(1); opacity: 0; }
}

.tile.fx-pop {
  animation: tile-pop 0.45s ease;
}

@keyframes tile-pop {
  0% { transform: scale(0.4) rotate(-10deg); }
  60% { transform: scale(1.18) rotate(4deg); }
  100% { transform: scale(1) rotate(0); }
}

.burst {
  position: fixed;
  z-index: 85;
  pointer-events: none;
  font-size: 15px;
  animation: burst-out 0.7s ease-out forwards;
}

@keyframes burst-out {
  0% { transform: translate(-50%, -50%) scale(0.5); opacity: 1; }
  100% {
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.25);
    opacity: 0;
  }
}

.confetti {
  position: fixed;
  top: -16px;
  z-index: 95;
  width: 10px;
  height: 14px;
  border: 2px solid var(--ink);
  border-radius: 3px;
  pointer-events: none;
  animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
  to { transform: translateY(108vh) rotate(720deg); }
}

.round-dot.now {
  animation: now-pulse 1.4s ease-in-out infinite;
}

@keyframes now-pulse {
  0%, 100% { transform: scale(1.12); }
  50% { transform: scale(1.26); }
}

.tile-forest > span:first-child,
.tile-meadow > span:first-child,
.tile-field > span:first-child {
  display: inline-block;
  animation: sway 3.6s ease-in-out infinite;
}

.board .tile:nth-child(odd) > span:first-child {
  animation-delay: -1.8s;
}

.board .tile:nth-child(3n) > span:first-child {
  animation-delay: -0.9s;
}

@keyframes sway {
  0%, 100% { transform: rotate(-4deg); }
  50% { transform: rotate(4deg); }
}

/* ---------- 반응형: PC는 오른쪽 패널, 모바일은 바텀시트 ---------- */

@media (min-width: 920px) {
  .mobile-only {
    display: none !important;
  }

  .app {
    max-width: 1080px;
    display: grid;
    grid-template-columns: minmax(0, 620px) minmax(330px, 1fr);
    justify-content: center;
    align-items: start;
    gap: 14px;
  }

  .actions-card {
    position: sticky;
    top: 14px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
  }

  .action-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 919.98px) {
  .actions-card {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: 0;
    z-index: 40;
    margin: 0 auto;
    max-width: 600px;
    max-height: 68vh;
    overflow-y: auto;
    border-radius: 22px 22px 0 0;
    border-bottom: none;
    box-shadow: 0 -5px 0 var(--ink-soft);
    padding-bottom: calc(86px + env(safe-area-inset-bottom));
    transform: translateY(110%);
    transition: transform 0.28s ease;
  }

  .actions-card.open {
    transform: translateY(0);
  }

  .action-scrim {
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(58, 36, 23, 0.45);
  }
}

@media (max-width: 480px) {
  .footer-bar {
    gap: 6px;
    padding-left: 8px;
    padding-right: 8px;
  }

  .footer-bar .btn {
    font-size: 14px;
    padding: 10px 6px;
  }
}
