:root {
  --ink: #17201c;
  --muted: #64736b;
  --paper: #fbfaf4;
  --line: rgba(28, 55, 46, .11);
  --gold: #c99a2e;
  --green: #34e28a;
  --green-deep: #0b8c55;
  --dock: rgba(255, 255, 255, .88);
  --shadow: 0 18px 54px rgba(19, 31, 25, .15);
}

* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; background: #ece8da; color: var(--ink); font-family: Inter, system-ui, sans-serif; overscroll-behavior: none; }
body { -webkit-font-smoothing: antialiased; }
button { font: inherit; }

.miro-shell {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr auto;
  background:
    radial-gradient(circle at 12% 8%, rgba(52, 226, 138, .14), transparent 28%),
    radial-gradient(circle at 85% 20%, rgba(201, 154, 46, .16), transparent 30%),
    #ece8da;
}

.board { min-height: 0; padding: max(10px, env(safe-area-inset-top)) 10px 0; }
.canvas-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 28px 28px 18px 18px;
  background: var(--paper);
  box-shadow: var(--shadow);
  border: 1px solid rgba(23, 32, 28, .09);
  touch-action: none;
}
#sketch-holder, #sketch-holder canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; display: block; }
.floating-layer { position: absolute; inset: 0; pointer-events: none; z-index: 4; }

.board-header {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  z-index: 7;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}
.board-header > * { pointer-events: auto; }
.eyebrow, .info-kicker { text-transform: uppercase; letter-spacing: .13em; color: var(--green-deep); font-size: 10px; font-weight: 850; }
h1 { margin: 3px 0 0; font-size: clamp(23px, 6vw, 36px); line-height: .92; letter-spacing: -.07em; max-width: 230px; }
.reset-btn {
  min-width: 64px;
  min-height: 48px;
  border: 0;
  border-radius: 999px;
  padding: 0 18px;
  color: #07361f;
  font-weight: 850;
  background: linear-gradient(135deg, #adffd2, #30d784);
  box-shadow: 0 12px 28px rgba(23, 169, 98, .25);
  cursor: pointer;
}
.reset-btn:active { transform: scale(.97); }

.hint-pill {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 5;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .82);
  border: 1px solid rgba(23, 32, 28, .08);
  color: #425249;
  font-size: 13px;
  font-weight: 750;
  box-shadow: 0 10px 30px rgba(19, 31, 25, .12);
  backdrop-filter: blur(12px);
  white-space: nowrap;
  transition: opacity .18s ease, transform .18s ease;
}
.hint-pill.hidden { opacity: 0; transform: translateX(-50%) translateY(8px); pointer-events: none; }

