:root {
  color: #172033;
  background: #eef3f8;
  font-family: Inter, "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; font-size: clamp(15px, 1.5vw, 17px); }
button, select { font: inherit; }

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 40px clamp(20px, 5vw, 64px);
  background: linear-gradient(135deg, #14213d, #315b8a);
  color: white;
}
h1 { margin: 0; font-size: clamp(26px, 4.2vw, 48px); line-height: 1.15; }
h2 { margin: 0; font-size: clamp(26px, 3.3vw, 42px); line-height: 1.2; }
.score-card { align-self: center; min-width: 140px; padding: 20px; border-radius: 20px; background: rgba(255,255,255,.15); text-align: center; }
.score-card strong { display: block; font-size: 32px; }

.app-shell { padding: 24px clamp(16px, 4vw, 48px) 48px; }
.controls, .board-panel, .tray-panel { background: rgba(255,255,255,.9); border: 1px solid #dce4ef; box-shadow: 0 18px 50px rgba(30, 45, 70, .08); }
.controls { display: flex; flex-wrap: wrap; gap: 16px; align-items: end; padding: 18px; border-radius: 22px; }
.controls label { display: grid; gap: 6px; font-weight: 700; }
select, button { border: 1px solid #cbd5e1; border-radius: 12px; padding: 10px 14px; background: white; }
#resetButton { cursor: pointer; background: #14213d; color: white; }
.game-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 340px); gap: 20px; align-items: start; }
.board-panel, .tray-panel { border-radius: 24px; padding: 20px; }
.panel-title { display: flex; justify-content: space-between; gap: 16px; align-items: start; }
.panel-title p, .tray-panel p { color: #64748b; line-height: 1.7; font-size: clamp(16px, 2.1vw, 22px); }
.zoom-controls { display: inline-flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.zoom-controls button { min-width: 42px; min-height: 42px; padding: 6px 10px; border-radius: 999px; cursor: pointer; font-weight: 800; }
.zoom-controls button:disabled { cursor: not-allowed; opacity: .45; }
#zoomText { min-width: 52px; text-align: center; font-weight: 800; color: #475569; }
.board { width: 100%; min-height: 360px; border-radius: 20px; background: #f8fafc; overflow: auto; touch-action: pan-x pan-y; }
.board-canvas { position: relative; min-width: 100%; }
.map-svg { display: block; width: 100%; height: 100%; min-height: 360px; }
.floor-outline { fill: #e7dcc7; stroke: #64748b; stroke-width: 5; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.floor-void { fill: #f8fafc; stroke: #94a3b8; stroke-width: 2; vector-effect: non-scaling-stroke; }
.floor-walkway { fill: none; stroke: rgba(255,255,255,.82); stroke-width: 44; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; pointer-events: none; }
.shop-slot { cursor: pointer; outline: none; }
.shop-slot path { fill: color-mix(in srgb, var(--piece-color), white 78%); stroke: color-mix(in srgb, var(--piece-color), #475569 45%); stroke-width: 2; stroke-dasharray: 8 5; transition: filter .15s, fill .15s, stroke .15s; vector-effect: non-scaling-stroke; }
.shop-slot:hover path { filter: drop-shadow(0 8px 12px rgba(15, 23, 42, .18)); fill: color-mix(in srgb, var(--piece-color), white 66%); }
.shop-slot:focus-visible path { stroke: #2563eb; stroke-width: 4; }
.shop-slot.placed path { stroke-dasharray: none; fill: color-mix(in srgb, var(--piece-color), white 18%); }
.shop-label { pointer-events: none; fill: #1e293b; stroke: rgba(255,255,255,.82); stroke-width: 3; paint-order: stroke fill; font-weight: 800; font-size: clamp(10px, 1.3vw, 18px); line-height: 1.2; }
.tray { display: grid; gap: 10px; max-height: min(62vh, 620px); overflow: auto; padding-right: 4px; }
.piece { width: 100%; padding: 14px 16px; border: 1px solid #dbe3ef; border-left: 8px solid var(--piece-color); background: white; box-shadow: 0 8px 22px rgba(15, 23, 42, .08); cursor: grab; touch-action: none; text-align: left; font-weight: 800; line-height: 1.35; user-select: none; }
.piece.dragging { position: relative; opacity: .92; cursor: grabbing; box-shadow: 0 18px 36px rgba(15, 23, 42, .22); }
.piece.selected { outline: 3px solid #2563eb; }
.toast { position: fixed; right: 24px; bottom: 24px; transform: translateY(16px); opacity: 0; padding: 14px 18px; border-radius: 14px; background: #14213d; color: white; transition: .2s; }
.toast.error { background: #b91c1c; }
.toast.visible { transform: translateY(0); opacity: 1; }

@media (max-width: 900px) {
  .hero, .game-grid { grid-template-columns: 1fr; display: grid; }
  .hero { padding: 24px 18px; }
  .score-card { justify-self: start; }
  .app-shell { padding: 16px 12px 36px; }
  .controls { align-items: stretch; }
  .controls label, .controls button { width: 100%; }
  .board-panel, .tray-panel { padding: 14px; border-radius: 18px; }
  h2 { font-size: clamp(24px, 8vw, 34px); }
  .panel-title { flex-direction: column; }
  .zoom-controls { align-self: flex-end; }
  .board { min-height: 260px; }
  .tray { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: none; }
  .piece { min-height: 54px; padding: 12px; font-size: clamp(14px, 4vw, 16px); }
  .map-svg { min-height: 260px; }
  .shop-label { font-size: clamp(9px, 2.4vw, 13px); }
}

@media (max-width: 520px) {
  .tray { grid-template-columns: 1fr; }
  h1 { font-size: clamp(24px, 8vw, 32px); }
  .panel-title p, .tray-panel p { font-size: 16px; }
  .board { min-height: 220px; }
}