.info-box {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 14px;
  z-index: 8;
  max-height: min(210px, 38%);
  overflow-y: auto;
  padding: 14px 16px 15px;
  border-radius: 22px;
  background: rgba(255, 255, 255, .90);
  border: 1px solid rgba(23, 32, 28, .10);
  box-shadow: 0 18px 48px rgba(19, 31, 25, .18);
  backdrop-filter: blur(14px);
  white-space: pre-line;
  transform: translateY(calc(100% + 22px));
  opacity: 0;
  pointer-events: none;
  transition: transform .22s cubic-bezier(.2,.8,.2,1), opacity .18s ease;
}
.info-box.show { transform: translateY(0); opacity: 1; pointer-events: auto; }
.info-box h2 { margin: 4px 0 8px; font-size: 20px; letter-spacing: -.04em; }
.info-box p { margin: 0; color: var(--muted); line-height: 1.42; font-size: 13.5px; }
.info-box .formula { margin-top: 9px; padding-top: 8px; border-top: 1px dashed rgba(23, 32, 28, .16); color: #435248; font-size: 12.5px; line-height: 1.42; }

.tool-dock {
  z-index: 12;
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(255,255,255,.60), rgba(255,255,255,.92));
  border-top: 1px solid rgba(23,32,28,.10);
  box-shadow: 0 -16px 42px rgba(19,31,25,.11);
  backdrop-filter: blur(18px);
}
.dock-grip { width: 42px; height: 5px; border-radius: 999px; margin: 0 auto 7px; background: rgba(23,32,28,.18); }
.dock-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 7px; }
.dock-head strong { font-size: 14px; letter-spacing: -.02em; }
.dock-head span { color: var(--muted); font-size: 12px; font-weight: 650; }
.dock-row-wrap { display: flex; flex-direction: column; gap: 8px; max-height: 190px; overflow-y: auto; }
.dock-group { display: grid; grid-template-columns: 50px minmax(0, 1fr); align-items: center; gap: 8px; }
.dock-label { color: #866522; text-transform: uppercase; font-size: 10px; font-weight: 850; letter-spacing: .12em; }
.item-list { display: flex; gap: 9px; overflow-x: auto; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; padding: 2px 2px 5px; }
.item-list::-webkit-scrollbar { display: none; }

.item-card {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 42px auto;
  align-items: center;
  gap: 9px;
  min-width: 132px;
  min-height: 58px;
  padding: 7px 10px 7px 7px;
  border: 1px solid rgba(23, 32, 28, .12);
  border-radius: 18px;
  background: rgba(255, 255, 255, .88);
  box-shadow: 0 8px 22px rgba(19, 31, 25, .09);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  scroll-snap-align: start;
  transition: transform .12s ease, opacity .12s ease, border-color .12s ease;
}
.item-card:hover { border-color: rgba(52,226,138,.55); }
.item-card:active { cursor: grabbing; transform: scale(.97); }
.item-card.locked-source { opacity: .32; pointer-events: none; }
.item-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 14px; background: #f5edcf; font-size: 24px; }
.item-name { font-size: 13px; font-weight: 850; line-height: 1.05; max-width: 72px; }
.item-kind, .item-slot { display: none; }

.placed-token, .drag-ghost {
  position: absolute;
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 22px;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, .94);
  border: 1.5px solid rgba(23, 32, 28, .14);
  box-shadow: 0 16px 32px rgba(19,31,25,.2), inset 0 0 0 7px rgba(243,210,118,.28);
  font-size: 38px;
  z-index: 6;
  will-change: transform, left, top;
}
.drag-ghost { pointer-events: none; z-index: 40; opacity: .98; touch-action: none; transform: translate(-50%, -50%) scale(1.04); }
.placed-token { animation: lockPulse .32s ease both; }
@keyframes lockPulse { from { transform: translate(-50%,-50%) scale(.78); } to { transform: translate(-50%,-50%) scale(1); } }

@media (min-width: 760px) {
  .miro-shell { grid-template-columns: 1fr 330px; grid-template-rows: 1fr; }
  .board { padding: 16px; }
  .tool-dock { border-top: 0; border-left: 1px solid rgba(23,32,28,.10); padding: 18px; overflow-y: auto; }
  .dock-grip { display: none; }
  .dock-head { margin-bottom: 18px; }
  .dock-row-wrap { max-height: none; gap: 22px; }
  .dock-group { display: block; }
  .dock-label { display: block; margin-bottom: 9px; }
  .item-list { display: grid; overflow: visible; gap: 10px; }
  .item-card { min-width: 0; min-height: 68px; grid-template-columns: 48px 1fr; padding: 10px; }
  .item-icon { width: 48px; height: 48px; font-size: 27px; }
  .item-name { max-width: none; font-size: 14px; }
  .item-kind { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; line-height: 1.2; }
  .info-box { left: auto; width: 390px; }
  h1 { max-width: none; }
}

@media (max-width: 430px) {
  .board { padding: max(8px, env(safe-area-inset-top)) 8px 0; }
  .canvas-wrap { border-radius: 24px 24px 16px 16px; }
  .board-header { top: 12px; left: 12px; right: 12px; }
  h1 { font-size: 25px; }
  .reset-btn { min-height: 46px; min-width: 60px; padding: 0 15px; }
  .tool-dock { padding-left: 10px; padding-right: 10px; }
  .dock-row-wrap { max-height: 178px; gap: 7px; }
  .dock-group { grid-template-columns: 42px minmax(0,1fr); gap: 6px; }
  .dock-label { font-size: 9px; letter-spacing: .1em; }
  .item-card { min-width: 122px; min-height: 56px; grid-template-columns: 40px auto; gap: 8px; }
  .item-icon { width: 40px; height: 40px; font-size: 23px; }
  .item-name { font-size: 12.5px; max-width: 66px; }
}
